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

- [#6403](https://github.com/ChainSafe/forest/pull/6403) Implemented `Filecoin.EthGetBalance` for API v2.

- [#6404](https://github.com/ChainSafe/forest/pull/6404) Implemented `Filecoin.EthGetBlockByNumber` for API v2.

### Changed

- [#6368](https://github.com/ChainSafe/forest/pull/6368): Migrated build and development tooling from Makefile to `mise`. Contributors should install `mise` and use `mise run` commands instead of `make` commands.
Expand Down
22 changes: 22 additions & 0 deletions src/rpc/methods/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,28 @@ impl RpcMethod<2> for EthGetBlockByNumber {
}
}

pub enum EthGetBlockByNumberV2 {}
impl RpcMethod<2> for EthGetBlockByNumberV2 {
const NAME: &'static str = "Filecoin.EthGetBlockByNumber";
const NAME_ALIAS: Option<&'static str> = Some("eth_getBlockByNumber");
const PARAM_NAMES: [&'static str; 2] = ["blockParam", "fullTxInfo"];
const API_PATHS: BitFlags<ApiPaths> = make_bitflags!(ApiPaths::V2);
const PERMISSION: Permission = Permission::Read;

type Params = (ExtBlockNumberOrHash, bool);
type Ok = Block;

async fn handle(
ctx: Ctx<impl Blockstore + Send + Sync + 'static>,
(block_param, full_tx_info): Self::Params,
) -> Result<Self::Ok, ServerError> {
let ts = tipset_by_block_number_or_hash_v2(&ctx, block_param, ResolveNullTipset::TakeOlder)
.await?;
let block = block_from_filecoin_tipset(ctx, ts, full_tx_info).await?;
Ok(block)
}
}
Comment thread
sudo-shashank marked this conversation as resolved.

async fn get_block_receipts<DB: Blockstore + Send + Sync + 'static>(
ctx: &Ctx<DB>,
block_param: BlockNumberOrHash,
Expand Down
1 change: 1 addition & 0 deletions src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ macro_rules! for_each_rpc_method {
$callback!($crate::rpc::eth::EthGetBalanceV2);
$callback!($crate::rpc::eth::EthGetBlockByHash);
$callback!($crate::rpc::eth::EthGetBlockByNumber);
$callback!($crate::rpc::eth::EthGetBlockByNumberV2);
$callback!($crate::rpc::eth::EthGetBlockReceipts);
$callback!($crate::rpc::eth::EthGetBlockReceiptsLimited);
$callback!($crate::rpc::eth::EthGetBlockTransactionCountByHash);
Expand Down
50 changes: 50 additions & 0 deletions src/tool/subcommands/api_cmd/api_compare_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1763,6 +1763,56 @@ fn eth_tests_with_tipset<DB: Blockstore>(store: &Arc<DB>, shared_tipset: &Tipset
))
.unwrap(),
),
RpcTest::identity(
EthGetBlockByNumberV2::request((
ExtBlockNumberOrHash::from_block_number(shared_tipset.epoch()),
false,
))
.unwrap(),
),
RpcTest::identity(
EthGetBlockByNumberV2::request((
ExtBlockNumberOrHash::from_block_number(shared_tipset.epoch()),
true,
))
.unwrap(),
),
RpcTest::identity(
EthGetBlockByNumberV2::request((
ExtBlockNumberOrHash::from_predefined(ExtPredefined::Earliest),
true,
))
.unwrap(),
)
.policy_on_rejected(PolicyOnRejected::PassWithQuasiIdenticalError),
RpcTest::basic(
EthGetBlockByNumberV2::request((
ExtBlockNumberOrHash::from_predefined(ExtPredefined::Pending),
true,
))
.unwrap(),
),
RpcTest::basic(
EthGetBlockByNumberV2::request((
ExtBlockNumberOrHash::from_predefined(ExtPredefined::Latest),
true,
))
.unwrap(),
),
RpcTest::basic(
EthGetBlockByNumberV2::request((
ExtBlockNumberOrHash::from_predefined(ExtPredefined::Safe),
true,
))
.unwrap(),
),
RpcTest::basic(
EthGetBlockByNumberV2::request((
ExtBlockNumberOrHash::from_predefined(ExtPredefined::Finalized),
true,
))
.unwrap(),
),
RpcTest::identity(
EthGetBlockReceipts::request((BlockNumberOrHash::from_block_hash_object(
block_hash.clone(),
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 @@ -62,6 +62,7 @@ filecoin_ethgetbalance_1740048634848277.rpcsnap.json.zst
filecoin_ethgetbalance_v2_1768188109932986.rpcsnap.json.zst
filecoin_ethgetblockbyhash_1740132537807408.rpcsnap.json.zst
filecoin_ethgetblockbynumber_1737446676696328.rpcsnap.json.zst
filecoin_ethgetblockbynumber_v2_1768192171057588.rpcsnap.json.zst
filecoin_ethgetblockreceipts_1740132537907751.rpcsnap.json.zst
filecoin_ethgetblockreceiptslimited_1740132537908421.rpcsnap.json.zst
filecoin_ethgetblocktransactioncountbyhash_1740132538001911.rpcsnap.json.zst
Expand Down
Loading