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

more address truncation fixes #399

Merged
merged 1 commit into from
Mar 6, 2024
Merged

Conversation

jsign
Copy link
Collaborator

@jsign jsign commented Mar 5, 2024

The replay found another case similar to #397. I scanned for more similar cases and found one extra.

Leaving some comments.

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Comment on lines +104 to +106
address := slot.Bytes20()
if evm.chainRules.IsPrague {
usedGas += evm.TxContext.Accesses.TouchAddressOnReadAndComputeGas(slot.Bytes(), uint256.Int{}, trieUtils.CodeSizeLeafKey)
usedGas += evm.TxContext.Accesses.TouchAddressOnReadAndComputeGas(address[:], uint256.Int{}, trieUtils.CodeSizeLeafKey)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was the offending line that caused the new panic.

But I was wondering if L105-107 are really needed. This method is the one that calculates the dynamic gas. This touch on CodeSizeLeafKey also happens in opExtCodeSize (which I also fixed, since if not it would panic there too).

The dynamic gas method is called before the actual opcode execution, so that's why it panicked here. But I think we can avoid the touching here, and just rely on the opcode execution method (i.e: opExtCodeSize)?

Copy link
Owner

Choose a reason for hiding this comment

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

yes, and in fact this is fixed in my access witness rebase but since it's going to take a bit of time, better merge this asap.

Comment on lines +356 to +359
address := slot.Bytes20()
cs := uint64(interpreter.evm.StateDB.GetCodeSize(address))
if interpreter.evm.chainRules.IsPrague {
statelessGas := interpreter.evm.Accesses.TouchAddressOnReadAndComputeGas(slot.Bytes(), uint256.Int{}, utils.CodeSizeLeafKey)
statelessGas := interpreter.evm.Accesses.TouchAddressOnReadAndComputeGas(address[:], uint256.Int{}, utils.CodeSizeLeafKey)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The replay panicked just before here, but this also requires a fix.

Copy link
Owner

Choose a reason for hiding this comment

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

ah ok so you're not actually removing it. nvm, it'll be removed soon enough.

Comment on lines -498 to +499
statelessGas := interpreter.evm.Accesses.TouchAddressOnReadAndComputeGas(slot.Bytes(), uint256.Int{}, utils.CodeKeccakLeafKey)
statelessGas := interpreter.evm.Accesses.TouchAddressOnReadAndComputeGas(address[:], uint256.Int{}, utils.CodeKeccakLeafKey)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is other case I found by code exploring.

@jsign jsign marked this pull request as ready for review March 5, 2024 11:17
@jsign jsign requested a review from gballet March 5, 2024 11:18
Copy link
Owner

@gballet gballet left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for catching that.

@gballet gballet merged commit 25a358f into kaustinen-with-shapella Mar 6, 2024
2 of 3 checks passed
gballet pushed a commit that referenced this pull request May 7, 2024
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
gballet pushed a commit that referenced this pull request May 8, 2024
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
gballet pushed a commit that referenced this pull request May 8, 2024
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
gballet pushed a commit that referenced this pull request May 8, 2024
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
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.

None yet

2 participants