Skip to content

Comments

cannon: allocator preheap instrumentation [rebased from ec2#2]#16030

Merged
Inphi merged 60 commits intoethereum-optimism:developfrom
ChainSafe:ec2/alloc-preheap
Aug 18, 2025
Merged

cannon: allocator preheap instrumentation [rebased from ec2#2]#16030
Inphi merged 60 commits intoethereum-optimism:developfrom
ChainSafe:ec2/alloc-preheap

Conversation

@salindne
Copy link
Contributor

@salindne salindne commented May 20, 2025

This PR revives ec2#2, originally opened by Eric from ChainSafe, for upstream consideration. It includes instrumentation for runtime allocator preheap behavior useful in constrained deployments of the OP Stack.

Changes were migrated to ChainSafe/optimism#ec2/alloc-preheap after Eric left our organization.

cc @clabby for context — reviving Eric's previous PR (#2 on ec2/optimism) now ported to ChainSafe's fork here. Will try to resolve conflicts

@salindne salindne requested a review from a team as a code owner May 20, 2025 17:45
@salindne
Copy link
Contributor Author

salindne commented Aug 1, 2025

I jumped in a bit. The stale cache issues seem to have gone with the changed testing, but will still probably want to add limiting the instruction set and heap size to the tests.

Ill wait for the rest to get merge, looks like fuzz tests are left, and can probably add the code/heap size VMfactory options in the difftester.go file after and remove the StoreInstructionWithCacheUpdate function I added earlier that helped with the stale cache issues.

Will wait for confirmation that test migration is done.

Thank you!

@mbaxter
Copy link
Contributor

mbaxter commented Aug 1, 2025

looks like fuzz tests are left ... Will wait for confirmation that test migration is done.

Yes - just need to get this last PR merged and then the migration will be done and tests will be stable again 🙏

@mbaxter
Copy link
Contributor

mbaxter commented Aug 11, 2025

Yes - just need to get this last PR merged and then the migration will be done and tests will be stable again 🙏

Update - this PR is merged now!

@Inphi
Copy link
Contributor

Inphi commented Aug 11, 2025

Yes - just need to get this last PR merged and then the migration will be done and tests will be stable again 🙏

Update - this PR is merged now!

Thanks. Let's rebase the migration changes from develop.

@Inphi
Copy link
Contributor

Inphi commented Aug 12, 2025

/ci authorize 98ae85b

…incremented, added decoded cache updateing to difftester_test.go
@salindne
Copy link
Contributor Author

salindne commented Aug 12, 2025

Missed integrating difftester_test.go with changes to cache and instr/heap size. Some tests that failed in instrumented_test.go I got working locally after slightly increasing the max step limit.

@Inphi
Copy link
Contributor

Inphi commented Aug 12, 2025

/ci authorize 25b4751

@Inphi
Copy link
Contributor

Inphi commented Aug 13, 2025

/ci authorize 11b2176

@salindne
Copy link
Contributor Author

salindne commented Aug 13, 2025

Im not sure how to approach the multithreaded test, looks like there is a timeout in the ci tests, the tests seem to individually pass, other than one test causes an OS signal kill for me locally.

For the fuzz tests, they all pass on my local implementation, Im not sure how to approach the error.

@Inphi
Copy link
Contributor

Inphi commented Aug 13, 2025

Im not sure how to approach the multithreaded test, looks like there is a timeout in the ci tests, the tests seem to individually pass, other than one test causes an OS signal kill for me locally.

For the fuzz tests, they all pass on my local implementation, Im not sure how to approach the error.

The tests are OOM'ing in CI as the test runner doesn't have much memory to work with. Lemme figure something out..

Inphi added 3 commits August 15, 2025 12:51
* uses a small i-cache by default to accomodate unit tests. This
  prevents tests from running out of memory in CI.
* fixes fuzz tests to preload the i-cache with the test instruction.
The fp tests now require alot of memory to run. Particularly when cannon
is used. So limit parallelism to avoid OOM.
@Inphi
Copy link
Contributor

Inphi commented Aug 16, 2025

@salindne Check out this branch that addresses the CI failures - https://github.com/ethereum-optimism/optimism/compare/inphi/ec2/alloc-preheap
Here's the diff of the changes for your convenience - https://github.com/ethereum-optimism/optimism/compare/11b2176e19b29f1005d60d0c9214d440dc7bed78..7707d3293bddfa5fd6030c5e1f2f66f7b8e1ad89.

The following adjustments were made to ensure that cannon is usable in CI:

  • the binary heap is instantiated with an 8K memory region by default. Only when Cannon is executed via the cannon/cmd package would the full 4 GiB preheap be used to cache instructions.
  • the test executor used by the op-e2e/faultproofs package prohibits too many tests from running in parallel.

If this all looks good to you, I can merge those changes into this PR and we should be good to merge to develop. I tried creating a PR on the Chainsafe/optimism targeting your branch but was unable to do so.

@salindne
Copy link
Contributor Author

@Inphi Looked through and looks good to me. Please do merge.

@Inphi
Copy link
Contributor

Inphi commented Aug 18, 2025

@salindne I don't have permission to push to your branch. I'm not sure why this didn't work before, but I've created a PR with the changes - ChainSafe#10. Could you please merge that in.

cannon: Ensure FP tests are runnable in CI
@Inphi
Copy link
Contributor

Inphi commented Aug 18, 2025

/ci authorize ce9dc7e

@Inphi Inphi added this pull request to the merge queue Aug 18, 2025
Merged via the queue into ethereum-optimism:develop with commit e7efd8b Aug 18, 2025
68 checks passed
janjakubnanista pushed a commit that referenced this pull request Aug 19, 2025
* Abstract the Merkle representation

* Implement asterisc's MPT

* migrate tests for mpt

* migrate tests for mpt

* copied benchmarks from asterisc

* fix failed merge

* Avoid pagelookup twice during setword invalidation

* use uints

* hashpool

* alloc pages upfront

* remove clutter

* fix

* gomallocregion

* more readable mapped regions

* fix state json codec test

* fix for singlethread too

* fix op-challenger test

* Remove MPT implementation

* address comments

* fix benchmark

* Use uint64 and also reuse hasher and buffers

* clean

* clean up some

* fix range

* Address reviewer feedback: clarify region bounds and add instruction cache fallback

* Revert "Address reviewer feedback: clarify region bounds and add instruction cache fallback"

This reverts commit 2a19b22.

* Clarify region bounds and add fallback to memory decode if PC exceeds instruction cache

* Update cannon/mipsevm/multithreaded/mips.go

Co-authored-by: Inphi <mlaw2501@gmail.com>

* fixed size of preheap cache for binaryTreeMemory

* slice out of bounds fixed in GetWord and AllocPage, pagetest syntax fix

* fix program heap initialization for binary tree

* moved cache decoded from instrumented state declaration to doMipsStep

* added default and set region map size to newMemory

* added 4096 byte memory region option to all testing cases using VMFactory

* clean up

* cache_decode to be initialize on first mipstep only for single step test compatibility

* added heap region sizing for unit/fuzz tests

* Revert " cache_decode to be initialize on first mipstep only for single step test compatibility"

This reverts commit 47a7166.

* cache allocation in instrumentedState initialization, catch for stale cache in doMipsStep

* remove unit test logic from domipstep and added helper for cache update in tests

* merge migration changes from develop

* some test step boundaries in instrumented_test needed to be slightly incremented, added decoded cache updateing to difftester_test.go

* small changes to step count and mismatch error vs string fault

* cannon: Use tiny i-cache by default

* uses a small i-cache by default to accomodate unit tests. This
  prevents tests from running out of memory in CI.
* fixes fuzz tests to preload the i-cache with the test instruction.

* op-e2e: Limit max parallelism for fp tests

The fp tests now require alot of memory to run. Particularly when cannon
is used. So limit parallelism to avoid OOM.

* increase parallelism

---------

Co-authored-by: Eric Tu <tu.eric@hotmail.com>
Co-authored-by: Inphi <mlaw2501@gmail.com>
leopoldjoy pushed a commit to leopoldjoy/optimism that referenced this pull request Aug 22, 2025
…eum-optimism#16030)

* Abstract the Merkle representation

* Implement asterisc's MPT

* migrate tests for mpt

* migrate tests for mpt

* copied benchmarks from asterisc

* fix failed merge

* Avoid pagelookup twice during setword invalidation

* use uints

* hashpool

* alloc pages upfront

* remove clutter

* fix

* gomallocregion

* more readable mapped regions

* fix state json codec test

* fix for singlethread too

* fix op-challenger test

* Remove MPT implementation

* address comments

* fix benchmark

* Use uint64 and also reuse hasher and buffers

* clean

* clean up some

* fix range

* Address reviewer feedback: clarify region bounds and add instruction cache fallback

* Revert "Address reviewer feedback: clarify region bounds and add instruction cache fallback"

This reverts commit 2a19b22.

* Clarify region bounds and add fallback to memory decode if PC exceeds instruction cache

* Update cannon/mipsevm/multithreaded/mips.go

Co-authored-by: Inphi <mlaw2501@gmail.com>

* fixed size of preheap cache for binaryTreeMemory

* slice out of bounds fixed in GetWord and AllocPage, pagetest syntax fix

* fix program heap initialization for binary tree

* moved cache decoded from instrumented state declaration to doMipsStep

* added default and set region map size to newMemory

* added 4096 byte memory region option to all testing cases using VMFactory

* clean up

* cache_decode to be initialize on first mipstep only for single step test compatibility

* added heap region sizing for unit/fuzz tests

* Revert " cache_decode to be initialize on first mipstep only for single step test compatibility"

This reverts commit 47a7166.

* cache allocation in instrumentedState initialization, catch for stale cache in doMipsStep

* remove unit test logic from domipstep and added helper for cache update in tests

* merge migration changes from develop

* some test step boundaries in instrumented_test needed to be slightly incremented, added decoded cache updateing to difftester_test.go

* small changes to step count and mismatch error vs string fault

* cannon: Use tiny i-cache by default

* uses a small i-cache by default to accomodate unit tests. This
  prevents tests from running out of memory in CI.
* fixes fuzz tests to preload the i-cache with the test instruction.

* op-e2e: Limit max parallelism for fp tests

The fp tests now require alot of memory to run. Particularly when cannon
is used. So limit parallelism to avoid OOM.

* increase parallelism

---------

Co-authored-by: Eric Tu <tu.eric@hotmail.com>
Co-authored-by: Inphi <mlaw2501@gmail.com>
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