Skip to content

Commit

Permalink
Add verkle execution support to executeBlocks (#3406)
Browse files Browse the repository at this point in the history
* Add verkle execution support to executeBlocks

* use block witness instead of parent block

* Shut down client after execution completes

* Fix test timing
  • Loading branch information
acolytec3 committed May 7, 2024
1 parent 0ed0a07 commit 9ec6bd2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
18 changes: 18 additions & 0 deletions packages/client/src/execution/vmexecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,24 @@ export class VMExecution extends Execution {
*/
async executeBlocks(first: number, last: number, txHashes: string[]) {
this.config.logger.info('Preparing for block execution (debug mode, no services started)...')

const block = await this.vm.blockchain.getBlock(first)
const parentBlock = await this.vm.blockchain.getBlock(block.header.parentHash)
const startExecutionParentTd = await this.chain.getTd(block.hash(), parentBlock.header.number)

const startExecutionHardfork = this.config.execCommon.getHardforkBy({
blockNumber: block.header.number,
td: startExecutionParentTd,
timestamp: block.header.timestamp,
})

// Setup VM with verkle state manager if Osaka is active
if (
this.config.execCommon.hardforkGteHardfork(startExecutionHardfork, Hardfork.Osaka) &&
this.config.statelessVerkle
) {
await this.transitionToVerkle(block.header.stateRoot, true)
}
const vm = await this.vm.shallowCopy(false)

for (let blockNumber = first; blockNumber <= last; blockNumber++) {
Expand Down
6 changes: 4 additions & 2 deletions packages/client/test/execution/vmexecution.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const shanghaiPayload = {
],
}

describe('[VMExecution]', async () => {
describe('[VMExecution]', () => {
it('Initialization', async () => {
const vm = await VM.create()
const config = new Config({ vm, accountCache: 10000, storageCache: 1000 })
Expand Down Expand Up @@ -140,7 +140,9 @@ describe('[VMExecution]', async () => {
validateBlocks: true,
validateConsensus: false,
})

exec = await testSetup(blockchain)

await exec.run()

assert.doesNotThrow(
Expand Down Expand Up @@ -234,4 +236,4 @@ describe('[VMExecution]', async () => {

closeRPC(server)
})
})
}, 30000)
1 change: 0 additions & 1 deletion packages/statemanager/src/statelessVerkleStateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ export class StatelessVerkleStateManager implements EVMStateManagerInterface {
*/
shallowCopy(): EVMStateManagerInterface {
const stateManager = new StatelessVerkleStateManager({ verkleCrypto: this.verkleCrypto })
stateManager.initVerkleExecutionWitness(this._blockNum, this._executionWitness!)
return stateManager
}

Expand Down

0 comments on commit 9ec6bd2

Please sign in to comment.