From e9d0c6bc2aaf49142ce6bdf5b12863369a0036ea Mon Sep 17 00:00:00 2001 From: cryptoAtwill Date: Tue, 17 Oct 2023 19:27:03 +0800 Subject: [PATCH 1/8] add relayer cli --- ipc/cli/src/commands/checkpoint/mod.rs | 4 ++ ipc/cli/src/commands/checkpoint/relayer.rs | 79 ++++++++++++++++++++++ ipc/cli/src/commands/mod.rs | 18 ++++- ipc/identity/src/evm/mod.rs | 2 +- ipc/provider/src/checkpoint.rs | 16 ++--- 5 files changed, 108 insertions(+), 11 deletions(-) create mode 100644 ipc/cli/src/commands/checkpoint/relayer.rs diff --git a/ipc/cli/src/commands/checkpoint/mod.rs b/ipc/cli/src/commands/checkpoint/mod.rs index f3c98bdc..cd46f837 100644 --- a/ipc/cli/src/commands/checkpoint/mod.rs +++ b/ipc/cli/src/commands/checkpoint/mod.rs @@ -3,10 +3,12 @@ use crate::commands::checkpoint::list_checkpoints::{ ListBottomUpCheckpoints, ListBottomUpCheckpointsArgs, }; +use crate::commands::checkpoint::relayer::{BottomUpRelayer, BottomUpRelayerArgs}; use crate::{CommandLineHandler, GlobalArguments}; use clap::{Args, Subcommand}; mod list_checkpoints; +mod relayer; #[derive(Debug, Args)] #[command(name = "checkpoint", about = "checkpoint related commands")] @@ -20,6 +22,7 @@ impl CheckpointCommandsArgs { pub async fn handle(&self, global: &GlobalArguments) -> anyhow::Result<()> { match &self.command { Commands::ListBottomup(args) => ListBottomUpCheckpoints::handle(global, args).await, + Commands::Relayer(args) => BottomUpRelayer::handle(global, args).await, } } } @@ -27,4 +30,5 @@ impl CheckpointCommandsArgs { #[derive(Debug, Subcommand)] pub(crate) enum Commands { ListBottomup(ListBottomUpCheckpointsArgs), + Relayer(BottomUpRelayerArgs), } diff --git a/ipc/cli/src/commands/checkpoint/relayer.rs b/ipc/cli/src/commands/checkpoint/relayer.rs new file mode 100644 index 00000000..6840bf97 --- /dev/null +++ b/ipc/cli/src/commands/checkpoint/relayer.rs @@ -0,0 +1,79 @@ +// Copyright 2022-2023 Protocol Labs +// SPDX-License-Identifier: MIT + +use crate::commands::get_subnet_config; +use crate::{CommandLineHandler, GlobalArguments}; +use anyhow::anyhow; +use async_trait::async_trait; +use clap::Args; +use fvm_shared::address::Address; +use ipc_identity::EvmKeyStore; +use ipc_provider::checkpoint::BottomUpCheckpointManager; +use ipc_provider::new_evm_keystore_from_path; +use ipc_sdk::subnet_id::SubnetID; +use std::str::FromStr; +use std::sync::{Arc, RwLock}; +use std::time::Duration; + +const DEFAULT_CHECKPOINT_INTERVAL: u64 = 15; + +/// The command to run the bottom up relayer in the background. +pub(crate) struct BottomUpRelayer; + +#[async_trait] +impl CommandLineHandler for BottomUpRelayer { + type Arguments = BottomUpRelayerArgs; + + async fn handle(global: &GlobalArguments, arguments: &Self::Arguments) -> anyhow::Result<()> { + log::debug!("start bottom up relayer with args: {:?}", arguments); + + let config_path = global.config_path(); + + let mut keystore = new_evm_keystore_from_path(&config_path)?; + let validator = match (arguments.validator.as_ref(), keystore.get_default()?) { + (Some(validator), _) => Address::from_str(validator)?, + (None, Some(addr)) => { + log::info!("using default address: {addr:?}"); + Address::try_from(addr)? + } + _ => { + return Err(anyhow!("no validator address provided")); + } + }; + + let subnet = SubnetID::from_str(&arguments.subnet)?; + let parent = subnet + .parent() + .ok_or_else(|| anyhow!("root does not have parent"))?; + + let child = get_subnet_config(&config_path, &subnet)?; + let parent = get_subnet_config(&config_path, &parent)?; + + let manager = BottomUpCheckpointManager::new_evm_manager( + parent.clone(), + child.clone(), + Arc::new(RwLock::new(keystore)), + ) + .await?; + + let interval = Duration::from_secs( + arguments + .checkpoint_interval_sec + .unwrap_or(DEFAULT_CHECKPOINT_INTERVAL), + ); + manager.run(validator, interval).await; + + Ok(()) + } +} + +#[derive(Debug, Args)] +#[command(about = "Start the bottom up relayer")] +pub(crate) struct BottomUpRelayerArgs { + #[arg(long, short, help = "The subnet id of the checkpointing subnet")] + pub subnet: String, + #[arg(long, short, help = "The number of seconds to submit checkpoint")] + pub checkpoint_interval_sec: Option, + #[arg(long, short, help = "The hex encoded address of the validator")] + pub validator: Option, +} diff --git a/ipc/cli/src/commands/mod.rs b/ipc/cli/src/commands/mod.rs index a35428e4..a3117061 100644 --- a/ipc/cli/src/commands/mod.rs +++ b/ipc/cli/src/commands/mod.rs @@ -14,15 +14,18 @@ use crate::commands::checkpoint::CheckpointCommandsArgs; use crate::commands::crossmsg::CrossMsgsCommandsArgs; use crate::commands::util::UtilCommandsArgs; use crate::GlobalArguments; -use anyhow::{Context, Result}; +use anyhow::{anyhow, Context, Result}; use clap::{Command, CommandFactory, Parser, Subcommand}; use clap_complete::{generate, Generator, Shell}; use fvm_shared::econ::TokenAmount; use ipc_sdk::ethers_address_to_fil_address; +use ipc_provider::config::{Config, Subnet}; +use ipc_sdk::subnet_id::SubnetID; use std::fmt::Debug; use std::io; +use std::path::Path; use std::str::FromStr; use crate::commands::config::ConfigCommandsArgs; @@ -146,6 +149,19 @@ pub(crate) fn require_fil_addr_from_str(s: &str) -> anyhow::Result, + subnet: &SubnetID, +) -> Result { + let config = Config::from_file(&config_path)?; + Ok(config + .subnets + .get(subnet) + .ok_or_else(|| anyhow!("{subnet} is not configured"))? + .clone()) +} + #[cfg(test)] mod tests { use crate::f64_to_token_amount; diff --git a/ipc/identity/src/evm/mod.rs b/ipc/identity/src/evm/mod.rs index e03b30ef..b28ea024 100644 --- a/ipc/identity/src/evm/mod.rs +++ b/ipc/identity/src/evm/mod.rs @@ -91,7 +91,7 @@ pub fn random_eth_key_info() -> KeyInfo { } #[cfg(feature = "with-ethers")] -#[derive(Clone, Eq, Hash, PartialEq, Default)] +#[derive(Debug, Clone, Eq, Hash, PartialEq, Default)] pub struct EthKeyAddress { inner: ethers::types::Address, } diff --git a/ipc/provider/src/checkpoint.rs b/ipc/provider/src/checkpoint.rs index abaf5404..25b75f87 100644 --- a/ipc/provider/src/checkpoint.rs +++ b/ipc/provider/src/checkpoint.rs @@ -89,16 +89,14 @@ impl BottomUpCheckpointMan } /// Run the bottom up checkpoint submission daemon in the background - pub fn run(self, validator: Address, submission_interval: Duration) { - tokio::spawn(async move { - loop { - if let Err(e) = self.submit_checkpoint(&validator).await { - log::error!("cannot submit checkpoint for validator: {validator} due to {e}"); - } - - tokio::time::sleep(submission_interval).await; + pub async fn run(self, validator: Address, submission_interval: Duration) { + loop { + if let Err(e) = self.submit_checkpoint(&validator).await { + log::error!("cannot submit checkpoint for validator: {validator} due to {e}"); } - }); + + tokio::time::sleep(submission_interval).await; + } } /// Submit the checkpoint from the target validator address From 3a42972450ba3b8d2e58c6bc1d240a25a623247f Mon Sep 17 00:00:00 2001 From: cryptoAtwill Date: Tue, 17 Oct 2023 19:44:04 +0800 Subject: [PATCH 2/8] update submit checkpoint --- Cargo.lock | 2 +- ipc/provider/src/checkpoint.rs | 52 +++++++++++++++++++------ ipc/provider/src/manager/evm/manager.rs | 17 ++++++++ ipc/provider/src/manager/subnet.rs | 6 +++ 4 files changed, 65 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dd9f53d3..9f996fb3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2694,7 +2694,7 @@ dependencies = [ [[package]] name = "ipc_actors_abis" version = "0.1.0" -source = "git+https://github.com/consensus-shipyard/ipc-solidity-actors.git?branch=dev#ad80d9b29c98473042c42b8f9cae5c7453620c25" +source = "git+https://github.com/consensus-shipyard/ipc-solidity-actors.git?branch=dev#7a396cf0a72a96b5e3b2e457b9ca7e42e5c6b924" dependencies = [ "anyhow", "ethers", diff --git a/ipc/provider/src/checkpoint.rs b/ipc/provider/src/checkpoint.rs index 25b75f87..72319c4a 100644 --- a/ipc/provider/src/checkpoint.rs +++ b/ipc/provider/src/checkpoint.rs @@ -101,6 +101,47 @@ impl BottomUpCheckpointMan /// Submit the checkpoint from the target validator address pub async fn submit_checkpoint(&self, validator: &Address) -> Result<()> { + self.submit_last_epoch(validator).await?; + self.submit_next_epoch(validator).await + } + + async fn next_submission_height(&self) -> Result { + let last_checkpoint_epoch = self + .parent_handler + .last_bottom_up_checkpoint_height(&self.metadata.child.id) + .await + .map_err(|e| { + anyhow!("cannot obtain the last bottom up checkpoint height due to: {e:}") + })?; + Ok(last_checkpoint_epoch + self.checkpoint_period()) + } + + async fn submit_last_epoch(&self, validator: &Address) -> Result<()> { + let subnet = &self.metadata.child.id; + if self + .child_handler + .has_submitted_in_last_checkpoint_height(subnet, validator) + .await? + { + return Ok(()); + } + + let height = self + .child_handler + .last_bottom_up_checkpoint_height(subnet) + .await?; + let bundle = self.child_handler.checkpoint_bundle_at(height).await?; + log::debug!("bottom up bundle: {bundle:?}"); + + self.parent_handler + .submit_checkpoint(validator, bundle) + .await + .map_err(|e| anyhow!("cannot submit bottom up checkpoint due to: {e:}"))?; + + Ok(()) + } + + async fn submit_next_epoch(&self, validator: &Address) -> Result<()> { let next_submission_height = self.next_submission_height().await?; let current_height = self.child_handler.current_epoch().await?; @@ -121,15 +162,4 @@ impl BottomUpCheckpointMan Ok(()) } - - async fn next_submission_height(&self) -> Result { - let last_checkpoint_epoch = self - .parent_handler - .last_bottom_up_checkpoint_height(&self.metadata.child.id) - .await - .map_err(|e| { - anyhow!("cannot obtain the last bottom up checkpoint height due to: {e:}") - })?; - Ok(last_checkpoint_epoch + self.checkpoint_period()) - } } diff --git a/ipc/provider/src/manager/evm/manager.rs b/ipc/provider/src/manager/evm/manager.rs index eeaf6782..dd0fe34d 100644 --- a/ipc/provider/src/manager/evm/manager.rs +++ b/ipc/provider/src/manager/evm/manager.rs @@ -841,6 +841,23 @@ impl BottomUpCheckpointRelayer for EthSubnetManager { Ok(epoch as ChainEpoch) } + async fn has_submitted_in_last_checkpoint_height( + &self, + subnet_id: &SubnetID, + submitter: &Address, + ) -> Result { + let address = contract_address_from_subnet(subnet_id)?; + let contract = subnet_actor_getter_facet::SubnetActorGetterFacet::new( + address, + Arc::new(self.ipc_contract_info.provider.clone()), + ); + let addr = payload_to_evm_address(submitter.payload())?; + Ok(contract + .has_submitted_in_last_bottom_up_checkpoint_height(addr) + .call() + .await?) + } + async fn checkpoint_period(&self, subnet_id: &SubnetID) -> anyhow::Result { let address = contract_address_from_subnet(subnet_id)?; let contract = subnet_actor_getter_facet::SubnetActorGetterFacet::new( diff --git a/ipc/provider/src/manager/subnet.rs b/ipc/provider/src/manager/subnet.rs index bf3f3999..1952db9b 100644 --- a/ipc/provider/src/manager/subnet.rs +++ b/ipc/provider/src/manager/subnet.rs @@ -165,6 +165,12 @@ pub trait BottomUpCheckpointRelayer: Send + Sync { ) -> Result<()>; /// The last confirmed/submitted checkpoint height. async fn last_bottom_up_checkpoint_height(&self, subnet_id: &SubnetID) -> Result; + /// Check if the submitter has already submitted in the `last_bottom_up_checkpoint_height` + async fn has_submitted_in_last_checkpoint_height( + &self, + subnet_id: &SubnetID, + submitter: &Address, + ) -> Result; /// Get the checkpoint period, i.e the number of blocks to submit bottom up checkpoints. async fn checkpoint_period(&self, subnet_id: &SubnetID) -> Result; /// Get the checkpoint at a specific height. If it does not exist, it will through error. From 69f002cbb31d211eec203b9dc7a24b0b13d0adaa Mon Sep 17 00:00:00 2001 From: cryptoAtwill <108330426+cryptoAtwill@users.noreply.github.com> Date: Tue, 17 Oct 2023 20:50:07 +0800 Subject: [PATCH 3/8] Update ipc/cli/src/commands/checkpoint/relayer.rs Co-authored-by: adlrocha <6717133+adlrocha@users.noreply.github.com> --- ipc/cli/src/commands/checkpoint/relayer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipc/cli/src/commands/checkpoint/relayer.rs b/ipc/cli/src/commands/checkpoint/relayer.rs index 6840bf97..638c68f7 100644 --- a/ipc/cli/src/commands/checkpoint/relayer.rs +++ b/ipc/cli/src/commands/checkpoint/relayer.rs @@ -68,7 +68,7 @@ impl CommandLineHandler for BottomUpRelayer { } #[derive(Debug, Args)] -#[command(about = "Start the bottom up relayer")] +#[command(about = "Start the bottom up relayer daemon")] pub(crate) struct BottomUpRelayerArgs { #[arg(long, short, help = "The subnet id of the checkpointing subnet")] pub subnet: String, From 0a1d916b5d2167f2069c76cf2f7d9e8b93852822 Mon Sep 17 00:00:00 2001 From: cryptoAtwill <108330426+cryptoAtwill@users.noreply.github.com> Date: Tue, 17 Oct 2023 20:51:12 +0800 Subject: [PATCH 4/8] Update ipc/provider/src/checkpoint.rs Co-authored-by: adlrocha <6717133+adlrocha@users.noreply.github.com> --- ipc/provider/src/checkpoint.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/ipc/provider/src/checkpoint.rs b/ipc/provider/src/checkpoint.rs index 72319c4a..24dea250 100644 --- a/ipc/provider/src/checkpoint.rs +++ b/ipc/provider/src/checkpoint.rs @@ -116,6 +116,7 @@ impl BottomUpCheckpointMan Ok(last_checkpoint_epoch + self.checkpoint_period()) } + /// Checks if the relayer has already submitted the last checkpoint, if not it submits it. async fn submit_last_epoch(&self, validator: &Address) -> Result<()> { let subnet = &self.metadata.child.id; if self From 43272a887188e952e5986f10b7c0629d1565e42f Mon Sep 17 00:00:00 2001 From: cryptoAtwill Date: Tue, 17 Oct 2023 20:54:53 +0800 Subject: [PATCH 5/8] rename --- ipc/cli/src/commands/checkpoint/relayer.rs | 14 +++++++------- ipc/provider/src/checkpoint.rs | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ipc/cli/src/commands/checkpoint/relayer.rs b/ipc/cli/src/commands/checkpoint/relayer.rs index 6840bf97..bae28b87 100644 --- a/ipc/cli/src/commands/checkpoint/relayer.rs +++ b/ipc/cli/src/commands/checkpoint/relayer.rs @@ -15,7 +15,7 @@ use std::str::FromStr; use std::sync::{Arc, RwLock}; use std::time::Duration; -const DEFAULT_CHECKPOINT_INTERVAL: u64 = 15; +const DEFAULT_POLLING_INTERVAL: u64 = 15; /// The command to run the bottom up relayer in the background. pub(crate) struct BottomUpRelayer; @@ -30,8 +30,8 @@ impl CommandLineHandler for BottomUpRelayer { let config_path = global.config_path(); let mut keystore = new_evm_keystore_from_path(&config_path)?; - let validator = match (arguments.validator.as_ref(), keystore.get_default()?) { - (Some(validator), _) => Address::from_str(validator)?, + let submitter = match (arguments.submitter.as_ref(), keystore.get_default()?) { + (Some(submitter), _) => Address::from_str(submitter)?, (None, Some(addr)) => { log::info!("using default address: {addr:?}"); Address::try_from(addr)? @@ -59,9 +59,9 @@ impl CommandLineHandler for BottomUpRelayer { let interval = Duration::from_secs( arguments .checkpoint_interval_sec - .unwrap_or(DEFAULT_CHECKPOINT_INTERVAL), + .unwrap_or(DEFAULT_POLLING_INTERVAL), ); - manager.run(validator, interval).await; + manager.run(submitter, interval).await; Ok(()) } @@ -74,6 +74,6 @@ pub(crate) struct BottomUpRelayerArgs { pub subnet: String, #[arg(long, short, help = "The number of seconds to submit checkpoint")] pub checkpoint_interval_sec: Option, - #[arg(long, short, help = "The hex encoded address of the validator")] - pub validator: Option, + #[arg(long, short, help = "The hex encoded address of the submitter")] + pub submitter: Option, } diff --git a/ipc/provider/src/checkpoint.rs b/ipc/provider/src/checkpoint.rs index 72319c4a..a649c03a 100644 --- a/ipc/provider/src/checkpoint.rs +++ b/ipc/provider/src/checkpoint.rs @@ -89,10 +89,10 @@ impl BottomUpCheckpointMan } /// Run the bottom up checkpoint submission daemon in the background - pub async fn run(self, validator: Address, submission_interval: Duration) { + pub async fn run(self, submitter: Address, submission_interval: Duration) { loop { - if let Err(e) = self.submit_checkpoint(&validator).await { - log::error!("cannot submit checkpoint for validator: {validator} due to {e}"); + if let Err(e) = self.submit_checkpoint(&submitter).await { + log::error!("cannot submit checkpoint for validator: {submitter} due to {e}"); } tokio::time::sleep(submission_interval).await; From de14f16414bcb7ff3caf569588c0ba71c36d4baa Mon Sep 17 00:00:00 2001 From: cryptoAtwill Date: Tue, 17 Oct 2023 20:57:48 +0800 Subject: [PATCH 6/8] rename field --- ipc/provider/src/checkpoint.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ipc/provider/src/checkpoint.rs b/ipc/provider/src/checkpoint.rs index e266dfe3..084b59a3 100644 --- a/ipc/provider/src/checkpoint.rs +++ b/ipc/provider/src/checkpoint.rs @@ -92,17 +92,17 @@ impl BottomUpCheckpointMan pub async fn run(self, submitter: Address, submission_interval: Duration) { loop { if let Err(e) = self.submit_checkpoint(&submitter).await { - log::error!("cannot submit checkpoint for validator: {submitter} due to {e}"); + log::error!("cannot submit checkpoint for submitter: {submitter} due to {e}"); } tokio::time::sleep(submission_interval).await; } } - /// Submit the checkpoint from the target validator address - pub async fn submit_checkpoint(&self, validator: &Address) -> Result<()> { - self.submit_last_epoch(validator).await?; - self.submit_next_epoch(validator).await + /// Submit the checkpoint from the target submitter address + pub async fn submit_checkpoint(&self, submitter: &Address) -> Result<()> { + self.submit_last_epoch(submitter).await?; + self.submit_next_epoch(submitter).await } async fn next_submission_height(&self) -> Result { @@ -117,11 +117,11 @@ impl BottomUpCheckpointMan } /// Checks if the relayer has already submitted the last checkpoint, if not it submits it. - async fn submit_last_epoch(&self, validator: &Address) -> Result<()> { + async fn submit_last_epoch(&self, submitter: &Address) -> Result<()> { let subnet = &self.metadata.child.id; if self .child_handler - .has_submitted_in_last_checkpoint_height(subnet, validator) + .has_submitted_in_last_checkpoint_height(subnet, submitter) .await? { return Ok(()); @@ -135,14 +135,14 @@ impl BottomUpCheckpointMan log::debug!("bottom up bundle: {bundle:?}"); self.parent_handler - .submit_checkpoint(validator, bundle) + .submit_checkpoint(submitter, bundle) .await .map_err(|e| anyhow!("cannot submit bottom up checkpoint due to: {e:}"))?; Ok(()) } - async fn submit_next_epoch(&self, validator: &Address) -> Result<()> { + async fn submit_next_epoch(&self, submitter: &Address) -> Result<()> { let next_submission_height = self.next_submission_height().await?; let current_height = self.child_handler.current_epoch().await?; @@ -157,7 +157,7 @@ impl BottomUpCheckpointMan log::debug!("bottom up bundle: {bundle:?}"); self.parent_handler - .submit_checkpoint(validator, bundle) + .submit_checkpoint(submitter, bundle) .await .map_err(|e| anyhow!("cannot submit bottom up checkpoint due to: {e:}"))?; From 6cd22a1a214570ed8af97c29ebc7d50873f64d8b Mon Sep 17 00:00:00 2001 From: cryptoAtwill Date: Tue, 17 Oct 2023 21:01:58 +0800 Subject: [PATCH 7/8] more comments --- ipc/provider/src/checkpoint.rs | 7 ++++++- ipc/provider/src/manager/subnet.rs | 2 +- ipc/sdk/src/checkpoint.rs | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ipc/provider/src/checkpoint.rs b/ipc/provider/src/checkpoint.rs index 084b59a3..2eb50bf7 100644 --- a/ipc/provider/src/checkpoint.rs +++ b/ipc/provider/src/checkpoint.rs @@ -20,6 +20,9 @@ pub struct CheckpointConfig { period: ChainEpoch, } +/// Manages the submission of bottom up checkpoint. It checks if the submitter has already +/// submitted in the `last_checkpoint_height`, if not, it will submit the checkpoint at that height. +/// Then it will submit at the next submission height for the new checkpoint. pub struct BottomUpCheckpointManager { metadata: CheckpointConfig, parent_handler: T, @@ -105,6 +108,7 @@ impl BottomUpCheckpointMan self.submit_next_epoch(submitter).await } + /// Derive the next submission checkpoint height async fn next_submission_height(&self) -> Result { let last_checkpoint_epoch = self .parent_handler @@ -116,7 +120,7 @@ impl BottomUpCheckpointMan Ok(last_checkpoint_epoch + self.checkpoint_period()) } - /// Checks if the relayer has already submitted the last checkpoint, if not it submits it. + /// Checks if the relayer has already submitted at the `last_checkpoint_height`, if not it submits it. async fn submit_last_epoch(&self, submitter: &Address) -> Result<()> { let subnet = &self.metadata.child.id; if self @@ -142,6 +146,7 @@ impl BottomUpCheckpointMan Ok(()) } + /// Checks if the relayer has already submitted at the next submission epoch, if not it submits it. async fn submit_next_epoch(&self, submitter: &Address) -> Result<()> { let next_submission_height = self.next_submission_height().await?; let current_height = self.child_handler.current_epoch().await?; diff --git a/ipc/provider/src/manager/subnet.rs b/ipc/provider/src/manager/subnet.rs index 1952db9b..7a291420 100644 --- a/ipc/provider/src/manager/subnet.rs +++ b/ipc/provider/src/manager/subnet.rs @@ -173,7 +173,7 @@ pub trait BottomUpCheckpointRelayer: Send + Sync { ) -> Result; /// Get the checkpoint period, i.e the number of blocks to submit bottom up checkpoints. async fn checkpoint_period(&self, subnet_id: &SubnetID) -> Result; - /// Get the checkpoint at a specific height. If it does not exist, it will through error. + /// Get the checkpoint bundle at a specific height. If it does not exist, it will through error. async fn checkpoint_bundle_at(&self, height: ChainEpoch) -> Result; /// Get the current epoch in the current subnet async fn current_epoch(&self) -> Result; diff --git a/ipc/sdk/src/checkpoint.rs b/ipc/sdk/src/checkpoint.rs index a604f999..1c38f94c 100644 --- a/ipc/sdk/src/checkpoint.rs +++ b/ipc/sdk/src/checkpoint.rs @@ -27,6 +27,7 @@ lazy_static! { pub type Signature = Vec; +/// The collection of items for the bottom up checkpoint submission #[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)] pub struct BottomUpCheckpointBundle { pub checkpoint: BottomUpCheckpoint, From 30d31bb75cfa3c2e85508a6b319fb17b9150255d Mon Sep 17 00:00:00 2001 From: adlrocha <6717133+adlrocha@users.noreply.github.com> Date: Tue, 17 Oct 2023 16:00:30 +0200 Subject: [PATCH 8/8] Apply suggestions from code review --- ipc/cli/src/commands/checkpoint/relayer.rs | 2 +- ipc/provider/src/checkpoint.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ipc/cli/src/commands/checkpoint/relayer.rs b/ipc/cli/src/commands/checkpoint/relayer.rs index 3502ba8c..33449c8a 100644 --- a/ipc/cli/src/commands/checkpoint/relayer.rs +++ b/ipc/cli/src/commands/checkpoint/relayer.rs @@ -37,7 +37,7 @@ impl CommandLineHandler for BottomUpRelayer { Address::try_from(addr)? } _ => { - return Err(anyhow!("no validator address provided")); + return Err(anyhow!("no submitter address provided")); } }; diff --git a/ipc/provider/src/checkpoint.rs b/ipc/provider/src/checkpoint.rs index 2eb50bf7..50cca5b4 100644 --- a/ipc/provider/src/checkpoint.rs +++ b/ipc/provider/src/checkpoint.rs @@ -91,7 +91,7 @@ impl BottomUpCheckpointMan self.metadata.period } - /// Run the bottom up checkpoint submission daemon in the background + /// Run the bottom up checkpoint submission daemon in the foreground pub async fn run(self, submitter: Address, submission_interval: Duration) { loop { if let Err(e) = self.submit_checkpoint(&submitter).await {