From d4a1c68812c42d3bf00bee13aee6bc4ff303be63 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Thu, 24 Oct 2024 12:10:47 +0000 Subject: [PATCH 01/14] Use CometClientState as Cosmos client state for Starknet counterparty --- relayer/Cargo.lock | 52 +++++++++---------- relayer/Cargo.toml | 52 +++++++++---------- .../src/components/starknet_to_cosmos.rs | 8 ++- .../src/types/cosmos/client_state.rs | 27 ++++++---- .../src/contexts/chain.rs | 4 +- 5 files changed, 79 insertions(+), 64 deletions(-) diff --git a/relayer/Cargo.lock b/relayer/Cargo.lock index 9a008143..454e01a0 100644 --- a/relayer/Cargo.lock +++ b/relayer/Cargo.lock @@ -1757,7 +1757,7 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermes-any-counterparty" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", "cgp-error-eyre", @@ -1774,7 +1774,7 @@ dependencies = [ [[package]] name = "hermes-async-runtime-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "async-trait", "cgp", @@ -1797,7 +1797,7 @@ dependencies = [ [[package]] name = "hermes-chain-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", "hermes-chain-type-components", @@ -1808,7 +1808,7 @@ dependencies = [ [[package]] name = "hermes-chain-type-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", ] @@ -1816,7 +1816,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-chain-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "bech32 0.9.1", "cgp", @@ -1850,7 +1850,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", "hermes-encoding-components", @@ -1864,7 +1864,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-integration-tests" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", "eyre", @@ -1898,7 +1898,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-relayer" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", "eyre", @@ -1944,7 +1944,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-test-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", "hdpath", @@ -1969,7 +1969,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-wasm-relayer" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", "eyre", @@ -2021,7 +2021,7 @@ dependencies = [ [[package]] name = "hermes-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", ] @@ -2029,7 +2029,7 @@ dependencies = [ [[package]] name = "hermes-error" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", "eyre", @@ -2039,7 +2039,7 @@ dependencies = [ [[package]] name = "hermes-ibc-test-suite" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", "hermes-logging-components", @@ -2050,7 +2050,7 @@ dependencies = [ [[package]] name = "hermes-logger" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", "hermes-logging-components", @@ -2062,7 +2062,7 @@ dependencies = [ [[package]] name = "hermes-logging-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", ] @@ -2070,7 +2070,7 @@ dependencies = [ [[package]] name = "hermes-protobuf-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", "hermes-encoding-components", @@ -2081,7 +2081,7 @@ dependencies = [ [[package]] name = "hermes-relayer-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", "hermes-chain-components", @@ -2093,7 +2093,7 @@ dependencies = [ [[package]] name = "hermes-relayer-components-extra" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", "hermes-chain-type-components", @@ -2105,7 +2105,7 @@ dependencies = [ [[package]] name = "hermes-runtime" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", "hermes-async-runtime-components", @@ -2117,7 +2117,7 @@ dependencies = [ [[package]] name = "hermes-runtime-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", ] @@ -2252,7 +2252,7 @@ dependencies = [ [[package]] name = "hermes-test-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", "hermes-chain-type-components", @@ -2264,7 +2264,7 @@ dependencies = [ [[package]] name = "hermes-tokio-runtime-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", "futures", @@ -2278,7 +2278,7 @@ dependencies = [ [[package]] name = "hermes-tracing-logging-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", "hermes-logging-components", @@ -2290,7 +2290,7 @@ dependencies = [ [[package]] name = "hermes-wasm-client-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", "cgp-error-eyre", @@ -2310,7 +2310,7 @@ dependencies = [ [[package]] name = "hermes-wasm-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", "hermes-cosmos-encoding-components", @@ -2324,7 +2324,7 @@ dependencies = [ [[package]] name = "hermes-wasm-test-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" dependencies = [ "cgp", "cgp-error-eyre", diff --git a/relayer/Cargo.toml b/relayer/Cargo.toml index 0c456121..f6056337 100644 --- a/relayer/Cargo.toml +++ b/relayer/Cargo.toml @@ -116,29 +116,29 @@ cgp-error = { git = "https://github.com/contextgeneric/cgp.git" } cgp-run = { git = "https://github.com/contextgeneric/cgp.git" } cgp-inner = { git = "https://github.com/contextgeneric/cgp.git" } -hermes-chain-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-chain-type-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-relayer-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-relayer-components-extra = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-runtime-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-async-runtime-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-tokio-runtime-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-runtime = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-error = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-encoding-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-protobuf-encoding-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-logging-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-tracing-logging-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-logger = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-test-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-ibc-test-suite = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-any-counterparty = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-cosmos-chain-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-cosmos-relayer = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-cosmos-wasm-relayer = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-cosmos-test-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-cosmos-encoding-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-cosmos-integration-tests = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-wasm-test-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-wasm-client-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } -hermes-wasm-encoding-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-chain-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-chain-type-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-relayer-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-relayer-components-extra = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-runtime-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-async-runtime-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-tokio-runtime-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-runtime = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-error = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-encoding-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-protobuf-encoding-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-logging-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-tracing-logging-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-logger = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-test-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-ibc-test-suite = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-any-counterparty = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-cosmos-chain-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-cosmos-relayer = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-cosmos-wasm-relayer = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-cosmos-test-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-cosmos-encoding-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-cosmos-integration-tests = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-wasm-test-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-wasm-client-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-wasm-encoding-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } diff --git a/relayer/crates/starknet-chain-components/src/components/starknet_to_cosmos.rs b/relayer/crates/starknet-chain-components/src/components/starknet_to_cosmos.rs index 0fbc1611..32414cc7 100644 --- a/relayer/crates/starknet-chain-components/src/components/starknet_to_cosmos.rs +++ b/relayer/crates/starknet-chain-components/src/components/starknet_to_cosmos.rs @@ -1,7 +1,8 @@ use cgp::prelude::*; use hermes_cosmos_chain_components::components::client::{ - ConsensusStateHeightsQuerierComponent, CreateClientMessageBuilderComponent, - CreateClientMessageOptionsTypeComponent, UpdateClientMessageBuilderComponent, + ClientStateTypeComponent, ConsensusStateHeightsQuerierComponent, + CreateClientMessageBuilderComponent, CreateClientMessageOptionsTypeComponent, + UpdateClientMessageBuilderComponent, }; use hermes_cosmos_chain_components::components::cosmos_to_cosmos::CosmosToCosmosComponents; use hermes_relayer_components::chain::traits::queries::client_state::{ @@ -13,6 +14,7 @@ use hermes_relayer_components::chain::traits::queries::consensus_state::{ use crate::impls::starknet_to_cosmos::query_consensus_state_height::QueryStarknetConsensusStateHeightsFromGrpc; use crate::impls::starknet_to_cosmos::update_client_message::BuildStarknetUpdateClientMessage; +use crate::types::cosmos::client_state::ProvideCometClientState; define_components! { StarknetToCosmosComponents { @@ -25,6 +27,8 @@ define_components! { CreateClientMessageBuilderComponent, ]: CosmosToCosmosComponents, + ClientStateTypeComponent: + ProvideCometClientState, UpdateClientMessageBuilderComponent: BuildStarknetUpdateClientMessage, ConsensusStateHeightsQuerierComponent: diff --git a/relayer/crates/starknet-chain-components/src/types/cosmos/client_state.rs b/relayer/crates/starknet-chain-components/src/types/cosmos/client_state.rs index d6ea8305..a3925865 100644 --- a/relayer/crates/starknet-chain-components/src/types/cosmos/client_state.rs +++ b/relayer/crates/starknet-chain-components/src/types/cosmos/client_state.rs @@ -3,6 +3,7 @@ use cgp::prelude::*; use hermes_cairo_encoding_components::impls::encode_mut::variant_from::EncodeVariantFrom; use hermes_cairo_encoding_components::types::either::Either; use hermes_cairo_encoding_components::Sum; +use hermes_chain_components::traits::types::client_state::ProvideClientStateType; use hermes_encoding_components::impls::encode_mut::combine::CombineEncoders; use hermes_encoding_components::impls::encode_mut::field::EncodeField; use hermes_encoding_components::impls::encode_mut::from::DecodeFrom; @@ -19,8 +20,25 @@ pub struct CometClientState { pub status: ClientStatus, } +#[derive(Debug)] +pub enum ClientStatus { + Active, + Expired, + Frozen(Height), +} + +pub struct ProvideCometClientState; + pub struct EncodeCometClientState; +pub struct EncodeClientStatus; + +impl ProvideClientStateType + for ProvideCometClientState +{ + type ClientState = CometClientState; +} + delegate_components! { EncodeCometClientState { MutEncoderComponent: CombineEncoders< @@ -47,15 +65,6 @@ impl Transformer for EncodeCometClientState { } } -#[derive(Debug)] -pub enum ClientStatus { - Active, - Expired, - Frozen(Height), -} - -pub struct EncodeClientStatus; - delegate_components! { EncodeClientStatus { [ diff --git a/relayer/crates/starknet-chain-context/src/contexts/chain.rs b/relayer/crates/starknet-chain-context/src/contexts/chain.rs index 9cf9e14e..ab9767fd 100644 --- a/relayer/crates/starknet-chain-context/src/contexts/chain.rs +++ b/relayer/crates/starknet-chain-context/src/contexts/chain.rs @@ -58,6 +58,7 @@ use hermes_starknet_chain_components::traits::types::blob::HasBlobType; use hermes_starknet_chain_components::traits::types::method::HasSelectorType; use hermes_starknet_chain_components::types::client_state::WasmStarknetClientState; use hermes_starknet_chain_components::types::consensus_state::WasmStarknetConsensusState; +use hermes_starknet_chain_components::types::cosmos::client_state::CometClientState; use hermes_starknet_test_components::impls::types::wallet::ProvideStarknetWalletType; use hermes_test_components::chain::traits::types::address::HasAddressType; use hermes_test_components::chain::traits::types::wallet::WalletTypeComponent; @@ -195,7 +196,8 @@ pub trait CanUseStarknetChain: impl CanUseStarknetChain for StarknetChain {} pub trait CanUseCosmosChainWithStarknet: - CanQueryClientState + HasClientStateType + + CanQueryClientState + CanQueryConsensusState + CanBuildCreateClientMessage + CanBuildUpdateClientMessage From 0151898b12abd35c0863a3051abaacf137bc1df7 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Thu, 24 Oct 2024 12:58:42 +0000 Subject: [PATCH 02/14] Scaffold implementation of QueryCometClientState --- relayer/Cargo.lock | 55 ++++++++++--------- .../src/components/chain.rs | 13 ++++- .../src/components/mod.rs | 1 + .../src/components/types.rs | 10 ++++ .../src/impls/queries/client_state.rs | 53 ++++++++++++++++++ .../src/impls/queries/mod.rs | 1 + .../src/contexts/chain.rs | 6 ++ .../tests/light_client.rs | 8 ++- relayer/crates/starknet-relayer/Cargo.toml | 25 +++++---- .../src/contexts/starknet_to_cosmos_relay.rs | 11 ++-- 10 files changed, 136 insertions(+), 47 deletions(-) create mode 100644 relayer/crates/starknet-chain-components/src/components/types.rs create mode 100644 relayer/crates/starknet-chain-components/src/impls/queries/client_state.rs diff --git a/relayer/Cargo.lock b/relayer/Cargo.lock index 454e01a0..3365a3bf 100644 --- a/relayer/Cargo.lock +++ b/relayer/Cargo.lock @@ -1757,7 +1757,7 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermes-any-counterparty" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", "cgp-error-eyre", @@ -1774,7 +1774,7 @@ dependencies = [ [[package]] name = "hermes-async-runtime-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "async-trait", "cgp", @@ -1797,7 +1797,7 @@ dependencies = [ [[package]] name = "hermes-chain-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", "hermes-chain-type-components", @@ -1808,7 +1808,7 @@ dependencies = [ [[package]] name = "hermes-chain-type-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", ] @@ -1816,7 +1816,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-chain-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "bech32 0.9.1", "cgp", @@ -1850,7 +1850,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", "hermes-encoding-components", @@ -1864,7 +1864,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-integration-tests" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", "eyre", @@ -1898,7 +1898,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-relayer" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", "eyre", @@ -1944,7 +1944,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-test-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", "hdpath", @@ -1969,7 +1969,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-wasm-relayer" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", "eyre", @@ -2021,7 +2021,7 @@ dependencies = [ [[package]] name = "hermes-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", ] @@ -2029,7 +2029,7 @@ dependencies = [ [[package]] name = "hermes-error" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", "eyre", @@ -2039,7 +2039,7 @@ dependencies = [ [[package]] name = "hermes-ibc-test-suite" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", "hermes-logging-components", @@ -2050,7 +2050,7 @@ dependencies = [ [[package]] name = "hermes-logger" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", "hermes-logging-components", @@ -2062,7 +2062,7 @@ dependencies = [ [[package]] name = "hermes-logging-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", ] @@ -2070,7 +2070,7 @@ dependencies = [ [[package]] name = "hermes-protobuf-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", "hermes-encoding-components", @@ -2081,7 +2081,7 @@ dependencies = [ [[package]] name = "hermes-relayer-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", "hermes-chain-components", @@ -2093,7 +2093,7 @@ dependencies = [ [[package]] name = "hermes-relayer-components-extra" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", "hermes-chain-type-components", @@ -2105,7 +2105,7 @@ dependencies = [ [[package]] name = "hermes-runtime" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", "hermes-async-runtime-components", @@ -2117,7 +2117,7 @@ dependencies = [ [[package]] name = "hermes-runtime-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", ] @@ -2231,6 +2231,7 @@ dependencies = [ "hermes-relayer-components", "hermes-runtime", "hermes-runtime-components", + "hermes-starknet-chain-components", "hermes-starknet-chain-context", "ibc", "ibc-relayer-types", @@ -2252,7 +2253,7 @@ dependencies = [ [[package]] name = "hermes-test-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", "hermes-chain-type-components", @@ -2264,7 +2265,7 @@ dependencies = [ [[package]] name = "hermes-tokio-runtime-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", "futures", @@ -2278,7 +2279,7 @@ dependencies = [ [[package]] name = "hermes-tracing-logging-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", "hermes-logging-components", @@ -2290,7 +2291,7 @@ dependencies = [ [[package]] name = "hermes-wasm-client-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", "cgp-error-eyre", @@ -2310,7 +2311,7 @@ dependencies = [ [[package]] name = "hermes-wasm-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", "hermes-cosmos-encoding-components", @@ -2324,7 +2325,7 @@ dependencies = [ [[package]] name = "hermes-wasm-test-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#8d3647367a438f9cd87ac57d1fcdfc4394f65ab0" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" dependencies = [ "cgp", "cgp-error-eyre", @@ -4102,7 +4103,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" dependencies = [ "anyhow", - "itertools 0.13.0", + "itertools 0.12.1", "proc-macro2", "quote", "syn 2.0.82", diff --git a/relayer/crates/starknet-chain-components/src/components/chain.rs b/relayer/crates/starknet-chain-components/src/components/chain.rs index 86ddfb36..c028b120 100644 --- a/relayer/crates/starknet-chain-components/src/components/chain.rs +++ b/relayer/crates/starknet-chain-components/src/components/chain.rs @@ -1,7 +1,9 @@ +use cgp::core::component::WithProvider; +use cgp::core::types::impls::UseDelegatedType; use cgp::prelude::*; pub use hermes_cosmos_chain_components::components::client::{ ChannelIdTypeComponent, ClientIdTypeComponent, ClientStateFieldsGetterComponent, - ConnectionIdTypeComponent, CreateClientPayloadBuilderComponent, + ClientStateQuerierComponent, ConnectionIdTypeComponent, CreateClientPayloadBuilderComponent, CreateClientPayloadOptionsTypeComponent, CreateClientPayloadTypeComponent, OutgoingPacketFieldsReaderComponent, OutgoingPacketTypeComponent, PortIdTypeComponent, SequenceTypeComponent, TimeTypeComponent, TimeoutTypeComponent, @@ -34,6 +36,7 @@ pub use hermes_test_components::chain::traits::types::address::AddressTypeCompon pub use hermes_test_components::chain::traits::types::amount::AmountTypeComponent; pub use hermes_test_components::chain::traits::types::denom::DenomTypeComponent; +use crate::components::types::StarknetChainTypes; use crate::impls::contract::call::CallStarknetContract; use crate::impls::contract::declare::DeclareSierraContract; use crate::impls::contract::deploy::DeployStarknetContract; @@ -41,6 +44,7 @@ use crate::impls::contract::invoke::InvokeStarknetContract; use crate::impls::contract::message::BuildInvokeContractCall; use crate::impls::payload_builders::create_client::BuildStarknetCreateClientPayload; use crate::impls::payload_builders::update_client::BuildStarknetUpdateClientPayload; +use crate::impls::queries::client_state::QueryCometClientState; use crate::impls::queries::status::QueryStarknetChainStatus; use crate::impls::queries::token_balance::QueryErc20TokenBalance; use crate::impls::send_message::SendCallMessages; @@ -115,7 +119,6 @@ define_components! { ]: ProvideStarknetContractTypes, [ - ClientIdTypeComponent, ConnectionIdTypeComponent, ChannelIdTypeComponent, PortIdTypeComponent, @@ -125,6 +128,10 @@ define_components! { TimeoutTypeComponent, ]: ProvideCosmosChainTypes, + [ + ClientIdTypeComponent, + ]: + WithProvider>, [ ClientStateTypeComponent, ConsensusStateTypeComponent, @@ -173,5 +180,7 @@ define_components! { BuildStarknetCreateClientPayload, UpdateClientPayloadBuilderComponent: BuildStarknetUpdateClientPayload, + ClientStateQuerierComponent: + QueryCometClientState, } } diff --git a/relayer/crates/starknet-chain-components/src/components/mod.rs b/relayer/crates/starknet-chain-components/src/components/mod.rs index 03ba4da6..f011a6b0 100644 --- a/relayer/crates/starknet-chain-components/src/components/mod.rs +++ b/relayer/crates/starknet-chain-components/src/components/mod.rs @@ -1,3 +1,4 @@ pub mod chain; pub mod encoding; pub mod starknet_to_cosmos; +pub mod types; diff --git a/relayer/crates/starknet-chain-components/src/components/types.rs b/relayer/crates/starknet-chain-components/src/components/types.rs new file mode 100644 index 00000000..893d7d16 --- /dev/null +++ b/relayer/crates/starknet-chain-components/src/components/types.rs @@ -0,0 +1,10 @@ +use cgp::prelude::*; +use hermes_cosmos_chain_components::components::client::ClientIdTypeComponent; + +use crate::types::client_id::ClientId; + +define_components! { + StarknetChainTypes { + ClientIdTypeComponent: ClientId, + } +} diff --git a/relayer/crates/starknet-chain-components/src/impls/queries/client_state.rs b/relayer/crates/starknet-chain-components/src/impls/queries/client_state.rs new file mode 100644 index 00000000..aca9ca9e --- /dev/null +++ b/relayer/crates/starknet-chain-components/src/impls/queries/client_state.rs @@ -0,0 +1,53 @@ +use cgp::prelude::CanRaiseError; +use hermes_cairo_encoding_components::strategy::ViaCairo; +use hermes_cairo_encoding_components::types::as_felt::AsFelt; +use hermes_chain_components::traits::queries::client_state::ClientStateQuerier; +use hermes_chain_components::traits::types::client_state::HasClientStateType; +use hermes_chain_components::traits::types::height::HasHeightType; +use hermes_chain_components::traits::types::ibc::HasClientIdType; +use hermes_chain_type_components::traits::types::address::HasAddressType; +use hermes_encoding_components::traits::encode::CanEncode; +use hermes_encoding_components::traits::has_encoding::HasEncoding; +use hermes_encoding_components::traits::types::encoded::HasEncodedType; +use starknet::core::types::Felt; +use starknet::macros::{felt, selector}; + +use crate::traits::contract::call::CanCallContract; +use crate::traits::types::blob::HasBlobType; +use crate::traits::types::method::HasSelectorType; +use crate::types::client_id::ClientId; +use crate::types::cosmos::client_state::CometClientState; + +pub struct QueryCometClientState; + +impl ClientStateQuerier + for QueryCometClientState +where + Chain: HasClientIdType + + HasHeightType + + CanCallContract + + HasAddressType
+ + HasSelectorType + + HasBlobType> + + HasEncoding + + CanRaiseError, + Counterparty: HasClientStateType, + Encoding: CanEncode + HasEncodedType>, +{ + async fn query_client_state( + chain: &Chain, + client_id: &Chain::ClientId, + _height: &Chain::Height, + ) -> Result { + let encoding = chain.encoding(); + let calldata = encoding + .encode(&client_id.sequence) + .map_err(Chain::raise_error)?; + + let _output = chain + .call_contract(&felt!("0x000"), &selector!("client_state"), &calldata) + .await?; + + todo!() + } +} diff --git a/relayer/crates/starknet-chain-components/src/impls/queries/mod.rs b/relayer/crates/starknet-chain-components/src/impls/queries/mod.rs index 70b11378..ed652a03 100644 --- a/relayer/crates/starknet-chain-components/src/impls/queries/mod.rs +++ b/relayer/crates/starknet-chain-components/src/impls/queries/mod.rs @@ -1,2 +1,3 @@ +pub mod client_state; pub mod status; pub mod token_balance; diff --git a/relayer/crates/starknet-chain-context/src/contexts/chain.rs b/relayer/crates/starknet-chain-context/src/contexts/chain.rs index ab9767fd..66134e5e 100644 --- a/relayer/crates/starknet-chain-context/src/contexts/chain.rs +++ b/relayer/crates/starknet-chain-context/src/contexts/chain.rs @@ -28,6 +28,7 @@ use hermes_relayer_components::chain::traits::send_message::CanSendMessages; use hermes_relayer_components::chain::traits::types::chain_id::ChainIdGetter; use hermes_relayer_components::chain::traits::types::client_state::HasClientStateType; use hermes_relayer_components::chain::traits::types::consensus_state::HasConsensusStateType; +use hermes_relayer_components::chain::traits::types::ibc::HasClientIdType; use hermes_relayer_components::chain::traits::types::packet::HasOutgoingPacketType; use hermes_relayer_components::error::traits::retry::HasRetryableError; use hermes_relayer_components::transaction::traits::poll_tx_response::CanPollTxResponse; @@ -56,6 +57,7 @@ use hermes_starknet_chain_components::traits::queries::token_balance::CanQueryTo use hermes_starknet_chain_components::traits::transfer::CanTransferToken; use hermes_starknet_chain_components::traits::types::blob::HasBlobType; use hermes_starknet_chain_components::traits::types::method::HasSelectorType; +use hermes_starknet_chain_components::types::client_id::ClientId; use hermes_starknet_chain_components::types::client_state::WasmStarknetClientState; use hermes_starknet_chain_components::types::consensus_state::WasmStarknetConsensusState; use hermes_starknet_chain_components::types::cosmos::client_state::CometClientState; @@ -173,6 +175,7 @@ pub trait CanUseStarknetChain: + HasBlobType> + HasClientStateType + HasConsensusStateType + + HasClientIdType + HasOutgoingPacketType + HasStarknetProvider + HasStarknetAccount @@ -190,6 +193,9 @@ pub trait CanUseStarknetChain: + HasRetryableError + CanBuildCreateClientPayload + CanBuildUpdateClientPayload + + CanQueryClientState +where + CosmosChain: HasClientStateType, { } diff --git a/relayer/crates/starknet-integration-tests/tests/light_client.rs b/relayer/crates/starknet-integration-tests/tests/light_client.rs index a6cbda01..57c4cd6a 100644 --- a/relayer/crates/starknet-integration-tests/tests/light_client.rs +++ b/relayer/crates/starknet-integration-tests/tests/light_client.rs @@ -30,6 +30,7 @@ use hermes_relayer_components::relay::traits::client_creator::CanCreateClient; use hermes_relayer_components::relay::traits::target::DestinationTarget; use hermes_relayer_components::relay::traits::update_client_message_builder::CanSendTargetUpdateClientMessage; use hermes_runtime_components::traits::sleep::CanSleep; +use hermes_starknet_chain_components::types::client_id::ClientId as StarknetClientId; use hermes_starknet_chain_components::types::payloads::client::StarknetCreateClientPayloadOptions; use hermes_starknet_chain_context::contexts::chain::StarknetChain; use hermes_starknet_integration_tests::contexts::bootstrap::StarknetBootstrap; @@ -44,6 +45,7 @@ use ibc_relayer::config::types::TrustThreshold; use ibc_relayer_types::core::ics04_channel::channel::Ordering; use ibc_relayer_types::Height; use sha2::{Digest, Sha256}; +use starknet::macros::short_string; #[test] fn test_starknet_light_client() -> Result<(), Error> { @@ -114,7 +116,11 @@ fn test_starknet_light_client() -> Result<(), Error> { runtime: runtime.clone(), src_chain: starknet_chain.clone(), dst_chain: cosmos_chain.clone(), - src_client_id: client_id.clone(), // TODO: stub + // TODO: stub + src_client_id: StarknetClientId { + client_type: short_string!("cometbft"), + sequence: 1, + }, dst_client_id: client_id.clone(), }; diff --git a/relayer/crates/starknet-relayer/Cargo.toml b/relayer/crates/starknet-relayer/Cargo.toml index 74f61f96..e96b4ce1 100644 --- a/relayer/crates/starknet-relayer/Cargo.toml +++ b/relayer/crates/starknet-relayer/Cargo.toml @@ -10,17 +10,18 @@ rust-version = { workspace = true } readme = "README.md" [dependencies] -cgp = { workspace = true } -ibc = { workspace = true } -ibc-relayer-types = { workspace = true } -hermes-error = { workspace = true } -hermes-runtime = { workspace = true } -hermes-runtime-components = { workspace = true } -hermes-logging-components = { workspace = true } -hermes-encoding-components = { workspace = true } -hermes-logger = { workspace = true } -hermes-relayer-components = { workspace = true } -hermes-cosmos-relayer = { workspace = true } -hermes-starknet-chain-context = { workspace = true } +cgp = { workspace = true } +ibc = { workspace = true } +ibc-relayer-types = { workspace = true } +hermes-error = { workspace = true } +hermes-runtime = { workspace = true } +hermes-runtime-components = { workspace = true } +hermes-logging-components = { workspace = true } +hermes-encoding-components = { workspace = true } +hermes-logger = { workspace = true } +hermes-relayer-components = { workspace = true } +hermes-cosmos-relayer = { workspace = true } +hermes-starknet-chain-context = { workspace = true } +hermes-starknet-chain-components = { workspace = true } eyre = { workspace = true } diff --git a/relayer/crates/starknet-relayer/src/contexts/starknet_to_cosmos_relay.rs b/relayer/crates/starknet-relayer/src/contexts/starknet_to_cosmos_relay.rs index d3755881..ebb25c63 100644 --- a/relayer/crates/starknet-relayer/src/contexts/starknet_to_cosmos_relay.rs +++ b/relayer/crates/starknet-relayer/src/contexts/starknet_to_cosmos_relay.rs @@ -22,8 +22,9 @@ use hermes_runtime::types::runtime::HermesRuntime; use hermes_runtime_components::traits::runtime::{ ProvideDefaultRuntimeField, RuntimeGetterComponent, RuntimeTypeComponent, }; +use hermes_starknet_chain_components::types::client_id::ClientId as StarknetClientId; use hermes_starknet_chain_context::contexts::chain::StarknetChain; -use ibc_relayer_types::core::ics24_host::identifier::ClientId; +use ibc_relayer_types::core::ics24_host::identifier::ClientId as CosmosClientId; use crate::impls::error::HandleStarknetRelayError; @@ -32,8 +33,8 @@ pub struct StarknetToCosmosRelay { pub runtime: HermesRuntime, pub src_chain: StarknetChain, pub dst_chain: CosmosChain, - pub src_client_id: ClientId, - pub dst_client_id: ClientId, + pub src_client_id: StarknetClientId, + pub dst_client_id: CosmosClientId, } pub struct StarknetToCosmosRelayComponents; @@ -83,11 +84,11 @@ impl ProvideRelayChains for StarknetToCosmosRelayComponen &relay.dst_chain } - fn src_client_id(relay: &StarknetToCosmosRelay) -> &ClientId { + fn src_client_id(relay: &StarknetToCosmosRelay) -> &StarknetClientId { &relay.src_client_id } - fn dst_client_id(relay: &StarknetToCosmosRelay) -> &ClientId { + fn dst_client_id(relay: &StarknetToCosmosRelay) -> &CosmosClientId { &relay.dst_client_id } } From 4c48cb5ac7c0ee1dd899602b403a0e41d37bfca1 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Thu, 24 Oct 2024 14:12:38 +0000 Subject: [PATCH 03/14] Add CanQueryContractAddress --- .../src/components/chain.rs | 4 +++ .../src/impls/queries/client_state.rs | 31 ++++++++++++++----- .../src/impls/queries/contract_address.rs | 29 +++++++++++++++++ .../src/impls/queries/mod.rs | 1 + .../src/traits/queries/address.rs | 13 ++++++++ .../src/traits/queries/mod.rs | 1 + .../src/contexts/chain.rs | 3 ++ .../starknet-chain-context/src/impls/error.rs | 2 ++ .../src/contexts/bootstrap.rs | 1 + 9 files changed, 77 insertions(+), 8 deletions(-) create mode 100644 relayer/crates/starknet-chain-components/src/impls/queries/contract_address.rs create mode 100644 relayer/crates/starknet-chain-components/src/traits/queries/address.rs diff --git a/relayer/crates/starknet-chain-components/src/components/chain.rs b/relayer/crates/starknet-chain-components/src/components/chain.rs index c028b120..31241b25 100644 --- a/relayer/crates/starknet-chain-components/src/components/chain.rs +++ b/relayer/crates/starknet-chain-components/src/components/chain.rs @@ -45,6 +45,7 @@ use crate::impls::contract::message::BuildInvokeContractCall; use crate::impls::payload_builders::create_client::BuildStarknetCreateClientPayload; use crate::impls::payload_builders::update_client::BuildStarknetUpdateClientPayload; use crate::impls::queries::client_state::QueryCometClientState; +use crate::impls::queries::contract_address::GetContractAddressFromField; use crate::impls::queries::status::QueryStarknetChainStatus; use crate::impls::queries::token_balance::QueryErc20TokenBalance; use crate::impls::send_message::SendCallMessages; @@ -73,6 +74,7 @@ pub use crate::traits::contract::deploy::ContractDeployerComponent; pub use crate::traits::contract::invoke::ContractInvokerComponent; pub use crate::traits::contract::message::InvokeContractMessageBuilderComponent; pub use crate::traits::messages::transfer::TransferTokenMessageBuilderComponent; +pub use crate::traits::queries::address::ContractAddressQuerierComponent; pub use crate::traits::queries::token_balance::TokenBalanceQuerierComponent; pub use crate::traits::transfer::TokenTransferComponent; pub use crate::traits::types::blob::BlobTypeComponent; @@ -182,5 +184,7 @@ define_components! { BuildStarknetUpdateClientPayload, ClientStateQuerierComponent: QueryCometClientState, + ContractAddressQuerierComponent: + GetContractAddressFromField, } } diff --git a/relayer/crates/starknet-chain-components/src/impls/queries/client_state.rs b/relayer/crates/starknet-chain-components/src/impls/queries/client_state.rs index aca9ca9e..5367cbdc 100644 --- a/relayer/crates/starknet-chain-components/src/impls/queries/client_state.rs +++ b/relayer/crates/starknet-chain-components/src/impls/queries/client_state.rs @@ -1,18 +1,21 @@ -use cgp::prelude::CanRaiseError; +use core::marker::PhantomData; + +use cgp::prelude::*; use hermes_cairo_encoding_components::strategy::ViaCairo; use hermes_cairo_encoding_components::types::as_felt::AsFelt; use hermes_chain_components::traits::queries::client_state::ClientStateQuerier; use hermes_chain_components::traits::types::client_state::HasClientStateType; use hermes_chain_components::traits::types::height::HasHeightType; use hermes_chain_components::traits::types::ibc::HasClientIdType; -use hermes_chain_type_components::traits::types::address::HasAddressType; +use hermes_encoding_components::traits::decode::CanDecode; use hermes_encoding_components::traits::encode::CanEncode; use hermes_encoding_components::traits::has_encoding::HasEncoding; use hermes_encoding_components::traits::types::encoded::HasEncodedType; use starknet::core::types::Felt; -use starknet::macros::{felt, selector}; +use starknet::macros::selector; use crate::traits::contract::call::CanCallContract; +use crate::traits::queries::address::CanQueryContractAddress; use crate::traits::types::blob::HasBlobType; use crate::traits::types::method::HasSelectorType; use crate::types::client_id::ClientId; @@ -26,13 +29,16 @@ where Chain: HasClientIdType + HasHeightType + CanCallContract - + HasAddressType
+ HasSelectorType + HasBlobType> + HasEncoding + + CanQueryContractAddress + CanRaiseError, Counterparty: HasClientStateType, - Encoding: CanEncode + HasEncodedType>, + Encoding: CanEncode + + CanDecode> + + CanDecode + + HasEncodedType>, { async fn query_client_state( chain: &Chain, @@ -40,14 +46,23 @@ where _height: &Chain::Height, ) -> Result { let encoding = chain.encoding(); + + let contract_address = chain.query_contract_address(PhantomData).await?; + let calldata = encoding .encode(&client_id.sequence) .map_err(Chain::raise_error)?; - let _output = chain - .call_contract(&felt!("0x000"), &selector!("client_state"), &calldata) + let output = chain + .call_contract(&contract_address, &selector!("client_state"), &calldata) .await?; - todo!() + let raw_client_state: Vec = encoding.decode(&output).map_err(Chain::raise_error)?; + + let client_state: CometClientState = encoding + .decode(&raw_client_state) + .map_err(Chain::raise_error)?; + + Ok(client_state) } } diff --git a/relayer/crates/starknet-chain-components/src/impls/queries/contract_address.rs b/relayer/crates/starknet-chain-components/src/impls/queries/contract_address.rs new file mode 100644 index 00000000..00257a9b --- /dev/null +++ b/relayer/crates/starknet-chain-components/src/impls/queries/contract_address.rs @@ -0,0 +1,29 @@ +use core::marker::PhantomData; + +use cgp::prelude::*; +use hermes_chain_type_components::traits::types::address::HasAddressType; + +use crate::traits::queries::address::ContractAddressQuerier; + +pub struct GetContractAddressFromField; + +#[derive(Debug)] +pub struct ContractAddressNotFound; + +impl ContractAddressQuerier for GetContractAddressFromField +where + Chain: HasAddressType + + CanRaiseError + + HasField>, + Tag: Async, +{ + async fn query_contract_address( + chain: &Chain, + tag: PhantomData, + ) -> Result { + chain + .get_field(tag) + .clone() + .ok_or_else(|| Chain::raise_error(ContractAddressNotFound)) + } +} diff --git a/relayer/crates/starknet-chain-components/src/impls/queries/mod.rs b/relayer/crates/starknet-chain-components/src/impls/queries/mod.rs index ed652a03..79692fdf 100644 --- a/relayer/crates/starknet-chain-components/src/impls/queries/mod.rs +++ b/relayer/crates/starknet-chain-components/src/impls/queries/mod.rs @@ -1,3 +1,4 @@ pub mod client_state; +pub mod contract_address; pub mod status; pub mod token_balance; diff --git a/relayer/crates/starknet-chain-components/src/traits/queries/address.rs b/relayer/crates/starknet-chain-components/src/traits/queries/address.rs new file mode 100644 index 00000000..d28bda4f --- /dev/null +++ b/relayer/crates/starknet-chain-components/src/traits/queries/address.rs @@ -0,0 +1,13 @@ +use core::marker::PhantomData; + +use cgp::prelude::*; +use hermes_chain_type_components::traits::types::address::HasAddressType; + +#[derive_component(ContractAddressQuerierComponent, ContractAddressQuerier)] +#[async_trait] +pub trait CanQueryContractAddress: HasAddressType + HasErrorType { + async fn query_contract_address( + &self, + tag: PhantomData, + ) -> Result; +} diff --git a/relayer/crates/starknet-chain-components/src/traits/queries/mod.rs b/relayer/crates/starknet-chain-components/src/traits/queries/mod.rs index 6ee97613..86b5c989 100644 --- a/relayer/crates/starknet-chain-components/src/traits/queries/mod.rs +++ b/relayer/crates/starknet-chain-components/src/traits/queries/mod.rs @@ -1 +1,2 @@ +pub mod address; pub mod token_balance; diff --git a/relayer/crates/starknet-chain-context/src/contexts/chain.rs b/relayer/crates/starknet-chain-context/src/contexts/chain.rs index 66134e5e..e0e6b795 100644 --- a/relayer/crates/starknet-chain-context/src/contexts/chain.rs +++ b/relayer/crates/starknet-chain-context/src/contexts/chain.rs @@ -53,6 +53,7 @@ use hermes_starknet_chain_components::traits::contract::invoke::CanInvokeContrac use hermes_starknet_chain_components::traits::provider::{ HasStarknetProvider, StarknetProviderGetterComponent, StarknetProviderTypeComponent, }; +use hermes_starknet_chain_components::traits::queries::address::CanQueryContractAddress; use hermes_starknet_chain_components::traits::queries::token_balance::CanQueryTokenBalance; use hermes_starknet_chain_components::traits::transfer::CanTransferToken; use hermes_starknet_chain_components::traits::types::blob::HasBlobType; @@ -80,6 +81,7 @@ pub struct StarknetChain { pub chain_id: Felt, pub rpc_client: Arc>, pub account: SingleOwnerAccount>, LocalWallet>, + pub ibc_client_contract_address: Option, } pub struct StarknetChainContextComponents; @@ -194,6 +196,7 @@ pub trait CanUseStarknetChain: + CanBuildCreateClientPayload + CanBuildUpdateClientPayload + CanQueryClientState + + CanQueryContractAddress where CosmosChain: HasClientStateType, { diff --git a/relayer/crates/starknet-chain-context/src/impls/error.rs b/relayer/crates/starknet-chain-context/src/impls/error.rs index ab23fd11..0b499ded 100644 --- a/relayer/crates/starknet-chain-context/src/impls/error.rs +++ b/relayer/crates/starknet-chain-context/src/impls/error.rs @@ -30,6 +30,7 @@ use hermes_runtime::types::error::TokioRuntimeError; use hermes_starknet_chain_components::impls::error::account::RaiseAccountError; use hermes_starknet_chain_components::impls::error::provider::RaiseProviderError; use hermes_starknet_chain_components::impls::error::starknet::RaiseStarknetError; +use hermes_starknet_chain_components::impls::queries::contract_address::ContractAddressNotFound; use hermes_starknet_chain_components::impls::send_message::UnexpectedTransactionTraceType; use hermes_starknet_chain_components::types::event::UnknownEvent; use ibc::core::client::types::error::ClientError; @@ -82,6 +83,7 @@ delegate_components! { InvalidWireType, UnsupportedWireType, RequiredFieldTagNotFound, + ContractAddressNotFound, <'a> UnknownEvent<'a>, <'a, Chain: HasTransactionHashType> TxNoResponseError<'a, Chain>, ]: diff --git a/relayer/crates/starknet-integration-tests/src/contexts/bootstrap.rs b/relayer/crates/starknet-integration-tests/src/contexts/bootstrap.rs index d4eac92a..771f6368 100644 --- a/relayer/crates/starknet-integration-tests/src/contexts/bootstrap.rs +++ b/relayer/crates/starknet-integration-tests/src/contexts/bootstrap.rs @@ -138,6 +138,7 @@ impl ChainDriverBuilder for StarknetBootstrapComponents { chain_id, rpc_client, account, + ibc_client_contract_address: None, }; let chain_driver = StarknetChainDriver { From 9346de474701b10d05741396037553979bec68b5 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Thu, 24 Oct 2024 14:20:43 +0000 Subject: [PATCH 04/14] Use query_client_state in test --- .../src/impls/queries/client_state.rs | 2 +- .../tests/ibc_client.rs | 26 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/relayer/crates/starknet-chain-components/src/impls/queries/client_state.rs b/relayer/crates/starknet-chain-components/src/impls/queries/client_state.rs index 5367cbdc..749a83d9 100644 --- a/relayer/crates/starknet-chain-components/src/impls/queries/client_state.rs +++ b/relayer/crates/starknet-chain-components/src/impls/queries/client_state.rs @@ -43,7 +43,7 @@ where async fn query_client_state( chain: &Chain, client_id: &Chain::ClientId, - _height: &Chain::Height, + _height: &Chain::Height, // TODO: figure whether we can perform height specific queries on Starknet ) -> Result { let encoding = chain.encoding(); diff --git a/relayer/crates/starknet-integration-tests/tests/ibc_client.rs b/relayer/crates/starknet-integration-tests/tests/ibc_client.rs index 0cfeb35d..a4a3abec 100644 --- a/relayer/crates/starknet-integration-tests/tests/ibc_client.rs +++ b/relayer/crates/starknet-integration-tests/tests/ibc_client.rs @@ -1,7 +1,9 @@ use std::time::{SystemTime, UNIX_EPOCH}; +use hermes_chain_components::traits::queries::client_state::CanQueryClientStateWithLatestHeight; use hermes_chain_components::traits::send_message::CanSendSingleMessage; use hermes_cosmos_integration_tests::init::init_test_runtime; +use hermes_cosmos_relayer::contexts::chain::CosmosChain; use hermes_encoding_components::traits::decode::CanDecode; use hermes_encoding_components::traits::encode::CanEncode; use hermes_encoding_components::HList; @@ -18,6 +20,7 @@ use hermes_starknet_chain_components::types::cosmos::consensus_state::CometConse use hermes_starknet_chain_components::types::cosmos::height::Height; use hermes_starknet_chain_components::types::cosmos::update::CometUpdateHeader; use hermes_starknet_chain_components::types::events::create_client::CreateClientEvent; +use hermes_starknet_chain_context::contexts::chain::StarknetChain; use hermes_starknet_chain_context::contexts::encoding::cairo::StarknetCairoEncoding; use hermes_starknet_chain_context::contexts::encoding::event::StarknetEventEncoding; use hermes_starknet_integration_tests::contexts::bootstrap::StarknetBootstrap; @@ -45,9 +48,9 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { chain_store_dir: format!("./test-data/{timestamp}").into(), }; - let chain_driver = bootstrap.bootstrap_chain("starknet").await?; + let mut chain_driver = bootstrap.bootstrap_chain("starknet").await?; - let chain = &chain_driver.chain; + let chain = &mut chain_driver.chain; let comet_client_class_hash = { let contract_path = std::env::var("COMET_CLIENT_CONTRACT")?; @@ -72,6 +75,8 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { comet_client_address ); + chain.ibc_client_contract_address = Some(comet_client_address); + let event_encoding = StarknetEventEncoding { erc20_hashes: Default::default(), ics20_hashes: Default::default(), @@ -161,17 +166,12 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { } { - let output = chain - .call_contract( - &comet_client_address, - &selector!("client_state"), - &StarknetCairoEncoding.encode(&client_id.sequence)?, - ) - .await?; - - let raw_client_state: Vec = StarknetCairoEncoding.decode(&output)?; - - let client_state: CometClientState = StarknetCairoEncoding.decode(&raw_client_state)?; + let client_state = >::query_client_state_with_latest_height( + chain, &client_id + ) + .await?; println!("queried client state: {client_state:?}"); } From 0f4a8ea84ccec95398cde0f7292def3e07093e23 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Thu, 24 Oct 2024 19:10:02 +0000 Subject: [PATCH 05/14] Use CometConsensusState as Cosmos consensus state --- relayer/Cargo.lock | 52 +++++++++---------- .../src/components/starknet_to_cosmos.rs | 10 ++-- .../src/types/cosmos/client_state.rs | 9 ---- .../src/contexts/chain.rs | 2 + 4 files changed, 35 insertions(+), 38 deletions(-) diff --git a/relayer/Cargo.lock b/relayer/Cargo.lock index 3365a3bf..6b371991 100644 --- a/relayer/Cargo.lock +++ b/relayer/Cargo.lock @@ -1757,7 +1757,7 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermes-any-counterparty" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", "cgp-error-eyre", @@ -1774,7 +1774,7 @@ dependencies = [ [[package]] name = "hermes-async-runtime-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "async-trait", "cgp", @@ -1797,7 +1797,7 @@ dependencies = [ [[package]] name = "hermes-chain-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", "hermes-chain-type-components", @@ -1808,7 +1808,7 @@ dependencies = [ [[package]] name = "hermes-chain-type-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", ] @@ -1816,7 +1816,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-chain-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "bech32 0.9.1", "cgp", @@ -1850,7 +1850,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", "hermes-encoding-components", @@ -1864,7 +1864,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-integration-tests" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", "eyre", @@ -1898,7 +1898,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-relayer" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", "eyre", @@ -1944,7 +1944,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-test-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", "hdpath", @@ -1969,7 +1969,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-wasm-relayer" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", "eyre", @@ -2021,7 +2021,7 @@ dependencies = [ [[package]] name = "hermes-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", ] @@ -2029,7 +2029,7 @@ dependencies = [ [[package]] name = "hermes-error" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", "eyre", @@ -2039,7 +2039,7 @@ dependencies = [ [[package]] name = "hermes-ibc-test-suite" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", "hermes-logging-components", @@ -2050,7 +2050,7 @@ dependencies = [ [[package]] name = "hermes-logger" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", "hermes-logging-components", @@ -2062,7 +2062,7 @@ dependencies = [ [[package]] name = "hermes-logging-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", ] @@ -2070,7 +2070,7 @@ dependencies = [ [[package]] name = "hermes-protobuf-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", "hermes-encoding-components", @@ -2081,7 +2081,7 @@ dependencies = [ [[package]] name = "hermes-relayer-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", "hermes-chain-components", @@ -2093,7 +2093,7 @@ dependencies = [ [[package]] name = "hermes-relayer-components-extra" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", "hermes-chain-type-components", @@ -2105,7 +2105,7 @@ dependencies = [ [[package]] name = "hermes-runtime" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", "hermes-async-runtime-components", @@ -2117,7 +2117,7 @@ dependencies = [ [[package]] name = "hermes-runtime-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", ] @@ -2253,7 +2253,7 @@ dependencies = [ [[package]] name = "hermes-test-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", "hermes-chain-type-components", @@ -2265,7 +2265,7 @@ dependencies = [ [[package]] name = "hermes-tokio-runtime-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", "futures", @@ -2279,7 +2279,7 @@ dependencies = [ [[package]] name = "hermes-tracing-logging-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", "hermes-logging-components", @@ -2291,7 +2291,7 @@ dependencies = [ [[package]] name = "hermes-wasm-client-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", "cgp-error-eyre", @@ -2311,7 +2311,7 @@ dependencies = [ [[package]] name = "hermes-wasm-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", "hermes-cosmos-encoding-components", @@ -2325,7 +2325,7 @@ dependencies = [ [[package]] name = "hermes-wasm-test-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#527a5ecfc7fd5b4a31a5cdfe6bef67ec6485171c" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" dependencies = [ "cgp", "cgp-error-eyre", diff --git a/relayer/crates/starknet-chain-components/src/components/starknet_to_cosmos.rs b/relayer/crates/starknet-chain-components/src/components/starknet_to_cosmos.rs index 32414cc7..01f86ee6 100644 --- a/relayer/crates/starknet-chain-components/src/components/starknet_to_cosmos.rs +++ b/relayer/crates/starknet-chain-components/src/components/starknet_to_cosmos.rs @@ -1,6 +1,7 @@ +use cgp::core::types::impls::WithType; use cgp::prelude::*; use hermes_cosmos_chain_components::components::client::{ - ClientStateTypeComponent, ConsensusStateHeightsQuerierComponent, + ClientStateTypeComponent, ConsensusStateHeightsQuerierComponent, ConsensusStateTypeComponent, CreateClientMessageBuilderComponent, CreateClientMessageOptionsTypeComponent, UpdateClientMessageBuilderComponent, }; @@ -14,7 +15,8 @@ use hermes_relayer_components::chain::traits::queries::consensus_state::{ use crate::impls::starknet_to_cosmos::query_consensus_state_height::QueryStarknetConsensusStateHeightsFromGrpc; use crate::impls::starknet_to_cosmos::update_client_message::BuildStarknetUpdateClientMessage; -use crate::types::cosmos::client_state::ProvideCometClientState; +use crate::types::cosmos::client_state::CometClientState; +use crate::types::cosmos::consensus_state::CometConsensusState; define_components! { StarknetToCosmosComponents { @@ -28,7 +30,9 @@ define_components! { ]: CosmosToCosmosComponents, ClientStateTypeComponent: - ProvideCometClientState, + WithType, + ConsensusStateTypeComponent: + WithType, UpdateClientMessageBuilderComponent: BuildStarknetUpdateClientMessage, ConsensusStateHeightsQuerierComponent: diff --git a/relayer/crates/starknet-chain-components/src/types/cosmos/client_state.rs b/relayer/crates/starknet-chain-components/src/types/cosmos/client_state.rs index a3925865..c42caae1 100644 --- a/relayer/crates/starknet-chain-components/src/types/cosmos/client_state.rs +++ b/relayer/crates/starknet-chain-components/src/types/cosmos/client_state.rs @@ -3,7 +3,6 @@ use cgp::prelude::*; use hermes_cairo_encoding_components::impls::encode_mut::variant_from::EncodeVariantFrom; use hermes_cairo_encoding_components::types::either::Either; use hermes_cairo_encoding_components::Sum; -use hermes_chain_components::traits::types::client_state::ProvideClientStateType; use hermes_encoding_components::impls::encode_mut::combine::CombineEncoders; use hermes_encoding_components::impls::encode_mut::field::EncodeField; use hermes_encoding_components::impls::encode_mut::from::DecodeFrom; @@ -27,18 +26,10 @@ pub enum ClientStatus { Frozen(Height), } -pub struct ProvideCometClientState; - pub struct EncodeCometClientState; pub struct EncodeClientStatus; -impl ProvideClientStateType - for ProvideCometClientState -{ - type ClientState = CometClientState; -} - delegate_components! { EncodeCometClientState { MutEncoderComponent: CombineEncoders< diff --git a/relayer/crates/starknet-chain-context/src/contexts/chain.rs b/relayer/crates/starknet-chain-context/src/contexts/chain.rs index e0e6b795..f4aef26a 100644 --- a/relayer/crates/starknet-chain-context/src/contexts/chain.rs +++ b/relayer/crates/starknet-chain-context/src/contexts/chain.rs @@ -62,6 +62,7 @@ use hermes_starknet_chain_components::types::client_id::ClientId; use hermes_starknet_chain_components::types::client_state::WasmStarknetClientState; use hermes_starknet_chain_components::types::consensus_state::WasmStarknetConsensusState; use hermes_starknet_chain_components::types::cosmos::client_state::CometClientState; +use hermes_starknet_chain_components::types::cosmos::consensus_state::CometConsensusState; use hermes_starknet_test_components::impls::types::wallet::ProvideStarknetWalletType; use hermes_test_components::chain::traits::types::address::HasAddressType; use hermes_test_components::chain::traits::types::wallet::WalletTypeComponent; @@ -206,6 +207,7 @@ impl CanUseStarknetChain for StarknetChain {} pub trait CanUseCosmosChainWithStarknet: HasClientStateType + + HasConsensusStateType + CanQueryClientState + CanQueryConsensusState + CanBuildCreateClientMessage From 4bbe07ab63c244224d3866b92f910fb89699fa6d Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Thu, 24 Oct 2024 19:21:59 +0000 Subject: [PATCH 06/14] Implement CanQueryConsensusState --- .../src/components/chain.rs | 13 ++-- .../src/impls/queries/consensus_state.rs | 78 +++++++++++++++++++ .../src/impls/queries/mod.rs | 1 + .../src/contexts/chain.rs | 3 +- .../tests/ibc_client.rs | 31 +++----- 5 files changed, 99 insertions(+), 27 deletions(-) create mode 100644 relayer/crates/starknet-chain-components/src/impls/queries/consensus_state.rs diff --git a/relayer/crates/starknet-chain-components/src/components/chain.rs b/relayer/crates/starknet-chain-components/src/components/chain.rs index 31241b25..e038d355 100644 --- a/relayer/crates/starknet-chain-components/src/components/chain.rs +++ b/relayer/crates/starknet-chain-components/src/components/chain.rs @@ -3,11 +3,11 @@ use cgp::core::types::impls::UseDelegatedType; use cgp::prelude::*; pub use hermes_cosmos_chain_components::components::client::{ ChannelIdTypeComponent, ClientIdTypeComponent, ClientStateFieldsGetterComponent, - ClientStateQuerierComponent, ConnectionIdTypeComponent, CreateClientPayloadBuilderComponent, - CreateClientPayloadOptionsTypeComponent, CreateClientPayloadTypeComponent, - OutgoingPacketFieldsReaderComponent, OutgoingPacketTypeComponent, PortIdTypeComponent, - SequenceTypeComponent, TimeTypeComponent, TimeoutTypeComponent, - UpdateClientPayloadBuilderComponent, UpdateClientPayloadTypeComponent, + ClientStateQuerierComponent, ConnectionIdTypeComponent, ConsensusStateQuerierComponent, + CreateClientPayloadBuilderComponent, CreateClientPayloadOptionsTypeComponent, + CreateClientPayloadTypeComponent, OutgoingPacketFieldsReaderComponent, + OutgoingPacketTypeComponent, PortIdTypeComponent, SequenceTypeComponent, TimeTypeComponent, + TimeoutTypeComponent, UpdateClientPayloadBuilderComponent, UpdateClientPayloadTypeComponent, }; use hermes_cosmos_chain_components::impls::packet::packet_fields::CosmosPacketFieldReader; use hermes_cosmos_chain_components::impls::types::chain::ProvideCosmosChainTypes; @@ -45,6 +45,7 @@ use crate::impls::contract::message::BuildInvokeContractCall; use crate::impls::payload_builders::create_client::BuildStarknetCreateClientPayload; use crate::impls::payload_builders::update_client::BuildStarknetUpdateClientPayload; use crate::impls::queries::client_state::QueryCometClientState; +use crate::impls::queries::consensus_state::QueryCometConsensusState; use crate::impls::queries::contract_address::GetContractAddressFromField; use crate::impls::queries::status::QueryStarknetChainStatus; use crate::impls::queries::token_balance::QueryErc20TokenBalance; @@ -184,6 +185,8 @@ define_components! { BuildStarknetUpdateClientPayload, ClientStateQuerierComponent: QueryCometClientState, + ConsensusStateQuerierComponent: + QueryCometConsensusState, ContractAddressQuerierComponent: GetContractAddressFromField, } diff --git a/relayer/crates/starknet-chain-components/src/impls/queries/consensus_state.rs b/relayer/crates/starknet-chain-components/src/impls/queries/consensus_state.rs new file mode 100644 index 00000000..a9c90d83 --- /dev/null +++ b/relayer/crates/starknet-chain-components/src/impls/queries/consensus_state.rs @@ -0,0 +1,78 @@ +use core::marker::PhantomData; + +use cgp::prelude::*; +use hermes_cairo_encoding_components::strategy::ViaCairo; +use hermes_cairo_encoding_components::types::as_felt::AsFelt; +use hermes_chain_components::traits::queries::consensus_state::ConsensusStateQuerier; +use hermes_chain_components::traits::types::consensus_state::HasConsensusStateType; +use hermes_chain_components::traits::types::height::{HasHeightFields, HasHeightType}; +use hermes_chain_components::traits::types::ibc::HasClientIdType; +use hermes_encoding_components::traits::decode::CanDecode; +use hermes_encoding_components::traits::encode::CanEncode; +use hermes_encoding_components::traits::has_encoding::HasEncoding; +use hermes_encoding_components::traits::types::encoded::HasEncodedType; +use starknet::core::types::Felt; +use starknet::macros::selector; + +use crate::traits::contract::call::CanCallContract; +use crate::traits::queries::address::CanQueryContractAddress; +use crate::traits::types::blob::HasBlobType; +use crate::traits::types::method::HasSelectorType; +use crate::types::client_id::ClientId; +use crate::types::cosmos::consensus_state::CometConsensusState; +use crate::types::cosmos::height::Height; + +pub struct QueryCometConsensusState; + +impl ConsensusStateQuerier + for QueryCometConsensusState +where + Chain: HasClientIdType + + HasHeightType + + CanCallContract + + HasSelectorType + + HasBlobType> + + HasEncoding + + CanQueryContractAddress + + CanRaiseError, + Counterparty: + HasConsensusStateType + HasHeightFields, + Encoding: CanEncode + + CanDecode> + + CanDecode + + HasEncodedType>, +{ + async fn query_consensus_state( + chain: &Chain, + client_id: &Chain::ClientId, + consensus_height: &Counterparty::Height, + _query_height: &Chain::Height, // TODO: figure whether we can perform height specific queries on Starknet + ) -> Result { + let encoding = chain.encoding(); + + let contract_address = chain.query_contract_address(PhantomData).await?; + + let calldata = encoding + .encode(&( + client_id.sequence, + Height { + revision_number: Counterparty::revision_number(consensus_height), + revision_height: Counterparty::revision_height(consensus_height), + }, + )) + .map_err(Chain::raise_error)?; + + let output = chain + .call_contract(&contract_address, &selector!("consensus_state"), &calldata) + .await?; + + let raw_consensus_state: Vec = + encoding.decode(&output).map_err(Chain::raise_error)?; + + let consensus_state: CometConsensusState = encoding + .decode(&raw_consensus_state) + .map_err(Chain::raise_error)?; + + Ok(consensus_state) + } +} diff --git a/relayer/crates/starknet-chain-components/src/impls/queries/mod.rs b/relayer/crates/starknet-chain-components/src/impls/queries/mod.rs index 79692fdf..528aa275 100644 --- a/relayer/crates/starknet-chain-components/src/impls/queries/mod.rs +++ b/relayer/crates/starknet-chain-components/src/impls/queries/mod.rs @@ -1,4 +1,5 @@ pub mod client_state; +pub mod consensus_state; pub mod contract_address; pub mod status; pub mod token_balance; diff --git a/relayer/crates/starknet-chain-context/src/contexts/chain.rs b/relayer/crates/starknet-chain-context/src/contexts/chain.rs index f4aef26a..e7636398 100644 --- a/relayer/crates/starknet-chain-context/src/contexts/chain.rs +++ b/relayer/crates/starknet-chain-context/src/contexts/chain.rs @@ -197,9 +197,10 @@ pub trait CanUseStarknetChain: + CanBuildCreateClientPayload + CanBuildUpdateClientPayload + CanQueryClientState + + CanQueryConsensusState + CanQueryContractAddress where - CosmosChain: HasClientStateType, + CosmosChain: HasClientStateType + HasConsensusStateType, { } diff --git a/relayer/crates/starknet-integration-tests/tests/ibc_client.rs b/relayer/crates/starknet-integration-tests/tests/ibc_client.rs index a4a3abec..3ebf0097 100644 --- a/relayer/crates/starknet-integration-tests/tests/ibc_client.rs +++ b/relayer/crates/starknet-integration-tests/tests/ibc_client.rs @@ -1,16 +1,15 @@ use std::time::{SystemTime, UNIX_EPOCH}; use hermes_chain_components::traits::queries::client_state::CanQueryClientStateWithLatestHeight; +use hermes_chain_components::traits::queries::consensus_state::CanQueryConsensusStateWithLatestHeight; use hermes_chain_components::traits::send_message::CanSendSingleMessage; use hermes_cosmos_integration_tests::init::init_test_runtime; use hermes_cosmos_relayer::contexts::chain::CosmosChain; -use hermes_encoding_components::traits::decode::CanDecode; use hermes_encoding_components::traits::encode::CanEncode; use hermes_encoding_components::HList; use hermes_error::types::Error; use hermes_runtime_components::traits::fs::read_file::CanReadFileAsString; use hermes_starknet_chain_components::impls::encoding::events::CanFilterDecodeEvents; -use hermes_starknet_chain_components::traits::contract::call::CanCallContract; use hermes_starknet_chain_components::traits::contract::declare::CanDeclareContract; use hermes_starknet_chain_components::traits::contract::deploy::CanDeployContract; use hermes_starknet_chain_components::types::cosmos::client_state::{ @@ -25,8 +24,8 @@ use hermes_starknet_chain_context::contexts::encoding::cairo::StarknetCairoEncod use hermes_starknet_chain_context::contexts::encoding::event::StarknetEventEncoding; use hermes_starknet_integration_tests::contexts::bootstrap::StarknetBootstrap; use hermes_test_components::bootstrap::traits::chain::CanBootstrapChain; +use ibc_relayer_types::Height as RelayerHeight; use starknet::accounts::Call; -use starknet::core::types::Felt; use starknet::macros::{selector, short_string}; #[test] @@ -177,24 +176,14 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { } { - let output = chain - .call_contract( - &comet_client_address, - &selector!("consensus_state"), - &StarknetCairoEncoding.encode(&( - client_id.sequence, - Height { - revision_number: 0, - revision_height: 2, - }, - ))?, - ) - .await?; - - let raw_consensus_state: Vec = StarknetCairoEncoding.decode(&output)?; - - let consensus_state: CometConsensusState = - StarknetCairoEncoding.decode(&raw_consensus_state)?; + let consensus_state = >::query_consensus_state_with_latest_height( + chain, + &client_id, + &RelayerHeight::new(0, 2)?, + ) + .await?; println!("queried consensus state: {consensus_state:?}"); From ee9e762ca4cc47b2eb6fe2967d959edca700d804 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Fri, 25 Oct 2024 08:20:16 +0000 Subject: [PATCH 07/14] Prepare for adding Cosmos chain to test --- .../src/contexts/chain.rs | 1 + .../tests/ibc_client.rs | 24 ++++++++--------- relayer/crates/starknet-relayer/Cargo.toml | 26 +++++++++---------- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/relayer/crates/starknet-chain-context/src/contexts/chain.rs b/relayer/crates/starknet-chain-context/src/contexts/chain.rs index e7636398..809e29b5 100644 --- a/relayer/crates/starknet-chain-context/src/contexts/chain.rs +++ b/relayer/crates/starknet-chain-context/src/contexts/chain.rs @@ -214,6 +214,7 @@ pub trait CanUseCosmosChainWithStarknet: + CanBuildCreateClientMessage + CanBuildUpdateClientMessage + CanQueryConsensusStateHeight + + CanBuildCreateClientPayload { } diff --git a/relayer/crates/starknet-integration-tests/tests/ibc_client.rs b/relayer/crates/starknet-integration-tests/tests/ibc_client.rs index 3ebf0097..7a321e92 100644 --- a/relayer/crates/starknet-integration-tests/tests/ibc_client.rs +++ b/relayer/crates/starknet-integration-tests/tests/ibc_client.rs @@ -33,7 +33,7 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { let runtime = init_test_runtime(); runtime.runtime.clone().block_on(async move { - let chain_command_path = std::env::var("STARKNET_BIN") + let starknet_chain_command_path = std::env::var("STARKNET_BIN") .unwrap_or("starknet-devnet".into()) .into(); @@ -41,15 +41,15 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { .duration_since(SystemTime::UNIX_EPOCH)? .as_secs(); - let bootstrap = StarknetBootstrap { + let starknet_bootstrap = StarknetBootstrap { runtime: runtime.clone(), - chain_command_path, + chain_command_path: starknet_chain_command_path, chain_store_dir: format!("./test-data/{timestamp}").into(), }; - let mut chain_driver = bootstrap.bootstrap_chain("starknet").await?; + let mut starknet_chain_driver = starknet_bootstrap.bootstrap_chain("starknet").await?; - let chain = &mut chain_driver.chain; + let starknet_chain = &mut starknet_chain_driver.chain; let comet_client_class_hash = { let contract_path = std::env::var("COMET_CLIENT_CONTRACT")?; @@ -58,14 +58,14 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { let contract = serde_json::from_str(&contract_str)?; - let class_hash = chain.declare_contract(&contract).await?; + let class_hash = starknet_chain.declare_contract(&contract).await?; println!("declared class: {:?}", class_hash); class_hash }; - let comet_client_address = chain + let comet_client_address = starknet_chain .deploy_contract(&comet_client_class_hash, false, &Vec::new()) .await?; @@ -74,7 +74,7 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { comet_client_address ); - chain.ibc_client_contract_address = Some(comet_client_address); + starknet_chain.ibc_client_contract_address = Some(comet_client_address); let event_encoding = StarknetEventEncoding { erc20_hashes: Default::default(), @@ -118,7 +118,7 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { } }; - let events = chain.send_message(message).await?; + let events = starknet_chain.send_message(message).await?; let create_client_event: CreateClientEvent = event_encoding .filter_decode_events(&events)? @@ -159,7 +159,7 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { } }; - let events = chain.send_message(message).await?; + let events = starknet_chain.send_message(message).await?; println!("update client events: {:?}", events); } @@ -168,7 +168,7 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { let client_state = >::query_client_state_with_latest_height( - chain, &client_id + starknet_chain, &client_id ) .await?; @@ -179,7 +179,7 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { let consensus_state = >::query_consensus_state_with_latest_height( - chain, + starknet_chain, &client_id, &RelayerHeight::new(0, 2)?, ) diff --git a/relayer/crates/starknet-relayer/Cargo.toml b/relayer/crates/starknet-relayer/Cargo.toml index e96b4ce1..5416c415 100644 --- a/relayer/crates/starknet-relayer/Cargo.toml +++ b/relayer/crates/starknet-relayer/Cargo.toml @@ -10,18 +10,18 @@ rust-version = { workspace = true } readme = "README.md" [dependencies] -cgp = { workspace = true } -ibc = { workspace = true } -ibc-relayer-types = { workspace = true } -hermes-error = { workspace = true } -hermes-runtime = { workspace = true } -hermes-runtime-components = { workspace = true } -hermes-logging-components = { workspace = true } -hermes-encoding-components = { workspace = true } -hermes-logger = { workspace = true } -hermes-relayer-components = { workspace = true } -hermes-cosmos-relayer = { workspace = true } -hermes-starknet-chain-context = { workspace = true } -hermes-starknet-chain-components = { workspace = true } +cgp = { workspace = true } +ibc = { workspace = true } +ibc-relayer-types = { workspace = true } +hermes-error = { workspace = true } +hermes-runtime = { workspace = true } +hermes-runtime-components = { workspace = true } +hermes-logging-components = { workspace = true } +hermes-encoding-components = { workspace = true } +hermes-logger = { workspace = true } +hermes-relayer-components = { workspace = true } +hermes-cosmos-relayer = { workspace = true } +hermes-starknet-chain-context = { workspace = true } +hermes-starknet-chain-components = { workspace = true } eyre = { workspace = true } From a3c5d6b5df6d71edc7e24080817501659c17c0c9 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Fri, 25 Oct 2024 08:46:10 +0000 Subject: [PATCH 08/14] Use params from Cosmos chain for create and update client --- .../src/types/cosmos/height.rs | 2 +- .../tests/ibc_client.rs | 88 ++++++++++++++----- 2 files changed, 68 insertions(+), 22 deletions(-) diff --git a/relayer/crates/starknet-chain-components/src/types/cosmos/height.rs b/relayer/crates/starknet-chain-components/src/types/cosmos/height.rs index e1aa4a83..25a45842 100644 --- a/relayer/crates/starknet-chain-components/src/types/cosmos/height.rs +++ b/relayer/crates/starknet-chain-components/src/types/cosmos/height.rs @@ -8,7 +8,7 @@ use hermes_encoding_components::traits::encode_mut::MutEncoderComponent; use hermes_encoding_components::traits::transform::Transformer; use hermes_encoding_components::HList; -#[derive(Debug, HasField)] +#[derive(Debug, Clone, HasField)] pub struct Height { pub revision_number: u64, pub revision_height: u64, diff --git a/relayer/crates/starknet-integration-tests/tests/ibc_client.rs b/relayer/crates/starknet-integration-tests/tests/ibc_client.rs index 7a321e92..96f352ed 100644 --- a/relayer/crates/starknet-integration-tests/tests/ibc_client.rs +++ b/relayer/crates/starknet-integration-tests/tests/ibc_client.rs @@ -1,10 +1,19 @@ +#![recursion_limit = "256"] + +use core::time::Duration; +use std::env::var; +use std::path::PathBuf; +use std::sync::Arc; use std::time::{SystemTime, UNIX_EPOCH}; +use hermes_chain_components::traits::payload_builders::create_client::CanBuildCreateClientPayload; use hermes_chain_components::traits::queries::client_state::CanQueryClientStateWithLatestHeight; use hermes_chain_components::traits::queries::consensus_state::CanQueryConsensusStateWithLatestHeight; use hermes_chain_components::traits::send_message::CanSendSingleMessage; use hermes_cosmos_integration_tests::init::init_test_runtime; +use hermes_cosmos_relayer::contexts::build::CosmosBuilder; use hermes_cosmos_relayer::contexts::chain::CosmosChain; +use hermes_cosmos_wasm_relayer::context::cosmos_bootstrap::CosmosWithWasmClientBootstrap; use hermes_encoding_components::traits::encode::CanEncode; use hermes_encoding_components::HList; use hermes_error::types::Error; @@ -24,6 +33,8 @@ use hermes_starknet_chain_context::contexts::encoding::cairo::StarknetCairoEncod use hermes_starknet_chain_context::contexts::encoding::event::StarknetEventEncoding; use hermes_starknet_integration_tests::contexts::bootstrap::StarknetBootstrap; use hermes_test_components::bootstrap::traits::chain::CanBootstrapChain; +use ibc_relayer::chain::cosmos::client::Settings; +use ibc_relayer::config::types::TrustThreshold; use ibc_relayer_types::Height as RelayerHeight; use starknet::accounts::Call; use starknet::macros::{selector, short_string}; @@ -37,6 +48,10 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { .unwrap_or("starknet-devnet".into()) .into(); + let wasm_client_code_path = PathBuf::from( + var("STARKNET_WASM_CLIENT_PATH").expect("Wasm blob for Starknet light client is required"), + ); + let timestamp = SystemTime::now() .duration_since(SystemTime::UNIX_EPOCH)? .as_secs(); @@ -44,13 +59,34 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { let starknet_bootstrap = StarknetBootstrap { runtime: runtime.clone(), chain_command_path: starknet_chain_command_path, - chain_store_dir: format!("./test-data/{timestamp}").into(), + chain_store_dir: format!("./test-data/{timestamp}/starknet").into(), }; + let wasm_client_byte_code = tokio::fs::read(&wasm_client_code_path).await?; + + let cosmos_builder = Arc::new(CosmosBuilder::new_with_default(runtime.clone())); + + let cosmos_bootstrap = Arc::new(CosmosWithWasmClientBootstrap { + runtime: runtime.clone(), + builder: cosmos_builder, + should_randomize_identifiers: true, + chain_store_dir: format!("./test-data/{timestamp}/cosmos").into(), + chain_command_path: "simd".into(), + account_prefix: "cosmos".into(), + staking_denom: "stake".into(), + transfer_denom: "coin".into(), + wasm_client_byte_code, + governance_proposal_authority: "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn".into(), // TODO: don't hard code this + }); + let mut starknet_chain_driver = starknet_bootstrap.bootstrap_chain("starknet").await?; let starknet_chain = &mut starknet_chain_driver.chain; + let cosmos_chain_driver = cosmos_bootstrap.bootstrap_chain("cosmos").await?; + + let cosmos_chain = &cosmos_chain_driver.chain; + let comet_client_class_hash = { let contract_path = std::env::var("COMET_CLIENT_CONTRACT")?; @@ -82,24 +118,32 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { ibc_client_hashes: [comet_client_class_hash].into(), }; + let create_client_settings = Settings { + max_clock_drift: Duration::from_secs(40), + trusting_period: Some(Duration::from_secs(60 * 60)), + trust_threshold: TrustThreshold::ONE_THIRD, + }; + + let create_client_payload_1 = >::build_create_client_payload(cosmos_chain, &create_client_settings).await?; + + let height_1 = Height { + revision_number: create_client_payload_1.client_state.latest_height().revision_number(), + revision_height: create_client_payload_1.client_state.latest_height().revision_height(), + }; + let client_id = { let message = { let client_type = short_string!("07-cometbft"); - let height = Height { - revision_number: 0, - revision_height: 1, - }; - let client_state = CometClientState { - latest_height: height, - trusting_period: 3600, + latest_height: height_1.clone(), + trusting_period: create_client_payload_1.client_state.trusting_period.as_secs(), status: ClientStatus::Active, }; let consensus_state = CometConsensusState { - timestamp: SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs() - 10, - root: vec![1, 2, 3], + timestamp: create_client_payload_1.consensus_state.timestamp.unix_timestamp() as u64, + root: create_client_payload_1.consensus_state.root.into_vec(), }; let raw_client_state = StarknetCairoEncoding.encode(&client_state)?; @@ -133,19 +177,21 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { client_id }; + let create_client_payload_2 = >::build_create_client_payload(cosmos_chain, &create_client_settings).await?; + let updated_root = create_client_payload_2.consensus_state.root.into_vec(); + { let message = { + let height_2 = Height { + revision_number: create_client_payload_2.client_state.latest_height().revision_number(), + revision_height: create_client_payload_2.client_state.latest_height().revision_height(), + }; + let update_header = CometUpdateHeader { - trusted_height: Height { - revision_number: 0, - revision_height: 1, - }, - target_height: Height { - revision_number: 0, - revision_height: 2, - }, - time: SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs() - 10, - root: vec![4, 5, 6], + trusted_height: height_1, + target_height: height_2, + time: create_client_payload_1.consensus_state.timestamp.unix_timestamp() as u64, + root: updated_root.clone(), }; let raw_header = StarknetCairoEncoding.encode(&update_header)?; @@ -187,7 +233,7 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { println!("queried consensus state: {consensus_state:?}"); - assert_eq!(consensus_state.root, vec![4, 5, 6]); + assert_eq!(consensus_state.root, updated_root); } Ok(()) From d4c27e74555aac1f62ceec47ce3a13d7e4505506 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Fri, 25 Oct 2024 08:54:13 +0000 Subject: [PATCH 09/14] Fix query consensus state height --- .../tests/ibc_client.rs | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/relayer/crates/starknet-integration-tests/tests/ibc_client.rs b/relayer/crates/starknet-integration-tests/tests/ibc_client.rs index 96f352ed..d385e186 100644 --- a/relayer/crates/starknet-integration-tests/tests/ibc_client.rs +++ b/relayer/crates/starknet-integration-tests/tests/ibc_client.rs @@ -4,7 +4,7 @@ use core::time::Duration; use std::env::var; use std::path::PathBuf; use std::sync::Arc; -use std::time::{SystemTime, UNIX_EPOCH}; +use std::time::SystemTime; use hermes_chain_components::traits::payload_builders::create_client::CanBuildCreateClientPayload; use hermes_chain_components::traits::queries::client_state::CanQueryClientStateWithLatestHeight; @@ -35,7 +35,6 @@ use hermes_starknet_integration_tests::contexts::bootstrap::StarknetBootstrap; use hermes_test_components::bootstrap::traits::chain::CanBootstrapChain; use ibc_relayer::chain::cosmos::client::Settings; use ibc_relayer::config::types::TrustThreshold; -use ibc_relayer_types::Height as RelayerHeight; use starknet::accounts::Call; use starknet::macros::{selector, short_string}; @@ -131,6 +130,8 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { revision_height: create_client_payload_1.client_state.latest_height().revision_height(), }; + let root_1 = create_client_payload_1.consensus_state.root.into_vec(); + let client_id = { let message = { let client_type = short_string!("07-cometbft"); @@ -143,7 +144,7 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { let consensus_state = CometConsensusState { timestamp: create_client_payload_1.consensus_state.timestamp.unix_timestamp() as u64, - root: create_client_payload_1.consensus_state.root.into_vec(), + root: root_1.clone(), }; let raw_client_state = StarknetCairoEncoding.encode(&client_state)?; @@ -177,8 +178,23 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { client_id }; + { + let consensus_state = >::query_consensus_state_with_latest_height( + starknet_chain, + &client_id, + &create_client_payload_1.client_state.latest_height(), + ) + .await?; + + println!("queried consensus state: {consensus_state:?}"); + + assert_eq!(consensus_state.root, root_1); + } + let create_client_payload_2 = >::build_create_client_payload(cosmos_chain, &create_client_settings).await?; - let updated_root = create_client_payload_2.consensus_state.root.into_vec(); + let root_2 = create_client_payload_2.consensus_state.root.into_vec(); { let message = { @@ -190,8 +206,8 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { let update_header = CometUpdateHeader { trusted_height: height_1, target_height: height_2, - time: create_client_payload_1.consensus_state.timestamp.unix_timestamp() as u64, - root: updated_root.clone(), + time: create_client_payload_2.consensus_state.timestamp.unix_timestamp() as u64, + root: root_2.clone(), }; let raw_header = StarknetCairoEncoding.encode(&update_header)?; @@ -227,13 +243,13 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { >>::query_consensus_state_with_latest_height( starknet_chain, &client_id, - &RelayerHeight::new(0, 2)?, + &create_client_payload_2.client_state.latest_height(), ) .await?; println!("queried consensus state: {consensus_state:?}"); - assert_eq!(consensus_state.root, updated_root); + assert_eq!(consensus_state.root, root_2); } Ok(()) From 0ade3235fe13bad8ed179e9134afe5259462ab73 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Fri, 25 Oct 2024 09:31:18 +0000 Subject: [PATCH 10/14] Implement BuildCreateCometClientMessage --- .../src/components/chain.rs | 7 ++ .../src/impls/messages/create_client.rs | 90 +++++++++++++++++++ .../src/impls/messages/mod.rs | 1 + .../src/impls/mod.rs | 1 + .../src/contexts/chain.rs | 1 + 5 files changed, 100 insertions(+) create mode 100644 relayer/crates/starknet-chain-components/src/impls/messages/create_client.rs create mode 100644 relayer/crates/starknet-chain-components/src/impls/messages/mod.rs diff --git a/relayer/crates/starknet-chain-components/src/components/chain.rs b/relayer/crates/starknet-chain-components/src/components/chain.rs index e038d355..d8a50cc5 100644 --- a/relayer/crates/starknet-chain-components/src/components/chain.rs +++ b/relayer/crates/starknet-chain-components/src/components/chain.rs @@ -4,6 +4,7 @@ use cgp::prelude::*; pub use hermes_cosmos_chain_components::components::client::{ ChannelIdTypeComponent, ClientIdTypeComponent, ClientStateFieldsGetterComponent, ClientStateQuerierComponent, ConnectionIdTypeComponent, ConsensusStateQuerierComponent, + CreateClientMessageBuilderComponent, CreateClientMessageOptionsTypeComponent, CreateClientPayloadBuilderComponent, CreateClientPayloadOptionsTypeComponent, CreateClientPayloadTypeComponent, OutgoingPacketFieldsReaderComponent, OutgoingPacketTypeComponent, PortIdTypeComponent, SequenceTypeComponent, TimeTypeComponent, @@ -11,6 +12,7 @@ pub use hermes_cosmos_chain_components::components::client::{ }; use hermes_cosmos_chain_components::impls::packet::packet_fields::CosmosPacketFieldReader; use hermes_cosmos_chain_components::impls::types::chain::ProvideCosmosChainTypes; +use hermes_cosmos_chain_components::impls::types::create_client_options::ProvideNoCreateClientMessageOptionsType; pub use hermes_relayer_components::chain::traits::queries::chain_status::ChainStatusQuerierComponent; pub use hermes_relayer_components::chain::traits::send_message::MessageSenderComponent; pub use hermes_relayer_components::chain::traits::types::chain_id::ChainIdTypeComponent; @@ -42,6 +44,7 @@ use crate::impls::contract::declare::DeclareSierraContract; use crate::impls::contract::deploy::DeployStarknetContract; use crate::impls::contract::invoke::InvokeStarknetContract; use crate::impls::contract::message::BuildInvokeContractCall; +use crate::impls::messages::create_client::BuildCreateCometClientMessage; use crate::impls::payload_builders::create_client::BuildStarknetCreateClientPayload; use crate::impls::payload_builders::update_client::BuildStarknetUpdateClientPayload; use crate::impls::queries::client_state::QueryCometClientState; @@ -179,8 +182,12 @@ define_components! { TransferErc20Token, TokenBalanceQuerierComponent: QueryErc20TokenBalance, + CreateClientMessageOptionsTypeComponent: + ProvideNoCreateClientMessageOptionsType, CreateClientPayloadBuilderComponent: BuildStarknetCreateClientPayload, + CreateClientMessageBuilderComponent: + BuildCreateCometClientMessage, UpdateClientPayloadBuilderComponent: BuildStarknetUpdateClientPayload, ClientStateQuerierComponent: diff --git a/relayer/crates/starknet-chain-components/src/impls/messages/create_client.rs b/relayer/crates/starknet-chain-components/src/impls/messages/create_client.rs new file mode 100644 index 00000000..f1475574 --- /dev/null +++ b/relayer/crates/starknet-chain-components/src/impls/messages/create_client.rs @@ -0,0 +1,90 @@ +use core::marker::PhantomData; + +use cgp::prelude::*; +use hermes_cairo_encoding_components::strategy::ViaCairo; +use hermes_cairo_encoding_components::types::as_felt::AsFelt; +use hermes_chain_components::traits::message_builders::create_client::CreateClientMessageBuilder; +use hermes_chain_components::traits::types::create_client::{ + HasCreateClientMessageOptionsType, HasCreateClientPayloadType, +}; +use hermes_chain_components::traits::types::message::HasMessageType; +use hermes_chain_type_components::traits::types::address::HasAddressType; +use hermes_cosmos_chain_components::types::payloads::client::CosmosCreateClientPayload; +use hermes_encoding_components::traits::encode::CanEncode; +use hermes_encoding_components::traits::has_encoding::HasEncoding; +use hermes_encoding_components::traits::types::encoded::HasEncodedType; +use hermes_encoding_components::HList; +use starknet::accounts::Call; +use starknet::core::types::Felt; +use starknet::macros::{selector, short_string}; + +use crate::traits::queries::address::CanQueryContractAddress; +use crate::types::cosmos::client_state::{ClientStatus, CometClientState}; +use crate::types::cosmos::consensus_state::CometConsensusState; +use crate::types::cosmos::height::Height; + +pub struct BuildCreateCometClientMessage; + +impl CreateClientMessageBuilder + for BuildCreateCometClientMessage +where + Chain: HasCreateClientMessageOptionsType + + HasMessageType + + HasAddressType
+ + HasEncoding + + CanQueryContractAddress + + CanRaiseError, + Counterparty: + HasCreateClientPayloadType, + Encoding: HasEncodedType> + + CanEncode + + CanEncode + + CanEncode, Vec]>, +{ + async fn build_create_client_message( + chain: &Chain, + _options: &Chain::CreateClientMessageOptions, + payload: CosmosCreateClientPayload, + ) -> Result { + let encoding = chain.encoding(); + + let contract_address = chain.query_contract_address(PhantomData).await?; + + let height = Height { + revision_number: payload.client_state.latest_height().revision_number(), + revision_height: payload.client_state.latest_height().revision_height(), + }; + + let root = payload.consensus_state.root.into_vec(); + + let client_type = short_string!("07-cometbft"); + + let client_state = CometClientState { + latest_height: height, + trusting_period: payload.client_state.trusting_period.as_secs(), + status: ClientStatus::Active, + }; + + let consensus_state = CometConsensusState { + timestamp: payload.consensus_state.timestamp.unix_timestamp() as u64, + root, + }; + + let raw_client_state = encoding.encode(&client_state).map_err(Chain::raise_error)?; + let raw_consensus_state = encoding + .encode(&consensus_state) + .map_err(Chain::raise_error)?; + + let calldata = encoding + .encode(&HList![client_type, raw_client_state, raw_consensus_state]) + .map_err(Chain::raise_error)?; + + let call = Call { + to: contract_address, + selector: selector!("create_client"), + calldata, + }; + + Ok(call) + } +} diff --git a/relayer/crates/starknet-chain-components/src/impls/messages/mod.rs b/relayer/crates/starknet-chain-components/src/impls/messages/mod.rs new file mode 100644 index 00000000..49c233e5 --- /dev/null +++ b/relayer/crates/starknet-chain-components/src/impls/messages/mod.rs @@ -0,0 +1 @@ +pub mod create_client; diff --git a/relayer/crates/starknet-chain-components/src/impls/mod.rs b/relayer/crates/starknet-chain-components/src/impls/mod.rs index 67b07d84..d89a535b 100644 --- a/relayer/crates/starknet-chain-components/src/impls/mod.rs +++ b/relayer/crates/starknet-chain-components/src/impls/mod.rs @@ -2,6 +2,7 @@ pub mod account; pub mod contract; pub mod encoding; pub mod error; +pub mod messages; pub mod payload_builders; pub mod provider; pub mod queries; diff --git a/relayer/crates/starknet-chain-context/src/contexts/chain.rs b/relayer/crates/starknet-chain-context/src/contexts/chain.rs index 809e29b5..22879af2 100644 --- a/relayer/crates/starknet-chain-context/src/contexts/chain.rs +++ b/relayer/crates/starknet-chain-context/src/contexts/chain.rs @@ -195,6 +195,7 @@ pub trait CanUseStarknetChain: + CanTransferToken + HasRetryableError + CanBuildCreateClientPayload + // + CanBuildCreateClientMessage + CanBuildUpdateClientPayload + CanQueryClientState + CanQueryConsensusState From e61e3135a03d583637dc70df6bc82e66af33459f Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Fri, 25 Oct 2024 09:37:40 +0000 Subject: [PATCH 11/14] Use create client message builder in test --- .../tests/ibc_client.rs | 53 ++++--------------- 1 file changed, 11 insertions(+), 42 deletions(-) diff --git a/relayer/crates/starknet-integration-tests/tests/ibc_client.rs b/relayer/crates/starknet-integration-tests/tests/ibc_client.rs index d385e186..1aa5851c 100644 --- a/relayer/crates/starknet-integration-tests/tests/ibc_client.rs +++ b/relayer/crates/starknet-integration-tests/tests/ibc_client.rs @@ -6,6 +6,7 @@ use std::path::PathBuf; use std::sync::Arc; use std::time::SystemTime; +use hermes_chain_components::traits::message_builders::create_client::CanBuildCreateClientMessage; use hermes_chain_components::traits::payload_builders::create_client::CanBuildCreateClientPayload; use hermes_chain_components::traits::queries::client_state::CanQueryClientStateWithLatestHeight; use hermes_chain_components::traits::queries::consensus_state::CanQueryConsensusStateWithLatestHeight; @@ -15,16 +16,11 @@ use hermes_cosmos_relayer::contexts::build::CosmosBuilder; use hermes_cosmos_relayer::contexts::chain::CosmosChain; use hermes_cosmos_wasm_relayer::context::cosmos_bootstrap::CosmosWithWasmClientBootstrap; use hermes_encoding_components::traits::encode::CanEncode; -use hermes_encoding_components::HList; use hermes_error::types::Error; use hermes_runtime_components::traits::fs::read_file::CanReadFileAsString; use hermes_starknet_chain_components::impls::encoding::events::CanFilterDecodeEvents; use hermes_starknet_chain_components::traits::contract::declare::CanDeclareContract; use hermes_starknet_chain_components::traits::contract::deploy::CanDeployContract; -use hermes_starknet_chain_components::types::cosmos::client_state::{ - ClientStatus, CometClientState, -}; -use hermes_starknet_chain_components::types::cosmos::consensus_state::CometConsensusState; use hermes_starknet_chain_components::types::cosmos::height::Height; use hermes_starknet_chain_components::types::cosmos::update::CometUpdateHeader; use hermes_starknet_chain_components::types::events::create_client::CreateClientEvent; @@ -36,7 +32,7 @@ use hermes_test_components::bootstrap::traits::chain::CanBootstrapChain; use ibc_relayer::chain::cosmos::client::Settings; use ibc_relayer::config::types::TrustThreshold; use starknet::accounts::Call; -use starknet::macros::{selector, short_string}; +use starknet::macros::selector; #[test] fn test_starknet_comet_client_contract() -> Result<(), Error> { @@ -125,43 +121,13 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { let create_client_payload_1 = >::build_create_client_payload(cosmos_chain, &create_client_settings).await?; - let height_1 = Height { - revision_number: create_client_payload_1.client_state.latest_height().revision_number(), - revision_height: create_client_payload_1.client_state.latest_height().revision_height(), - }; + let height_1 = create_client_payload_1.client_state.latest_height(); - let root_1 = create_client_payload_1.consensus_state.root.into_vec(); + let root_1 = create_client_payload_1.consensus_state.root.clone().into_vec(); let client_id = { - let message = { - let client_type = short_string!("07-cometbft"); - - let client_state = CometClientState { - latest_height: height_1.clone(), - trusting_period: create_client_payload_1.client_state.trusting_period.as_secs(), - status: ClientStatus::Active, - }; - - let consensus_state = CometConsensusState { - timestamp: create_client_payload_1.consensus_state.timestamp.unix_timestamp() as u64, - root: root_1.clone(), - }; - - let raw_client_state = StarknetCairoEncoding.encode(&client_state)?; - let raw_consensus_state = StarknetCairoEncoding.encode(&consensus_state)?; - - let calldata = StarknetCairoEncoding.encode(&HList![ - client_type, - raw_client_state, - raw_consensus_state - ])?; - - Call { - to: comet_client_address, - selector: selector!("create_client"), - calldata, - } - }; + let message = > + ::build_create_client_message(starknet_chain, &(), create_client_payload_1).await?; let events = starknet_chain.send_message(message).await?; @@ -184,7 +150,7 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { >>::query_consensus_state_with_latest_height( starknet_chain, &client_id, - &create_client_payload_1.client_state.latest_height(), + &height_1, ) .await?; @@ -204,7 +170,10 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { }; let update_header = CometUpdateHeader { - trusted_height: height_1, + trusted_height: Height { + revision_number: height_1.revision_number(), + revision_height: height_1.revision_height(), + }, target_height: height_2, time: create_client_payload_2.consensus_state.timestamp.unix_timestamp() as u64, root: root_2.clone(), From 2a2d5d700b9b7dd30302b6d824d71265122de30c Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Fri, 25 Oct 2024 09:58:33 +0000 Subject: [PATCH 12/14] Pass tag paramter to query client/consensus-state --- relayer/Cargo.lock | 54 +++++++++---------- .../src/impls/queries/client_state.rs | 1 + .../src/impls/queries/consensus_state.rs | 1 + .../tests/ibc_client.rs | 19 +++---- .../tests/light_client.rs | 13 ++--- 5 files changed, 43 insertions(+), 45 deletions(-) diff --git a/relayer/Cargo.lock b/relayer/Cargo.lock index 6b371991..a064ad53 100644 --- a/relayer/Cargo.lock +++ b/relayer/Cargo.lock @@ -1757,7 +1757,7 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermes-any-counterparty" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", "cgp-error-eyre", @@ -1774,7 +1774,7 @@ dependencies = [ [[package]] name = "hermes-async-runtime-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "async-trait", "cgp", @@ -1797,7 +1797,7 @@ dependencies = [ [[package]] name = "hermes-chain-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", "hermes-chain-type-components", @@ -1808,7 +1808,7 @@ dependencies = [ [[package]] name = "hermes-chain-type-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", ] @@ -1816,7 +1816,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-chain-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "bech32 0.9.1", "cgp", @@ -1850,7 +1850,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", "hermes-encoding-components", @@ -1864,7 +1864,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-integration-tests" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", "eyre", @@ -1898,7 +1898,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-relayer" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", "eyre", @@ -1944,7 +1944,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-test-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", "hdpath", @@ -1969,7 +1969,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-wasm-relayer" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", "eyre", @@ -2021,7 +2021,7 @@ dependencies = [ [[package]] name = "hermes-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", ] @@ -2029,7 +2029,7 @@ dependencies = [ [[package]] name = "hermes-error" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", "eyre", @@ -2039,7 +2039,7 @@ dependencies = [ [[package]] name = "hermes-ibc-test-suite" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", "hermes-logging-components", @@ -2050,7 +2050,7 @@ dependencies = [ [[package]] name = "hermes-logger" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", "hermes-logging-components", @@ -2062,7 +2062,7 @@ dependencies = [ [[package]] name = "hermes-logging-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", ] @@ -2070,7 +2070,7 @@ dependencies = [ [[package]] name = "hermes-protobuf-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", "hermes-encoding-components", @@ -2081,7 +2081,7 @@ dependencies = [ [[package]] name = "hermes-relayer-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", "hermes-chain-components", @@ -2093,7 +2093,7 @@ dependencies = [ [[package]] name = "hermes-relayer-components-extra" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", "hermes-chain-type-components", @@ -2105,7 +2105,7 @@ dependencies = [ [[package]] name = "hermes-runtime" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", "hermes-async-runtime-components", @@ -2117,7 +2117,7 @@ dependencies = [ [[package]] name = "hermes-runtime-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", ] @@ -2253,7 +2253,7 @@ dependencies = [ [[package]] name = "hermes-test-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", "hermes-chain-type-components", @@ -2265,7 +2265,7 @@ dependencies = [ [[package]] name = "hermes-tokio-runtime-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", "futures", @@ -2279,7 +2279,7 @@ dependencies = [ [[package]] name = "hermes-tracing-logging-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", "hermes-logging-components", @@ -2291,7 +2291,7 @@ dependencies = [ [[package]] name = "hermes-wasm-client-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", "cgp-error-eyre", @@ -2311,7 +2311,7 @@ dependencies = [ [[package]] name = "hermes-wasm-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", "hermes-cosmos-encoding-components", @@ -2325,7 +2325,7 @@ dependencies = [ [[package]] name = "hermes-wasm-test-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#3440bd74513d323a280eced340b4618ae6b639f6" +source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" dependencies = [ "cgp", "cgp-error-eyre", @@ -4103,7 +4103,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" dependencies = [ "anyhow", - "itertools 0.12.1", + "itertools 0.13.0", "proc-macro2", "quote", "syn 2.0.82", diff --git a/relayer/crates/starknet-chain-components/src/impls/queries/client_state.rs b/relayer/crates/starknet-chain-components/src/impls/queries/client_state.rs index 749a83d9..89ac655d 100644 --- a/relayer/crates/starknet-chain-components/src/impls/queries/client_state.rs +++ b/relayer/crates/starknet-chain-components/src/impls/queries/client_state.rs @@ -42,6 +42,7 @@ where { async fn query_client_state( chain: &Chain, + _tag: PhantomData, client_id: &Chain::ClientId, _height: &Chain::Height, // TODO: figure whether we can perform height specific queries on Starknet ) -> Result { diff --git a/relayer/crates/starknet-chain-components/src/impls/queries/consensus_state.rs b/relayer/crates/starknet-chain-components/src/impls/queries/consensus_state.rs index a9c90d83..560d458d 100644 --- a/relayer/crates/starknet-chain-components/src/impls/queries/consensus_state.rs +++ b/relayer/crates/starknet-chain-components/src/impls/queries/consensus_state.rs @@ -44,6 +44,7 @@ where { async fn query_consensus_state( chain: &Chain, + _tag: PhantomData, client_id: &Chain::ClientId, consensus_height: &Counterparty::Height, _query_height: &Chain::Height, // TODO: figure whether we can perform height specific queries on Starknet diff --git a/relayer/crates/starknet-integration-tests/tests/ibc_client.rs b/relayer/crates/starknet-integration-tests/tests/ibc_client.rs index 1aa5851c..35e1e3cc 100644 --- a/relayer/crates/starknet-integration-tests/tests/ibc_client.rs +++ b/relayer/crates/starknet-integration-tests/tests/ibc_client.rs @@ -1,5 +1,6 @@ #![recursion_limit = "256"] +use core::marker::PhantomData; use core::time::Duration; use std::env::var; use std::path::PathBuf; @@ -145,10 +146,8 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { }; { - let consensus_state = >::query_consensus_state_with_latest_height( - starknet_chain, + let consensus_state = starknet_chain.query_consensus_state_with_latest_height( + PhantomData::, &client_id, &height_1, ) @@ -196,10 +195,8 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { } { - let client_state = >::query_client_state_with_latest_height( - starknet_chain, &client_id + let client_state = starknet_chain.query_client_state_with_latest_height( + PhantomData::, &client_id ) .await?; @@ -207,10 +204,8 @@ fn test_starknet_comet_client_contract() -> Result<(), Error> { } { - let consensus_state = >::query_consensus_state_with_latest_height( - starknet_chain, + let consensus_state = starknet_chain.query_consensus_state_with_latest_height( + PhantomData::, &client_id, &create_client_payload_2.client_state.latest_height(), ) diff --git a/relayer/crates/starknet-integration-tests/tests/light_client.rs b/relayer/crates/starknet-integration-tests/tests/light_client.rs index 57c4cd6a..a4ab039a 100644 --- a/relayer/crates/starknet-integration-tests/tests/light_client.rs +++ b/relayer/crates/starknet-integration-tests/tests/light_client.rs @@ -1,5 +1,6 @@ #![recursion_limit = "256"] +use core::marker::PhantomData; use std::env::var; use std::path::PathBuf; use std::sync::Arc; @@ -126,8 +127,8 @@ fn test_starknet_light_client() -> Result<(), Error> { { let client_state = - >::query_client_state( - cosmos_chain, + cosmos_chain.query_client_state( + PhantomData::, &client_id, &cosmos_chain.query_chain_height().await?, ) @@ -136,8 +137,8 @@ fn test_starknet_light_client() -> Result<(), Error> { let client_height = client_state.client_state.latest_height.revision_height(); let consensus_state = - >::query_consensus_state( - cosmos_chain, + cosmos_chain.query_consensus_state( + PhantomData::, &client_id, &client_height, &cosmos_chain.query_chain_height().await?, @@ -167,8 +168,8 @@ fn test_starknet_light_client() -> Result<(), Error> { .await?; let consensus_state = - >::query_consensus_state( - cosmos_chain, + cosmos_chain.query_consensus_state( + PhantomData::, &client_id, &starknet_status.height, &cosmos_chain.query_chain_height().await?, From fee07b91d72bdc40224a064c4253574701b539af Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Fri, 25 Oct 2024 10:03:26 +0000 Subject: [PATCH 13/14] Put tests inside crate to reduce compile time --- relayer/crates/starknet-integration-tests/src/lib.rs | 5 +++++ .../starknet-integration-tests/{ => src}/tests/erc20.rs | 3 ++- .../starknet-integration-tests/{ => src}/tests/ibc_client.rs | 5 ++--- .../starknet-integration-tests/{ => src}/tests/ics20.rs | 3 ++- .../{ => src}/tests/light_client.rs | 5 ++--- relayer/crates/starknet-integration-tests/src/tests/mod.rs | 4 ++++ 6 files changed, 17 insertions(+), 8 deletions(-) rename relayer/crates/starknet-integration-tests/{ => src}/tests/erc20.rs (98%) rename relayer/crates/starknet-integration-tests/{ => src}/tests/ibc_client.rs (98%) rename relayer/crates/starknet-integration-tests/{ => src}/tests/ics20.rs (99%) rename relayer/crates/starknet-integration-tests/{ => src}/tests/light_client.rs (99%) create mode 100644 relayer/crates/starknet-integration-tests/src/tests/mod.rs diff --git a/relayer/crates/starknet-integration-tests/src/lib.rs b/relayer/crates/starknet-integration-tests/src/lib.rs index 0f9779b8..4c4e8044 100644 --- a/relayer/crates/starknet-integration-tests/src/lib.rs +++ b/relayer/crates/starknet-integration-tests/src/lib.rs @@ -1 +1,6 @@ +#![recursion_limit = "256"] + pub mod contexts; + +#[cfg(test)] +pub mod tests; diff --git a/relayer/crates/starknet-integration-tests/tests/erc20.rs b/relayer/crates/starknet-integration-tests/src/tests/erc20.rs similarity index 98% rename from relayer/crates/starknet-integration-tests/tests/erc20.rs rename to relayer/crates/starknet-integration-tests/src/tests/erc20.rs index 58f3b48a..70952af0 100644 --- a/relayer/crates/starknet-integration-tests/tests/erc20.rs +++ b/relayer/crates/starknet-integration-tests/src/tests/erc20.rs @@ -15,9 +15,10 @@ use hermes_starknet_chain_components::types::events::erc20::Erc20Event; use hermes_starknet_chain_components::types::messages::erc20::deploy::DeployErc20TokenMessage; use hermes_starknet_chain_context::contexts::encoding::cairo::StarknetCairoEncoding; use hermes_starknet_chain_context::contexts::encoding::event::StarknetEventEncoding; -use hermes_starknet_integration_tests::contexts::bootstrap::StarknetBootstrap; use hermes_test_components::bootstrap::traits::chain::CanBootstrapChain; +use crate::contexts::bootstrap::StarknetBootstrap; + #[test] fn test_erc20_transfer() -> Result<(), Error> { let runtime = init_test_runtime(); diff --git a/relayer/crates/starknet-integration-tests/tests/ibc_client.rs b/relayer/crates/starknet-integration-tests/src/tests/ibc_client.rs similarity index 98% rename from relayer/crates/starknet-integration-tests/tests/ibc_client.rs rename to relayer/crates/starknet-integration-tests/src/tests/ibc_client.rs index 35e1e3cc..5a454a3b 100644 --- a/relayer/crates/starknet-integration-tests/tests/ibc_client.rs +++ b/relayer/crates/starknet-integration-tests/src/tests/ibc_client.rs @@ -1,5 +1,3 @@ -#![recursion_limit = "256"] - use core::marker::PhantomData; use core::time::Duration; use std::env::var; @@ -28,13 +26,14 @@ use hermes_starknet_chain_components::types::events::create_client::CreateClient use hermes_starknet_chain_context::contexts::chain::StarknetChain; use hermes_starknet_chain_context::contexts::encoding::cairo::StarknetCairoEncoding; use hermes_starknet_chain_context::contexts::encoding::event::StarknetEventEncoding; -use hermes_starknet_integration_tests::contexts::bootstrap::StarknetBootstrap; use hermes_test_components::bootstrap::traits::chain::CanBootstrapChain; use ibc_relayer::chain::cosmos::client::Settings; use ibc_relayer::config::types::TrustThreshold; use starknet::accounts::Call; use starknet::macros::selector; +use crate::contexts::bootstrap::StarknetBootstrap; + #[test] fn test_starknet_comet_client_contract() -> Result<(), Error> { let runtime = init_test_runtime(); diff --git a/relayer/crates/starknet-integration-tests/tests/ics20.rs b/relayer/crates/starknet-integration-tests/src/tests/ics20.rs similarity index 99% rename from relayer/crates/starknet-integration-tests/tests/ics20.rs rename to relayer/crates/starknet-integration-tests/src/tests/ics20.rs index 1a9dc55a..f5cad420 100644 --- a/relayer/crates/starknet-integration-tests/tests/ics20.rs +++ b/relayer/crates/starknet-integration-tests/src/tests/ics20.rs @@ -19,11 +19,12 @@ use hermes_starknet_chain_components::types::messages::ibc::ibc_transfer::{ use hermes_starknet_chain_components::types::messages::ibc::packet::Packet; use hermes_starknet_chain_context::contexts::encoding::cairo::StarknetCairoEncoding; use hermes_starknet_chain_context::contexts::encoding::event::StarknetEventEncoding; -use hermes_starknet_integration_tests::contexts::bootstrap::StarknetBootstrap; use hermes_test_components::bootstrap::traits::chain::CanBootstrapChain; use starknet::accounts::Call; use starknet::macros::selector; +use crate::contexts::bootstrap::StarknetBootstrap; + #[test] fn test_starknet_ics20_contract() -> Result<(), Error> { let runtime = init_test_runtime(); diff --git a/relayer/crates/starknet-integration-tests/tests/light_client.rs b/relayer/crates/starknet-integration-tests/src/tests/light_client.rs similarity index 99% rename from relayer/crates/starknet-integration-tests/tests/light_client.rs rename to relayer/crates/starknet-integration-tests/src/tests/light_client.rs index a4ab039a..96319b2e 100644 --- a/relayer/crates/starknet-integration-tests/tests/light_client.rs +++ b/relayer/crates/starknet-integration-tests/src/tests/light_client.rs @@ -1,5 +1,3 @@ -#![recursion_limit = "256"] - use core::marker::PhantomData; use std::env::var; use std::path::PathBuf; @@ -34,7 +32,6 @@ use hermes_runtime_components::traits::sleep::CanSleep; use hermes_starknet_chain_components::types::client_id::ClientId as StarknetClientId; use hermes_starknet_chain_components::types::payloads::client::StarknetCreateClientPayloadOptions; use hermes_starknet_chain_context::contexts::chain::StarknetChain; -use hermes_starknet_integration_tests::contexts::bootstrap::StarknetBootstrap; use hermes_starknet_relayer::contexts::starknet_to_cosmos_relay::StarknetToCosmosRelay; use hermes_test_components::bootstrap::traits::chain::CanBootstrapChain; use hermes_test_components::chain_driver::traits::types::chain::HasChain; @@ -48,6 +45,8 @@ use ibc_relayer_types::Height; use sha2::{Digest, Sha256}; use starknet::macros::short_string; +use crate::contexts::bootstrap::StarknetBootstrap; + #[test] fn test_starknet_light_client() -> Result<(), Error> { let runtime = init_test_runtime(); diff --git a/relayer/crates/starknet-integration-tests/src/tests/mod.rs b/relayer/crates/starknet-integration-tests/src/tests/mod.rs new file mode 100644 index 00000000..255a6f7a --- /dev/null +++ b/relayer/crates/starknet-integration-tests/src/tests/mod.rs @@ -0,0 +1,4 @@ +pub mod erc20; +pub mod ibc_client; +pub mod ics20; +pub mod light_client; From b73fe9c801e73b24a53655cf9225c4cf78f81688 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Fri, 25 Oct 2024 11:09:44 +0000 Subject: [PATCH 14/14] Use back main branch --- light-client/Cargo.lock | 17 ++---- relayer/Cargo.lock | 52 +++++++++---------- relayer/Cargo.toml | 52 +++++++++---------- .../src/components/chain.rs | 4 +- 4 files changed, 58 insertions(+), 67 deletions(-) diff --git a/light-client/Cargo.lock b/light-client/Cargo.lock index ebbe61f2..dfc54e99 100644 --- a/light-client/Cargo.lock +++ b/light-client/Cargo.lock @@ -1004,7 +1004,7 @@ checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" [[package]] name = "hermes-cosmos-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", "hermes-encoding-components", @@ -1018,7 +1018,7 @@ dependencies = [ [[package]] name = "hermes-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", ] @@ -1026,7 +1026,7 @@ dependencies = [ [[package]] name = "hermes-protobuf-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git#77bea854d6472e188644a1aa174131f21164a6f5" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", "hermes-encoding-components", @@ -1613,15 +1613,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.11" @@ -1850,7 +1841,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" dependencies = [ "anyhow", - "itertools 0.13.0", + "itertools 0.10.5", "proc-macro2", "quote", "syn 2.0.82", diff --git a/relayer/Cargo.lock b/relayer/Cargo.lock index a064ad53..939cc0e7 100644 --- a/relayer/Cargo.lock +++ b/relayer/Cargo.lock @@ -1757,7 +1757,7 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermes-any-counterparty" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", "cgp-error-eyre", @@ -1774,7 +1774,7 @@ dependencies = [ [[package]] name = "hermes-async-runtime-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "async-trait", "cgp", @@ -1797,7 +1797,7 @@ dependencies = [ [[package]] name = "hermes-chain-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", "hermes-chain-type-components", @@ -1808,7 +1808,7 @@ dependencies = [ [[package]] name = "hermes-chain-type-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", ] @@ -1816,7 +1816,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-chain-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "bech32 0.9.1", "cgp", @@ -1850,7 +1850,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", "hermes-encoding-components", @@ -1864,7 +1864,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-integration-tests" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", "eyre", @@ -1898,7 +1898,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-relayer" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", "eyre", @@ -1944,7 +1944,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-test-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", "hdpath", @@ -1969,7 +1969,7 @@ dependencies = [ [[package]] name = "hermes-cosmos-wasm-relayer" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", "eyre", @@ -2021,7 +2021,7 @@ dependencies = [ [[package]] name = "hermes-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", ] @@ -2029,7 +2029,7 @@ dependencies = [ [[package]] name = "hermes-error" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", "eyre", @@ -2039,7 +2039,7 @@ dependencies = [ [[package]] name = "hermes-ibc-test-suite" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", "hermes-logging-components", @@ -2050,7 +2050,7 @@ dependencies = [ [[package]] name = "hermes-logger" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", "hermes-logging-components", @@ -2062,7 +2062,7 @@ dependencies = [ [[package]] name = "hermes-logging-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", ] @@ -2070,7 +2070,7 @@ dependencies = [ [[package]] name = "hermes-protobuf-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", "hermes-encoding-components", @@ -2081,7 +2081,7 @@ dependencies = [ [[package]] name = "hermes-relayer-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", "hermes-chain-components", @@ -2093,7 +2093,7 @@ dependencies = [ [[package]] name = "hermes-relayer-components-extra" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", "hermes-chain-type-components", @@ -2105,7 +2105,7 @@ dependencies = [ [[package]] name = "hermes-runtime" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", "hermes-async-runtime-components", @@ -2117,7 +2117,7 @@ dependencies = [ [[package]] name = "hermes-runtime-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", ] @@ -2253,7 +2253,7 @@ dependencies = [ [[package]] name = "hermes-test-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", "hermes-chain-type-components", @@ -2265,7 +2265,7 @@ dependencies = [ [[package]] name = "hermes-tokio-runtime-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", "futures", @@ -2279,7 +2279,7 @@ dependencies = [ [[package]] name = "hermes-tracing-logging-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", "hermes-logging-components", @@ -2291,7 +2291,7 @@ dependencies = [ [[package]] name = "hermes-wasm-client-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", "cgp-error-eyre", @@ -2311,7 +2311,7 @@ dependencies = [ [[package]] name = "hermes-wasm-encoding-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", "hermes-cosmos-encoding-components", @@ -2325,7 +2325,7 @@ dependencies = [ [[package]] name = "hermes-wasm-test-components" version = "0.1.0" -source = "git+https://github.com/informalsystems/hermes-sdk.git?branch=soares/delegate-client-state#ca22dfff24dd2b6f355566c8af3470334e228cc7" +source = "git+https://github.com/informalsystems/hermes-sdk.git#621b45a59cba6982a2141327ea58ffacbc491b27" dependencies = [ "cgp", "cgp-error-eyre", diff --git a/relayer/Cargo.toml b/relayer/Cargo.toml index f6056337..0c456121 100644 --- a/relayer/Cargo.toml +++ b/relayer/Cargo.toml @@ -116,29 +116,29 @@ cgp-error = { git = "https://github.com/contextgeneric/cgp.git" } cgp-run = { git = "https://github.com/contextgeneric/cgp.git" } cgp-inner = { git = "https://github.com/contextgeneric/cgp.git" } -hermes-chain-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-chain-type-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-relayer-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-relayer-components-extra = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-runtime-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-async-runtime-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-tokio-runtime-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-runtime = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-error = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-encoding-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-protobuf-encoding-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-logging-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-tracing-logging-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-logger = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-test-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-ibc-test-suite = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-any-counterparty = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-cosmos-chain-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-cosmos-relayer = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-cosmos-wasm-relayer = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-cosmos-test-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-cosmos-encoding-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-cosmos-integration-tests = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-wasm-test-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-wasm-client-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } -hermes-wasm-encoding-components = { git = "https://github.com/informalsystems/hermes-sdk.git", branch = "soares/delegate-client-state" } +hermes-chain-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-chain-type-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-relayer-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-relayer-components-extra = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-runtime-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-async-runtime-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-tokio-runtime-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-runtime = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-error = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-encoding-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-protobuf-encoding-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-logging-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-tracing-logging-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-logger = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-test-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-ibc-test-suite = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-any-counterparty = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-cosmos-chain-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-cosmos-relayer = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-cosmos-wasm-relayer = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-cosmos-test-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-cosmos-encoding-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-cosmos-integration-tests = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-wasm-test-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-wasm-client-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } +hermes-wasm-encoding-components = { git = "https://github.com/informalsystems/hermes-sdk.git" } diff --git a/relayer/crates/starknet-chain-components/src/components/chain.rs b/relayer/crates/starknet-chain-components/src/components/chain.rs index d8a50cc5..8909a1fa 100644 --- a/relayer/crates/starknet-chain-components/src/components/chain.rs +++ b/relayer/crates/starknet-chain-components/src/components/chain.rs @@ -2,7 +2,7 @@ use cgp::core::component::WithProvider; use cgp::core::types::impls::UseDelegatedType; use cgp::prelude::*; pub use hermes_cosmos_chain_components::components::client::{ - ChannelIdTypeComponent, ClientIdTypeComponent, ClientStateFieldsGetterComponent, + ChannelIdTypeComponent, ClientIdTypeComponent, ClientStateFieldsComponent, ClientStateQuerierComponent, ConnectionIdTypeComponent, ConsensusStateQuerierComponent, CreateClientMessageBuilderComponent, CreateClientMessageOptionsTypeComponent, CreateClientPayloadBuilderComponent, CreateClientPayloadOptionsTypeComponent, @@ -141,7 +141,7 @@ define_components! { [ ClientStateTypeComponent, ConsensusStateTypeComponent, - ClientStateFieldsGetterComponent, + ClientStateFieldsComponent, ]: ProvideStarknetIbcClientTypes, [