1
1
import { RLP } from '@ethereumjs/rlp'
2
- import { Trie } from '@ethereumjs/trie'
2
+ import { MerklePatriciaTrie } from '@ethereumjs/trie'
3
3
import { Blob4844Tx } from '@ethereumjs/tx'
4
4
import { BIGINT_0 , BIGINT_1 , TypeOutput , isHexString , toType } from '@ethereumjs/util'
5
5
@@ -124,8 +124,8 @@ export const fakeExponential = (factor: bigint, numerator: bigint, denominator:
124
124
* @param wts array of Withdrawal to compute the root of
125
125
* @param optional emptyTrie to use to generate the root
126
126
*/
127
- export async function genWithdrawalsTrieRoot ( wts : Withdrawal [ ] , emptyTrie ?: Trie ) {
128
- const trie = emptyTrie ?? new Trie ( )
127
+ export async function genWithdrawalsTrieRoot ( wts : Withdrawal [ ] , emptyTrie ?: MerklePatriciaTrie ) {
128
+ const trie = emptyTrie ?? new MerklePatriciaTrie ( )
129
129
for ( const [ i , wt ] of wts . entries ( ) ) {
130
130
await trie . put ( RLP . encode ( i ) , RLP . encode ( wt . raw ( ) ) )
131
131
}
@@ -137,8 +137,11 @@ export async function genWithdrawalsTrieRoot(wts: Withdrawal[], emptyTrie?: Trie
137
137
* @param txs array of TypedTransaction to compute the root of
138
138
* @param optional emptyTrie to use to generate the root
139
139
*/
140
- export async function genTransactionsTrieRoot ( txs : TypedTransaction [ ] , emptyTrie ?: Trie ) {
141
- const trie = emptyTrie ?? new Trie ( )
140
+ export async function genTransactionsTrieRoot (
141
+ txs : TypedTransaction [ ] ,
142
+ emptyTrie ?: MerklePatriciaTrie ,
143
+ ) {
144
+ const trie = emptyTrie ?? new MerklePatriciaTrie ( )
142
145
for ( const [ i , tx ] of txs . entries ( ) ) {
143
146
await trie . put ( RLP . encode ( i ) , tx . serialize ( ) )
144
147
}
@@ -151,7 +154,10 @@ export async function genTransactionsTrieRoot(txs: TypedTransaction[], emptyTrie
151
154
* @param emptyTrie optional empty trie used to generate the root
152
155
* @returns a 32 byte Uint8Array representing the requests trie root
153
156
*/
154
- export async function genRequestsTrieRoot ( requests : CLRequest < CLRequestType > [ ] , emptyTrie ?: Trie ) {
157
+ export async function genRequestsTrieRoot (
158
+ requests : CLRequest < CLRequestType > [ ] ,
159
+ emptyTrie ?: MerklePatriciaTrie ,
160
+ ) {
155
161
// Requests should be sorted in monotonically ascending order based on type
156
162
// and whatever internal sorting logic is defined by each request type
157
163
if ( requests . length > 1 ) {
@@ -160,7 +166,7 @@ export async function genRequestsTrieRoot(requests: CLRequest<CLRequestType>[],
160
166
throw new Error ( 'requests are not sorted in ascending order' )
161
167
}
162
168
}
163
- const trie = emptyTrie ?? new Trie ( )
169
+ const trie = emptyTrie ?? new MerklePatriciaTrie ( )
164
170
for ( const [ i , req ] of requests . entries ( ) ) {
165
171
await trie . put ( RLP . encode ( i ) , req . serialize ( ) )
166
172
}
0 commit comments