feat: CLI: add target-client and max-days-from-now filters to extend-claim#13527
feat: CLI: add target-client and max-days-from-now filters to extend-claim#13527
Conversation
There was a problem hiding this comment.
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-clientto only extend claims belonging to a specified client. - Add
--max-days-from-nowto only extend claims expiring within a given time window. - Thread the new filters through
CreateExtendClaimMsgand apply them when selecting eligible claims.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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) { | ||
|
|
There was a problem hiding this comment.
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.
| client := cctx.String("client") | ||
| targetClient := cctx.String("target-client") | ||
| tmax := cctx.Int64("term-max") | ||
| maxDaysFromNow := cctx.Int("max-days-from-now") |
There was a problem hiding this comment.
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.
| 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) | |
| } |
| // 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) |
There was a problem hiding this comment.
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.
| maxExpirationEpoch = head.Height() + abi.ChainEpoch(maxDaysFromNow*2880) | |
| maxExpirationEpoch = head.Height() + abi.ChainEpoch(maxDaysFromNow*builtin.EpochsInDay) |
| // 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 |
There was a problem hiding this comment.
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.
| // 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 |
There was a problem hiding this comment.
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.
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: