From cd360722f0f538db9332dec5e72e892cb22500f7 Mon Sep 17 00:00:00 2001 From: Hubert Bugaj Date: Mon, 24 Feb 2025 11:24:47 +0100 Subject: [PATCH] fix: map RPC aliases to what Lotus uses --- CHANGELOG.md | 4 ++++ src/rpc/methods/eth.rs | 9 ++++++--- src/rpc/methods/net.rs | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87bc14df64a..21bf9062a4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,8 @@ - [#4261](https://github.com/ChainSafe/forest/issues/4261) Remove the short flags from `forest-wallet list` and `forest-wallet balance` commands. +- [#5329](https://github.com/ChainSafe/forest/pull/5329) Changed JSON-RPC alias for `Filecoin.NetListening`, `Filecoin.NetVersion`, `Filecoin.EthTraceBlock`, `Filecoin.EthTraceReplayBlockTransactions` to adhere to Lotus API. + ### Added - [#5244](https://github.com/ChainSafe/forest/issues/5244) Add `live` and `healthy` subcommands to `forest-cli healthcheck`. @@ -77,6 +79,8 @@ - [#5237](https://github.com/ChainSafe/forest/pull/5237) Stylistic changes to FIL pretty printing. +- [#5329](https://github.com/ChainSafe/forest/pull/5329) `Filecoin.Web3ClientVersion` now returns the name of the node and its version, e.g., `forest/0.23.3+git.32a34e92`. + ### Removed ### Fixed diff --git a/src/rpc/methods/eth.rs b/src/rpc/methods/eth.rs index fdf275a173d..0b2371cbb31 100644 --- a/src/rpc/methods/eth.rs +++ b/src/rpc/methods/eth.rs @@ -656,7 +656,10 @@ impl RpcMethod<0> for Web3ClientVersion { _: Ctx, (): Self::Params, ) -> Result { - Ok(crate::utils::version::FOREST_VERSION_STRING.clone()) + Ok(format!( + "forest/{}", + *crate::utils::version::FOREST_VERSION_STRING + )) } } @@ -2842,7 +2845,7 @@ impl RpcMethod<1> for EthGetFilterLogs { pub enum EthTraceBlock {} impl RpcMethod<1> for EthTraceBlock { const NAME: &'static str = "Filecoin.EthTraceBlock"; - const NAME_ALIAS: Option<&'static str> = Some("eth_traceBlock"); + const NAME_ALIAS: Option<&'static str> = Some("trace_block"); const N_REQUIRED_PARAMS: usize = 1; const PARAM_NAMES: [&'static str; 1] = ["block_param"]; const API_PATHS: ApiPaths = ApiPaths::V1; @@ -2912,7 +2915,7 @@ pub enum EthTraceReplayBlockTransactions {} impl RpcMethod<2> for EthTraceReplayBlockTransactions { const N_REQUIRED_PARAMS: usize = 2; const NAME: &'static str = "Filecoin.EthTraceReplayBlockTransactions"; - const NAME_ALIAS: Option<&'static str> = Some("eth_traceReplayBlockTransactions"); + const NAME_ALIAS: Option<&'static str> = Some("trace_replayBlockTransactions"); const PARAM_NAMES: [&'static str; 2] = ["block_param", "trace_types"]; const API_PATHS: ApiPaths = ApiPaths::V1; const PERMISSION: Permission = Permission::Read; diff --git a/src/rpc/methods/net.rs b/src/rpc/methods/net.rs index b65224e57a9..ea24ed51c1f 100644 --- a/src/rpc/methods/net.rs +++ b/src/rpc/methods/net.rs @@ -103,6 +103,7 @@ impl RpcMethod<0> for NetListening { const PARAM_NAMES: [&'static str; 0] = []; const API_PATHS: ApiPaths = ApiPaths::V1; const PERMISSION: Permission = Permission::Read; + const NAME_ALIAS: Option<&'static str> = Some("net_listening"); type Params = (); type Ok = bool; @@ -249,6 +250,7 @@ impl RpcMethod<0> for NetVersion { const PARAM_NAMES: [&'static str; 0] = []; const API_PATHS: ApiPaths = ApiPaths::V1; const PERMISSION: Permission = Permission::Read; + const NAME_ALIAS: Option<&'static str> = Some("net_version"); type Params = (); type Ok = String;