Skip to content

Comments

cannon: Make state version available to MIPS contracts.#15425

Closed
ajsutton wants to merge 18 commits intodevelopfrom
aj/cannon-solidity-feature-toggles
Closed

cannon: Make state version available to MIPS contracts.#15425
ajsutton wants to merge 18 commits intodevelopfrom
aj/cannon-solidity-feature-toggles

Conversation

@ajsutton
Copy link
Contributor

@ajsutton ajsutton commented Apr 16, 2025

Description

Updates MIPS2.sol and MIPS64.sol to pass the state version through to the contract constructor. This can then be used as a feature toggle like in the go version to enable new opcodes or sys calls only when a new state version is used.

The MIPS deployment is still a singleton that can be shared across the superchain, this just allows maintaining support for multiple versions in develop branch and thus not blocking contract releases while new features are in development.

The existing mipsVersion used with op-deployer and OPCM is reused here, so version 1 continues to mean the single threaded MIPS.sol and 2 means MIPS64.sol as before. Going forward when a new state version is added (e.g. for go 1.23 support), MIPS64.sol should be deployed with the actual state version specified. Defaults in op-deployer can be updated when the new version becomes the standard version so this option should only need to be specified as part of testing.

Implementing the new sys call would be done with a feature toggle. We currently have a bunch of ifs like:

} else if (syscall_no == sys.SYS_LSEEK) {
// ignored

and this would just add another one:

} else if (STATE_VERSION >=6 && syscall_no == sys.SYS_EVENTFD2) {
  // ignored
} else ....

Tests

Updated tests.

@codecov
Copy link

codecov bot commented Apr 16, 2025

Codecov Report

Attention: Patch coverage is 81.11111% with 17 lines in your changes missing coverage. Please review.

Project coverage is 46.39%. Comparing base (11ace4c) to head (92f7de5).
Report is 28 commits behind head on develop.

Files with missing lines Patch % Lines
cannon/mipsevm/tests/helpers.go 83.87% 5 Missing ⚠️
cannon/cmd/load_elf.go 0.00% 4 Missing ⚠️
cannon/mipsevm/versions/state.go 84.61% 4 Missing ⚠️
cannon/mipsevm/multithreaded/state.go 0.00% 2 Missing ⚠️
cannon/mipsevm/program/testutil/mocks.go 0.00% 1 Missing ⚠️
cannon/mipsevm/singlethreaded/state.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #15425      +/-   ##
===========================================
- Coverage    46.48%   46.39%   -0.10%     
===========================================
  Files         1250     1250              
  Lines       103813   103845      +32     
===========================================
- Hits         48262    48180      -82     
- Misses       52159    52287     +128     
+ Partials      3392     3378      -14     
Flag Coverage Δ
cannon-go-tests-32 62.26% <70.45%> (-1.73%) ⬇️
cannon-go-tests-64 57.41% <56.81%> (-1.27%) ⬇️
contracts-bedrock-tests 94.30% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cannon/mipsevm/multithreaded/instrumented.go 60.75% <100.00%> (-4.63%) ⬇️
cannon/mipsevm/testutil/evm.go 70.58% <100.00%> (+2.33%) ⬆️
cannon/mipsevm/versions/version.go 80.00% <100.00%> (ø)
op-deployer/pkg/deployer/opcm/implementations.go 52.38% <100.00%> (+1.16%) ⬆️
packages/contracts-bedrock/src/cannon/MIPS2.sol 84.90% <100.00%> (ø)
cannon/mipsevm/program/testutil/mocks.go 46.66% <0.00%> (ø)
cannon/mipsevm/singlethreaded/state.go 55.88% <0.00%> (ø)
cannon/mipsevm/multithreaded/state.go 55.13% <0.00%> (ø)
cannon/cmd/load_elf.go 0.00% <0.00%> (ø)
cannon/mipsevm/versions/state.go 59.79% <84.61%> (+10.38%) ⬆️
... and 1 more

... and 12 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Base automatically changed from aj/cannon-feature-toggles to develop April 16, 2025 21:50
@ajsutton
Copy link
Contributor Author

Closing in favour of #15487

@ajsutton ajsutton closed this Apr 22, 2025
@ajsutton ajsutton deleted the aj/cannon-solidity-feature-toggles branch September 8, 2025 23:04
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