From 78939cb8af6120577415b75322a827647a7a57aa Mon Sep 17 00:00:00 2001 From: Holger Drewes Date: Sat, 17 Aug 2024 19:00:22 +0200 Subject: [PATCH] Also align client (no real effect yet, but generally try to work more on the interfaces and not the classes directly) --- packages/client/src/execution/vmexecution.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/client/src/execution/vmexecution.ts b/packages/client/src/execution/vmexecution.ts index 0bdf364195..9070f53d09 100644 --- a/packages/client/src/execution/vmexecution.ts +++ b/packages/client/src/execution/vmexecution.ts @@ -221,7 +221,7 @@ export class VMExecution extends Execution { } async transitionToVerkle(merkleStateRoot: Uint8Array, assignToVM: boolean = true): Promise { - if (this.vm.stateManager instanceof StatelessVerkleStateManager) { + if (typeof this.vm.stateManager.initVerkleExecutionWitness === 'function') { return } @@ -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, ) @@ -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 { @@ -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) ) {