-
Notifications
You must be signed in to change notification settings - Fork 20.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
eth/state, les/state, et/tracers: properly init statedb accesslist #22480
Conversation
eth/state_accessor.go
Outdated
@@ -212,6 +212,7 @@ func (eth *Ethereum) stateAtTransaction(block *types.Block, txIndex int, reexec | |||
msg, _ := tx.AsMessage(signer) | |||
txContext := core.NewEVMTxContext(msg) | |||
context := core.NewEVMBlockContext(block.Header(), eth.blockchain, nil) | |||
statedb.Prepare(tx.Hash(), block.Hash(), idx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should move this down (so that it does not prepare the statedb for the tx to be traced), and rather do it on call-site. That way all 4 invocations of traceTx
will be the same. In the current code 3 manually does a prep and one inherits it from here, which seems brittle.
eth/tracers/api.go
Outdated
@@ -266,6 +266,7 @@ func (api *API) traceChain(ctx context.Context, start, end *types.Block, config | |||
// Trace all the transactions contained within | |||
for i, tx := range task.block.Transactions() { | |||
msg, _ := tx.AsMessage(signer) | |||
task.statedb.Prepare(tx.Hash(), task.block.Hash(), i) | |||
res, err := api.traceTx(ctx, msg, blockCtx, task.statedb, config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be a lot happier if we did thins in traceTx, seems wried to manually do this at all callsites
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, but we don't actually have the index nor the hash at that point. That may be fine, but might also at some later point pop up as as bug
I think the call-sites are fixed |
@holiman Don't know if it is relevant, but afaict we call ApplyTransaction in the miner without preparing the db too. Line 739 in 6387c52
|
That may indeed be really bad |
Ah no it's fine. It's done by the caller
|
At least the traces would have been correct then |
Proposed diff on top https://gist.github.com/karalabe/fdf7c431fceabc7f2e15ac6f041d6800 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
…2480) * eth/state, les/state: properly init statedb accesslist when tracing, fixes ethereum#22475 * eth: review comments * eth/tracers: fix compilation err * eth/tracers: apply @karalabe's suggested fix
....during tracing. Fixes #22475