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