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 @@ -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`.
Expand Down
30 changes: 30 additions & 0 deletions src/rpc/methods/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1775,6 +1775,10 @@ impl RpcMethod<2> for EthGetBlockReceiptsLimited {
const PARAM_NAMES: [&'static str; 2] = ["blockParam", "limit"];
const API_PATHS: BitFlags<ApiPaths> = 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.",
);
Comment thread
sudo-shashank marked this conversation as resolved.

type Params = (BlockNumberOrHash, ChainEpoch);
type Ok = Vec<EthTxReceipt>;

Expand All @@ -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<ApiPaths> = 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<EthTxReceipt>;

async fn handle(
ctx: Ctx<impl Blockstore + Send + Sync + 'static>,
(block_param, limit): Self::Params,
) -> Result<Self::Ok, ServerError> {
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";
Expand Down
1 change: 1 addition & 0 deletions src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 15 additions & 0 deletions src/tool/subcommands/api_cmd/api_compare_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1864,6 +1864,21 @@ fn eth_tests_with_tipset<DB: Blockstore>(store: &Arc<DB>, 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(),
Expand Down
1 change: 1 addition & 0 deletions src/tool/subcommands/api_cmd/test_snapshots.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading