cmd/evm: removed -sysstat and moved content to -debug flag
Added the ability to directly compile and run ethereum assembly using the evm utility: `evm run <file>`. This is equivalant to `evm compile <file> | evm run`.
This commit is contained in:
parent
bf4155846c
commit
f30733c806
@ -66,10 +66,6 @@ var (
|
|||||||
Name: "input",
|
Name: "input",
|
||||||
Usage: "input for the EVM",
|
Usage: "input for the EVM",
|
||||||
}
|
}
|
||||||
SysStatFlag = cli.BoolFlag{
|
|
||||||
Name: "sysstat",
|
|
||||||
Usage: "display system stats",
|
|
||||||
}
|
|
||||||
VerbosityFlag = cli.IntFlag{
|
VerbosityFlag = cli.IntFlag{
|
||||||
Name: "verbosity",
|
Name: "verbosity",
|
||||||
Usage: "sets the verbosity level",
|
Usage: "sets the verbosity level",
|
||||||
@ -89,7 +85,6 @@ func init() {
|
|||||||
CreateFlag,
|
CreateFlag,
|
||||||
DebugFlag,
|
DebugFlag,
|
||||||
VerbosityFlag,
|
VerbosityFlag,
|
||||||
SysStatFlag,
|
|
||||||
CodeFlag,
|
CodeFlag,
|
||||||
CodeFileFlag,
|
CodeFileFlag,
|
||||||
GasFlag,
|
GasFlag,
|
||||||
|
@ -25,6 +25,7 @@ import (
|
|||||||
|
|
||||||
goruntime "runtime"
|
goruntime "runtime"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/cmd/evm/internal/compiler"
|
||||||
"github.com/ethereum/go-ethereum/cmd/utils"
|
"github.com/ethereum/go-ethereum/cmd/utils"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
@ -61,7 +62,18 @@ func runCmd(ctx *cli.Context) error {
|
|||||||
ret []byte
|
ret []byte
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
if ctx.GlobalString(CodeFlag.Name) != "" {
|
if fn := ctx.Args().First(); len(fn) > 0 {
|
||||||
|
src, err := ioutil.ReadFile(fn)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
bin, err := compiler.Compile(fn, src, false)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
code = common.Hex2Bytes(bin)
|
||||||
|
} else if ctx.GlobalString(CodeFlag.Name) != "" {
|
||||||
code = common.Hex2Bytes(ctx.GlobalString(CodeFlag.Name))
|
code = common.Hex2Bytes(ctx.GlobalString(CodeFlag.Name))
|
||||||
} else {
|
} else {
|
||||||
var hexcode []byte
|
var hexcode []byte
|
||||||
@ -106,7 +118,7 @@ func runCmd(ctx *cli.Context) error {
|
|||||||
|
|
||||||
ret, err = runtime.Call(receiver, common.Hex2Bytes(ctx.GlobalString(InputFlag.Name)), &runtimeConfig)
|
ret, err = runtime.Call(receiver, common.Hex2Bytes(ctx.GlobalString(InputFlag.Name)), &runtimeConfig)
|
||||||
}
|
}
|
||||||
vmdone := time.Since(tstart)
|
execTime := time.Since(tstart)
|
||||||
|
|
||||||
if ctx.GlobalBool(DumpFlag.Name) {
|
if ctx.GlobalBool(DumpFlag.Name) {
|
||||||
statedb.Commit(true)
|
statedb.Commit(true)
|
||||||
@ -118,19 +130,16 @@ func runCmd(ctx *cli.Context) error {
|
|||||||
vm.WriteTrace(os.Stderr, logger.StructLogs())
|
vm.WriteTrace(os.Stderr, logger.StructLogs())
|
||||||
fmt.Fprintln(os.Stderr, "#### LOGS ####")
|
fmt.Fprintln(os.Stderr, "#### LOGS ####")
|
||||||
vm.WriteLogs(os.Stderr, statedb.Logs())
|
vm.WriteLogs(os.Stderr, statedb.Logs())
|
||||||
}
|
|
||||||
|
|
||||||
if ctx.GlobalBool(SysStatFlag.Name) {
|
|
||||||
var mem goruntime.MemStats
|
var mem goruntime.MemStats
|
||||||
goruntime.ReadMemStats(&mem)
|
goruntime.ReadMemStats(&mem)
|
||||||
fmt.Printf("vm took %v\n", vmdone)
|
fmt.Fprintf(os.Stderr, `evm execution time: %v
|
||||||
fmt.Printf(`alloc: %d
|
heap objects: %d
|
||||||
tot alloc: %d
|
allocations: %d
|
||||||
no. malloc: %d
|
total allocations: %d
|
||||||
heap alloc: %d
|
GC calls: %d
|
||||||
heap objs: %d
|
|
||||||
num gc: %d
|
`, execTime, mem.HeapObjects, mem.Alloc, mem.TotalAlloc, mem.NumGC)
|
||||||
`, mem.Alloc, mem.TotalAlloc, mem.Mallocs, mem.HeapAlloc, mem.HeapObjects, mem.NumGC)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("0x%x", ret)
|
fmt.Printf("0x%x", ret)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user