diff --git a/packages/block/src/index.ts b/packages/block/src/index.ts index 074d1a1c04..4de8000a07 100644 --- a/packages/block/src/index.ts +++ b/packages/block/src/index.ts @@ -6,7 +6,9 @@ export * from './header/index.js' export { genRequestsTrieRoot, genTransactionsTrieRoot, + genTransactionsSszRoot, genWithdrawalsTrieRoot, + genWithdrawalsSszRoot, getDifficulty, valuesArrayToHeaderData, } from './helpers.js' diff --git a/packages/vm/src/buildBlock.ts b/packages/vm/src/buildBlock.ts index 7dcc2b7c7b..d10faa05cd 100644 --- a/packages/vm/src/buildBlock.ts +++ b/packages/vm/src/buildBlock.ts @@ -2,10 +2,10 @@ import { createBlock, createSealedCliqueBlock, genRequestsTrieRoot, - genTransactionsTrieRoot, genTransactionsSszRoot, - genWithdrawalsTrieRoot, + genTransactionsTrieRoot, genWithdrawalsSszRoot, + genWithdrawalsTrieRoot, } from '@ethereumjs/block' import { ConsensusType, Hardfork } from '@ethereumjs/common' import { RLP } from '@ethereumjs/rlp' @@ -151,6 +151,16 @@ export class BlockBuilder { : genTransactionsTrieRoot(this.transactions, new Trie({ common: this.vm.common })) } + public async withdrawalsTrie() { + if (this.withdrawals === undefined) { + return + } + + return this.vm.common.isActivatedEIP(6493) + ? genWithdrawalsSszRoot(this.withdrawals) + : genWithdrawalsTrieRoot(this.withdrawals, new Trie({ common: this.vm.common })) + } + /** * Calculates and returns the logs bloom for the block. */ @@ -326,11 +336,7 @@ export class BlockBuilder { await this.processWithdrawals() const transactionsTrie = await this.transactionsTrie() - const withdrawalsRoot = this.withdrawals - ? this.vm.common.isActivatedEIP(6493) - ? genWithdrawalsSszRoot(this.withdrawals) - : genWithdrawalsTrieRoot(this.withdrawals, new Trie({ common: this.vm.common })) - : undefined + const withdrawalsRoot = await this.withdrawalsTrie() const receiptTrie = await this.receiptTrie() const logsBloom = this.logsBloom() const gasUsed = this.gasUsed