Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: Cosmos SDK Module #5370

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions rust/main/Cargo.lock

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

15 changes: 1 addition & 14 deletions rust/main/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"agents/scraper",
"agents/validator",
"chains/hyperlane-cosmos",
"chains/hyperlane-cosmos-native",
"chains/hyperlane-ethereum",
"chains/hyperlane-fuel",
"chains/hyperlane-sealevel",
Expand Down Expand Up @@ -40,7 +41,6 @@ bincode = "1.3"
borsh = "0.9"
bs58 = "0.5.0"
bytes = "1"
clap = "4"
chrono = "*"
color-eyre = "0.6"
config = "0.13.3"
Expand All @@ -55,7 +55,6 @@ cosmrs = { version = "0.21.0", default-features = false, features = [
cosmwasm-std = "*"
crunchy = "0.2"
ctrlc = "3.2"
curve25519-dalek = { version = "~3.2", features = ["serde"] }
derive-new = "0.5"
derive_builder = "0.12"
derive_more = "0.99"
Expand All @@ -67,7 +66,6 @@ fuels = "0.65.0"
fuels-code-gen = "0.65.0"
futures = "0.3"
futures-util = "0.3"
generic-array = { version = "0.14", features = ["serde", "more_lengths"] }
# Required for WASM support https://docs.rs/getrandom/latest/getrandom/#webassembly-support
bech32 = "0.11.0"
elliptic-curve = "0.13.8"
Expand Down Expand Up @@ -97,15 +95,13 @@ num-traits = "0.2"
once_cell = "1.18.0"
parking_lot = "0.12"
paste = "1.0"
pretty_env_logger = "0.5.0"
primitive-types = "=0.12.1"
prometheus = "0.13"
protobuf = "*"
rand = "0.8.5"
regex = "1.5"
reqwest = "0.11"
ripemd = "0.1.3"
rlp = "=0.5.2"
rocksdb = "0.21.0"
sea-orm = { version = "0.11.1", features = [
"sqlx-postgres",
Expand All @@ -118,10 +114,7 @@ sea-orm-migration = { version = "0.11.1", features = [
"sqlx-postgres",
"runtime-tokio-native-tls",
] }
semver = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_bytes = "0.11"
serde_derive = "1.0"
serde_json = "1.0"
sha2 = { version = "0.10.6", default-features = false }
sha256 = "1.1.4"
Expand Down Expand Up @@ -163,15 +156,9 @@ ya-gcp = { version = "0.11.3", features = ["storage"] }
## TODO: remove this
cosmwasm-schema = "2.2.0"

[profile.release.package.access-control]
overflow-checks = true

[profile.release.package.account-utils]
overflow-checks = true

[profile.release.package.ecdsa-signature]
overflow-checks = true

[profile.release.package.hyperlane-sealevel-interchain-security-module-interface]
overflow-checks = true

Expand Down
1 change: 1 addition & 0 deletions rust/main/agents/relayer/src/msg/metadata/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ impl MessageMetadataBuilder {
.module_type()
.await
.context("When fetching module type")?;

let cloned = self.clone_with_incremented_depth()?;

let metadata_builder: Box<dyn MetadataBuilder> = match module_type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,22 @@ const DOMAINS: &[RawDomain] = &[
is_test_net: true,
is_deprecated: false,
},
RawDomain {
name: "cosmostestnative1",
token: "KYVE",
domain: 75898670,
chain_id: 75898670,
is_test_net: true,
is_deprecated: false,
},
RawDomain {
name: "cosmostestnative2",
token: "KYVE",
domain: 75898671,
chain_id: 75898671,
is_test_net: true,
is_deprecated: false,
},
// ---------- End: E2E tests chains ----------------
];

Expand Down
43 changes: 43 additions & 0 deletions rust/main/chains/hyperlane-cosmos-native/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

[package]
name = "hyperlane-cosmos-native"
documentation = { workspace = true }
edition = { workspace = true }
homepage = { workspace = true }
license-file = { workspace = true }
publish = { workspace = true }
version = { workspace = true }

[dependencies]
async-trait = { workspace = true }
base64 = { workspace = true }
bech32 = { workspace = true }
cosmrs = { workspace = true, features = ["tokio", "grpc", "rpc"] }
crypto = { path = "../../utils/crypto" }
derive-new = { workspace = true }
futures = { workspace = true }
hex = { workspace = true }
http = { workspace = true }
hyperlane-core = { path = "../../hyperlane-core", features = ["async"] }
hyperlane-cosmwasm-interface.workspace = true
hyper = { workspace = true }
hyper-tls = { workspace = true }
itertools = { workspace = true }
once_cell = { workspace = true }
protobuf = { workspace = true }
ripemd = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
sha2 = { workspace = true }
sha256 = { workspace = true }
tendermint = { workspace = true, features = ["rust-crypto", "secp256k1"] }
tendermint-rpc = { workspace = true }
time = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
reqwest = { workspace = true, features = ["json"] }
tonic = { workspace = true, features = ["transport", "tls", "tls-roots"] }
tracing = { workspace = true }
tracing-futures = { workspace = true }
url = { workspace = true }
prost = "0.13.4"
95 changes: 95 additions & 0 deletions rust/main/chains/hyperlane-cosmos-native/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
use std::fmt::Debug;

use cosmrs::proto::prost;

use crypto::PublicKeyError;
use hyperlane_core::ChainCommunicationError;

/// Errors from the crates specific to the hyperlane-cosmos
/// implementation.
/// This error can then be converted into the broader error type
/// in hyperlane-core using the `From` trait impl
#[derive(Debug, thiserror::Error)]
pub enum HyperlaneCosmosError {
/// base64 error
#[error("{0}")]
Base64(#[from] base64::DecodeError),
/// bech32 decode error
#[error("{0}")]
Bech32Decode(#[from] bech32::DecodeError),
/// bech32 encode error
#[error("{0}")]
Bech32Encode(#[from] bech32::EncodeError),
/// gRPC error
#[error("{0}")]
GrpcError(#[from] tonic::Status),
/// Cosmos error
#[error("{0}")]
CosmosError(#[from] cosmrs::Error),
/// Cosmos error report
#[error("{0}")]
CosmosErrorReport(#[from] cosmrs::ErrorReport),
/// Cosmrs Tendermint Error
#[error("{0}")]
CosmrsTendermintError(#[from] cosmrs::tendermint::Error),
/// Tonic error
#[error("{0}")]
Tonic(#[from] tonic::transport::Error),
/// Tonic codegen error
#[error("{0}")]
TonicGenError(#[from] tonic::codegen::StdError),
/// Tendermint RPC Error
#[error(transparent)]
TendermintRpcError(#[from] tendermint_rpc::error::Error),
/// Prost error
#[error("{0}")]
Prost(#[from] prost::DecodeError),
/// Protobuf error
#[error("{0}")]
Protobuf(#[from] protobuf::ProtobufError),
/// Fallback providers failed
#[error("Fallback providers failed. (Errors: {0:?})")]
FallbackProvidersFailed(Vec<HyperlaneCosmosError>),
/// Public key error
#[error("{0}")]
PublicKeyError(String),
/// Address error
#[error("{0}")]
AddressError(String),
/// Signer info error
#[error("{0}")]
SignerInfoError(String),
/// Serde error
#[error("{0}")]
SerdeError(#[from] serde_json::Error),
/// Empty error
#[error("{0}")]
UnparsableEmptyField(String),
/// Parsing error
#[error("{0}")]
ParsingFailed(String),
/// Parsing attempt failed
#[error("Parsing attempt failed. (Errors: {0:?})")]
ParsingAttemptsFailed(Vec<HyperlaneCosmosError>),
/// Reqwest Error
#[error("{0}")]
ReqwestError(reqwest::Error),
}

impl From<HyperlaneCosmosError> for ChainCommunicationError {
fn from(value: HyperlaneCosmosError) -> Self {
ChainCommunicationError::from_other(value)
}
}

impl From<PublicKeyError> for HyperlaneCosmosError {
fn from(value: PublicKeyError) -> Self {
HyperlaneCosmosError::PublicKeyError(value.to_string())
}
}

impl From<reqwest::Error> for HyperlaneCosmosError {
fn from(value: reqwest::Error) -> Self {
HyperlaneCosmosError::ReqwestError(value)
}
}
11 changes: 11 additions & 0 deletions rust/main/chains/hyperlane-cosmos-native/src/indexers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
mod delivery;
mod dispatch;
mod gas_paymaster;
mod indexer;
mod tree_insertion;

pub use delivery::*;
pub use dispatch::*;
pub use gas_paymaster::*;
pub use indexer::*;
pub use tree_insertion::*;
Loading