Skip to content

cmd: accept N+ syntax in seg rm-state --step flag - #21853

Merged
AskAlexSharov merged 2 commits into
mainfrom
awskii/rm-state-fromstep-plus
Jun 17, 2026
Merged

AskAlexSharov merged 2 commits into
mainfrom
awskii/rm-state-fromstep-plus

Conversation

@awskii

@awskii awskii commented Jun 16, 2026

Copy link
Copy Markdown
Member

What

erigon seg rm-state --step now accepts an N+ form meaning "from step N to the latest available step":

  • --step 5+ — remove everything from step 5 to the latest
  • --step 5-10 — unchanged

Previously the only way to express "from step N to the end" was an arbitrarily large upper bound like --step 5-9999999.

How

The --step parsing is extracted into parseStepRange(stepRange, maxAvailableStep). For the N+ form it parses the prefix as from and sets to to the highest toStep among the state files already scanned by DeleteStateSnapshots (respecting any --domain filter). The from-to form is unchanged. Only the range parsing changed — the file-removal logic is untouched.

Tests

  • Test_parseStepRange — table-driven unit test covering both formats and error cases (empty, + only, bad prefix, non-numeric).
  • Test_DeleteStateSnaps_StepRange_FromPlus — end-to-end: 192+ removes the 192-224 merged file plus its sub-ranges and keeps 0-128 / 128-192, identical to 192-224 since 224 is the highest step.

make lint clean; go test ./cmd/utils/app/ passing.

@awskii awskii left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@copilot review this PR

Copilot AI commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

@copilot review this PR

Reviewed and pushed 286ff95 to reject malformed ranges like 5-10x and 5-10-20; go test ./cmd/utils/app and make lint are clean.

@awskii
awskii marked this pull request as ready for review June 17, 2026 01:28
@AskAlexSharov
AskAlexSharov added this pull request to the merge queue Jun 17, 2026
Merged via the queue into main with commit cafc238 Jun 17, 2026
102 of 163 checks passed
@AskAlexSharov
AskAlexSharov deleted the awskii/rm-state-fromstep-plus branch June 17, 2026 04:28
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