Skip to content

Conversation

julienrbrt
Copy link

@julienrbrt julienrbrt commented Sep 9, 2025

Overview

d
Implement DeleteRange on store.
This methods truncates the head to the given height. (different from DeleteTo that truncates the tail to the given height)

@Wondertan
Copy link
Member

Wondertan commented Sep 9, 2025

One thing we should explore is making DeleteRange [from:to) instead of introducing a new method. It's gonna have better ergonomics, allow both usecase, and have less duplicated code and easier to maintain longer term.

We actually wanted to make it DeleteRange from the start, but then we selfishly moved towards DeleteTo because deleting from Tail is all we needed. This is the exact case where we should have gone for a more general solution it turns out.

@julienrbrt julienrbrt changed the title feat: Add DeleteFromHead method to Store feat: Add DeleteRange method to Store Sep 9, 2025
@julienrbrt julienrbrt marked this pull request as ready for review September 9, 2025 13:14
Copy link
Member

@Wondertan Wondertan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass.

I still need to sit down and verify new logic of DeleteRange

Comment on lines 395 to 411
deleteCtx := ctx
if deadline, ok := ctx.Deadline(); ok {
// allocate 95% of caller's set deadline for deletion
// and give leftover to save progress
sub := deadline.Sub(startTime) / 100 * 95
var cancel context.CancelFunc
deleteCtx, cancel = context.WithDeadlineCause(ctx, startTime.Add(sub), errDeleteTimeout)
defer cancel()
}

if to-from < deleteRangeParallelThreshold {
height, missing, err = s.deleteSequential(deleteCtx, from, to)
} else {
height, missing, err = s.deleteParallel(deleteCtx, from, to)
}

return err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, updateTail was in the defer of the same function, so even if an error occurred, the partial progress was saved. This is no longer true as the call deleteRangeRaw short-circuits on error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we return from this method the actual values that were successfully deleted to?

@julienrbrt
Copy link
Author

Thanks! Implementing your suggestions...

github-merge-queue bot pushed a commit to evstack/ev-node that referenced this pull request Sep 17, 2025
github-merge-queue bot pushed a commit to evstack/ev-node that referenced this pull request Sep 17, 2025
This PR was blocked but got merged:
#2638.
It isn't bad to merge it, but we are relying on a fork of go-header for
the apps until celestiaorg/go-header#347 is
merged.
Let's delete it in the main go.mod
@julienrbrt
Copy link
Author

Any update on this @Wondertan?

@Wondertan
Copy link
Member

We qim to get it done by this week

}

// Update HeadHeight if we deleted from the end
if to >= m.HeadHeight {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fail out here if to > m.HeadHeight (we should catch this err case in tests)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or actually do we have to allow this condition as we allow deletion --> beyond store head (to sync head) ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it is fine to be able to delete beyond. it allows you to put a big number if you do not know the head.

Comment on lines 395 to 411
deleteCtx := ctx
if deadline, ok := ctx.Deadline(); ok {
// allocate 95% of caller's set deadline for deletion
// and give leftover to save progress
sub := deadline.Sub(startTime) / 100 * 95
var cancel context.CancelFunc
deleteCtx, cancel = context.WithDeadlineCause(ctx, startTime.Add(sub), errDeleteTimeout)
defer cancel()
}

if to-from < deleteRangeParallelThreshold {
height, missing, err = s.deleteSequential(deleteCtx, from, to)
} else {
height, missing, err = s.deleteParallel(deleteCtx, from, to)
}

return err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we return from this method the actual values that were successfully deleted to?

julienrbrt and others added 2 commits October 7, 2025 23:06
@julienrbrt julienrbrt requested a review from renaynay October 8, 2025 13:43
tac0turtle pushed a commit to evstack/ev-node that referenced this pull request Oct 8, 2025
<!--
Please read and fill out this form before submitting your PR.

Please make sure you have reviewed our contributors guide before
submitting your
first PR.

NOTE: PR titles should follow semantic commits:
https://www.conventionalcommits.org/en/v1.0.0/
-->

## Overview

With the fix from #2736, the
`--skip-p2p-stores` flag isn't needed.
Additionally, this bump go-header to the latest changes from
celestiaorg/go-header#347

<!-- 
Please provide an explanation of the PR, including the appropriate
context,
background, goal, and rationale. If there is an issue with this
information,
please provide a tl;dr and link the issue. 

Ex: Closes #<issue number>
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants