Skip to content

Convert StatelessVerkleStateManager usage to type in vm #4021

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

Merged
merged 6 commits into from
Apr 25, 2025

Conversation

acolytec3
Copy link
Contributor

This modifies our usage of StatelessVerkleStateManager in vm to import it only as a type so it does not get included in a bundle where the StatelessVerkleStateManager isn't actually used

Copy link

codecov bot commented Apr 24, 2025

Codecov Report

Attention: Patch coverage is 16.66667% with 10 lines in your changes missing coverage. Please review.

Project coverage is 79.54%. Comparing base (3d94933) to head (4d13bbe).
Report is 13 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 84.33% <ø> (ø)
blockchain 89.32% <ø> (ø)
client 67.99% <ø> (?)
common 97.51% <ø> (ø)
devp2p 86.78% <ø> (+0.07%) ⬆️
evm 73.02% <ø> (ø)
mpt 89.74% <ø> (+0.30%) ⬆️
statemanager 69.06% <0.00%> (ø)
static 99.11% <ø> (ø)
tx 90.59% <ø> (ø)
util 89.36% <ø> (ø)
vm 55.50% <20.00%> (ø)

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

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

Copy link
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

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

Some comments 😄 👍

@@ -160,10 +160,10 @@ export async function runBlock(vm: VM, opts: RunBlockOpts): Promise<RunBlockResu
// Populate the execution witness
stateManager.initVerkleExecutionWitness!(block.header.number, block.executionWitness)

if (stateManager instanceof StatelessVerkleStateManager) {
if ('verifyPostState' in stateManager) {
Copy link
Member

Choose a reason for hiding this comment

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

The line was previously very descriptive stateManager instanceof StatelessVerkleStateManager such that it is clear that stateManager is actually a StatelessVerkleStateManager. Could you add a comment here? Check if stateManager is of type StatelessVerkleStateManager for instance

@@ -273,7 +273,7 @@ export async function runBlock(vm: VM, opts: RunBlockOpts): Promise<RunBlockResu
}
}

if (!(vm.stateManager instanceof StatelessVerkleStateManager)) {
if (!('verifyPostState' in vm.stateManager)) {
Copy link
Member

Choose a reason for hiding this comment

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

Here a comment for StatelessVerkleStateManager

!(vm.stateManager instanceof StatefulVerkleStateManager) &&
!(vm.stateManager instanceof StatelessVerkleStateManager)
) {
if (!('verifyPostState' in vm.stateManager) && !('verifyPostState' in vm.stateManager)) {
Copy link
Member

Choose a reason for hiding this comment

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

Here thus a check if it's a *VerkleStateManager type (Stateful or Stateless)

Copy link
Contributor Author

@acolytec3 acolytec3 left a comment

Choose a reason for hiding this comment

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

Update evm/vite.config.bundler.ts to point to ../vm/examples/runGoerliBlock.ts and then run npm run visualize:bundle from root/packages/evm and verify that only the MerkleStateManager appears under the statemanager in the bundle

@acolytec3 acolytec3 marked this pull request as ready for review April 24, 2025 15:31
!(vm.stateManager instanceof StatefulVerkleStateManager) &&
!(vm.stateManager instanceof StatelessVerkleStateManager)
) {
if (!('verifyPostState' in vm.stateManager) && !('verifyPostState' in vm.stateManager)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this checking the same condition twice?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, good point, I did not catch this 😅 If verifyPostState is only a method of StatefulVerkleStateManager and StatelessVerkleStateManager and not of any other StateManager then we can indeed compactify it to one check (and not the same check twice)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hah, sorry I missed that. Will update!

@@ -160,10 +160,10 @@ export async function runBlock(vm: VM, opts: RunBlockOpts): Promise<RunBlockResu
// Populate the execution witness
stateManager.initVerkleExecutionWitness!(block.header.number, block.executionWitness)

if (stateManager instanceof StatelessVerkleStateManager) {
if ('verifyPostState' in stateManager) {
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be nice to have a code comment directly on the original verifyPostState method how the method is (mis-)used and that it should therefore not be renamed.

holgerd77
holgerd77 previously approved these changes Apr 25, 2025
Copy link
Member

@holgerd77 holgerd77 left a comment

Choose a reason for hiding this comment

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

Will take this in here, additional comments on the other PR(s).

Copy link
Member

@holgerd77 holgerd77 left a comment

Choose a reason for hiding this comment

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

LGTM

@holgerd77 holgerd77 merged commit 934e20d into master Apr 25, 2025
38 of 40 checks passed
@holgerd77 holgerd77 deleted the make-statemanagers-types branch April 25, 2025 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants