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

cannon: Implement 64-bit Solidity VM #12665

Merged
merged 14 commits into from
Oct 30, 2024
Merged

cannon: Implement 64-bit Solidity VM #12665

merged 14 commits into from
Oct 30, 2024

Conversation

Inphi
Copy link
Contributor

@Inphi Inphi commented Oct 26, 2024

Introduces a new VM smart contract that implements 64-bit Cannon (with multitasking). This is implemented in MIPS64.sol.

Testing

Differential testing of both 64-bit VMs is re-enabled. These tests can be run using make -C ./cannon test64.
These tests include:

  • single step 32 and 64-bit instructions for the cannon64 build.
  • hello.64.elf and claim.64.elf program execution.

These tests don't yet run in CI because there are existing diff tests for the cannon32 build that aren't 64-bit compatible. Fixing those tests and CI integration will be addressed in another PR.

Meta

Fixes #12250

@Inphi Inphi force-pushed the inphi/mips64-contract branch from 7010229 to 7a4d3d2 Compare October 26, 2024 21:11
Copy link

codecov bot commented Oct 26, 2024

Codecov Report

Attention: Patch coverage is 49.01961% with 26 lines in your changes missing coverage. Please review.

Project coverage is 63.62%. Comparing base (d6bda03) to head (1078359).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
cannon/mipsevm/testutil/mips.go 55.55% 15 Missing and 1 partial ⚠️
cannon/mipsevm/testutil/evm.go 20.00% 7 Missing and 1 partial ⚠️
cannon/mipsevm/exec/memory.go 0.00% 0 Missing and 1 partial ⚠️
cannon/mipsevm/exec/mips_instructions.go 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #12665      +/-   ##
===========================================
- Coverage    63.99%   63.62%   -0.38%     
===========================================
  Files           55       55              
  Lines         4605     4629      +24     
===========================================
- Hits          2947     2945       -2     
- Misses        1475     1502      +27     
+ Partials       183      182       -1     
Flag Coverage Δ
cannon-go-tests 63.62% <49.01%> (-0.38%) ⬇️

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

Files with missing lines Coverage Δ
cannon/mipsevm/testutil/memory.go 77.77% <100.00%> (ø)
cannon/mipsevm/exec/memory.go 80.95% <0.00%> (ø)
cannon/mipsevm/exec/mips_instructions.go 67.17% <66.66%> (+0.34%) ⬆️
cannon/mipsevm/testutil/evm.go 66.94% <20.00%> (-3.86%) ⬇️
cannon/mipsevm/testutil/mips.go 78.82% <55.55%> (-6.25%) ⬇️

... and 1 file with indirect coverage changes

@Inphi Inphi force-pushed the inphi/mips64-contract branch from 7a4d3d2 to 1d8d82e Compare October 27, 2024 04:13
@Inphi Inphi requested a review from mbaxter October 28, 2024 16:13
- Implements 64-bit Cannon (with multithreading) in MIPS64.sol
- Re-enable differential testing for 64-bit VMs
@Inphi Inphi force-pushed the inphi/mips64-contract branch from 1d8d82e to 4046108 Compare October 28, 2024 16:15
@Inphi Inphi marked this pull request as ready for review October 28, 2024 16:15
cannon/mipsevm/testutil/mips.go Show resolved Hide resolved
packages/contracts-bedrock/src/cannon/MIPS64.sol Outdated Show resolved Hide resolved
packages/contracts-bedrock/src/cannon/MIPS64.sol Outdated Show resolved Hide resolved
packages/contracts-bedrock/src/cannon/MIPS64.sol Outdated Show resolved Hide resolved
cannon/mipsevm/exec/mips_instructions.go Show resolved Hide resolved
cannon/mipsevm/exec/mips_instructions.go Show resolved Hide resolved
@Inphi Inphi requested a review from mbaxter October 29, 2024 15:43
Copy link
Contributor

@mbaxter mbaxter left a comment

Choose a reason for hiding this comment

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

Did another pass comparing on/off-chain impls. Left a few more nits which are pretty minor. I think we should probably add a test around the InvalidPC error. I would feel better if we had more differential tests on some of the math, but if you feel strongly we can always follow up with more testing in later PRs.

Base automatically changed from inphi/cannon64-memory-sol to develop October 29, 2024 21:04
cannon/mipsevm/tests/evm_common_test.go Outdated Show resolved Hide resolved
cannon/mipsevm/tests/evm_common_test.go Show resolved Hide resolved
cannon/mipsevm/tests/evm_common_test.go Outdated Show resolved Hide resolved
@Inphi Inphi added this pull request to the merge queue Oct 30, 2024
Merged via the queue into develop with commit 96ef7bb Oct 30, 2024
51 checks passed
@Inphi Inphi deleted the inphi/mips64-contract branch October 30, 2024 17:30
axelKingsley pushed a commit that referenced this pull request Oct 31, 2024
* cannon: Implement MIPS64Memory.sol

* cannon: Implement 64-bit Solidity VM

- Implements 64-bit Cannon (with multithreading) in MIPS64.sol
- Re-enable differential testing for 64-bit VMs

* review comments

* check pc for 4-byte alignment

* gofmt

* update snapshot

* address nits; add more add/sub/mult overflow tests

* diff test misaligned instruction

* fix mul[t] MIPS64.sol emulation

* diff fuzz mul operations

* fix addiu test case

* fix GetInstruction return value type
samlaf pushed a commit to samlaf/optimism that referenced this pull request Nov 10, 2024
* cannon: Implement MIPS64Memory.sol

* cannon: Implement 64-bit Solidity VM

- Implements 64-bit Cannon (with multithreading) in MIPS64.sol
- Re-enable differential testing for 64-bit VMs

* review comments

* check pc for 4-byte alignment

* gofmt

* update snapshot

* address nits; add more add/sub/mult overflow tests

* diff test misaligned instruction

* fix mul[t] MIPS64.sol emulation

* diff fuzz mul operations

* fix addiu test case

* fix GetInstruction return value type
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.

64-bit MT-Cannon Solidity Implementation
2 participants