github.com/bigzoro/my_simplechain@v0.0.0-20240315012955-8ad0a2a29bb9/cmd/evm/main.go (about) 1 // Copyright 2014 The go-simplechain Authors 2 // This file is part of go-simplechain. 3 // 4 // go-simplechain 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-simplechain 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-simplechain. 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/bigzoro/my_simplechain/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 InputFileFlag = cli.StringFlag{ 83 Name: "inputfile", 84 Usage: "file containing input for the EVM", 85 } 86 VerbosityFlag = cli.IntFlag{ 87 Name: "verbosity", 88 Usage: "sets the verbosity level", 89 } 90 CreateFlag = cli.BoolFlag{ 91 Name: "create", 92 Usage: "indicates the action should be create rather than call", 93 } 94 GenesisFlag = cli.StringFlag{ 95 Name: "prestate", 96 Usage: "JSON file with prestate (genesis) config", 97 } 98 MachineFlag = cli.BoolFlag{ 99 Name: "json", 100 Usage: "output trace logs in machine readable format (json)", 101 } 102 SenderFlag = cli.StringFlag{ 103 Name: "sender", 104 Usage: "The transaction origin", 105 } 106 ReceiverFlag = cli.StringFlag{ 107 Name: "receiver", 108 Usage: "The transaction receiver (execution context)", 109 } 110 DisableMemoryFlag = cli.BoolFlag{ 111 Name: "nomemory", 112 Usage: "disable memory output", 113 } 114 DisableStackFlag = cli.BoolFlag{ 115 Name: "nostack", 116 Usage: "disable stack output", 117 } 118 EVMInterpreterFlag = cli.StringFlag{ 119 Name: "vm.evm", 120 Usage: "External EVM configuration (default = built-in interpreter)", 121 Value: "", 122 } 123 ) 124 125 func init() { 126 app.Flags = []cli.Flag{ 127 CreateFlag, 128 DebugFlag, 129 VerbosityFlag, 130 CodeFlag, 131 CodeFileFlag, 132 GasFlag, 133 PriceFlag, 134 ValueFlag, 135 DumpFlag, 136 InputFlag, 137 InputFileFlag, 138 MemProfileFlag, 139 CPUProfileFlag, 140 StatDumpFlag, 141 GenesisFlag, 142 MachineFlag, 143 SenderFlag, 144 ReceiverFlag, 145 DisableMemoryFlag, 146 DisableStackFlag, 147 EVMInterpreterFlag, 148 } 149 app.Commands = []cli.Command{ 150 compileCommand, 151 disasmCommand, 152 runCommand, 153 } 154 cli.CommandHelpTemplate = utils.OriginCommandHelpTemplate 155 } 156 157 func main() { 158 if err := app.Run(os.Args); err != nil { 159 fmt.Fprintln(os.Stderr, err) 160 os.Exit(1) 161 } 162 }