Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 7 additions & 10 deletions baseapp/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ const (
QueryPathStore = "store"

QueryPathBroadcastTx = "/cosmos.tx.v1beta1.Service/BroadcastTx"

// DefaultBlockRetentionHeight is the default number of blocks to retain
// for block pruning when no other constraints are specified. This value
// is set larger than typical snapshot intervals to ensure nodes can
// successfully block sync after state sync.
DefaultBlockRetentionHeight = 5000
)

func (app *BaseApp) InitChain(req *abci.RequestInitChain) (*abci.ResponseInitChain, error) {
Expand Down Expand Up @@ -1353,21 +1359,12 @@ func (app *BaseApp) GetBlockRetentionHeight(commitHeight int64) int64 {
return y
}
}

// Define retentionHeight as the minimum value that satisfies all non-zero
// constraints. All blocks below (commitHeight-retentionHeight) are pruned
// from CometBFT.
var retentionHeight int64

// Define the number of blocks needed to protect against misbehaving validators
// which allows light clients to operate safely. Note, we piggy back of the
// evidence parameters instead of computing an estimated number of blocks based
// on the unbonding period and block commitment time as the two should be
// equivalent.
cp := app.GetConsensusParams(app.finalizeBlockState.Context())
if cp.Evidence != nil && cp.Evidence.MaxAgeNumBlocks > 0 {
retentionHeight = commitHeight - cp.Evidence.MaxAgeNumBlocks
}
retentionHeight = commitHeight - DefaultBlockRetentionHeight

if app.snapshotManager != nil {
snapshotRetentionHeights := app.snapshotManager.GetSnapshotBlockRetentionHeights()
Expand Down
2 changes: 1 addition & 1 deletion baseapp/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ func TestABCI_GetBlockRetentionHeight(t *testing.T) {
expected: 0,
},
"pruning unbonding time only": {
bapp: baseapp.NewBaseApp(name, logger, db, nil, baseapp.SetMinRetainBlocks(1)),
bapp: baseapp.NewBaseApp(name, logger, db, nil, baseapp.SetMinRetainBlocks(362880)),
maxAgeBlocks: 362880,
commitHeight: 499000,
expected: 136120,
Expand Down
5 changes: 3 additions & 2 deletions server/config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ halt-time = {{ .BaseConfig.HaltTime }}
# It has no bearing on application state pruning which is determined by the
# "pruning-*" configurations.
#
# Note: CometBFT block pruning is dependant on this parameter in conjunction
# with the unbonding (safety threshold) period, state pruning and state sync
# Note: CometBFT block pruning is dependant on this parameter
# snapshot parameters to determine the correct minimum value of
# ResponseCommit.RetainHeight.
# NOTE: in celestia-app v6, block pruning will prune 1500 + minRetainBlocks blocks behind the tip,
# if this value is greater than 1.
min-retain-blocks = {{ .BaseConfig.MinRetainBlocks }}

# InterBlockCache enables inter-block caching.
Expand Down
Loading