core/vm: start tracer before update callee's nonce #28445
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #28439
I see what the question is :)
If the transaction is after EIP158(absolutely it is), we will set the created contract's nonce to 1
go-ethereum/core/vm/evm.go
Lines 445 to 461 in 233db64
But in the inner created contracts, we fetch the nonce in front of entering this scope, so its nonce is 0
go-ethereum/eth/tracers/native/prestate.go
Lines 161 to 179 in 233db64
So in general, the outer tx's created contract's nonce is always 1, and the inner created contracts' nonce is 0.
I found this issue does not happen in Erigon's node, dig into the code and found they will first start the tracer, and then launch the creating process. so the nonce is 0
https://github.com/ledgerwatch/erigon/blob/c90bff7e22337691ca4c41df41a782e805435f46/core/vm/evm.go#L335-L347
So I proposed to move the tracer a little forward, this will not affect the current implementation,