Skip to content

Conversation

@holiman
Copy link
Contributor

@holiman holiman commented Mar 11, 2021

....during tracing. Fixes #22475

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.

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