Thanks to visit codestin.com
Credit goes to GitHub.com

Skip to content

feat: CLI: add target-client and max-days-from-now filters to extend-claim#13527

Open
magik6k wants to merge 1 commit intomasterfrom
feat/claim-ext-client-filter
Open

feat: CLI: add target-client and max-days-from-now filters to extend-claim#13527
magik6k wants to merge 1 commit intomasterfrom
feat/claim-ext-client-filter

Conversation

@magik6k
Copy link
Contributor

@magik6k magik6k commented Feb 23, 2026

Related Issues

Proposed Changes

Two new flags making extend-claims far far more usable for actual clients

Additional Info

Checklist

Before you mark the PR ready for review, please make sure that:

Copilot AI review requested due to automatic review settings February 23, 2026 22:23
@github-project-automation github-project-automation bot moved this to 📌 Triage in FilOz Feb 23, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the filplus extend-claim CLI command with additional filtering options to make extending claims more practical for real-world client workflows.

Changes:

  • Add --target-client to only extend claims belonging to a specified client.
  • Add --max-days-from-now to only extend claims expiring within a given time window.
  • Thread the new filters through CreateExtendClaimMsg and apply them when selecting eligible claims.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1159 to 1160
func CreateExtendClaimMsg(ctx context.Context, api api.FullNode, pcm map[verifregtypes13.ClaimId]ProvInfo, miners []string, wallet, targetClient address.Address, tmax abi.ChainEpoch, all, assumeYes bool, batchSize, maxDaysFromNow int) ([]*types.Message, error) {

Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

CreateExtendClaimMsg is an exported function and its signature change will break existing call sites (e.g., the itests that call cli.CreateExtendClaimMsg), causing the repo to no longer compile/tests to fail. Update all callers to pass the new targetClient and maxDaysFromNow arguments, or keep the old signature as a wrapper that forwards to a new internal helper to avoid a breaking change.

Copilot uses AI. Check for mistakes.
client := cctx.String("client")
targetClient := cctx.String("target-client")
tmax := cctx.Int64("term-max")
maxDaysFromNow := cctx.Int("max-days-from-now")
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

max-days-from-now accepts negative values; with the current logic a negative value silently disables the filter (because only > 0 is checked). Consider validating max-days-from-now is >= 0 and returning a clear error if it’s negative so users don’t accidentally run an unfiltered extend.

Suggested change
maxDaysFromNow := cctx.Int("max-days-from-now")
maxDaysFromNow := cctx.Int("max-days-from-now")
if maxDaysFromNow < 0 {
return xerrors.Errorf("--max-days-from-now must be >= 0, got %d", maxDaysFromNow)
}

Copilot uses AI. Check for mistakes.
// Convert maxDaysFromNow to epochs (30 seconds per epoch = 2880 epochs per day)
var maxExpirationEpoch abi.ChainEpoch
if maxDaysFromNow > 0 {
maxExpirationEpoch = head.Height() + abi.ChainEpoch(maxDaysFromNow*2880)
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

Avoid the hard-coded 2880 epochs/day constant here; the repo already imports go-state-types/builtin in this file and provides builtin.EpochsInDay, which keeps the conversion self-documenting and consistent with other code.

Suggested change
maxExpirationEpoch = head.Height() + abi.ChainEpoch(maxDaysFromNow*2880)
maxExpirationEpoch = head.Height() + abi.ChainEpoch(maxDaysFromNow*builtin.EpochsInDay)

Copilot uses AI. Check for mistakes.
Comment on lines +1218 to +1224
// Skip if target client is specified and doesn't match
if targetClient != (address.Undef) && claim.Client != targetClientID {
continue
}
// Skip if claim expires later than maxDaysFromNow
if maxDaysFromNow > 0 && claim.TermStart+claim.TermMax > maxExpirationEpoch {
continue
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

The new filtering logic (targetClient match + expiration cutoff) is duplicated in three separate loops. Consider extracting a small helper predicate (or a local inline function) to ensure future changes don’t accidentally diverge between the --all, single-miner, and no-miner code paths.

Copilot uses AI. Check for mistakes.
Comment on lines +1218 to +1224
// Skip if target client is specified and doesn't match
if targetClient != (address.Undef) && claim.Client != targetClientID {
continue
}
// Skip if claim expires later than maxDaysFromNow
if maxDaysFromNow > 0 && claim.TermStart+claim.TermMax > maxExpirationEpoch {
continue
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

New behavior introduced by --target-client and --max-days-from-now doesn’t appear to have coverage. Since CreateExtendClaimMsg is already exercised by itests, please extend those tests to assert that claims are correctly included/excluded when these filters are set.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📌 Triage

Development

Successfully merging this pull request may close these issues.

2 participants