Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rpc): Filecoin.F3GetProgress #4878

Merged
merged 2 commits into from
Oct 11, 2024
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
- [#4865](https://github.com/ChainSafe/forest/issues/4865) Add support for the
`Filecoin.F3IsRunning` RPC method.

- [#4878](https://github.com/ChainSafe/forest/issues/4878) Add support for the
`Filecoin.F3GetProgress` RPC method.

- [#4857](https://github.com/ChainSafe/forest/pull/4857) Add support for nv24
(TukTuk).

Expand Down
4 changes: 4 additions & 0 deletions f3-sidecar/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ func (h *F3ServerHandler) F3GetF3PowerTable(ctx context.Context, tsk []byte) (gp
func (h *F3ServerHandler) F3IsRunning(_ context.Context) bool {
return h.f3.IsRunning()
}

func (h *F3ServerHandler) F3GetProgress(_ context.Context) gpbft.Instant {
return h.f3.Progress()
}
18 changes: 18 additions & 0 deletions src/rpc/methods/f3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,24 @@ impl RpcMethod<0> for F3IsRunning {
}
}

/// See <https://github.com/filecoin-project/lotus/blob/master/documentation/en/api-v1-unstable-methods.md#F3GetProgress>
pub enum F3GetProgress {}
impl RpcMethod<0> for F3GetProgress {
const NAME: &'static str = "Filecoin.F3GetProgress";
const PARAM_NAMES: [&'static str; 0] = [];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

type Params = ();
type Ok = serde_json::Value;

async fn handle(_: Ctx<impl Blockstore>, (): Self::Params) -> Result<Self::Ok, ServerError> {
let client = get_rpc_http_client()?;
let response = client.request(Self::NAME, ArrayParams::new()).await?;
Ok(response)
}
}

/// F3Participate should be called by a storage provider to participate in signing F3 consensus.
/// Calling this API gives the node a lease to sign in F3 on behalf of given SP.
/// The lease should be active only on one node. The lease will expire at the newLeaseExpiration.
Expand Down
1 change: 1 addition & 0 deletions src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ macro_rules! for_each_method {
$callback!(crate::rpc::f3::F3GetECPowerTable);
$callback!(crate::rpc::f3::F3GetF3PowerTable);
$callback!(crate::rpc::f3::F3IsRunning);
$callback!(crate::rpc::f3::F3GetProgress);
$callback!(crate::rpc::f3::F3GetLatestCertificate);
$callback!(crate::rpc::f3::F3Participate);
$callback!(crate::rpc::f3::GetHead);
Expand Down
Loading