Skip to content

Commit 93bfed8

Browse files
MariusVanDerWijdencp-wjhan
authored andcommitted
consensus/beacon: check ttd reached on pos blocks (ethereum#25552)
* consensus/beacon: check ttd reached on pos blocks * consensus/beacon: check ttd reached on pos blocks * consensus/beacon: check ttd reached on pos blocks
1 parent 797a104 commit 93bfed8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

consensus/beacon/consensus.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,16 @@ func (beacon *Beacon) VerifyHeaders(chain consensus.ChainHeaderReader, headers [
114114
}
115115
}
116116

117-
// All the headers have passed the transition point, use new rules.
118117
if len(preHeaders) == 0 {
118+
// All the headers are pos headers. Verify that the parent block reached total terminal difficulty.
119+
if reached, _ := IsTTDReached(chain, headers[0].ParentHash, headers[0].Number.Uint64()-1); !reached {
120+
// TTD not reached for the first block, mark subsequent with invalid terminal block
121+
results := make(chan error, len(headers))
122+
for i := 0; i < len(headers); i++ {
123+
results <- consensus.ErrInvalidTerminalBlock
124+
}
125+
return make(chan struct{}), results
126+
}
119127
return beacon.verifyHeaders(chain, headers, nil)
120128
}
121129

0 commit comments

Comments
 (0)