-
Notifications
You must be signed in to change notification settings - Fork 13
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
Conversation
Signed-off-by: Ignacio Hagopian <[email protected]>
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) |
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.
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
)?
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.
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.
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) |
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.
The replay panicked just before here, but this also requires a fix.
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.
ah ok so you're not actually removing it. nvm, it'll be removed soon enough.
statelessGas := interpreter.evm.Accesses.TouchAddressOnReadAndComputeGas(slot.Bytes(), uint256.Int{}, utils.CodeKeccakLeafKey) | ||
statelessGas := interpreter.evm.Accesses.TouchAddressOnReadAndComputeGas(address[:], uint256.Int{}, utils.CodeKeccakLeafKey) |
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.
This is other case I found by code exploring.
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.
LGTM. Thanks for catching that.
Signed-off-by: Ignacio Hagopian <[email protected]>
Signed-off-by: Ignacio Hagopian <[email protected]>
Signed-off-by: Ignacio Hagopian <[email protected]>
The replay found another case similar to #397. I scanned for more similar cases and found one extra.
Leaving some comments.