Skip to content

Commit

Permalink
dont prune too earlyy
Browse files Browse the repository at this point in the history
  • Loading branch information
dshulyak committed Oct 21, 2023
1 parent 9fa0feb commit e668c58
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion proposals/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,11 @@ func (h *Handler) checkBallotDataIntegrity(ctx context.Context, b *types.Ballot)
if b.EpochData.Beacon == types.EmptyBeacon {
return nil, errMissingBeacon
}
if b.Layer.GetEpoch() == h.clock.CurrentLayer().GetEpoch() {
epoch := h.clock.CurrentLayer().GetEpoch()
if epoch > 0 {
epoch-- // download activesets in the previous epoch too
}
if b.Layer.GetEpoch() >= epoch {
if err := h.fetcher.GetActiveSet(ctx, b.EpochData.ActiveSetHash); err != nil {
return nil, err
}
Expand Down
7 changes: 6 additions & 1 deletion prune/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ func (p *Pruner) Prune(current types.LayerID) error {
propTxLatency.Observe(time.Since(start).Seconds())
if current.GetEpoch() > p.activesetEpoch {
start = time.Now()
if err := activesets.DeleteBeforeEpoch(p.db, current.GetEpoch()); err != nil {
epoch := current.GetEpoch()
if epoch > 0 {
epoch--
}
// current - 1 as activesets will be fetched in hare eligibility oracle
if err := activesets.DeleteBeforeEpoch(p.db, epoch); err != nil {
return err
}
activeSetLatency.Observe(time.Since(start).Seconds())
Expand Down
2 changes: 1 addition & 1 deletion prune/prune_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestPrune(t *testing.T) {
for epoch, epochSets := range sets {
for _, id := range epochSets {
_, err := activesets.Get(db, id)
if epoch >= current.GetEpoch() {
if epoch >= current.GetEpoch()-1 {
require.NoError(t, err)
} else {
require.ErrorIs(t, err, sql.ErrNotFound)
Expand Down

0 comments on commit e668c58

Please sign in to comment.