From 027a5ced6d7fb1d1715b69bd39909ccd05b7f98b Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Mon, 4 Jul 2022 10:46:17 +0200 Subject: [PATCH 1/2] consensus/beacon: copy td value so we can modify it --- consensus/beacon/consensus.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consensus/beacon/consensus.go b/consensus/beacon/consensus.go index e090a03990f6..7180418110f1 100644 --- a/consensus/beacon/consensus.go +++ b/consensus/beacon/consensus.go @@ -174,7 +174,7 @@ func (beacon *Beacon) VerifyHeaders(chain consensus.ChainHeaderReader, headers [ // - the preHeaders to have a set difficulty // - the last element to be the terminal block func verifyTerminalPoWBlock(chain consensus.ChainHeaderReader, preHeaders []*types.Header) (int, error) { - td := chain.GetTd(preHeaders[0].ParentHash, preHeaders[0].Number.Uint64()-1) + td := new(big.Int).Set(chain.GetTd(preHeaders[0].ParentHash, preHeaders[0].Number.Uint64()-1)) if td == nil { return 0, consensus.ErrUnknownAncestor } From f3188330393ddcc1796227df8070653e87b5f7f1 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Mon, 4 Jul 2022 10:51:18 +0200 Subject: [PATCH 2/2] consensus/beacon: copy td value so we can modify it --- consensus/beacon/consensus.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/consensus/beacon/consensus.go b/consensus/beacon/consensus.go index 7180418110f1..2b4f6ee0d662 100644 --- a/consensus/beacon/consensus.go +++ b/consensus/beacon/consensus.go @@ -174,10 +174,11 @@ func (beacon *Beacon) VerifyHeaders(chain consensus.ChainHeaderReader, headers [ // - the preHeaders to have a set difficulty // - the last element to be the terminal block func verifyTerminalPoWBlock(chain consensus.ChainHeaderReader, preHeaders []*types.Header) (int, error) { - td := new(big.Int).Set(chain.GetTd(preHeaders[0].ParentHash, preHeaders[0].Number.Uint64()-1)) + td := chain.GetTd(preHeaders[0].ParentHash, preHeaders[0].Number.Uint64()-1) if td == nil { return 0, consensus.ErrUnknownAncestor } + td = new(big.Int).Set(td) // Check that all blocks before the last one are below the TTD for i, head := range preHeaders { if td.Cmp(chain.Config().TerminalTotalDifficulty) >= 0 {