feat(core): implement eip-7954 increase Maximum Contract Size #33832#2222
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Implements EIP-7954 by introducing Osaka-era contract/initcode size limits and centralizing size-limit enforcement across the EVM, state transition, txpool, and RPC error mapping to ensure consistent behavior post-Osaka.
Changes:
- Added Osaka max code/initcode size constants (
MaxCodeSizeOsaka,MaxInitCodeSizeOsaka) in protocol params. - Introduced VM helper checks (
CheckMaxCodeSize,CheckMaxInitCodeSize) and reused them in EVM contract creation and CREATE/CREATE2 gas paths. - Updated RPC validation error mapping to use
vm.ErrMaxInitCodeSizeExceededand removed the obsoletecore.ErrMaxInitCodeSizeExceededsentinel.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| params/protocol_params.go | Adds Osaka-specific max code and initcode size constants. |
| internal/ethapi/errors.go | Maps initcode-size validation failures to vm.ErrMaxInitCodeSizeExceeded. |
| core/vm/gas_table.go | Routes EIP-3860 CREATE/CREATE2 gas path initcode size checks through VM helper. |
| core/vm/gas_table_test.go | Updates CREATE/CREATE2 gas tests for Osaka-sized over-limit cases and new test DB helpers. |
| core/vm/evm.go | Centralizes deployed code size enforcement via CheckMaxCodeSize. |
| core/vm/common.go | Adds CheckMaxCodeSize / CheckMaxInitCodeSize helpers (Osaka-aware). |
| core/txpool/validation.go | Uses VM helper for initcode size validation in txpool. |
| core/state_transition.go | Uses VM helper for initcode size validation in state transition. |
| core/error.go | Removes obsolete core.ErrMaxInitCodeSizeExceeded sentinel. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // CheckMaxCodeSize checks the size of contract code against the protocol-defined limit. | ||
| func CheckMaxCodeSize(rules *params.Rules, size uint64) error { | ||
| if rules.IsOsaka { | ||
| if size > params.MaxCodeSizeOsaka { | ||
| return fmt.Errorf("%w: code size %v limit %v", ErrMaxCodeSizeExceeded, size, params.MaxCodeSizeOsaka) | ||
| } | ||
| } else if rules.IsEIP158 { | ||
| if size > params.MaxCodeSize { | ||
| return fmt.Errorf("%w: code size %v limit %v", ErrMaxCodeSizeExceeded, size, params.MaxCodeSize) | ||
| } |
There was a problem hiding this comment.
CheckMaxCodeSize now returns a wrapped error with additional context ("%w: code size ..."). This changes the error string from exactly "max code size exceeded" to something with a suffix, which breaks consumers doing string-equality mappings (e.g. eth/tracers/native/call_flat.go maps only the exact string "max code size exceeded"). Either keep the original error message stable for ErrMaxCodeSizeExceeded (and attach details another way), or update the string-based mapping logic to handle the new message format (e.g., prefix match).
…m#33832 - add Osaka contract size limits: MaxCodeSizeOsaka=32768 and MaxInitCodeSizeOsaka=65536 - centralize size checks in vm helpers (CheckMaxCodeSize / CheckMaxInitCodeSize) and reuse in state transition, txpool, EVM and CREATE/CREATE2 gas paths - map max-initcode-size RPC validation errors to vm.ErrMaxInitCodeSizeExceeded - remove obsolete core.ErrMaxInitCodeSizeExceeded sentinel - update create gas tests to validate post-Osaka behavior and explicit over-limit cases (0x10001)
Proposed changes
implement eip-7954
Ref: ethereum#33832
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which parts of the codebase does this PR touch?
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that