From e76d9dc483c55222ae30c4c3fa26376c3f8e97c5 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Mon, 16 Jun 2025 11:26:29 +0200 Subject: [PATCH] Improvements --- eth/tracers/native/prestate.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/eth/tracers/native/prestate.go b/eth/tracers/native/prestate.go index 6ded980d7a..0e9aafac8b 100644 --- a/eth/tracers/native/prestate.go +++ b/eth/tracers/native/prestate.go @@ -19,6 +19,7 @@ package native import ( "bytes" "encoding/json" + "errors" "math/big" "sync/atomic" @@ -75,7 +76,7 @@ type prestateTracerConfig struct { DiffMode bool `json:"diffMode"` // If true, this tracer will return state modifications DisableCode bool `json:"disableCode"` // If true, this tracer will not return the contract code DisableStorage bool `json:"disableStorage"` // If true, this tracer will not return the contract storage - EnableEmpty bool `json:"enableEmpty"` // If true, this tracer will return empty state objects + IncludeEmpty bool `json:"includeEmpty"` // If true, this tracer will return empty state objects } func newPrestateTracer(ctx *tracers.Context, cfg json.RawMessage, chainConfig *params.ChainConfig) (*tracers.Tracer, error) { @@ -83,6 +84,11 @@ func newPrestateTracer(ctx *tracers.Context, cfg json.RawMessage, chainConfig *p if err := json.Unmarshal(cfg, &config); err != nil { return nil, err } + // Diff mode has special semantics around account creating and deletion which + // requires it to include empty accounts and storage. + if config.DiffMode && config.IncludeEmpty { + return nil, errors.New("cannot use diffMode with includeEmpty") + } t := &prestateTracer{ pre: stateMap{}, post: stateMap{}, @@ -181,7 +187,7 @@ func (t *prestateTracer) OnTxEnd(receipt *types.Receipt, err error) { // the new created contracts' prestate were empty, so delete them for a := range t.created { // the created contract maybe exists in statedb before the creating tx - if s := t.pre[a]; s != nil && s.empty && !t.config.EnableEmpty { + if s := t.pre[a]; s != nil && s.empty && !t.config.IncludeEmpty { delete(t.pre, a) } }