aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2017-03-01 17:19:15 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2017-03-01 18:20:25 +0800
commitbf4155846cf1adaf03e6395a93ce911f315acdbf (patch)
treeeec6000ddf86fda4b71c7da1ecd078043884b379 /cmd
parent230cf2ec9142b6a8f421cb8873deb5df1566e89c (diff)
downloadgo-tangerine-bf4155846cf1adaf03e6395a93ce911f315acdbf.tar
go-tangerine-bf4155846cf1adaf03e6395a93ce911f315acdbf.tar.gz
go-tangerine-bf4155846cf1adaf03e6395a93ce911f315acdbf.tar.bz2
go-tangerine-bf4155846cf1adaf03e6395a93ce911f315acdbf.tar.lz
go-tangerine-bf4155846cf1adaf03e6395a93ce911f315acdbf.tar.xz
go-tangerine-bf4155846cf1adaf03e6395a93ce911f315acdbf.tar.zst
go-tangerine-bf4155846cf1adaf03e6395a93ce911f315acdbf.zip
core/evm, core/vm: improved evm trace output
* Improved the standard evm tracer output and renamed it to WriteTrace which now takes an io.Writer to write the logs to. * Added WriteLogs which writes logs to the given writer in a readable format. * evm utility now also prints logs generated during the execution.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/evm/runner.go51
1 files changed, 24 insertions, 27 deletions
diff --git a/cmd/evm/runner.go b/cmd/evm/runner.go
index 0bed46894..8a71a92f7 100644
--- a/cmd/evm/runner.go
+++ b/cmd/evm/runner.go
@@ -53,7 +53,6 @@ func runCmd(ctx *cli.Context) error {
statedb, _ = state.New(common.Hash{}, db)
sender = common.StringToAddress("sender")
logger = vm.NewStructLogger(nil)
- tstart = time.Now()
)
statedb.CreateAccount(sender)
@@ -84,36 +83,28 @@ func runCmd(ctx *cli.Context) error {
code = common.Hex2Bytes(string(bytes.TrimRight(hexcode, "\n")))
}
+ runtimeConfig := runtime.Config{
+ Origin: sender,
+ State: statedb,
+ GasLimit: ctx.GlobalUint64(GasFlag.Name),
+ GasPrice: utils.GlobalBig(ctx, PriceFlag.Name),
+ Value: utils.GlobalBig(ctx, ValueFlag.Name),
+ EVMConfig: vm.Config{
+ Tracer: logger,
+ Debug: ctx.GlobalBool(DebugFlag.Name),
+ DisableGasMetering: ctx.GlobalBool(DisableGasMeteringFlag.Name),
+ },
+ }
+
+ tstart := time.Now()
if ctx.GlobalBool(CreateFlag.Name) {
input := append(code, common.Hex2Bytes(ctx.GlobalString(InputFlag.Name))...)
- ret, _, err = runtime.Create(input, &runtime.Config{
- Origin: sender,
- State: statedb,
- GasLimit: ctx.GlobalUint64(GasFlag.Name),
- GasPrice: utils.GlobalBig(ctx, PriceFlag.Name),
- Value: utils.GlobalBig(ctx, ValueFlag.Name),
- EVMConfig: vm.Config{
- Tracer: logger,
- Debug: ctx.GlobalBool(DebugFlag.Name),
- DisableGasMetering: ctx.GlobalBool(DisableGasMeteringFlag.Name),
- },
- })
+ ret, _, err = runtime.Create(input, &runtimeConfig)
} else {
receiver := common.StringToAddress("receiver")
statedb.SetCode(receiver, code)
- ret, err = runtime.Call(receiver, common.Hex2Bytes(ctx.GlobalString(InputFlag.Name)), &runtime.Config{
- Origin: sender,
- State: statedb,
- GasLimit: ctx.GlobalUint64(GasFlag.Name),
- GasPrice: utils.GlobalBig(ctx, PriceFlag.Name),
- Value: utils.GlobalBig(ctx, ValueFlag.Name),
- EVMConfig: vm.Config{
- Tracer: logger,
- Debug: ctx.GlobalBool(DebugFlag.Name),
- DisableGasMetering: ctx.GlobalBool(DisableGasMeteringFlag.Name),
- },
- })
+ ret, err = runtime.Call(receiver, common.Hex2Bytes(ctx.GlobalString(InputFlag.Name)), &runtimeConfig)
}
vmdone := time.Since(tstart)
@@ -121,7 +112,13 @@ func runCmd(ctx *cli.Context) error {
statedb.Commit(true)
fmt.Println(string(statedb.Dump()))
}
- vm.StdErrFormat(logger.StructLogs())
+
+ if ctx.GlobalBool(DebugFlag.Name) {
+ fmt.Fprintln(os.Stderr, "#### TRACE ####")
+ vm.WriteTrace(os.Stderr, logger.StructLogs())
+ fmt.Fprintln(os.Stderr, "#### LOGS ####")
+ vm.WriteLogs(os.Stderr, statedb.Logs())
+ }
if ctx.GlobalBool(SysStatFlag.Name) {
var mem goruntime.MemStats
@@ -136,7 +133,7 @@ num gc: %d
`, mem.Alloc, mem.TotalAlloc, mem.Mallocs, mem.HeapAlloc, mem.HeapObjects, mem.NumGC)
}
- fmt.Printf("OUT: 0x%x", ret)
+ fmt.Printf("0x%x", ret)
if err != nil {
fmt.Printf(" error: %v", err)
}