1+ import { Common , Mainnet } from '@ethereumjs/common'
12import {
23 Account ,
34 VerkleLeafType ,
@@ -11,22 +12,22 @@ import {
1112} from '@ethereumjs/util'
1213import { createVerkleTree } from '@ethereumjs/verkle'
1314import * as verkle from 'micro-eth-signer/verkle'
14- import { assert , beforeAll , describe , it } from 'vitest'
15+ import { assert , describe , it } from 'vitest'
1516
1617import { Caches } from '../src/index.js'
1718import { StatefulVerkleStateManager } from '../src/statefulVerkleStateManager.js'
1819
19- import type { PrefixedHexString , VerkleCrypto } from '@ethereumjs/util'
20- const loadVerkleCrypto = ( ) => Promise . resolve ( verkle )
20+ import type { PrefixedHexString } from '@ethereumjs/util'
2121
2222describe ( 'Verkle Tree API tests' , ( ) => {
23- let verkleCrypto : VerkleCrypto
24- beforeAll ( async ( ) => {
25- verkleCrypto = await loadVerkleCrypto ( )
26- } )
2723 it ( 'should put/get/delete an account (with no storage/code from the trie)' , async ( ) => {
2824 const trie = await createVerkleTree ( )
29- const sm = new StatefulVerkleStateManager ( { trie, verkleCrypto } )
25+ const common = new Common ( {
26+ chain : Mainnet ,
27+ eips : [ 6800 ] ,
28+ customCrypto : { verkleCrypto : verkle } ,
29+ } )
30+ const sm = new StatefulVerkleStateManager ( { common, trie } )
3031 const address = createAddressFromString ( '0x9e5ef720fa2cdfa5291eb7e711cfd2e62196f4b3' )
3132 const account = createAccount ( { nonce : 3n , balance : 0xfffn } )
3233 await sm . putAccount ( address , account )
@@ -40,7 +41,12 @@ describe('Verkle Tree API tests', () => {
4041
4142 it ( 'should return same stateRoot when putting and then deleting account' , async ( ) => {
4243 const trie = await createVerkleTree ( )
43- const sm = new StatefulVerkleStateManager ( { trie, verkleCrypto } )
44+ const common = new Common ( {
45+ chain : Mainnet ,
46+ eips : [ 6800 ] ,
47+ customCrypto : { verkleCrypto : verkle } ,
48+ } )
49+ const sm = new StatefulVerkleStateManager ( { common, trie } )
4450
4551 const address1 = createAddressFromString ( '0x9e5ef720fa2cdfa5291eb7e711cfd2e62196f4b3' )
4652 const account1 = createAccount ( { nonce : 3n , balance : 0xfffn } )
@@ -61,7 +67,12 @@ describe('Verkle Tree API tests', () => {
6167
6268 it ( 'should put and get code' , async ( ) => {
6369 const trie = await createVerkleTree ( )
64- const sm = new StatefulVerkleStateManager ( { trie, verkleCrypto } )
70+ const common = new Common ( {
71+ chain : Mainnet ,
72+ eips : [ 6800 ] ,
73+ customCrypto : { verkleCrypto : verkle } ,
74+ } )
75+ const sm = new StatefulVerkleStateManager ( { common, trie } )
6576 const address = createAddressFromString ( '0x9e5ef720fa2cdfa5291eb7e711cfd2e62196f4b3' )
6677 const code = hexToBytes ( '0x6001' ) // PUSH 01
6778 await sm . putCode ( address , code )
@@ -90,7 +101,12 @@ describe('Verkle Tree API tests', () => {
90101 const zeroSlot = setLengthLeft ( bigIntToBytes ( 0n ) , 32 )
91102 const zeroSlotValue = hexToBytes ( '0x1' )
92103 const trie = await createVerkleTree ( )
93- const sm = new StatefulVerkleStateManager ( { trie, verkleCrypto } )
104+ const common = new Common ( {
105+ chain : Mainnet ,
106+ eips : [ 6800 ] ,
107+ customCrypto : { verkleCrypto : verkle } ,
108+ } )
109+ const sm = new StatefulVerkleStateManager ( { common, trie } )
94110 const address = createAddressFromString ( '0x9e5ef720fa2cdfa5291eb7e711cfd2e62196f4b3' )
95111 await sm . putAccount ( address , new Account ( 0n , 1n ) )
96112 await sm . putStorage ( address , zeroSlot , zeroSlotValue )
@@ -100,19 +116,20 @@ describe('Verkle Tree API tests', () => {
100116} )
101117
102118describe ( 'caching functionality works' , ( ) => {
103- let verkleCrypto : VerkleCrypto
104- beforeAll ( async ( ) => {
105- verkleCrypto = await loadVerkleCrypto ( )
106- } )
107119 it ( 'should cache accounts and then write to trie' , async ( ) => {
108120 const trie = await createVerkleTree ( )
109- const sm = new StatefulVerkleStateManager ( { trie, verkleCrypto, caches : new Caches ( ) } )
121+ const common = new Common ( {
122+ chain : Mainnet ,
123+ eips : [ 6800 ] ,
124+ customCrypto : { verkleCrypto : verkle } ,
125+ } )
126+ const sm = new StatefulVerkleStateManager ( { common, trie, caches : new Caches ( ) } )
110127 const address = createAddressFromString ( '0x9e5ef720fa2cdfa5291eb7e711cfd2e62196f4b3' )
111128 const account = createAccount ( { nonce : 3n , balance : 0xfffn } )
112129 await sm . putAccount ( address , account )
113130
114131 // Confirm account doesn't exist in trie
115- const stem = getVerkleStem ( verkleCrypto , address , 0 )
132+ const stem = getVerkleStem ( verkle , address , 0 )
116133 const accountData = await sm [ '_trie' ] . get ( stem , [
117134 VerkleLeafType . BasicData ,
118135 VerkleLeafType . CodeHash ,
0 commit comments