Add nonce-fix and replace mpool tools#7084
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds ChangesMempool CLI nonce-fix and replace commands
Sequence DiagramsequenceDiagram
participant User
participant CLI as forest-cli mpool
participant RPC as Filecoin RPC (MpoolPending / ChainNonce)
participant MsgPool as MessagePool (MsgSet / push)
User->>CLI: run `mpool nonce-fix --auto` / `mpool replace --auto`
CLI->>RPC: query actor nonce and MpoolPending
CLI->>CLI: compute fill range / find pending message
CLI->>CLI: compute_replacement_gas() -> compute_rbf_min_premium()
CLI->>RPC: (optional) gas estimation via RPC
CLI->>MsgPool: push signed filler or replacement messages
MsgPool->>RPC: messages propagated to network / mempool state updated
CLI->>User: print new CID / success
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/docs/users/reference/cli.md`:
- Line 678: Two fenced code blocks in the markdown use bare backticks (``` ) and
need explicit language tags for markdownlint MD040; update the two blocks that
currently start and end with ``` to use ```text as the opening fence so the
examples "Fill an on-chain nonce gap..." and "Replace a pending message in the
mempool..." are fenced with ```text ... ``` instead of just ```, keeping the
content unchanged and only modifying the opening fences to include the language
tag.
In `@src/cli/subcommands/mpool_cmd.rs`:
- Around line 553-564: The Manual branch should validate that gas_feecap >=
gas_premium before calling compute_replacement_gas to avoid late runtime
rejection; add a pre-check where the variables gas_premium and gas_feecap are
available (the Manual branch handling that constructs ReplaceGasInput::Manual)
and return a user-facing error if gas_feecap < gas_premium (e.g. via
context/bail/Err) so the CLI rejects the input immediately rather than letting
compute_replacement_gas or downstream code fail.
- Around line 507-523: When --cid is passed the code currently derives
sender/sequence from ChainGetMessage and then calls find_pending_message(sender,
sequence, &pending), which can match a different pending message if the nonce
was superseded; instead, in the branch where cid is Some(msg_cid) use the
pending list to locate the exact pending entry whose .cid() equals msg_cid (or
otherwise compare the Cid from MpoolPending entries) and use that entry as
original_msg; keep the ChainGetMessage/sequence logic only for the
fallback/no-cid path and ensure find_pending_message is only used when matching
by sender+nonce.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 93adfebf-9a5e-495c-b3ed-1bbebb33f1fe
📒 Files selected for processing (12)
.config/forest.dicCargo.tomldocs/docs/users/reference/cli.mdmise.tomlsrc/cli/subcommands/mpool_cmd.rssrc/message_pool/mod.rssrc/message_pool/msgpool/msg_set.rssrc/message_pool/msgpool/utils.rssrc/rpc/methods/gas.rstests/calibnet_mpool_tools.rstests/calibnet_wallet.rstests/common/calibnet_wallet_helpers.rs
Codecov Report❌ Patch coverage is
Additional details and impacted files
... and 11 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
39795f8 to
203a8f5
Compare
203a8f5 to
10c1b66
Compare
| }, | ||
| } | ||
|
|
||
| fn compute_replacement_gas(input: ReplaceGasInput) -> anyhow::Result<Message> { |
There was a problem hiding this comment.
Can you please add clear comments/documentaion explaining what are the different calculations happening and why, so we can have clarity and verify the correct behaviour.
| } | ||
|
|
||
| pub(crate) fn compute_rbf_min_premium(premium: &TokenAmount) -> TokenAmount { | ||
| premium + (premium * RBF_NUM).div_floor(RBF_DENOM) + TokenAmount::from_atto(1u8) |
There was a problem hiding this comment.
@sudo-shashank If we are matching the calculation with lotus then it doesn't match, the constant we are using has different values.
Lotus made changes here: filecoin-project/lotus@58900a7.
please verify all the constants and calculations and provide documentation for explaining if we are intentionally diverging from lotus or not. It will be helpful later on.
Summary of changes
Changes introduced in this pull request:
nonce-fixandreplacecli commands with test.GasPriceTooLowcondition to check ifgas_premium < min_priceinstead ofgas_premium <= min_price.Reference issue to close (if applicable)
Closes #7085
Closes #7086
Other information and links
Change checklist
Outside contributions
Summary by CodeRabbit
New Features
mpool nonce-fix(auto/manual) andmpool replace(auto/manual RBF) CLI commands.Documentation
nonce-fixandreplaceusage and options.Tests
Chores
Other