aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-11-17 00:53:18 +0800
committerGitHub <noreply@github.com>2017-11-17 00:53:18 +0800
commitb0190189a386d13eb2e8bbdb6d64d9ef8c0e572a (patch)
tree527d628292c98a8b550584fa0483a85c55779b50 /core
parent87f5b4123c6e2a48ad67426a34763acc50c821f8 (diff)
downloaddexon-b0190189a386d13eb2e8bbdb6d64d9ef8c0e572a.tar
dexon-b0190189a386d13eb2e8bbdb6d64d9ef8c0e572a.tar.gz
dexon-b0190189a386d13eb2e8bbdb6d64d9ef8c0e572a.tar.bz2
dexon-b0190189a386d13eb2e8bbdb6d64d9ef8c0e572a.tar.lz
dexon-b0190189a386d13eb2e8bbdb6d64d9ef8c0e572a.tar.xz
dexon-b0190189a386d13eb2e8bbdb6d64d9ef8c0e572a.tar.zst
dexon-b0190189a386d13eb2e8bbdb6d64d9ef8c0e572a.zip
core/vm, internal/ethapi: tracer no full storage, nicer json output (#15499)
* core/vm, internal/ethapi: tracer no full storage, nicer json output * core/vm, internal/ethapi: omit disabled trace fields
Diffstat (limited to 'core')
-rw-r--r--core/vm/logger.go26
-rw-r--r--core/vm/logger_test.go24
2 files changed, 4 insertions, 46 deletions
diff --git a/core/vm/logger.go b/core/vm/logger.go
index 623c0d563..75309da92 100644
--- a/core/vm/logger.go
+++ b/core/vm/logger.go
@@ -45,7 +45,6 @@ type LogConfig struct {
DisableMemory bool // disable memory capture
DisableStack bool // disable stack capture
DisableStorage bool // disable storage capture
- FullStorage bool // show full storage (slow)
Limit int // maximum length of output, but zero means unlimited
}
@@ -136,14 +135,13 @@ func (l *StructLogger) CaptureState(env *EVM, pc uint64, op OpCode, gas, cost ui
)
l.changedValues[contract.Address()][address] = value
}
- // copy a snapstot of the current memory state to a new buffer
+ // Copy a snapstot of the current memory state to a new buffer
var mem []byte
if !l.cfg.DisableMemory {
mem = make([]byte, len(memory.Data()))
copy(mem, memory.Data())
}
-
- // copy a snapshot of the current stack state to a new buffer
+ // Copy a snapshot of the current stack state to a new buffer
var stck []*big.Int
if !l.cfg.DisableStack {
stck = make([]*big.Int, len(stack.Data()))
@@ -151,26 +149,10 @@ func (l *StructLogger) CaptureState(env *EVM, pc uint64, op OpCode, gas, cost ui
stck[i] = new(big.Int).Set(item)
}
}
-
- // Copy the storage based on the settings specified in the log config. If full storage
- // is disabled (default) we can use the simple Storage.Copy method, otherwise we use
- // the state object to query for all values (slow process).
+ // Copy a snapshot of the current storage to a new container
var storage Storage
if !l.cfg.DisableStorage {
- if l.cfg.FullStorage {
- storage = make(Storage)
- // Get the contract account and loop over each storage entry. This may involve looping over
- // the trie and is a very expensive process.
-
- env.StateDB.ForEachStorage(contract.Address(), func(key, value common.Hash) bool {
- storage[key] = value
- // Return true, indicating we'd like to continue.
- return true
- })
- } else {
- // copy a snapshot of the current storage to a new container.
- storage = l.changedValues[contract.Address()].Copy()
- }
+ storage = l.changedValues[contract.Address()].Copy()
}
// create a new snaptshot of the EVM.
log := StructLog{pc, op, gas, cost, mem, memory.Len(), stck, storage, depth, err}
diff --git a/core/vm/logger_test.go b/core/vm/logger_test.go
index b6fa31132..915f7177e 100644
--- a/core/vm/logger_test.go
+++ b/core/vm/logger_test.go
@@ -63,32 +63,8 @@ func TestStoreCapture(t *testing.T) {
if len(logger.changedValues[contract.Address()]) == 0 {
t.Fatalf("expected exactly 1 changed value on address %x, got %d", contract.Address(), len(logger.changedValues[contract.Address()]))
}
-
exp := common.BigToHash(big.NewInt(1))
if logger.changedValues[contract.Address()][index] != exp {
t.Errorf("expected %x, got %x", exp, logger.changedValues[contract.Address()][index])
}
}
-
-func TestStorageCapture(t *testing.T) {
- t.Skip("implementing this function is difficult. it requires all sort of interfaces to be implemented which isn't trivial. The value (the actual test) isn't worth it")
- var (
- ref = &dummyContractRef{}
- contract = NewContract(ref, ref, new(big.Int), 0)
- env = NewEVM(Context{}, dummyStateDB{ref: ref}, params.TestChainConfig, Config{EnableJit: false, ForceJit: false})
- logger = NewStructLogger(nil)
- mem = NewMemory()
- stack = newstack()
- )
-
- logger.CaptureState(env, 0, STOP, 0, 0, mem, stack, contract, 0, nil)
- if ref.calledForEach {
- t.Error("didn't expect for each to be called")
- }
-
- logger = NewStructLogger(&LogConfig{FullStorage: true})
- logger.CaptureState(env, 0, STOP, 0, 0, mem, stack, contract, 0, nil)
- if !ref.calledForEach {
- t.Error("expected for each to be called")
- }
-}