Skip to content

feat(core): implement eip-7954 increase Maximum Contract Size #33832#2222

Merged
AnilChinchawale merged 1 commit into
XinFinOrg:dev-upgradefrom
gzliudan:eip-7954
Mar 24, 2026
Merged

feat(core): implement eip-7954 increase Maximum Contract Size #33832#2222
AnilChinchawale merged 1 commit into
XinFinOrg:dev-upgradefrom
gzliudan:eip-7954

Conversation

@gzliudan
Copy link
Copy Markdown
Collaborator

Proposed changes

implement eip-7954

  • 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)

Ref: ethereum#33832

Types of changes

What types of changes does your code introduce to XDC network?
Put an in the boxes that apply

  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Changes that don't change source code or tests
  • docs: Documentation only changes
  • feat: A new feature
  • fix: A bug fix
  • perf: A code change that improves performance
  • refactor: A code change that neither fixes a bug nor adds a feature
  • revert: Revert something
  • style: Changes that do not affect the meaning of the code
  • test: Adding missing tests or correcting existing tests

Impacted Components

Which parts of the codebase does this PR touch?
Put an in the boxes that apply

  • Consensus
  • Account
  • Network
  • Geth
  • Smart Contract
  • External components
  • Not sure (Please specify below)

Checklist

Put an in the boxes once you have confirmed below actions (or provide reasons on not doing so) that

  • This PR has sufficient test coverage (unit/integration test) OR I have provided reason in the PR description for not having test coverage
  • Tested on a private network from the genesis block and monitored the chain operating correctly for multiple epochs.
  • Provide an end-to-end test plan in the PR description on how to manually test it on the devnet/testnet.
  • Tested the backwards compatibility.
  • Tested with XDC nodes running this version co-exist with those running the previous version.
  • Relevant documentation has been updated as part of this PR
  • N/A

Copilot AI review requested due to automatic review settings March 21, 2026 15:53
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 21, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9a4d2d35-0424-4094-95a1-2ff03d456243

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.ErrMaxInitCodeSizeExceeded and removed the obsolete core.ErrMaxInitCodeSizeExceeded sentinel.

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.

Comment thread core/vm/gas_table.go
Comment thread core/vm/common.go
Comment thread core/vm/common.go
Comment on lines +43 to +52
// 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)
}
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
…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)
@AnilChinchawale AnilChinchawale merged commit 1c5b9e6 into XinFinOrg:dev-upgrade Mar 24, 2026
13 checks passed
@gzliudan gzliudan deleted the eip-7954 branch March 24, 2026 10:58
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.

6 participants