Skip to content

Commit a799b9b

Browse files
MariusVanDerWijdenshekhirin
authored andcommitted
core, eth/catalyst: fix race conditions in tests (ethereum#26790)
Fixes a race in TestNewPayloadOnInvalidTerminalBlock where setting the TTD raced with the miner. Solution: set the TTD on the blockchain config not the genesis config. Also fixes a race in CopyHeader which resulted in race reports all over the place.
1 parent 56a0c60 commit a799b9b

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

core/types/block.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ func CopyHeader(h *Header) *Header {
279279
copy(cpy.Extra, h.Extra)
280280
}
281281
if h.WithdrawalsHash != nil {
282+
cpy.WithdrawalsHash = new(common.Hash)
282283
*cpy.WithdrawalsHash = *h.WithdrawalsHash
283284
}
284285
return &cpy

eth/catalyst/api_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ func TestNewPayloadOnInvalidTerminalBlock(t *testing.T) {
874874
n, ethservice := startEthService(t, genesis, preMergeBlocks)
875875
defer n.Close()
876876

877-
genesis.Config.TerminalTotalDifficulty = preMergeBlocks[0].Difficulty() //.Sub(genesis.Config.TerminalTotalDifficulty, preMergeBlocks[len(preMergeBlocks)-1].Difficulty())
877+
ethservice.BlockChain().Config().TerminalTotalDifficulty = preMergeBlocks[0].Difficulty() //.Sub(genesis.Config.TerminalTotalDifficulty, preMergeBlocks[len(preMergeBlocks)-1].Difficulty())
878878

879879
var (
880880
api = NewConsensusAPI(ethservice)

0 commit comments

Comments
 (0)