Skip to content

Conversation

@unnawut
Copy link
Contributor

@unnawut unnawut commented Jun 13, 2025

What are you trying to achieve?

This PR adds "zkvm" feature flag so that external programs can config ream codebase in the way that can be run on zkVMs.

In this PR, the feature flag would drop VariableList that are 240 in size down to 229 when enabled, so that 32-bit zkVMs can work with our BeaconState.

See ReamLabs/consenzero-bench#24 for how this feature flag is used.

How was it implemented/fixed?

The BeaconState contains some "zkvm" features where 32-bit zkVMs would fail on constructing a VariableList larger than 232 size (i.e. 240). When "zkvm" feature is enabled, it would construct the BeaconState with 229 list instead.

To remain conformant with consensus-specs, this feature needs to be used with the modified ssz_types crate at https://github.com/ReamLabs/ssz_types/tree/magic-extended-list where the crate would detect 229 as a magic number when computing the root hash, and it will compute as a 240 list root instead.

Tbh I'm not sure I actually want to add this to ream's main codebase, but it's needed to run ream-consensus on zkVMs with correct results. If it's not ideal to merge, I'm happy to keep it as a long running zkvm branch on ream as well. Happy to discuss this and also in case anyone has a better idea to manage these differences.

To-Do

@unnawut unnawut self-assigned this Jun 13, 2025
@unnawut unnawut requested a review from jihoonsong June 13, 2025 19:15
Copy link
Contributor

@KolbyML KolbyML left a comment

Choose a reason for hiding this comment

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

Left some feedback

@jihoonsong
Copy link
Contributor

Having a long standing branch is a pain. Given that Beam chain client itself is a prototype, I think it's okay to merge it.

But this is apparently a tech debt. This issue is coming from ssz-types and I do think this workaround is a temporary stopgap. We need to modify ssz-types and relevant libraries properly or use other SSZ implementation whether it be ours or Grandine's or whatever.

After we become able to run Ream in 32-bit zkVMs, I think it's a good time to work on a proper solution.

@unnawut unnawut marked this pull request as draft June 16, 2025 09:48
@unnawut unnawut marked this pull request as ready for review June 16, 2025 10:00
@unnawut unnawut requested a review from KolbyML June 16, 2025 10:00
Copy link
Contributor

@jihoonsong jihoonsong left a comment

Choose a reason for hiding this comment

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

Great work!

Copy link
Contributor

@KolbyML KolbyML left a comment

Choose a reason for hiding this comment

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

:shipit: I am good with this change

@unnawut unnawut added this pull request to the merge queue Jun 16, 2025
Merged via the queue into ReamLabs:master with commit 2759da1 Jun 16, 2025
14 checks passed
@unnawut unnawut deleted the zkvm branch June 16, 2025 16:47
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.

3 participants