This repository has been archived by the owner on Jan 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* list cross msgs * cli * query parent * add genesis epoch * query genesis epoch * debug * Revert debug * add more commands * add to cli * update event * update crate * update cargo * Fix tests * Update ipc/cli/src/commands/checkpoint/list_validator_changes.rs Co-authored-by: adlrocha <[email protected]> * Update ipc/cli/src/commands/checkpoint/list_validator_changes.rs Co-authored-by: adlrocha <[email protected]> * Update ipc/cli/src/commands/checkpoint/topdow_cross.rs Co-authored-by: adlrocha <[email protected]> * Update ipc/cli/src/commands/checkpoint/topdow_cross.rs Co-authored-by: adlrocha <[email protected]> * Update ipc/cli/src/commands/checkpoint/list_validator_changes.rs Co-authored-by: adlrocha <[email protected]> * Update ipc/cli/src/commands/subnet/genesis_epoch.rs Co-authored-by: adlrocha <[email protected]> --------- Co-authored-by: adlrocha <[email protected]>
- Loading branch information
1 parent
d4a1fe2
commit 31a3be2
Showing
14 changed files
with
318 additions
and
103 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2022-2023 Protocol Labs | ||
// SPDX-License-Identifier: MIT | ||
//! List validator change set cli command | ||
use std::fmt::Debug; | ||
use std::str::FromStr; | ||
|
||
use async_trait::async_trait; | ||
use clap::Args; | ||
use fvm_shared::clock::ChainEpoch; | ||
use ipc_sdk::subnet_id::SubnetID; | ||
|
||
use crate::commands::get_ipc_provider; | ||
use crate::{CommandLineHandler, GlobalArguments}; | ||
|
||
/// The command to list validator changes committed in a subnet. | ||
pub(crate) struct ListValidatorChanges; | ||
|
||
#[async_trait] | ||
impl CommandLineHandler for ListValidatorChanges { | ||
type Arguments = ListValidatorChangesArgs; | ||
|
||
async fn handle(global: &GlobalArguments, arguments: &Self::Arguments) -> anyhow::Result<()> { | ||
log::debug!("list validator changes with args: {:?}", arguments); | ||
|
||
let provider = get_ipc_provider(global)?; | ||
let subnet = SubnetID::from_str(&arguments.subnet)?; | ||
|
||
for h in arguments.from_epoch..=arguments.to_epoch { | ||
let changes = provider.get_validator_changeset(&subnet, h).await?; | ||
log::info!("changes at height: {h} are: {:?}", changes.value); | ||
} | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
#[derive(Debug, Args)] | ||
#[command(about = "List of validator changes commmitted for a child subnet")] | ||
pub(crate) struct ListValidatorChangesArgs { | ||
#[arg(long, short, help = "Lists the validator changes between two epochs")] | ||
pub subnet: String, | ||
#[arg(long, short, help = "Include checkpoints from this epoch")] | ||
pub from_epoch: ChainEpoch, | ||
#[arg(long, short, help = "Include checkpoints up to this epoch")] | ||
pub to_epoch: ChainEpoch, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2022-2023 Protocol Labs | ||
// SPDX-License-Identifier: MIT | ||
//! List top down cross messages | ||
use anyhow::anyhow; | ||
use std::fmt::Debug; | ||
use std::str::FromStr; | ||
|
||
use async_trait::async_trait; | ||
use clap::Args; | ||
use fvm_shared::clock::ChainEpoch; | ||
use ipc_sdk::subnet_id::SubnetID; | ||
|
||
use crate::commands::get_ipc_provider; | ||
use crate::{CommandLineHandler, GlobalArguments}; | ||
|
||
/// The command to list top down cross messages in a subnet | ||
pub(crate) struct ListTopdownCrossMessages; | ||
|
||
#[async_trait] | ||
impl CommandLineHandler for ListTopdownCrossMessages { | ||
type Arguments = ListTopdownCrossMessagesArgs; | ||
|
||
async fn handle(global: &GlobalArguments, arguments: &Self::Arguments) -> anyhow::Result<()> { | ||
log::debug!("list topdown messages with args: {:?}", arguments); | ||
|
||
let provider = get_ipc_provider(global)?; | ||
let subnet = SubnetID::from_str(&arguments.subnet)?; | ||
|
||
let hash = if let Some(hash) = &arguments.block_hash { | ||
hex::decode(hash)? | ||
} else { | ||
let parent = subnet | ||
.parent() | ||
.ok_or_else(|| anyhow!("subnet has not parent"))?; | ||
let epoch = provider.get_chain_head_height(&parent).await?; | ||
let hash = provider.get_block_hash(&parent, epoch).await?; | ||
hash.block_hash | ||
}; | ||
let msgs = provider | ||
.get_top_down_msgs(&subnet, arguments.epoch, &hash) | ||
.await?; | ||
for msg in msgs { | ||
println!("{msg:?}"); | ||
} | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
#[derive(Debug, Args)] | ||
#[command(about = "List topdown cross messages for a specific epoch")] | ||
pub(crate) struct ListTopdownCrossMessagesArgs { | ||
#[arg(long, short, help = "The subnet id of the topdown subnet")] | ||
pub subnet: String, | ||
#[arg(long, short, help = "Include topdown messages of this epoch")] | ||
pub epoch: ChainEpoch, | ||
#[arg(long, short, help = "The block hash to query until")] | ||
pub block_hash: Option<String>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2022-2023 Protocol Labs | ||
// SPDX-License-Identifier: MIT | ||
//! Get the genesis epoch cli command | ||
use async_trait::async_trait; | ||
use clap::Args; | ||
use ipc_sdk::subnet_id::SubnetID; | ||
use std::fmt::Debug; | ||
use std::str::FromStr; | ||
|
||
use crate::{get_ipc_provider, CommandLineHandler, GlobalArguments}; | ||
|
||
/// The command to get the genensis epoch. | ||
pub(crate) struct GenesisEpoch; | ||
|
||
#[async_trait] | ||
impl CommandLineHandler for GenesisEpoch { | ||
type Arguments = GenesisEpochArgs; | ||
|
||
async fn handle(global: &GlobalArguments, arguments: &Self::Arguments) -> anyhow::Result<()> { | ||
log::debug!("get genesis epoch with args: {:?}", arguments); | ||
|
||
let provider = get_ipc_provider(global)?; | ||
let subnet = SubnetID::from_str(&arguments.subnet)?; | ||
|
||
let ls = provider.genesis_epoch(&subnet).await?; | ||
println!("genesis epoch: {}", ls); | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
#[derive(Debug, Args)] | ||
#[command(name = "genesis-epoch", about = "Get the genesis epoch of subnet")] | ||
pub(crate) struct GenesisEpochArgs { | ||
#[arg(long, short, help = "The subnet id to query genesis epoch")] | ||
pub subnet: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters