diff options
author | Martin Holst Swende <martin@swende.se> | 2018-10-23 22:28:18 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2018-10-23 22:28:18 +0800 |
commit | 4c0883e20d78b987dc95acd46498f326626aaee3 (patch) | |
tree | 056c6ae87ae9e4746affe66058396162910021fa /eth/tracers/tracer.go | |
parent | 3088c122d8497acf176f03a3f19f6292e817cab7 (diff) | |
download | dexon-4c0883e20d78b987dc95acd46498f326626aaee3.tar dexon-4c0883e20d78b987dc95acd46498f326626aaee3.tar.gz dexon-4c0883e20d78b987dc95acd46498f326626aaee3.tar.bz2 dexon-4c0883e20d78b987dc95acd46498f326626aaee3.tar.lz dexon-4c0883e20d78b987dc95acd46498f326626aaee3.tar.xz dexon-4c0883e20d78b987dc95acd46498f326626aaee3.tar.zst dexon-4c0883e20d78b987dc95acd46498f326626aaee3.zip |
core/vm: adds refund as part of the json standard trace (#17910)
This adds the global accumulated refund counter to the standard
json output as a numeric json value. Previously this was not very
interesting since it was not used much, but with the new sstore
gas changes the value is a lot more interesting from a consensus
investigation perspective.
Diffstat (limited to 'eth/tracers/tracer.go')
-rw-r--r-- | eth/tracers/tracer.go | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/eth/tracers/tracer.go b/eth/tracers/tracer.go index b519236f2..3533a831f 100644 --- a/eth/tracers/tracer.go +++ b/eth/tracers/tracer.go @@ -290,11 +290,12 @@ type Tracer struct { contractWrapper *contractWrapper // Wrapper around the contract object dbWrapper *dbWrapper // Wrapper around the VM environment - pcValue *uint // Swappable pc value wrapped by a log accessor - gasValue *uint // Swappable gas value wrapped by a log accessor - costValue *uint // Swappable cost value wrapped by a log accessor - depthValue *uint // Swappable depth value wrapped by a log accessor - errorValue *string // Swappable error value wrapped by a log accessor + pcValue *uint // Swappable pc value wrapped by a log accessor + gasValue *uint // Swappable gas value wrapped by a log accessor + costValue *uint // Swappable cost value wrapped by a log accessor + depthValue *uint // Swappable depth value wrapped by a log accessor + errorValue *string // Swappable error value wrapped by a log accessor + refundValue *uint // Swappable refund value wrapped by a log accessor ctx map[string]interface{} // Transaction context gathered throughout execution err error // Error, if one has occurred @@ -323,6 +324,7 @@ func New(code string) (*Tracer, error) { gasValue: new(uint), costValue: new(uint), depthValue: new(uint), + refundValue: new(uint), } // Set up builtins for this environment tracer.vm.PushGlobalGoFunction("toHex", func(ctx *duktape.Context) int { @@ -442,6 +444,9 @@ func New(code string) (*Tracer, error) { tracer.vm.PushGoFunction(func(ctx *duktape.Context) int { ctx.PushUint(*tracer.depthValue); return 1 }) tracer.vm.PutPropString(logObject, "getDepth") + tracer.vm.PushGoFunction(func(ctx *duktape.Context) int { ctx.PushUint(*tracer.refundValue); return 1 }) + tracer.vm.PutPropString(logObject, "getRefund") + tracer.vm.PushGoFunction(func(ctx *duktape.Context) int { if tracer.errorValue != nil { ctx.PushString(*tracer.errorValue) @@ -527,6 +532,7 @@ func (jst *Tracer) CaptureState(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost *jst.gasValue = uint(gas) *jst.costValue = uint(cost) *jst.depthValue = uint(depth) + *jst.refundValue = uint(env.StateDB.GetRefund()) jst.errorValue = nil if err != nil { |