Skip to content

Commit c83107d

Browse files
authored
Merge pull request #129 from bane-labs/allow-shanghai-in-fetcher
eth: support empty withdrawals in block fetcher
2 parents 6bb36f4 + 9960054 commit c83107d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

eth/fetcher/block_fetcher.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,10 +599,13 @@ func (f *BlockFetcher) loop() {
599599
announce.time = task.time
600600

601601
// If the block is empty (header only), short circuit into the final import queue
602-
if header.TxHash == types.EmptyTxsHash && header.UncleHash == types.EmptyUncleHash {
602+
if header.TxHash == types.EmptyTxsHash && header.UncleHash == types.EmptyUncleHash && (header.WithdrawalsHash == nil || *header.WithdrawalsHash == types.EmptyWithdrawalsHash) {
603603
log.Trace("Block empty, skipping body retrieval", "peer", announce.origin, "number", header.Number, "hash", header.Hash())
604604

605605
block := types.NewBlockWithHeader(header)
606+
if header.WithdrawalsHash != nil {
607+
block = block.WithWithdrawals([]*types.Withdrawal{})
608+
}
606609
block.ReceivedAt = task.time
607610

608611
complete = append(complete, block)
@@ -687,6 +690,10 @@ func (f *BlockFetcher) loop() {
687690
matched = true
688691
if f.getBlock(hash) == nil {
689692
block := types.NewBlockWithHeader(announce.header).WithBody(task.transactions[i], task.uncles[i])
693+
if announce.header.WithdrawalsHash != nil && *announce.header.WithdrawalsHash == types.EmptyWithdrawalsHash {
694+
// Only empty withdrawals are supported in case of pre-merge dBFT with Shanghai enabled.
695+
block = block.WithWithdrawals([]*types.Withdrawal{})
696+
}
690697
block.ReceivedAt = task.time
691698
blocks = append(blocks, block)
692699
} else {

0 commit comments

Comments
 (0)