Skip to content

Commit

Permalink
Implement start CLI for Starknet to Cosmos auto relaying (#245)
Browse files Browse the repository at this point in the history
* Implement StarknetCosmosBiRelay

* Implement BiRelayBuilder for StarknetBuilder

* Implement start command on Starknet CLI

* Use back main branch
  • Loading branch information
soareschen authored Feb 3, 2025
1 parent a3248f9 commit c1608b6
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 44 deletions.
62 changes: 31 additions & 31 deletions relayer/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions relayer/crates/starknet-cli/src/contexts/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use hermes_cli_components::impls::commands::queries::client_state::{
use hermes_cli_components::impls::commands::queries::consensus_state::{
QueryConsensusStateArgs, RunQueryConsensusStateCommand,
};
use hermes_cli_components::impls::commands::start::{RunStartRelayerCommand, StartRelayerArgs};
use hermes_cli_components::impls::config::get_config_path::GetDefaultConfigField;
use hermes_cli_components::impls::config::load_toml_config::LoadTomlConfig;
use hermes_cli_components::impls::config::save_toml_config::WriteTomlConfig;
Expand Down Expand Up @@ -168,6 +169,12 @@ delegate_components! {

(CreateClientArgs, symbol!("target_chain_id")): ParseFromString<ChainId>,
(CreateClientArgs, symbol!("counterparty_chain_id")): ParseFromString<ChainId>,

(StartRelayerArgs, symbol!("chain_id_a")): ParseFromString<ChainId>,
(StartRelayerArgs, symbol!("client_id_a")): ParseFromString<ClientId>,
(StartRelayerArgs, symbol!("chain_id_b")): ParseFromString<ChainId>,
(StartRelayerArgs, symbol!("client_id_b")): ParseFromString<ClientId>,

}
}

Expand All @@ -176,6 +183,8 @@ delegate_components! {
AllSubCommands: RunAllSubCommand,
BootstrapSubCommand: RunBootstrapSubCommand,

StartRelayerArgs: RunStartRelayerCommand,

QuerySubCommand: RunQuerySubCommand,
QueryClientStateArgs: RunQueryClientStateCommand,
QueryConsensusStateArgs: RunQueryConsensusStateCommand,
Expand Down Expand Up @@ -303,6 +312,7 @@ pub trait CanUseStarknetApp:
+ CanRunCommand<UpdateSubCommand>
+ CanRunCommand<UpdateClientArgs>
+ CanRunCommand<CreateClientArgs>
+ CanRunCommand<StartRelayerArgs>
{
}

Expand Down
7 changes: 6 additions & 1 deletion relayer/crates/starknet-cli/src/impls/subcommand.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use hermes_cli_components::impls::commands::start::StartRelayerArgs;
use hermes_cli_components::traits::command::{CanRunCommand, CommandRunner};

use crate::commands::create::subcommand::CreateSubCommand;
Expand All @@ -7,6 +8,8 @@ use crate::impls::bootstrap::subcommand::BootstrapSubCommand;

#[derive(Debug, clap::Subcommand)]
pub enum AllSubCommands {
Start(StartRelayerArgs),

#[clap(subcommand)]
Bootstrap(BootstrapSubCommand),
#[clap(subcommand)]
Expand All @@ -24,13 +27,15 @@ where
App: CanRunCommand<BootstrapSubCommand>
+ CanRunCommand<QuerySubCommand>
+ CanRunCommand<CreateSubCommand>
+ CanRunCommand<UpdateSubCommand>,
+ CanRunCommand<UpdateSubCommand>
+ CanRunCommand<StartRelayerArgs>,
{
async fn run_command(
app: &App,
subcommand: &AllSubCommands,
) -> Result<App::Output, App::Error> {
match subcommand {
AllSubCommands::Start(args) => app.run_command(args).await,
AllSubCommands::Bootstrap(args) => app.run_command(args).await,
AllSubCommands::Query(args) => app.run_command(args).await,
AllSubCommands::Create(args) => app.run_command(args).await,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ impl RelayBuilder<StarknetBuilder, Index<0>, Index<1>> for StarknetBuildComponen
async fn build_relay(
build: &StarknetBuilder,
_index: PhantomData<(Index<0>, Index<1>)>,
_src_chain_id: &ChainId,
src_chain_id: &ChainId,
dst_chain_id: &ChainId,
src_client_id: &StarknetClientId,
dst_client_id: &CosmosClientId,
) -> Result<StarknetToCosmosRelay, HermesError> {
let src_chain = build.build_chain().await?;
let src_chain = build.build_chain(src_chain_id).await?;

let dst_chain = build.cosmos_builder.build_chain(dst_chain_id).await?;

Expand Down
Loading

0 comments on commit c1608b6

Please sign in to comment.