Skip to content

Fix calibnet wallet test#7183

Draft
sudo-shashank wants to merge 6 commits into
mainfrom
shashank/wallet-test-fix
Draft

Fix calibnet wallet test#7183
sudo-shashank wants to merge 6 commits into
mainfrom
shashank/wallet-test-fix

Conversation

@sudo-shashank

@sudo-shashank sudo-shashank commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary of changes

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 message pool's account state resolution for more accurate transaction processing at different blockchain heights.
  • Tests

    • Enhanced message execution validation to verify successful transaction processing, including receipt verification and exit code checking.

@sudo-shashank sudo-shashank added the RPC requires calibnet RPC checks to run on CI label Jun 17, 2026
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 00243dcd-c58a-4e33-8de2-01c1af028343

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch shashank/wallet-test-fix
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch shashank/wallet-test-fix

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

@sudo-shashank sudo-shashank changed the title Fix wallet check Fix calibnet wallet test Jun 18, 2026

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

Actionable comments posted: 2

🤖 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 `@src/message_pool/msgpool/provider.rs`:
- Around line 94-100: The get_actor_after method has a contract violation in the
None branch where there is no child tipset. When load_child_tipset returns None
(at the head), the code incorrectly uses ts.parent_state() which returns the
state BEFORE ts executes, but the method contract requires the state AFTER ts
executes. Replace the None branch to compute the true post-tipset state by
applying the tipset's state transitions instead of using the parent state,
ensuring that stale pre-tipset actor state is not fed into message pool
validation paths.

In `@src/message_pool/msgpool/test_provider.rs`:
- Around line 155-178: The get_actor_before method always returns
Ok(Some(actor)) with a default balance when an actor is not found in the test
data, but according to the Provider contract it should return Ok(None) when the
actor is absent. Modify the method to check if the actor exists in
inner.balances; if the get call returns None, return Ok(None) immediately
instead of proceeding to create an ActorState with default values. Only
construct and return the ActorState when the actor actually exists in the test
data.
🪄 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: 9d379f2a-3f89-441e-bdb0-809467f2ea14

📥 Commits

Reviewing files that changed from the base of the PR and between 82dd116 and 6e0c729.

📒 Files selected for processing (4)
  • src/message_pool/msgpool/msg_pool.rs
  • src/message_pool/msgpool/provider.rs
  • src/message_pool/msgpool/test_provider.rs
  • tests/common/calibnet_wallet_helpers.rs
🔗 Linked repositories identified

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

  • filecoin-project/lotus (manual)

Comment on lines +94 to +100
fn get_actor_after(&self, addr: &Address, ts: &Tipset) -> Result<ActorState, Error> {
let state_root = match self.load_child_tipset(ts)? {
Some(child) => *child.parent_state(),
None => *ts.parent_state(),
};
let state = StateTree::new_from_root(self.db(), &state_root)
.map_err(|e| Error::Other(e.to_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.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

get_actor_after can return pre-tipset state on head tipsets.

On Line 97, the None branch uses *ts.parent_state(), which is the state before ts executes, while the contract on Line 39 says this method is after ts’s messages. When ts has no child yet (common at head), this can feed stale actor sequence/balance into message-pool validation paths.

Please switch the no-child branch to a true post-ts state computation path (Lotus-equivalent TipSetState(ts) semantics), instead of falling back to ts.parent_state().

🤖 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/message_pool/msgpool/provider.rs` around lines 94 - 100, The
get_actor_after method has a contract violation in the None branch where there
is no child tipset. When load_child_tipset returns None (at the head), the code
incorrectly uses ts.parent_state() which returns the state BEFORE ts executes,
but the method contract requires the state AFTER ts executes. Replace the None
branch to compute the true post-tipset state by applying the tipset's state
transitions instead of using the parent state, ensuring that stale pre-tipset
actor state is not fed into message pool validation paths.

Source: Linked repositories

Comment on lines +155 to +178
fn get_actor_before(&self, addr: &Address, _ts: &Tipset) -> Result<Option<ActorState>, Error> {
let inner = self.inner.lock();
let canonical = inner.resolve_addr(addr);
let balance = match inner.balances.get(&canonical) {
Some(b) => b.clone(),
None => TokenAmount::from_atto(10_000_000_000_u64),
};
let sequence = inner
.state_sequence
.get(&canonical)
.copied()
.unwrap_or_default();
let actor = ActorState::new(
// Account Actor code (v10, calibnet)
Cid::try_from("bafk2bzacebhfuz3sv7duvk653544xsxhdn4lsmy7ol7k6gdgancyctvmd7lnq")
.unwrap(),
Cid::default(),
balance,
sequence,
None,
);

Ok(Some(actor))
}

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

TestApi::get_actor_before never returns None, so fallback behavior is untestable.

Line 177 always returns Ok(Some(actor)) (with defaulted state), even when actor state is absent. That diverges from the Provider contract (“None if absent”) and prevents get_state_sequence’s get_actor_after fallback path from being exercised in tests.

🔧 Suggested fix
 fn get_actor_before(&self, addr: &Address, _ts: &Tipset) -> Result<Option<ActorState>, Error> {
     let inner = self.inner.lock();
     let canonical = inner.resolve_addr(addr);
+    let has_actor =
+        inner.state_sequence.contains_key(&canonical) || inner.balances.contains_key(&canonical);
+    if !has_actor {
+        return Ok(None);
+    }
+
     let balance = match inner.balances.get(&canonical) {
         Some(b) => b.clone(),
         None => TokenAmount::from_atto(10_000_000_000_u64),
     };
     let sequence = inner
         .state_sequence
         .get(&canonical)
         .copied()
         .unwrap_or_default();
@@
-    Ok(Some(actor))
+    Ok(Some(actor))
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fn get_actor_before(&self, addr: &Address, _ts: &Tipset) -> Result<Option<ActorState>, Error> {
let inner = self.inner.lock();
let canonical = inner.resolve_addr(addr);
let balance = match inner.balances.get(&canonical) {
Some(b) => b.clone(),
None => TokenAmount::from_atto(10_000_000_000_u64),
};
let sequence = inner
.state_sequence
.get(&canonical)
.copied()
.unwrap_or_default();
let actor = ActorState::new(
// Account Actor code (v10, calibnet)
Cid::try_from("bafk2bzacebhfuz3sv7duvk653544xsxhdn4lsmy7ol7k6gdgancyctvmd7lnq")
.unwrap(),
Cid::default(),
balance,
sequence,
None,
);
Ok(Some(actor))
}
fn get_actor_before(&self, addr: &Address, _ts: &Tipset) -> Result<Option<ActorState>, Error> {
let inner = self.inner.lock();
let canonical = inner.resolve_addr(addr);
let has_actor =
inner.state_sequence.contains_key(&canonical) || inner.balances.contains_key(&canonical);
if !has_actor {
return Ok(None);
}
let balance = match inner.balances.get(&canonical) {
Some(b) => b.clone(),
None => TokenAmount::from_atto(10_000_000_000_u64),
};
let sequence = inner
.state_sequence
.get(&canonical)
.copied()
.unwrap_or_default();
let actor = ActorState::new(
// Account Actor code (v10, calibnet)
Cid::try_from("bafk2bzacebhfuz3sv7duvk653544xsxhdn4lsmy7ol7k6gdgancyctvmd7lnq")
.unwrap(),
Cid::default(),
balance,
sequence,
None,
);
Ok(Some(actor))
}
🤖 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/message_pool/msgpool/test_provider.rs` around lines 155 - 178, The
get_actor_before method always returns Ok(Some(actor)) with a default balance
when an actor is not found in the test data, but according to the Provider
contract it should return Ok(None) when the actor is absent. Modify the method
to check if the actor exists in inner.balances; if the get call returns None,
return Ok(None) immediately instead of proceeding to create an ActorState with
default values. Only construct and return the ActorState when the actor actually
exists in the test data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RPC requires calibnet RPC checks to run on CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant