@ -23,6 +23,7 @@ import (
"os"
"os"
"github.com/ethereum/go-ethereum/cmd/evm/internal/t8ntool"
"github.com/ethereum/go-ethereum/cmd/evm/internal/t8ntool"
"github.com/ethereum/go-ethereum/internal/debug"
"github.com/ethereum/go-ethereum/internal/flags"
"github.com/ethereum/go-ethereum/internal/flags"
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v2"
)
)
@ -31,99 +32,107 @@ var (
DebugFlag = & cli . BoolFlag {
DebugFlag = & cli . BoolFlag {
Name : "debug" ,
Name : "debug" ,
Usage : "output full trace logs" ,
Usage : "output full trace logs" ,
}
Category : flags . VMCategory ,
MemProfileFlag = & cli . StringFlag {
Name : "memprofile" ,
Usage : "creates a memory profile at the given path" ,
}
CPUProfileFlag = & cli . StringFlag {
Name : "cpuprofile" ,
Usage : "creates a CPU profile at the given path" ,
}
}
StatDumpFlag = & cli . BoolFlag {
StatDumpFlag = & cli . BoolFlag {
Name : "statdump" ,
Name : "statdump" ,
Usage : "displays stack and heap memory information" ,
Usage : "displays stack and heap memory information" ,
Category : flags . VMCategory ,
}
}
CodeFlag = & cli . StringFlag {
CodeFlag = & cli . StringFlag {
Name : "code" ,
Name : "code" ,
Usage : "EVM code" ,
Usage : "EVM code" ,
Category : flags . VMCategory ,
}
}
CodeFileFlag = & cli . StringFlag {
CodeFileFlag = & cli . StringFlag {
Name : "codefile" ,
Name : "codefile" ,
Usage : "File containing EVM code. If '-' is specified, code is read from stdin " ,
Usage : "File containing EVM code. If '-' is specified, code is read from stdin " ,
Category : flags . VMCategory ,
}
}
GasFlag = & cli . Uint64Flag {
GasFlag = & cli . Uint64Flag {
Name : "gas" ,
Name : "gas" ,
Usage : "gas limit for the evm" ,
Usage : "gas limit for the evm" ,
Value : 10000000000 ,
Value : 10000000000 ,
Category : flags . VMCategory ,
}
}
PriceFlag = & flags . BigFlag {
PriceFlag = & flags . BigFlag {
Name : "price" ,
Name : "price" ,
Usage : "price set for the evm" ,
Usage : "price set for the evm" ,
Value : new ( big . Int ) ,
Value : new ( big . Int ) ,
Category : flags . VMCategory ,
}
}
ValueFlag = & flags . BigFlag {
ValueFlag = & flags . BigFlag {
Name : "value" ,
Name : "value" ,
Usage : "value set for the evm" ,
Usage : "value set for the evm" ,
Value : new ( big . Int ) ,
Value : new ( big . Int ) ,
Category : flags . VMCategory ,
}
}
DumpFlag = & cli . BoolFlag {
DumpFlag = & cli . BoolFlag {
Name : "dump" ,
Name : "dump" ,
Usage : "dumps the state after the run" ,
Usage : "dumps the state after the run" ,
Category : flags . VMCategory ,
}
}
InputFlag = & cli . StringFlag {
InputFlag = & cli . StringFlag {
Name : "input" ,
Name : "input" ,
Usage : "input for the EVM" ,
Usage : "input for the EVM" ,
Category : flags . VMCategory ,
}
}
InputFileFlag = & cli . StringFlag {
InputFileFlag = & cli . StringFlag {
Name : "inputfile" ,
Name : "inputfile" ,
Usage : "file containing input for the EVM" ,
Usage : "file containing input for the EVM" ,
}
Category : flags . VMCategory ,
VerbosityFlag = & cli . IntFlag {
Name : "verbosity" ,
Usage : "sets the verbosity level" ,
}
}
BenchFlag = & cli . BoolFlag {
BenchFlag = & cli . BoolFlag {
Name : "bench" ,
Name : "bench" ,
Usage : "benchmark the execution" ,
Usage : "benchmark the execution" ,
Category : flags . VMCategory ,
}
}
CreateFlag = & cli . BoolFlag {
CreateFlag = & cli . BoolFlag {
Name : "create" ,
Name : "create" ,
Usage : "indicates the action should be create rather than call" ,
Usage : "indicates the action should be create rather than call" ,
Category : flags . VMCategory ,
}
}
GenesisFlag = & cli . StringFlag {
GenesisFlag = & cli . StringFlag {
Name : "prestate" ,
Name : "prestate" ,
Usage : "JSON file with prestate (genesis) config" ,
Usage : "JSON file with prestate (genesis) config" ,
Category : flags . VMCategory ,
}
}
MachineFlag = & cli . BoolFlag {
MachineFlag = & cli . BoolFlag {
Name : "json" ,
Name : "json" ,
Usage : "output trace logs in machine readable format (json)" ,
Usage : "output trace logs in machine readable format (json)" ,
Category : flags . VMCategory ,
}
}
SenderFlag = & cli . StringFlag {
SenderFlag = & cli . StringFlag {
Name : "sender" ,
Name : "sender" ,
Usage : "The transaction origin" ,
Usage : "The transaction origin" ,
Category : flags . VMCategory ,
}
}
ReceiverFlag = & cli . StringFlag {
ReceiverFlag = & cli . StringFlag {
Name : "receiver" ,
Name : "receiver" ,
Usage : "The transaction receiver (execution context)" ,
Usage : "The transaction receiver (execution context)" ,
Category : flags . VMCategory ,
}
}
DisableMemoryFlag = & cli . BoolFlag {
DisableMemoryFlag = & cli . BoolFlag {
Name : "nomemory" ,
Name : "nomemory" ,
Value : true ,
Value : true ,
Usage : "disable memory output" ,
Usage : "disable memory output" ,
Category : flags . VMCategory ,
}
}
DisableStackFlag = & cli . BoolFlag {
DisableStackFlag = & cli . BoolFlag {
Name : "nostack" ,
Name : "nostack" ,
Usage : "disable stack output" ,
Usage : "disable stack output" ,
Category : flags . VMCategory ,
}
}
DisableStorageFlag = & cli . BoolFlag {
DisableStorageFlag = & cli . BoolFlag {
Name : "nostorage" ,
Name : "nostorage" ,
Usage : "disable storage output" ,
Usage : "disable storage output" ,
Category : flags . VMCategory ,
}
}
DisableReturnDataFlag = & cli . BoolFlag {
DisableReturnDataFlag = & cli . BoolFlag {
Name : "noreturndata" ,
Name : "noreturndata" ,
Value : true ,
Value : true ,
Usage : "enable return data output" ,
Usage : "enable return data output" ,
Category : flags . VMCategory ,
}
}
)
)
@ -183,34 +192,38 @@ var blockBuilderCommand = &cli.Command{
} ,
} ,
}
}
var app = flags . NewApp ( "the evm command line interface" )
// vmFlags contains flags related to running the EVM.
var vmFlags = [ ] cli . Flag {
func init ( ) {
app . Flags = [ ] cli . Flag {
BenchFlag ,
CreateFlag ,
DebugFlag ,
VerbosityFlag ,
CodeFlag ,
CodeFlag ,
CodeFileFlag ,
CodeFileFlag ,
CreateFlag ,
GasFlag ,
GasFlag ,
PriceFlag ,
PriceFlag ,
ValueFlag ,
ValueFlag ,
DumpFlag ,
InputFlag ,
InputFlag ,
InputFileFlag ,
InputFileFlag ,
MemProfileFlag ,
CPUProfileFlag ,
StatDumpFlag ,
GenesisFlag ,
GenesisFlag ,
MachineFlag ,
SenderFlag ,
SenderFlag ,
ReceiverFlag ,
ReceiverFlag ,
}
// traceFlags contains flags that configure tracing output.
var traceFlags = [ ] cli . Flag {
BenchFlag ,
DebugFlag ,
DumpFlag ,
MachineFlag ,
StatDumpFlag ,
DisableMemoryFlag ,
DisableMemoryFlag ,
DisableStackFlag ,
DisableStackFlag ,
DisableStorageFlag ,
DisableStorageFlag ,
DisableReturnDataFlag ,
DisableReturnDataFlag ,
}
}
var app = flags . NewApp ( "the evm command line interface" )
func init ( ) {
app . Flags = flags . Merge ( vmFlags , traceFlags , debug . Flags )
app . Commands = [ ] * cli . Command {
app . Commands = [ ] * cli . Command {
compileCommand ,
compileCommand ,
disasmCommand ,
disasmCommand ,
@ -221,6 +234,14 @@ func init() {
transactionCommand ,
transactionCommand ,
blockBuilderCommand ,
blockBuilderCommand ,
}
}
app . Before = func ( ctx * cli . Context ) error {
flags . MigrateGlobalFlags ( ctx )
return debug . Setup ( ctx )
}
app . After = func ( ctx * cli . Context ) error {
debug . Exit ( )
return nil
}
}
}
func main ( ) {
func main ( ) {