Skip to content

feat: add forest-cli mpool nonce + add RPC snapshot test#5999

Merged
LesnyRumcajs merged 4 commits intomainfrom
add-forest-cli-mpool-nonce
Aug 27, 2025
Merged

feat: add forest-cli mpool nonce + add RPC snapshot test#5999
LesnyRumcajs merged 4 commits intomainfrom
add-forest-cli-mpool-nonce

Conversation

@LesnyRumcajs
Copy link
Copy Markdown
Member

@LesnyRumcajs LesnyRumcajs commented Aug 26, 2025

Summary of changes

Changes introduced in this pull request:

  • added forest-cli mpool nonce to get the current nonce of an address
  • no tests because it's trivial - it's just a thin wrapper around the RPC call.
  • added the RPC snapshot to the tests so that we have one less ignored one. Added sad path with unused address.

Reference issue to close (if applicable)

Closes

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

Summary by CodeRabbit

  • New Features

    • Added a new forest-cli command "mpool nonce" to display the current nonce for a specified address.
  • Documentation

    • CLI reference and changelog updated to document the new mpool nonce command.
  • Tests

    • Snapshot listings and API tests updated to cover the mpool nonce behavior; previously-ignored snapshot entry for this call was re-enabled and tests reference a known-empty test address.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 26, 2025

Walkthrough

Adds a new forest-cli subcommand mpool nonce to fetch and print an address nonce, updates CLI docs generation and CHANGELOG, adds MpoolGetNonce RPC snapshots, removes Filecoin.MpoolGetNonce from ignored snapshots, and updates API conformance tests to use a known-empty calibnet address.

Changes

Cohort / File(s) Summary
Changelog
CHANGELOG.md
Replaces previous Added entry with a new Added entry for #5999 introducing forest-cli mpool nonce and inserts a blank line.
CLI docs generation
docs/docs/users/reference/cli.sh
Adds generate_markdown_section "forest-cli" "mpool nonce" to include docs for the new command.
CLI implementation
src/cli/subcommands/mpool_cmd.rs
Adds MpoolCommands::Nonce { address: Address }, implements the Nonce arm to call MpoolGetNonce and print the nonce; ensures Stat arm returns Ok(()).
RPC snapshots (added)
src/tool/subcommands/api_cmd/test_snapshots.txt
Adds filecoin_mpoolgetnonce_1756218632700175.rpcsnap.json.zst and filecoin_mpoolgetnonce_1756220013069333.rpcsnap.json.zst.
RPC ignored list (modified)
src/tool/subcommands/api_cmd/test_snapshots_ignored.txt
Removes the Filecoin.MpoolGetNonce entry so the RPC is no longer ignored.
API conformance tests
src/tool/subcommands/api_cmd/api_compare_tests.rs
Adds KNOWN_EMPTY_CALIBNET_ADDRESS and updates mpool/wallet tests to use it for MpoolGetNonce-related assertions.
Test snapshots metadata (narrative)
src/tool/subcommands/api_cmd/test_snapshots_ignored.txt
Removed ignore entry for Filecoin.MpoolGetNonce.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User as User
  participant CLI as forest-cli
  participant Parser as Address Parser
  participant RPC as RPC Client
  participant Node as Filecoin Node

  User->>CLI: forest-cli mpool nonce <address>
  CLI->>Parser: parse <address>
  Parser-->>CLI: Address
  CLI->>RPC: MpoolGetNonce(Address)
  RPC->>Node: JSON-RPC request
  Node-->>RPC: nonce / error
  RPC-->>CLI: nonce / error
  CLI-->>User: print nonce or error
  Note right of CLI: returns Ok(()) on success
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

RPC

Suggested reviewers

  • elmattic
  • akaladarshi
  • hanabi1224

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e4548a8 and fe3a0cc.

📒 Files selected for processing (1)
  • src/cli/subcommands/mpool_cmd.rs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/cli/subcommands/mpool_cmd.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Build forest binaries on Linux AMD64
  • GitHub Check: Build MacOS
  • GitHub Check: tests
  • GitHub Check: cargo-publish-dry-run
  • GitHub Check: tests-release
  • GitHub Check: Build Ubuntu
  • GitHub Check: All lint checks
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (rust)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-forest-cli-mpool-nonce

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@LesnyRumcajs LesnyRumcajs force-pushed the add-forest-cli-mpool-nonce branch from e2ed3be to a63d144 Compare August 26, 2025 12:56
@LesnyRumcajs LesnyRumcajs marked this pull request as ready for review August 26, 2025 12:57
@LesnyRumcajs LesnyRumcajs requested a review from a team as a code owner August 26, 2025 12:57
@LesnyRumcajs LesnyRumcajs requested review from akaladarshi and elmattic and removed request for a team August 26, 2025 12:57
@LesnyRumcajs LesnyRumcajs enabled auto-merge August 26, 2025 12:57
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/cli/subcommands/mpool_cmd.rs (1)

138-144: Avoid panic in mpool stat when actor sequence is unavailable

compute_stats uses expect("get must succeed"). However, actor_sequences is built from get_actor_sequence, which may return None on lookup errors, making the expect reachable and crashing mpool stat. Prefer a graceful skip.

Apply:

@@
-    for (address, bucket) in buckets {
-        let actor_sequence = *actor_sequences.get(&address).expect("get must succeed");
+    for (address, bucket) in buckets {
+        let Some(&actor_sequence) = actor_sequences.get(&address) else {
+            // Skip addresses where actor state could not be fetched
+            continue;
+        };

This keeps the command robust in the presence of transient RPC/state issues.

Also applies to: 270-275

🧹 Nitpick comments (4)
docs/docs/users/reference/cli.sh (1)

65-65: Docs: add mpool nonce section — LGTM

The new docs section hook for forest-cli mpool nonce is correctly added and follows the existing pattern.

If you want the subcommands to be easier to scan, consider grouping them alphabetically within the mpool block (mpool nonce, mpool pending, mpool stat). No action needed for this PR.

src/cli/subcommands/mpool_cmd.rs (3)

35-39: Type the CLI argument as Address and let clap parse it

Minor ergonomics improvement: accept Address directly in the enum and let clap perform parsing via FromStr. This removes a runtime parse in run and yields better error messages from clap.

Apply:

@@
-    /// Get the current nonce for an address
+    /// Get the current nonce for an address
     Nonce {
-        /// Address to check nonce for
-        address: String,
+        /// Address to check nonce for
+        #[arg(value_name = "ADDRESS")]
+        address: Address,
     },

283-289: Nonce subcommand implementation — solid and minimal

Parsing the address and delegating to MpoolGetNonce is exactly the thin wrapper we want. Output is unambiguous (just the nonce).

If you adopt the typed-argument refactor above, you can drop the parse:

-            Self::Nonce { address } => {
-                let address = Address::from_str(&address)?;
+            Self::Nonce { address } => {
                 let nonce = MpoolGetNonce::call(&client, (address,)).await?;
                 println!("{nonce}");
                 Ok(())
             }

Optionally, consider a --json flag for machine-readable output (in line with other commands that support JSON), but that's not required here.


96-104: Send lookup warnings to stderr

These diagnostics currently go to stdout and can mix with the primary command output. Use stderr to keep output streams clean.

Apply:

-                println!("{address}, actor state not found");
+                eprintln!("mpool stat: actor state for {address} not found");
                 return None;
@@
-            println!("{address}, err: {err}");
+            eprintln!("mpool stat: error getting actor state for {address}: {err}");
             return None;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between c357975 and a63d144.

📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • docs/docs/users/reference/cli.sh (1 hunks)
  • src/cli/subcommands/mpool_cmd.rs (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: LesnyRumcajs
PR: ChainSafe/forest#5907
File: src/rpc/methods/state.rs:523-570
Timestamp: 2025-08-06T15:44:33.467Z
Learning: LesnyRumcajs prefers to rely on BufWriter's Drop implementation for automatic flushing rather than explicit flush() calls in Forest codebase.
🧬 Code graph analysis (1)
src/cli/subcommands/mpool_cmd.rs (3)
src/shim/address.rs (2)
  • from_str (178-183)
  • from_str (299-302)
src/rpc/reflect/mod.rs (1)
  • call (316-325)
src/rpc/client.rs (2)
  • call (92-151)
  • client (114-114)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: Build forest binaries on Linux AMD64
  • GitHub Check: tests-release
  • GitHub Check: tests
  • GitHub Check: Build MacOS
  • GitHub Check: cargo-publish-dry-run
  • GitHub Check: Build Ubuntu
  • GitHub Check: All lint checks
  • GitHub Check: Analyze (rust)
  • GitHub Check: Analyze (go)
🔇 Additional comments (2)
CHANGELOG.md (1)

52-53: Changelog entry reads well and matches house style

The wording, link, and placement under “Added” look consistent with the rest of the file.

src/cli/subcommands/mpool_cmd.rs (1)

281-282: Explicit Ok(()) — good return-path hygiene

Adding Ok(()) aligns arm semantics and avoids accidental fall-through or future regressions.

@LesnyRumcajs LesnyRumcajs changed the title feat: add forest-cli mpool nonce feat: add forest-cli mpool nonce + add RPC snapshot test Aug 26, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a63d144 and 93564ae.

📒 Files selected for processing (2)
  • src/tool/subcommands/api_cmd/test_snapshots.txt (1 hunks)
  • src/tool/subcommands/api_cmd/test_snapshots_ignored.txt (0 hunks)
💤 Files with no reviewable changes (1)
  • src/tool/subcommands/api_cmd/test_snapshots_ignored.txt
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: LesnyRumcajs
PR: ChainSafe/forest#5907
File: src/rpc/methods/state.rs:523-570
Timestamp: 2025-08-06T15:44:33.467Z
Learning: LesnyRumcajs prefers to rely on BufWriter's Drop implementation for automatic flushing rather than explicit flush() calls in Forest codebase.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: Build MacOS
  • GitHub Check: cargo-publish-dry-run
  • GitHub Check: Build forest binaries on Linux AMD64
  • GitHub Check: Check
  • GitHub Check: tests
  • GitHub Check: Analyze (ruby)
  • GitHub Check: Deploy to Cloudflare Pages

Comment thread src/tool/subcommands/api_cmd/test_snapshots.txt
@LesnyRumcajs LesnyRumcajs marked this pull request as draft August 26, 2025 14:39
auto-merge was automatically disabled August 26, 2025 14:39

Pull request was converted to draft

@LesnyRumcajs LesnyRumcajs marked this pull request as ready for review August 26, 2025 14:58
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/tool/subcommands/api_cmd/api_compare_tests.rs (2)

84-91: Clarify invariant: “zero balance” ≠ “no actor”; document intended error behavior

This constant is used to provoke “actor not found” (uninitialized address) in MpoolGetNonce, but the doc only promises zero balance. An address can have zero balance and still have an account actor, which would make MpoolGetNonce return a nonce (often 0) instead of an error. Tighten the comment to state “no actor/uninitialized” and spell out the maintenance note.

Apply this doc-only diff:

-/// This address is known to be empty on calibnet. It should always have a zero balance.
+/// This address is known to be uninitialized (no actor) on calibnet at the time of writing.
+/// Practical effects:
+/// - Methods like `MpoolGetNonce` should return an error (`actor not found`).
+/// - `WalletBalance` should be zero.
+/// If calibnet is reset or this address is ever funded/initialized, update this constant.
 static KNOWN_EMPTY_CALIBNET_ADDRESS: LazyLock<Address> = LazyLock::new(|| {
     crate::shim::address::Network::Testnet
         .parse_address("t1qb2x5qctp34rxd7ucl327h5ru6aazj2heno7x5y")
         .unwrap()
         .into()
 });

1168-1169: Reduce future flakiness risk for the “known-empty” wallet entry

Including a publicly known empty address is convenient, but if it’s ever funded (or calibnet resets), the WalletBalance test may change behavior. Two options (non-blocking):

  • Generate a fresh, random t1 address per run for unhappy-path tests (almost guaranteed to be uninitialized).
  • Keep the constant, but add a short maintenance note near this array mirroring the constant’s doc (“update if funded/reset”).
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 93564ae and e4548a8.

📒 Files selected for processing (6)
  • CHANGELOG.md (1 hunks)
  • docs/docs/users/reference/cli.sh (1 hunks)
  • src/cli/subcommands/mpool_cmd.rs (2 hunks)
  • src/tool/subcommands/api_cmd/api_compare_tests.rs (3 hunks)
  • src/tool/subcommands/api_cmd/test_snapshots.txt (1 hunks)
  • src/tool/subcommands/api_cmd/test_snapshots_ignored.txt (0 hunks)
💤 Files with no reviewable changes (1)
  • src/tool/subcommands/api_cmd/test_snapshots_ignored.txt
✅ Files skipped from review due to trivial changes (1)
  • docs/docs/users/reference/cli.sh
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/cli/subcommands/mpool_cmd.rs
  • CHANGELOG.md
  • src/tool/subcommands/api_cmd/test_snapshots.txt
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: LesnyRumcajs
PR: ChainSafe/forest#5907
File: src/rpc/methods/state.rs:523-570
Timestamp: 2025-08-06T15:44:33.467Z
Learning: LesnyRumcajs prefers to rely on BufWriter's Drop implementation for automatic flushing rather than explicit flush() calls in Forest codebase.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Build forest binaries on Linux AMD64
  • GitHub Check: cargo-publish-dry-run
  • GitHub Check: Build Ubuntu
  • GitHub Check: tests-release
  • GitHub Check: tests
  • GitHub Check: All lint checks
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (rust)

Comment thread src/tool/subcommands/api_cmd/api_compare_tests.rs
Comment thread src/cli/subcommands/mpool_cmd.rs Outdated
/// Get the current nonce for an address
Nonce {
/// Address to check nonce for
address: String,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think address: Address works here since Address implements FromStr

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.

Yeah, but no. There are those weird network shenanigans (global static variable that governs whether it's t or f) so we can't do it trivially here. See other arguments in this module.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it works.

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.

Oh yeah, actually it works. We have this rather backwards logic here that make it work.

forest/src/shim/address.rs

Lines 178 to 182 in e4548a8

fn from_str(s: &str) -> Result<Self, Self::Err> {
Network::Testnet
.parse_address(s)
.or_else(|_| Network::Mainnet.parse_address(s))
.map(Address::from)

Copy link
Copy Markdown
Member Author

@LesnyRumcajs LesnyRumcajs Aug 27, 2025

Choose a reason for hiding this comment

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

@coderabbitai create an issue to tackle other occurrences of the String that could be Address type in forest-cli params

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧩 Analysis chain

I'll help you create an issue to track the opportunity to use Address type instead of String for address parameters in forest-cli. Let me first search the codebase to identify specific occurrences.

@LesnyRumcajs I've created an issue to track the opportunity to replace String with Address type for address parameters in forest-cli commands. The issue includes:

  • Context from the current PR discussion
  • Examples found in the codebase (like the to/from parameters in mpool commands)
  • Benefits of making this change
  • Scope and background information
  • Links back to this PR and comment

The issue has been assigned to you as requested. This will help ensure consistency across the CLI interface and provide better type safety for address parameters throughout the forest-cli codebase.

🐰✨ ears perk up with organizational satisfaction


🏁 Script executed:

#!/bin/bash
# Find CLI command definitions with String parameters that likely represent addresses
echo "=== Searching for CLI commands with String address parameters ==="
rg -nP --type=rust -C3 'address.*:\s*(Option<)?String' src/cli/subcommands/
echo
echo "=== Looking for from/to String parameters in CLI ==="
rg -nP --type=rust -C3 '(from|to).*:\s*Option<String>' src/cli/subcommands/
echo
echo "=== Finding other potential address String parameters ==="
rg -nP --type=rust -C2 '#\[arg.*\]\s*\w+.*:\s*(Option<)?String' src/cli/subcommands/ | grep -i -A2 -B2 'address\|from\|to\|sender\|recipient'

Length of output: 3982


🏁 Script executed:

#!/bin/bash
# Let's also check the specific files mentioned to get a comprehensive view
echo "=== Examining mpool_cmd.rs for String parameters ==="
rg -nP --type=rust -C3 ':\s*(Option<)?String' src/cli/subcommands/mpool_cmd.rs
echo
echo "=== Looking at other CLI subcommand files ==="
fd -e rs . src/cli/subcommands/ --exec basename {} | sort | uniq

Length of output: 1065


🏁 Script executed:

#!/bin/bash
# Let's examine a few key CLI subcommand files to find String parameters that could be Address
echo "=== Checking state_cmd.rs ==="
rg -nP --type=rust -C2 ':\s*(Option<)?String' src/cli/subcommands/state_cmd.rs | head -20
echo
echo "=== Checking wallet_cmd.rs ==="
rg -nP --type=rust -C2 ':\s*(Option<)?String' src/cli/subcommands/wallet_cmd.rs | head -20
echo
echo "=== Checking send_cmd.rs ==="
rg -nP --type=rust -C2 ':\s*(Option<)?String' src/cli/subcommands/send_cmd.rs | head -20

Length of output: 875


🏁 Script executed:

#!/bin/bash
# Create the GitHub issue
gh issue create \
  --title "Replace String with Address type for address parameters in forest-cli commands" \
  --body "## Summary

During the review of PR #5999 (https://github.com/ChainSafe/forest/pull/5999#discussion_r2304022509), it was discovered that many forest-cli commands use \`String\` parameters for addresses when they could use the \`Address\` type directly.

As noted in the discussion, \`Address\` implements \`FromStr\` and works correctly with clap due to backwards logic in the Address::from_str implementation: https://github.com/ChainSafe/forest/blob/e4548a87ebb897f5e74282939c063727c6f4d460/src/shim/address.rs#L178-L182

## Examples Found

Based on a search of the codebase, the following CLI commands currently use String parameters that could potentially be Address types:

### mpool_cmd.rs
- \`to: Option<String>\` and \`from: Option<String>\` in the Pending command
- The newly added \`address: String\` in the Nonce command (from PR #5999)

### Other CLI commands
Multiple other CLI subcommands likely have similar opportunities for improvement.

## Benefits

- **Type Safety**: Using Address type provides compile-time validation
- **Consistency**: Aligns with the type system and reduces string parsing errors
- **Better API**: More semantic parameter types make the CLI interface clearer

## Scope

This issue should cover:
1. Audit all forest-cli subcommands for String parameters that represent addresses
2. Replace appropriate String parameters with Address type
3. Update any related parsing/conversion logic
4. Ensure tests are updated accordingly

## Background

This was identified during the implementation of \`forest-cli mpool nonce\` command where the discussion revealed that Address type works correctly with clap argument parsing.

**Related PR**: https://github.com/ChainSafe/forest/pull/5999
**Comment**: https://github.com/ChainSafe/forest/pull/5999#discussion_r2304022509

**Requested by**: @LesnyRumcajs" \
  --assignee LesnyRumcajs

Length of output: 2005


@LesnyRumcajs Perfect! I've successfully created issue #6006 to track replacing String with Address type for address parameters in forest-cli commands.

Here's what I found during the codebase search:

Confirmed examples that could use Address type:

  1. mpool_cmd.rs:

    • to: Option<String> and from: Option<String> in the Pending command
    • address: String in the new Nonce command (from this PR)
  2. state_cmd.rs:

    • actor_address: String in the ReadState command
  3. send_cmd.rs:

    • from: Option<String> and target_address: String
  4. net_cmd.rs:

    • address: String in the Connect command (though this might be a multiaddress rather than a Filecoin address)

The issue has been assigned to you and includes:

  • Complete context from our discussion
  • Specific examples found in the codebase
  • Benefits of the change (type safety, consistency, better API)
  • Clear scope for implementation
  • Links back to this PR and comment thread

This should provide a solid foundation for systematically improving the type safety across forest-cli address parameters!

🐰📝 proudly organizes the technical debt into a neat tracking issue


🧠 Learnings used
Learnt from: LesnyRumcajs
PR: ChainSafe/forest#5907
File: src/rpc/methods/state.rs:523-570
Timestamp: 2025-08-06T15:44:33.467Z
Learning: LesnyRumcajs prefers to rely on BufWriter's Drop implementation for automatic flushing rather than explicit flush() calls in Forest codebase.

hanabi1224
hanabi1224 previously approved these changes Aug 27, 2025
@LesnyRumcajs LesnyRumcajs enabled auto-merge August 27, 2025 14:35
@LesnyRumcajs LesnyRumcajs added this pull request to the merge queue Aug 27, 2025
Merged via the queue into main with commit 5a4d358 Aug 27, 2025
56 checks passed
@LesnyRumcajs LesnyRumcajs deleted the add-forest-cli-mpool-nonce branch August 27, 2025 15:07
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