Skip to content

EIP-2681 compliance - fail CREATE/CREATE2 at nonce max uint64-1#8

Open
Cordtus wants to merge 3 commits intocosmos:masterfrom
Cordtus:cordt/fix-nonce-check
Open

EIP-2681 compliance - fail CREATE/CREATE2 at nonce max uint64-1#8
Cordtus wants to merge 3 commits intocosmos:masterfrom
Cordtus:cordt/fix-nonce-check

Conversation

@Cordtus
Copy link

@Cordtus Cordtus commented Aug 6, 2025

Changes

  • Add guard in core/vm/evm.go:create - if creator nonce == math.MaxUint64 ⇒ return (nil, addr{}, gas, ErrNonceMax) before any side effects.
  • core/vm/errors.go: add ErrNonceMax. No opcode changes needed (errors already push 0).
  • Tests: top-level and internal create fail at 2⁶⁴−1 (full child gas returned); boundary at 2⁶⁴−2 succeeds and increments.
  • Addresses Issue #400
  • EIP-2681 referene

Testing

# Top-level create must fail at nonce==2^64-1 (no initcode gas)
go test ./core/vm -run TestCreate_TopLevel_MaxNonce -v

# Internal CREATE must fail at nonce==2^64-1 (pushes 0; no side effects)
go test ./core/vm -run TestCreate_Internal_MaxNonce -v

# Boundary: nonce==2^64-2 succeeds, increments to 2^64-1
go test ./core/vm -run TestCreate_Boundary_SucceedsAtMaxMinus1 -v

@Cordtus Cordtus marked this pull request as ready for review August 6, 2025 16:17
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.

1 participant