@@ -15,8 +15,8 @@ const level = require('level')
15
15
const rlp = utils . rlp
16
16
17
17
async function main ( ) {
18
- const state = new Trie ( )
19
18
const blockchainDB = levelMem ( )
19
+ const state = new Trie ( blockchainDB )
20
20
21
21
const hardfork = testData . network . toLowerCase ( )
22
22
@@ -39,7 +39,7 @@ async function main() {
39
39
hardfork,
40
40
} )
41
41
42
- await setupPreConditions ( state , testData )
42
+ await setupPreConditions ( blockchainDB , state , testData )
43
43
44
44
await setGenesisBlock ( blockchain , hardfork )
45
45
@@ -60,16 +60,15 @@ function setEthashCache(blockchain: any) {
60
60
}
61
61
}
62
62
63
- async function setupPreConditions ( state : any , testData : any ) {
63
+ async function setupPreConditions ( db : any , state : any , testData : any ) {
64
64
for ( const address of Object . keys ( testData . pre ) ) {
65
65
const acctData = testData . pre [ address ]
66
66
const account = new Account ( )
67
67
68
68
account . nonce = utils . toBuffer ( acctData . nonce )
69
69
account . balance = utils . toBuffer ( acctData . balance )
70
70
71
- const storageTrie = state . copy ( )
72
- storageTrie . root = null
71
+ const storageTrie = new Trie ( db )
73
72
74
73
for ( const hexStorageKey of Object . keys ( acctData . storage ) ) {
75
74
const val = utils . toBuffer ( acctData . storage [ hexStorageKey ] )
0 commit comments