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

spec bugfixes #505

Merged
merged 2 commits into from
Oct 8, 2024
Merged

spec bugfixes #505

merged 2 commits into from
Oct 8, 2024

Conversation

jsign
Copy link
Collaborator

@jsign jsign commented Oct 4, 2024

This PR fixes two apparent bugs:

  • callGasVariant4762 not ignoring system contracts
  • pushN touching off-by-one error.

Signed-off-by: Ignacio Hagopian <[email protected]>
Signed-off-by: Ignacio Hagopian <[email protected]>
@jsign jsign changed the title chargeCallVariantEIP4762: don't charge if the target is a system contract spec bugfixes Oct 5, 2024
@@ -763,7 +763,7 @@ func opCreate2(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]

func chargeCallVariantEIP4762(evm *EVM, scope *ScopeContext) bool {
target := common.Address(scope.Stack.Back(1).Bytes20())
if _, isPrecompile := evm.precompile(target); isPrecompile {
if _, isPrecompile := evm.precompile(target); isPrecompile || evm.isSystemContract(target) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image

if !interpreter.evm.Accesses.TouchCodeChunksRangeAndChargeGas(codeAddr[:], *pc+1, uint64(1), uint64(len(scope.Contract.Code)), false, scope.Contract.UseGas) {
if !interpreter.evm.Accesses.TouchCodeChunksRangeAndChargeGas(codeAddr[:], *pc, uint64(1), uint64(len(scope.Contract.Code)), false, scope.Contract.UseGas) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note that in L1073, pc is already pointed at the first byte of the immediate.

@jsign jsign requested a review from gballet October 7, 2024 13:34
@jsign jsign marked this pull request as ready for review October 7, 2024 13:34
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. Weird that the +1 issue was uncaught for so long.

@gballet gballet merged commit 85196cc into jsign-witness-fix Oct 8, 2024
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.

2 participants