Skip to content

Commit

Permalink
consensus/beacon: check ttd reached on pos blocks (ethereum#25552)
Browse files Browse the repository at this point in the history
* consensus/beacon: check ttd reached on pos blocks

* consensus/beacon: check ttd reached on pos blocks

* consensus/beacon: check ttd reached on pos blocks
  • Loading branch information
MariusVanDerWijden authored and jagdeep sidhu committed Aug 21, 2022
1 parent e8b1369 commit c03a8da
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion consensus/beacon/consensus.go
Expand Up @@ -114,8 +114,16 @@ func (beacon *Beacon) VerifyHeaders(chain consensus.ChainHeaderReader, headers [
}
}

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

Expand Down

0 comments on commit c03a8da

Please sign in to comment.