Skip to content

Commit

Permalink
move pruning right after commit
Browse files Browse the repository at this point in the history
  • Loading branch information
srene committed Aug 30, 2024
1 parent 829ef48 commit 0bcddeb
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions block/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ func (m *Manager) applyBlock(block *types.Block, commit *types.Commit, blockMeta
return fmt.Errorf("commit block: %w", err)
}

// Prune old heights, if requested by ABCI app.
// retainHeight is determined by currentHeight - min-retain-blocks (app.toml config).
// Unless max_age_num_blocks in consensus params is higher than min-retain-block, then max_age_num_blocks will be used instead of min-retain-blocks.

m.logger.Error("retain height", "retainHeight", retainHeight)
if 0 < retainHeight {
select {
case m.pruningC <- retainHeight:
default:
m.logger.Error("pruning channel full. skipping pruning", "retainHeight", retainHeight)
}
}
// Update the state with the new app hash, and store height from the commit.
// Every one of those, if happens before commit, prevents us from re-executing the block in case failed during commit.
m.Executor.UpdateStateAfterCommit(m.State, responses, appHash, block.Header.Height)
Expand Down Expand Up @@ -96,18 +108,6 @@ func (m *Manager) applyBlock(block *types.Block, commit *types.Commit, blockMeta

types.RollappHeightGauge.Set(float64(block.Header.Height))

// Prune old heights, if requested by ABCI app.
// retainHeight is determined by currentHeight - min-retain-blocks (app.toml config).
// Unless max_age_num_blocks in consensus params is higher than min-retain-block, then max_age_num_blocks will be used instead of min-retain-blocks.

if 0 < retainHeight {
select {
case m.pruningC <- retainHeight:
default:
m.logger.Error("pruning channel full. skipping pruning", "retainHeight", retainHeight)
}
}

m.blockCache.Delete(block.Header.Height)

if switchRole {
Expand Down

0 comments on commit 0bcddeb

Please sign in to comment.