diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d49f6dd22cc..8a801a05906f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,8 @@ - [#6490](https://github.com/ChainSafe/forest/pull/6490): Implemented `Filecoin.EthGetCode` for API v2. +- [#6498](https://github.com/ChainSafe/forest/pull/6498): Implemented `Filecoin.EthGetBlockReceiptsLimited` for API v2. + ### Changed - [#6471](https://github.com/ChainSafe/forest/pull/6471): Moved `forest-tool state` subcommand to `forest-dev`. diff --git a/src/rpc/methods/eth.rs b/src/rpc/methods/eth.rs index 6e06dee085d8..a1cc3120d055 100644 --- a/src/rpc/methods/eth.rs +++ b/src/rpc/methods/eth.rs @@ -1775,6 +1775,10 @@ impl RpcMethod<2> for EthGetBlockReceiptsLimited { const PARAM_NAMES: [&'static str; 2] = ["blockParam", "limit"]; const API_PATHS: BitFlags = ApiPaths::all(); const PERMISSION: Permission = Permission::Read; + const DESCRIPTION: Option<&'static str> = Some( + "Retrieves all transaction receipts for a block identified by its number, hash or a special tag along with an optional limit on the chain epoch for state resolution.", + ); + type Params = (BlockNumberOrHash, ChainEpoch); type Ok = Vec; @@ -1793,6 +1797,32 @@ impl RpcMethod<2> for EthGetBlockReceiptsLimited { } } +pub enum EthGetBlockReceiptsLimitedV2 {} +impl RpcMethod<2> for EthGetBlockReceiptsLimitedV2 { + const NAME: &'static str = "Filecoin.EthGetBlockReceiptsLimited"; + const NAME_ALIAS: Option<&'static str> = Some("eth_getBlockReceiptsLimited"); + const PARAM_NAMES: [&'static str; 2] = ["blockParam", "limit"]; + const API_PATHS: BitFlags = make_bitflags!(ApiPaths::V2); + const PERMISSION: Permission = Permission::Read; + const DESCRIPTION: Option<&'static str> = Some( + "Retrieves all transaction receipts for a block identified by its number, hash or a special tag along with an optional limit on the chain epoch for state resolution.", + ); + + type Params = (ExtBlockNumberOrHash, ChainEpoch); + type Ok = Vec; + + async fn handle( + ctx: Ctx, + (block_param, limit): Self::Params, + ) -> Result { + let ts = tipset_by_block_number_or_hash_v2(&ctx, block_param, ResolveNullTipset::TakeOlder) + .await?; + get_block_receipts(&ctx, ts, Some(limit)) + .await + .map_err(ServerError::from) + } +} + pub enum EthGetBlockTransactionCountByHash {} impl RpcMethod<1> for EthGetBlockTransactionCountByHash { const NAME: &'static str = "Filecoin.EthGetBlockTransactionCountByHash"; diff --git a/src/rpc/mod.rs b/src/rpc/mod.rs index 85844c207172..e7d55df8e16b 100644 --- a/src/rpc/mod.rs +++ b/src/rpc/mod.rs @@ -120,6 +120,7 @@ macro_rules! for_each_rpc_method { $callback!($crate::rpc::eth::EthGetBlockReceipts); $callback!($crate::rpc::eth::EthGetBlockReceiptsV2); $callback!($crate::rpc::eth::EthGetBlockReceiptsLimited); + $callback!($crate::rpc::eth::EthGetBlockReceiptsLimitedV2); $callback!($crate::rpc::eth::EthGetBlockTransactionCountByHash); $callback!($crate::rpc::eth::EthGetBlockTransactionCountByNumber); $callback!($crate::rpc::eth::EthGetBlockTransactionCountByNumberV2); diff --git a/src/tool/subcommands/api_cmd/api_compare_tests.rs b/src/tool/subcommands/api_cmd/api_compare_tests.rs index 011fbe903852..690c9df2ff02 100644 --- a/src/tool/subcommands/api_cmd/api_compare_tests.rs +++ b/src/tool/subcommands/api_cmd/api_compare_tests.rs @@ -1864,6 +1864,21 @@ fn eth_tests_with_tipset(store: &Arc, shared_tipset: &Tipset )) .unwrap(), ), + RpcTest::identity( + EthGetBlockReceiptsLimitedV2::request(( + ExtBlockNumberOrHash::from_block_hash_object(block_hash.clone(), true), + 4, + )) + .unwrap(), + ) + .policy_on_rejected(PolicyOnRejected::PassWithIdenticalError), + RpcTest::identity( + EthGetBlockReceiptsLimitedV2::request(( + ExtBlockNumberOrHash::from_block_hash_object(block_hash.clone(), true), + -1, + )) + .unwrap(), + ), RpcTest::identity( EthGetBlockTransactionCountByNumber::request((EthInt64(shared_tipset.epoch()),)) .unwrap(), diff --git a/src/tool/subcommands/api_cmd/test_snapshots.txt b/src/tool/subcommands/api_cmd/test_snapshots.txt index dc6698eeb152..dcb624a8e350 100644 --- a/src/tool/subcommands/api_cmd/test_snapshots.txt +++ b/src/tool/subcommands/api_cmd/test_snapshots.txt @@ -68,6 +68,7 @@ filecoin_ethgetblockreceipts_v2_1769603485649087.rpcsnap.json.zst filecoin_ethgetblockreceipts_v2_finalized_1769603486031510.rpcsnap.json.zst filecoin_ethgetblockreceipts_v2_safe_1769603485649367.rpcsnap.json.zst filecoin_ethgetblockreceiptslimited_1740132537908421.rpcsnap.json.zst +filecoin_ethgetblockreceiptslimited_v2_1769630813979893.rpcsnap.json.zst filecoin_ethgetblocktransactioncountbyhash_1740132538001911.rpcsnap.json.zst filecoin_ethgetblocktransactioncountbynumber_1737446676697272.rpcsnap.json.zst filecoin_ethgetblocktransactioncountbynumber_v2_1769099953133906.rpcsnap.json.zst