Patch for concurrent iterator & others (onto v1.11.6) #386

Closed
roysc wants to merge 1565 commits from v1.11.6-statediff-v5 into master
3 changed files with 8 additions and 2 deletions
Showing only changes of commit 7fb42e6db2 - Show all commits

View File

@ -465,10 +465,12 @@ func (g *Genesis) ToBlock() *types.Block {
head.BaseFee = new(big.Int).SetUint64(params.InitialBaseFee) head.BaseFee = new(big.Int).SetUint64(params.InitialBaseFee)
} }
} }
var withdrawals []*types.Withdrawal
if g.Config != nil && g.Config.IsShanghai(g.Timestamp) { if g.Config != nil && g.Config.IsShanghai(g.Timestamp) {
head.WithdrawalsHash = &types.EmptyRootHash head.WithdrawalsHash = &types.EmptyRootHash
withdrawals = make([]*types.Withdrawal, 0)
} }
return types.NewBlock(head, nil, nil, nil, trie.NewStackTrie(nil)) return types.NewBlock(head, nil, nil, nil, trie.NewStackTrie(nil)).WithWithdrawals(withdrawals)
} }
// Commit writes the block and state of a genesis specification to the database. // Commit writes the block and state of a genesis specification to the database.

View File

@ -783,6 +783,10 @@ func (q *queue) DeliverBodies(id string, txLists [][]*types.Transaction, txListH
if header.WithdrawalsHash == nil { if header.WithdrawalsHash == nil {
// discard any withdrawals if we don't have a withdrawal hash set // discard any withdrawals if we don't have a withdrawal hash set
withdrawalLists[index] = nil 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 { } else if withdrawalListHashes[index] != *header.WithdrawalsHash {
return errInvalidBody return errInvalidBody
} }

View File

@ -424,7 +424,7 @@ func testGetBlockBodies(t *testing.T, protocol uint) {
RequestId: 123, RequestId: 123,
BlockBodiesPacket: bodies, BlockBodiesPacket: bodies,
}); err != nil { }); err != nil {
t.Errorf("test %d: bodies mismatch: %v", i, err) t.Fatalf("test %d: bodies mismatch: %v", i, err)
} }
} }
} }