-
Notifications
You must be signed in to change notification settings - Fork 808
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments 😄 👍
packages/vm/src/runBlock.ts
Outdated
@@ -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) { |
There was a problem hiding this comment.
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
packages/vm/src/runBlock.ts
Outdated
@@ -273,7 +273,7 @@ export async function runBlock(vm: VM, opts: RunBlockOpts): Promise<RunBlockResu | |||
} | |||
} | |||
|
|||
if (!(vm.stateManager instanceof StatelessVerkleStateManager)) { | |||
if (!('verifyPostState' in vm.stateManager)) { |
There was a problem hiding this comment.
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
packages/vm/src/runTx.ts
Outdated
!(vm.stateManager instanceof StatefulVerkleStateManager) && | ||
!(vm.stateManager instanceof StatelessVerkleStateManager) | ||
) { | ||
if (!('verifyPostState' in vm.stateManager) && !('verifyPostState' in vm.stateManager)) { |
There was a problem hiding this comment.
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)
There was a problem hiding this 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
packages/vm/src/runTx.ts
Outdated
!(vm.stateManager instanceof StatefulVerkleStateManager) && | ||
!(vm.stateManager instanceof StatelessVerkleStateManager) | ||
) { | ||
if (!('verifyPostState' in vm.stateManager) && !('verifyPostState' in vm.stateManager)) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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!
packages/vm/src/runBlock.ts
Outdated
@@ -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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this 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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This modifies our usage of
StatelessVerkleStateManager
invm
to import it only as a type so it does not get included in a bundle where theStatelessVerkleStateManager
isn't actually used