Skip to content

fix(ci): allow concurrent wallet tests on CI#7229

Merged
hanabi1224 merged 2 commits into
mainfrom
hm/concurrent-wallet-test-ci
Jun 23, 2026
Merged

fix(ci): allow concurrent wallet tests on CI#7229
hanabi1224 merged 2 commits into
mainfrom
hm/concurrent-wallet-test-ci

Conversation

@hanabi1224

@hanabi1224 hanabi1224 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary of changes

Now it takes ~7min without blocking other PRs: https://github.com/ChainSafe/forest/actions/runs/28035122912/job/82987732860?pr=7229

Changes introduced in this pull request:

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.

Outside contributions

  • I have read and agree to the CONTRIBUTING document.
  • I have read and agree to the AI Policy document. I understand that failure to comply with the guidelines will lead to rejection of the pull request.

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Improved insufficient-funds error reporting by including both the available balance and the required amount during transaction/message pool validation.
  • Chores

    • Improved integration test execution reliability by increasing parallelism for wallet and message pool test runs.
    • Added retry behavior to the mpool auto-unblock test to reduce intermittent failures.
    • Updated the Calibnet wallet check CI gating to run for all pull requests (including draft removal).

@hanabi1224 hanabi1224 marked this pull request as ready for review June 23, 2026 13:51
@hanabi1224 hanabi1224 requested a review from a team as a code owner June 23, 2026 13:51
@hanabi1224 hanabi1224 requested review from LesnyRumcajs and sudo-shashank and removed request for a team June 23, 2026 13:51
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Error::NotEnoughFunds is enriched with balance and required TokenAmount fields, and validate_with_state is updated to populate them. Separately, the Calibnet test harness receives a new block_on implementation using a dedicated OS thread and multi-thread Tokio runtime, funded_delegated_addr is refactored to poll both Local and Remote backends, mpool_replace_auto_unblocks_pending gains a retry wrapper with backoff, test thread counts are raised to 8, and the CI calibnet-wallet-check job loses its draft-PR gate and concurrency group.

Changes

NotEnoughFunds Error Enrichment

Layer / File(s) Summary
NotEnoughFunds variant and usage
src/message_pool/errors.rs, src/message_pool/msgpool/msg_pool.rs
TokenAmount is imported, NotEnoughFunds is changed from a unit to a struct-like variant with balance and required fields, the error message is updated to interpolate both values, and validate_with_state is updated to compute and pass required = msg.required_funds() at the return site.

Calibnet Test Harness and CI Improvements

Layer / File(s) Summary
block_on reimplementation and poll helper refactoring
src/dev/subcommands/tests_cmd/calibnet/helpers.rs
use std::future::Future is added, the poll helper generic bound is updated to use the alias, and block_on is replaced with an implementation that spawns an OS thread, builds a new multi-thread Tokio runtime with enable_all(), calls rt.block_on(future), and joins the thread. Generic constraints are tightened to Send + Sync + 'static.
funded_delegated_addr refactoring
src/dev/subcommands/tests_cmd/calibnet/helpers.rs
The OnceCell<String> cache is moved from module scope to function-local scope; the delegated wallet initialization refactored to poll both Backend::Local and Backend::Remote until funded, logging per-backend balances; the return path condensed to directly unwrap the OnceCell and call as_str().
Mpool retry logic, parallel threads, and CI cleanup
src/dev/subcommands/tests_cmd/calibnet/mpool.rs, src/dev/subcommands/tests_cmd/calibnet/wallet.rs, .github/workflows/forest.yml
Duration is imported; mpool and wallet runners switch from 1 to 8 test threads; the nonce-fix test is deregistered, leaving only mpool_replace_auto_unblocks_pending; that test becomes a synchronous retry wrapper (3 attempts, catch_unwind, 5-second backoff) calling the renamed async body mpool_replace_auto_unblocks_pending_async; the calibnet-wallet-check CI job loses its if: draft == false guard and its calibnet-wallet-tests concurrency group.

Sequence Diagram(s)

sequenceDiagram
  participant Runner as CalibnetMpoolTestCommand
  participant Wrapper as mpool_replace_auto_unblocks_pending
  participant BlockOn as block_on
  participant RT as Tokio Runtime (new OS thread)
  participant Async as mpool_replace_auto_unblocks_pending_async

  Runner->>Wrapper: invoke (libtest-mimic, 8 threads)
  loop retry 3 → 2 → 1
    Wrapper->>BlockOn: catch_unwind(block_on(future))
    BlockOn->>RT: spawn thread, build multi-thread runtime
    RT->>Async: rt.block_on(future)
    Async-->>RT: Result
    RT-->>BlockOn: join thread result
    BlockOn-->>Wrapper: Ok or Err
    alt Ok
      Wrapper-->>Runner: return Ok(())
    else Err and retries remain
      Wrapper->>Wrapper: sleep 5s, retry
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • ChainSafe/forest#6542: Both PRs modify .github/workflows/forest.yml CI concurrency and draft-PR gating for Calibnet jobs, with this PR removing the draft == false condition and concurrency group from calibnet-wallet-check.
  • ChainSafe/forest#6983: Introduces the Rust-based calibnet wallet integration test runner and helpers (including block_on and funded_delegated_addr) that this PR significantly refactors.
  • ChainSafe/forest#7084: Adds the mpool_replace and nonce-fix calibnet test cases; this PR refactors mpool_replace_auto_unblocks_pending with retry logic and deregisters the nonce-fix test.

Suggested labels

RPC

Suggested reviewers

  • sudo-shashank
  • LesnyRumcajs
  • akaladarshi
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 72.73% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately reflects the main change: removing draft-gating and concurrency constraints from wallet tests to enable concurrent CI execution.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hm/concurrent-wallet-test-ci
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch hm/concurrent-wallet-test-ci

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

Comment thread src/dev/subcommands/tests_cmd/calibnet/mpool.rs
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 5.26316% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.01%. Comparing base (08d39a2) to head (2cba945).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/dev/subcommands/tests_cmd/calibnet/helpers.rs 0.00% 18 Missing ⚠️
src/dev/subcommands/tests_cmd/calibnet/mpool.rs 0.00% 16 Missing ⚠️
src/dev/subcommands/tests_cmd/calibnet/wallet.rs 0.00% 1 Missing ⚠️
src/message_pool/msgpool/msg_pool.rs 66.66% 1 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/message_pool/errors.rs 66.66% <ø> (ø)
src/dev/subcommands/tests_cmd/calibnet/wallet.rs 0.00% <0.00%> (ø)
src/message_pool/msgpool/msg_pool.rs 87.98% <66.66%> (+0.17%) ⬆️
src/dev/subcommands/tests_cmd/calibnet/mpool.rs 0.00% <0.00%> (ø)
src/dev/subcommands/tests_cmd/calibnet/helpers.rs 0.00% <0.00%> (ø)

... and 11 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 08d39a2...2cba945. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

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.

Caution

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

⚠️ Outside diff range comments (1)
src/dev/subcommands/tests_cmd/calibnet/helpers.rs (1)

388-400: 🩺 Stability & Availability | 🟡 Minor

Remove unnecessary Sync bounds; keep fresh runtime per call due to thread-spawned test execution.

The test closures execute in threads spawned by libtest_mimic's thread pool, not within the Tokio async context. Because there is no active runtime available via Handle::current() in those threads, creating a fresh multi-thread runtime per call is architecturally necessary. However, the Sync bounds on F and F::Output are overly restrictive—std::thread::spawn requires only Send, not Sync.

Suggested adjustment
 pub fn block_on<F: Future + Send + 'static>(future: F) -> F::Output
 where
-    F::Output: Send + Sync + 'static,
+    F::Output: Send + 'static,
 {
     std::thread::spawn(|| {
         let rt = tokio::runtime::Builder::new_multi_thread()
             .enable_all()
             .build()
             .unwrap();
         rt.block_on(future)
     })
     .join()
     .unwrap()
 }
🤖 Prompt for 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.

In `@src/dev/subcommands/tests_cmd/calibnet/helpers.rs` around lines 388 - 400,
The generic bounds on the block_on function are overly restrictive. Remove the
Sync trait bounds from both the F generic parameter and the F::Output associated
type, keeping only the Send bounds since std::thread::spawn only requires Send.
The function signature should be updated so that F and F::Output only require
Send, not Sync, while preserving all other constraints and the implementation
that spawns a fresh multi-thread Tokio runtime per call.

Source: Learnings

🧹 Nitpick comments (1)
src/dev/subcommands/tests_cmd/calibnet/helpers.rs (1)

207-213: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Keep OnceCell initialization failures contextual.

Line 208 discards which backend failed, and Line 225 turns the whole init error into a bare panic. Since the initializer already returns anyhow::Result, propagate the poll error with backend context and use a descriptive expect only at the infallible API boundary.

Proposed error-context cleanup
             for backend in [Backend::Local, Backend::Remote] {
-                let funded = poll_until_funded(&addr, backend).await.unwrap();
+                let funded = poll_until_funded(&addr, backend)
+                    .await
+                    .with_context(|| {
+                        format!(
+                            "delegated wallet {addr} was not funded via {}",
+                            backend.label()
+                        )
+                    })?;
                 eprintln!(
                     "delegated wallet {addr} funded balance: {funded} ({})",
                     backend.label()
                 );
             }
@@
         })
         .await
-        .unwrap()
+        .expect("failed to initialize funded delegated wallet")
         .as_str()

If anyhow::Context is not already imported in this file, add it to the existing anyhow imports.

As per coding guidelines, Rust operations should use anyhow::Result<T> with .context() when errors occur and avoid bare unwrap() in production-style code.

Also applies to: 225-226

🤖 Prompt for 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.

In `@src/dev/subcommands/tests_cmd/calibnet/helpers.rs` around lines 207 - 213,
The poll_until_funded call on line 208 uses bare .unwrap() which discards
context about which backend failed, making debugging difficult. Replace the
.unwrap() with .context() to add backend context to the error, allowing the
anyhow::Result to propagate meaningful error information instead of panicking
silently. Include backend.label() or similar identifying information in the
context message. Additionally, ensure anyhow::Context is imported in the file if
not already present, and apply the same contextual error handling pattern to the
similar issue on line 225 where init errors are turned into bare panics.

Source: Coding guidelines

🤖 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.

Outside diff comments:
In `@src/dev/subcommands/tests_cmd/calibnet/helpers.rs`:
- Around line 388-400: The generic bounds on the block_on function are overly
restrictive. Remove the Sync trait bounds from both the F generic parameter and
the F::Output associated type, keeping only the Send bounds since
std::thread::spawn only requires Send. The function signature should be updated
so that F and F::Output only require Send, not Sync, while preserving all other
constraints and the implementation that spawns a fresh multi-thread Tokio
runtime per call.

---

Nitpick comments:
In `@src/dev/subcommands/tests_cmd/calibnet/helpers.rs`:
- Around line 207-213: The poll_until_funded call on line 208 uses bare
.unwrap() which discards context about which backend failed, making debugging
difficult. Replace the .unwrap() with .context() to add backend context to the
error, allowing the anyhow::Result to propagate meaningful error information
instead of panicking silently. Include backend.label() or similar identifying
information in the context message. Additionally, ensure anyhow::Context is
imported in the file if not already present, and apply the same contextual error
handling pattern to the similar issue on line 225 where init errors are turned
into bare panics.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3e820547-95e1-4544-998d-f81bc630518d

📥 Commits

Reviewing files that changed from the base of the PR and between e01b6da and 2cba945.

📒 Files selected for processing (1)
  • src/dev/subcommands/tests_cmd/calibnet/helpers.rs
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • filecoin-project/lotus (manual)

@hanabi1224 hanabi1224 added this pull request to the merge queue Jun 23, 2026
Merged via the queue into main with commit b3a2fc5 Jun 23, 2026
35 checks passed
@hanabi1224 hanabi1224 deleted the hm/concurrent-wallet-test-ci branch June 23, 2026 16:10
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.

2 participants