github.hscsec.cn/scroll-tech/go-ethereum@v1.9.7/cmd/evm/main.go (about) 1 // Copyright 2014 The go-ethereum Authors 2 // This file is part of go-ethereum. 3 // 4 // go-ethereum is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // go-ethereum is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with go-ethereum. If not, see <http://www.gnu.org/licenses/>. 16 17 // evm executes EVM code snippets. 18 package main 19 20 import ( 21 "fmt" 22 "math/big" 23 "os" 24 25 "github.com/ethereum/go-ethereum/cmd/utils" 26 "gopkg.in/urfave/cli.v1" 27 ) 28 29 var gitCommit = "" // Git SHA1 commit hash of the release (set via linker flags) 30 var gitDate = "" 31 32 var ( 33 app = utils.NewApp(gitCommit, gitDate, "the evm command line interface") 34 35 DebugFlag = cli.BoolFlag{ 36 Name: "debug", 37 Usage: "output full trace logs", 38 } 39 MemProfileFlag = cli.StringFlag{ 40 Name: "memprofile", 41 Usage: "creates a memory profile at the given path", 42 } 43 CPUProfileFlag = cli.StringFlag{ 44 Name: "cpuprofile", 45 Usage: "creates a CPU profile at the given path", 46 } 47 StatDumpFlag = cli.BoolFlag{ 48 Name: "statdump", 49 Usage: "displays stack and heap memory information", 50 } 51 CodeFlag = cli.StringFlag{ 52 Name: "code", 53 Usage: "EVM code", 54 } 55 CodeFileFlag = cli.StringFlag{ 56 Name: "codefile", 57 Usage: "File containing EVM code. If '-' is specified, code is read from stdin ", 58 } 59 GasFlag = cli.Uint64Flag{ 60 Name: "gas", 61 Usage: "gas limit for the evm", 62 Value: 10000000000, 63 } 64 PriceFlag = utils.BigFlag{ 65 Name: "price", 66 Usage: "price set for the evm", 67 Value: new(big.Int), 68 } 69 ValueFlag = utils.BigFlag{ 70 Name: "value", 71 Usage: "value set for the evm", 72 Value: new(big.Int), 73 } 74 DumpFlag = cli.BoolFlag{ 75 Name: "dump", 76 Usage: "dumps the state after the run", 77 } 78 InputFlag = cli.StringFlag{ 79 Name: "input", 80 Usage: "input for the EVM", 81 } 82 VerbosityFlag = cli.IntFlag{ 83 Name: "verbosity", 84 Usage: "sets the verbosity level", 85 } 86 CreateFlag = cli.BoolFlag{ 87 Name: "create", 88 Usage: "indicates the action should be create rather than call", 89 } 90 GenesisFlag = cli.StringFlag{ 91 Name: "prestate", 92 Usage: "JSON file with prestate (genesis) config", 93 } 94 MachineFlag = cli.BoolFlag{ 95 Name: "json", 96 Usage: "output trace logs in machine readable format (json)", 97 } 98 SenderFlag = cli.StringFlag{ 99 Name: "sender", 100 Usage: "The transaction origin", 101 } 102 ReceiverFlag = cli.StringFlag{ 103 Name: "receiver", 104 Usage: "The transaction receiver (execution context)", 105 } 106 DisableMemoryFlag = cli.BoolFlag{ 107 Name: "nomemory", 108 Usage: "disable memory output", 109 } 110 DisableStackFlag = cli.BoolFlag{ 111 Name: "nostack", 112 Usage: "disable stack output", 113 } 114 EVMInterpreterFlag = cli.StringFlag{ 115 Name: "vm.evm", 116 Usage: "External EVM configuration (default = built-in interpreter)", 117 Value: "", 118 } 119 ) 120 121 func init() { 122 app.Flags = []cli.Flag{ 123 CreateFlag, 124 DebugFlag, 125 VerbosityFlag, 126 CodeFlag, 127 CodeFileFlag, 128 GasFlag, 129 PriceFlag, 130 ValueFlag, 131 DumpFlag, 132 InputFlag, 133 MemProfileFlag, 134 CPUProfileFlag, 135 StatDumpFlag, 136 GenesisFlag, 137 MachineFlag, 138 SenderFlag, 139 ReceiverFlag, 140 DisableMemoryFlag, 141 DisableStackFlag, 142 EVMInterpreterFlag, 143 } 144 app.Commands = []cli.Command{ 145 compileCommand, 146 disasmCommand, 147 runCommand, 148 stateTestCommand, 149 } 150 } 151 152 func main() { 153 if err := app.Run(os.Args); err != nil { 154 fmt.Fprintln(os.Stderr, err) 155 os.Exit(1) 156 } 157 }