Skip to content

Commit cfd71d4

Browse files
committed
Use checkpoint and commit in run-blockchain example
1 parent 2a1a30b commit cfd71d4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

examples/run-blockchain/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import Account from 'ethereumjs-account'
44
import * as utils from 'ethereumjs-util'
55
import { promisify } from 'util'
66
import PStateManager from '../../lib/state/promisified'
7-
import { toBuffer } from 'ethereumjs-util'
87

98
const Block = require('ethereumjs-block')
109
const Blockchain = require('ethereumjs-blockchain')
@@ -55,6 +54,9 @@ function setEthashCache(blockchain: any) {
5554

5655
async function setupPreConditions(vm: VM, testData: any) {
5756
const psm = new PStateManager(vm.stateManager)
57+
58+
await psm.checkpoint()
59+
5860
for (const address of Object.keys(testData.pre)) {
5961
const addressBuf = utils.toBuffer(address)
6062

@@ -78,8 +80,7 @@ async function setupPreConditions(vm: VM, testData: any) {
7880
await psm.putContractCode(addressBuf, codeBuf)
7981
}
8082

81-
// This forces a cache flush, which is necessary here
82-
await psm.getStateRoot()
83+
await psm.commit()
8384
}
8485

8586
async function setGenesisBlock(blockchain: any, hardfork: string) {

0 commit comments

Comments
 (0)