Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@

- [#6707](https://github.com/ChainSafe/forest/issues/6707): Added missing `GoldenWeek` network upgrade entry in `Filecoin.StateGetNetworkParams` RPC method.

- [#6817](https://github.com/ChainSafe/forest/pull/6817): Fixed `StateSearchMsg` to return null instead of error when not found to match Lotus behaviour.

## Forest v0.32.4 "Mild Inconvenience"

This is a non-mandatory release for all node operators. It enables F3 finality resolution on ETH v1 RPC methods.
Expand Down
3 changes: 1 addition & 2 deletions mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ tail -n +2 .config/forest.dic | diff - "$TMPFILE"
[tasks.insta]
description = "Update insta snapshots."
run = '''
cargo test --lib -- rpc::tests::openrpc
cargo insta accept
cargo test --lib -- rpc::tests::openrpc || cargo insta accept
'''
tools.cargo-insta = "1.46"

Expand Down
33 changes: 18 additions & 15 deletions src/rpc/methods/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1267,11 +1267,12 @@ impl RpcMethod<4> for StateSearchMsg {
["tipsetKey", "messageCid", "lookBackLimit", "allowReplaced"];
const API_PATHS: BitFlags<ApiPaths> = ApiPaths::all();
const PERMISSION: Permission = Permission::Read;
const DESCRIPTION: Option<&'static str> =
Some("Returns the receipt and tipset the specified message was included in.");
const DESCRIPTION: Option<&'static str> = Some(
"Returns the receipt and tipset the specified message was included in, or null if the message was not found.",
);

type Params = (ApiTipsetKey, Cid, i64, bool);
type Ok = MessageLookup;
type Ok = Option<MessageLookup>;
Comment thread
coderabbitai[bot] marked this conversation as resolved.

async fn handle(
ctx: Ctx<impl Blockstore + Send + Sync + 'static>,
Expand All @@ -1281,7 +1282,7 @@ impl RpcMethod<4> for StateSearchMsg {
let from = tsk
.map(|k| ctx.chain_index().load_required_tipset(&k))
.transpose()?;
let (tipset, receipt) = ctx
let Some((tipset, receipt)) = ctx
.state_manager
.search_for_message(
from,
Expand All @@ -1290,15 +1291,17 @@ impl RpcMethod<4> for StateSearchMsg {
Some(allow_replaced),
)
.await?
.with_context(|| format!("message {message_cid} not found."))?;
else {
return Ok(None);
};
let ipld = receipt.return_data().deserialize().unwrap_or(Ipld::Null);
Ok(MessageLookup {
Ok(Some(MessageLookup {
receipt,
tipset: tipset.key().clone(),
height: tipset.epoch(),
message: message_cid,
return_dec: ipld,
})
}))
}
}

Expand All @@ -1311,31 +1314,31 @@ impl RpcMethod<2> for StateSearchMsgLimited {
const API_PATHS: BitFlags<ApiPaths> = make_bitflags!(ApiPaths::V0); // Not supported in V1
const PERMISSION: Permission = Permission::Read;
const DESCRIPTION: Option<&'static str> = Some(
"Looks back up to limit epochs in the chain for a message, and returns its receipt and the tipset where it was executed.",
"Looks back up to limit epochs in the chain for a message, and returns its receipt and the tipset where it was executed, or null if it was not found.",
);
type Params = (Cid, i64);
type Ok = MessageLookup;
type Ok = Option<MessageLookup>;

async fn handle(
ctx: Ctx<impl Blockstore + Send + Sync + 'static>,
(message_cid, look_back_limit): Self::Params,
_: &http::Extensions,
) -> Result<Self::Ok, ServerError> {
let (tipset, receipt) = ctx
let Some((tipset, receipt)) = ctx
.state_manager
.search_for_message(None, message_cid, Some(look_back_limit), None)
.await?
.with_context(|| {
format!("message {message_cid} not found within the last {look_back_limit} epochs")
})?;
else {
return Ok(None);
};
let ipld = receipt.return_data().deserialize().unwrap_or(Ipld::Null);
Ok(MessageLookup {
Ok(Some(MessageLookup {
receipt,
tipset: tipset.key().clone(),
height: tipset.epoch(),
message: message_cid,
return_dec: ipld,
})
}))
}
}

Expand Down
16 changes: 10 additions & 6 deletions src/rpc/snapshots/forest__rpc__tests__rpc__v0.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions src/rpc/snapshots/forest__rpc__tests__rpc__v1.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 16 additions & 3 deletions src/tool/subcommands/api_cmd/api_compare_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1226,11 +1226,11 @@ fn state_tests_with_tipset<DB: Blockstore>(
for msg_cid in sample_message_cids(bls_messages.iter(), secp_messages.iter()) {
tests.extend([
RpcTest::identity(StateReplay::request((tipset.key().into(), msg_cid))?),
validate_message_lookup(
validate_message_wait(
StateWaitMsg::request((msg_cid, 0, 10101, true))?
.with_timeout(Duration::from_secs(15)),
),
validate_message_lookup(
validate_message_wait(
StateWaitMsg::request((msg_cid, 0, 10101, false))?
.with_timeout(Duration::from_secs(15)),
),
Expand Down Expand Up @@ -2780,7 +2780,7 @@ fn dump_test_data(dump_dir: &Path, success: bool, test_dump: &TestDump) -> anyho
Ok(())
}

fn validate_message_lookup(req: rpc::Request<MessageLookup>) -> RpcTest {
fn validate_message_wait(req: rpc::Request<MessageLookup>) -> RpcTest {
RpcTest::validate(req, |mut forest, mut lotus| {
// TODO(hanabi1224): https://github.com/ChainSafe/forest/issues/3784
forest.return_dec = Ipld::Null;
Expand All @@ -2789,6 +2789,19 @@ fn validate_message_lookup(req: rpc::Request<MessageLookup>) -> RpcTest {
})
}

fn validate_message_lookup(req: rpc::Request<Option<MessageLookup>>) -> RpcTest {
RpcTest::validate(req, |mut forest, mut lotus| {
// TODO(hanabi1224): https://github.com/ChainSafe/forest/issues/3784
if let Some(forest) = &mut forest {
forest.return_dec = Ipld::Null;
}
if let Some(lotus) = &mut lotus {
lotus.return_dec = Ipld::Null;
}
forest == lotus
})
}

fn validate_tagged_tipset_v2(req: rpc::Request<Tipset>, offline: bool) -> RpcTest {
RpcTest::validate(req, move |forest, lotus| {
if offline {
Expand Down
Loading