@@ -2,10 +2,10 @@ import {
22 createBlock ,
33 createSealedCliqueBlock ,
44 genRequestsTrieRoot ,
5- genTransactionsTrieRoot ,
65 genTransactionsSszRoot ,
7- genWithdrawalsTrieRoot ,
6+ genTransactionsTrieRoot ,
87 genWithdrawalsSszRoot ,
8+ genWithdrawalsTrieRoot ,
99} from '@ethereumjs/block'
1010import { ConsensusType , Hardfork } from '@ethereumjs/common'
1111import { RLP } from '@ethereumjs/rlp'
@@ -151,6 +151,16 @@ export class BlockBuilder {
151151 : genTransactionsTrieRoot ( this . transactions , new Trie ( { common : this . vm . common } ) )
152152 }
153153
154+ public async withdrawalsTrie ( ) {
155+ if ( this . withdrawals === undefined ) {
156+ return
157+ }
158+
159+ return this . vm . common . isActivatedEIP ( 6493 )
160+ ? genWithdrawalsSszRoot ( this . withdrawals )
161+ : genWithdrawalsTrieRoot ( this . withdrawals , new Trie ( { common : this . vm . common } ) )
162+ }
163+
154164 /**
155165 * Calculates and returns the logs bloom for the block.
156166 */
@@ -326,11 +336,7 @@ export class BlockBuilder {
326336 await this . processWithdrawals ( )
327337
328338 const transactionsTrie = await this . transactionsTrie ( )
329- const withdrawalsRoot = this . withdrawals
330- ? this . vm . common . isActivatedEIP ( 6493 )
331- ? genWithdrawalsSszRoot ( this . withdrawals )
332- : genWithdrawalsTrieRoot ( this . withdrawals , new Trie ( { common : this . vm . common } ) )
333- : undefined
339+ const withdrawalsRoot = await this . withdrawalsTrie ( )
334340 const receiptTrie = await this . receiptTrie ( )
335341 const logsBloom = this . logsBloom ( )
336342 const gasUsed = this . gasUsed
0 commit comments