Skip to content
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

Merged
merged 4 commits into from
Mar 14, 2021

Conversation

holiman
Copy link
Contributor

@holiman holiman commented Mar 11, 2021

....during tracing. Fixes #22475

@@ -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)
Copy link
Member

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.

@@ -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)
Copy link
Member

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

Copy link
Contributor Author

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

@holiman
Copy link
Contributor Author

holiman commented Mar 11, 2021

I think the call-sites are fixed

@MariusVanDerWijden
Copy link
Member

@holiman Don't know if it is relevant, but afaict we call ApplyTransaction in the miner without preparing the db too.
See:

receipt, err := core.ApplyTransaction(w.chainConfig, w.chain, &coinbase, w.current.gasPool, w.current.state, w.current.header, tx, &w.current.header.GasUsed, *w.chain.GetVMConfig())

@holiman
Copy link
Contributor Author

holiman commented Mar 12, 2021

@holiman Don't know if it is relevant, but afaict we call ApplyTransaction in the miner without preparing the db too.

cc @fjl could you PTAL?

@holiman
Copy link
Contributor Author

holiman commented Mar 12, 2021

That may indeed be really bad

@holiman
Copy link
Contributor Author

holiman commented Mar 12, 2021

Ah no it's fine. It's done by the caller

		w.current.state.Prepare(tx.Hash(), common.Hash{}, w.current.tcount)

		logs, err := w.commitTransaction(tx, coinbase)

@karalabe
Copy link
Member

@holiman Don't know if it is relevant, but afaict we call ApplyTransaction in the miner without preparing the db too.

At least the traces would have been correct then :trollface:

@karalabe
Copy link
Member

Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

@karalabe karalabe added this to the 1.10.2 milestone Mar 14, 2021
@karalabe karalabe merged commit c6d4500 into ethereum:master Mar 14, 2021
atif-konasl pushed a commit to frozeman/pandora-execution-engine that referenced this pull request Oct 15, 2021
…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
formingform added a commit to formingform/PlatON-Go that referenced this pull request Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

debug_traceTransaction gas usage doesn't match transaction receipt
3 participants