Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocks: Bump min to save based on catchpoint support #5927

Merged
merged 5 commits into from
Feb 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions ledger/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"context"
"database/sql"
"fmt"
"math"
"path/filepath"
"time"

Expand Down Expand Up @@ -473,18 +472,24 @@
return minToSave
}

func (l *Ledger) calcMinCatchpointRoundsLookback() (minCatchpointRoundsLookback basics.Round) {
func (l *Ledger) calcMinCatchpointRoundsLookback() basics.Round {
// cfg.StoresCatchpoints checks that CatchpointInterval is positive
if l.cfg.StoresCatchpoints() && l.cfg.CatchpointFileHistoryLength != 0 {
// Nodes catching up from the _most recent_
// catchpoint will need to look back at least MaxTxnLife+DeeperBlockHeaderHistory+CatchpointLookback+
// buffer rounds before the catchpoint round in order to build up the necessary state.
// The max comparison is to mitigate against small catchpoint interval configurations.
minCatchpointRoundsLookback = basics.Round(math.Max(float64(2*l.cfg.CatchpointInterval),
float64(l.cfg.CatchpointInterval+l.genesisProto.MaxTxnLife+l.genesisProto.DeeperBlockHeaderHistory+
l.genesisProto.CatchpointLookback+100)))
if !l.cfg.StoresCatchpoints() || l.cfg.CatchpointFileHistoryLength == 0 {
return 0
}
return

// Nodes catching up from the _most recent_
// catchpoint will need to look back at least MaxTxnLife+DeeperBlockHeaderHistory+CatchpointLookback+
// buffer rounds before the catchpoint round in order to build up the necessary state.
// The max comparison is to mitigate against small catchpoint interval configurations.
catchpointIntervalLookback := 2 * l.cfg.CatchpointInterval
existingEstimatedLookback := l.cfg.CatchpointInterval + l.genesisProto.MaxTxnLife + l.genesisProto.DeeperBlockHeaderHistory +
l.genesisProto.CatchpointLookback + 100 // 100 rounds buffer
if catchpointIntervalLookback > existingEstimatedLookback {
return basics.Round(catchpointIntervalLookback)
}
gmalouf marked this conversation as resolved.
Show resolved Hide resolved

return 0 // should be treated as a no-op

Check warning on line 492 in ledger/ledger.go

View check run for this annotation

Codecov / codecov/patch

ledger/ledger.go#L492

Added line #L492 was not covered by tests
}

// GetLastCatchpointLabel returns the latest catchpoint label that was written to the
Expand Down
Loading