eth/downloader: handle missing withdrawals if empty list is expected (#26675)

This PR relaxes the block body ingress handling a bit: if block body withdrawals are missing (but expected to be empty), the body withdrawals are set to 'empty list' before being passed to upper layers. 

This fixes an issue where a block passed from EthereumJS to geth was deemed invalid.
This commit is contained in:
Marius van der Wijden
2023-02-15 07:23:07 -05:00
committed by GitHub
parent 5967a2290a
commit 7fb42e6db2
3 changed files with 8 additions and 2 deletions
+4
View File
@@ -783,6 +783,10 @@ func (q *queue) DeliverBodies(id string, txLists [][]*types.Transaction, txListH
if header.WithdrawalsHash == nil {
// discard any withdrawals if we don't have a withdrawal hash set
withdrawalLists[index] = nil
} else if *header.WithdrawalsHash == types.EmptyRootHash && withdrawalLists[index] == nil {
// if the withdrawal hash is the emptyRootHash,
// we expect withdrawals to be [] instead of nil
withdrawalLists[index] = make([]*types.Withdrawal, 0)
} else if withdrawalListHashes[index] != *header.WithdrawalsHash {
return errInvalidBody
}
+1 -1
View File
@@ -424,7 +424,7 @@ func testGetBlockBodies(t *testing.T, protocol uint) {
RequestId: 123,
BlockBodiesPacket: bodies,
}); err != nil {
t.Errorf("test %d: bodies mismatch: %v", i, err)
t.Fatalf("test %d: bodies mismatch: %v", i, err)
}
}
}