Skip to content

Commit

Permalink
Also align client (no real effect yet, but generally try to work more…
Browse files Browse the repository at this point in the history
… on the interfaces and not the classes directly)
  • Loading branch information
holgerd77 committed Aug 17, 2024
1 parent 83db446 commit 78939cb
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/client/src/execution/vmexecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export class VMExecution extends Execution {
}

async transitionToVerkle(merkleStateRoot: Uint8Array, assignToVM: boolean = true): Promise<void> {
if (this.vm.stateManager instanceof StatelessVerkleStateManager) {
if (typeof this.vm.stateManager.initVerkleExecutionWitness === 'function') {
return
}

Expand All @@ -230,15 +230,19 @@ export class VMExecution extends Execution {
await this.setupMerkleVM()
}
const merkleVM = this.merkleVM!
const merkleStateManager = merkleVM.stateManager as DefaultStateManager
const merkleStateManager = merkleVM.stateManager

if (this.verkleVM === undefined) {
await this.setupVerkleVM()
}
const verkleVM = this.verkleVM!
const verkleStateManager = verkleVM.stateManager as StatelessVerkleStateManager
const verkleStateManager = verkleVM.stateManager

const verkleStateRoot = await verkleStateManager.getTransitionStateRoot(
// TODO: can we please implement this in a different way and not introduce a method
// *inside* one state manager which takes another state manager?
// That bloats the interface too much, this should be minimally a separate util method
// or fully move to client
const verkleStateRoot = await (verkleStateManager as any).getTransitionStateRoot(
merkleStateManager,
merkleStateRoot,
)
Expand Down Expand Up @@ -416,7 +420,8 @@ export class VMExecution extends Execution {
vm = this.verkleVM
}

const needsStatelessExecution = vm.stateManager instanceof StatelessVerkleStateManager
const needsStatelessExecution =
typeof this.vm.stateManager.initVerkleExecutionWitness === 'function'
if (needsStatelessExecution && block.executionWitness === undefined) {
throw Error(`Verkle blocks need executionWitness for stateless execution`)
} else {
Expand Down Expand Up @@ -677,7 +682,7 @@ export class VMExecution extends Execution {
}
if (
(!this.config.execCommon.gteHardfork(Hardfork.Osaka) &&
this.vm.stateManager instanceof StatelessVerkleStateManager) ||
typeof this.vm.stateManager.initVerkleExecutionWitness === 'function') ||
(this.config.execCommon.gteHardfork(Hardfork.Osaka) &&
this.vm.stateManager instanceof DefaultStateManager)
) {
Expand Down

0 comments on commit 78939cb

Please sign in to comment.