Skip to content

Commit

Permalink
fix the vm build
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed Sep 23, 2024
1 parent 2c1efa8 commit 449a9e2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 2 additions & 0 deletions packages/block/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ export * from './header/index.js'
export {
genRequestsTrieRoot,
genTransactionsTrieRoot,
genTransactionsSszRoot,
genWithdrawalsTrieRoot,
genWithdrawalsSszRoot,
getDifficulty,
valuesArrayToHeaderData,
} from './helpers.js'
Expand Down
20 changes: 13 additions & 7 deletions packages/vm/src/buildBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 449a9e2

Please sign in to comment.