diff --git a/catchup/catchpointService.go b/catchup/catchpointService.go index 5d01fa9608..e2a9fcc387 100644 --- a/catchup/catchpointService.go +++ b/catchup/catchpointService.go @@ -473,8 +473,10 @@ func lookbackForStateproofsSupport(topBlock *bookkeeping.Block) uint64 { return 0 } lowestStateProofRound := stateproof.GetOldestExpectedStateProof(&topBlock.BlockHeader) - // in order to be able to confirm lowestStateProofRound we need to have round number: (lowestStateProofRound - stateproofInterval) + // in order to be able to confirm/build lowestStateProofRound we would need to reconstruct + // the corresponding voterForRound which is (lowestStateProofRound - stateproofInterval - VotersLookback) lowestStateProofRound = lowestStateProofRound.SubSaturate(basics.Round(proto.StateProofInterval)) + lowestStateProofRound = lowestStateProofRound.SubSaturate(basics.Round(proto.StateProofVotersLookback)) return uint64(topBlock.Round().SubSaturate(lowestStateProofRound)) } diff --git a/catchup/service_test.go b/catchup/service_test.go index 679ee3239e..676a283bad 100644 --- a/catchup/service_test.go +++ b/catchup/service_test.go @@ -988,7 +988,7 @@ func TestDownloadBlocksToSupportStateProofs(t *testing.T) { lookback := lookbackForStateproofsSupport(&topBlk) oldestRound := topBlk.BlockHeader.Round.SubSaturate(basics.Round(lookback)) - assert.Equal(t, uint64(oldestRound), 512-config.Consensus[protocol.ConsensusFuture].StateProofInterval) + assert.Equal(t, uint64(oldestRound), 512-config.Consensus[protocol.ConsensusFuture].StateProofInterval-config.Consensus[protocol.ConsensusFuture].StateProofVotersLookback) // the network has made progress and now it is on round 8000. in this case we would not download blocks to cover 512. // instead, we will download blocks to confirm only the recovery period lookback. @@ -1002,7 +1002,9 @@ func TestDownloadBlocksToSupportStateProofs(t *testing.T) { lookback = lookbackForStateproofsSupport(&topBlk) oldestRound = topBlk.BlockHeader.Round.SubSaturate(basics.Round(lookback)) - lowestRoundToRetain := 8000 - (8000 % 256) - (config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval * (config.Consensus[protocol.ConsensusCurrentVersion].StateProofMaxRecoveryIntervals + 1)) + lowestRoundToRetain := 8000 - (8000 % config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval) - + config.Consensus[protocol.ConsensusCurrentVersion].StateProofInterval*(config.Consensus[protocol.ConsensusCurrentVersion].StateProofMaxRecoveryIntervals+1) - config.Consensus[protocol.ConsensusFuture].StateProofVotersLookback + assert.Equal(t, uint64(oldestRound), lowestRoundToRetain) topBlk = bookkeeping.Block{}