diff --git a/rust/agents/validator/src/validator.rs b/rust/agents/validator/src/validator.rs index e70a50a69f..bc9ba325b4 100644 --- a/rust/agents/validator/src/validator.rs +++ b/rust/agents/validator/src/validator.rs @@ -308,73 +308,3 @@ impl Validator { Ok(()) } } - -#[cfg(test)] -mod test { - use std::str::FromStr; - - use ethers::{ - signers::Wallet, - utils::{self}, - }; - use hyperlane_core::{Announcement, HyperlaneSigner, Signable, H256}; - use hyperlane_ethereum::Signers; - use k256::ecdsa::SigningKey; - - #[tokio::test] - async fn sign_manual() -> eyre::Result<()> { - let test_key = "45bde72a537e11d1cef58836d9278268fd393c0400852ce045fc0c2de7bbe90d"; - - let cases = [( - "0xf9e25a6be80f6d48727e42381fc3c3b7834c0cb4", - "0xcb4530690c80917c7e412498e7258fff4569857b2aae8e020091cf2d75730656", - 26657, - "file:///var/folders/3v/g38z040x54x8l6b160vv66b40000gn/T/.tmpY4ofw1/checkpoint", - )]; - - let to_announcement = |c: (&str, &str, u32, &str)| -> eyre::Result { - let validator = hyperlane_core::H160::from_str(c.0)?; - let mailbox_address = hyperlane_core::H256::from_str(c.1)?; - let mailbox_domain = c.2; - let storage_location = c.3.to_string(); - - Ok(Announcement { - validator, - mailbox_address, - mailbox_domain, - storage_location, - }) - }; - - for c in cases { - let announcement = to_announcement(c)?; - let hash = announcement.signing_hash(); - - // eth sign - let eth_signer = Signers::Local(Wallet::from_str(test_key)?); - let eth_sign = eth_signer.sign_hash(&hash).await?; - let eth_sign_raw = eth_sign.to_vec(); - - // raw sign - let cosmos_sign_raw = { - let signing_key = - SigningKey::from_bytes(H256::from_str(test_key)?.as_bytes().into())?; - - let message = hash.as_ref(); - let message_hash = utils::hash_message(message); // ERC-191 - - let (sign, recov) = - signing_key.sign_prehash_recoverable(message_hash.as_bytes())?; - - let mut sign_raw = sign.to_vec(); - sign_raw.push(recov.to_byte() + 27); // ERC-155 - - sign_raw - }; - - assert_eq!(eth_sign_raw, cosmos_sign_raw); - } - - Ok(()) - } -} diff --git a/rust/build b/rust/build deleted file mode 100755 index 807b06cac6..0000000000 --- a/rust/build +++ /dev/null @@ -1,20 +0,0 @@ -TAG=$1 -USE_DEFAULT_PLATFORM=$2 -if [[ -z $TAG ]]; then - TAG="sha-$(git rev-parse --short HEAD)" - echo "Defaulting to tag $TAG" - - if [[ ! -z $(git status -s) ]]; then - echo "Note there are uncommitted changes" - fi - - # Apple M1 chips by default will build for arm64, which isn't compatible - # with our K8s setup. By manually building for amd64, we build an image - # compatible with our K8s infrastructure. - # More info: https://stackoverflow.com/a/71102144 - if [[ $USE_DEFAULT_PLATFORM != "true" ]]; then - PLATFORM="--platform=linux/amd64" - fi -fi - -DOCKER_BUILDKIT=1 docker build $PLATFORM -t gcr.io/abacus-labs-dev/hyperlane-agent:$TAG . diff --git a/rust/chains/hyperlane-cosmos/.gitignore b/rust/chains/hyperlane-cosmos/.gitignore deleted file mode 100644 index 7040d337ab..0000000000 --- a/rust/chains/hyperlane-cosmos/.gitignore +++ /dev/null @@ -1 +0,0 @@ -src/contracts \ No newline at end of file diff --git a/rust/chains/hyperlane-cosmos/src/aggregation_ism.rs b/rust/chains/hyperlane-cosmos/src/aggregation_ism.rs index 30f123bf1a..772a552e25 100644 --- a/rust/chains/hyperlane-cosmos/src/aggregation_ism.rs +++ b/rust/chains/hyperlane-cosmos/src/aggregation_ism.rs @@ -1,25 +1,21 @@ use crate::{ grpc::{WasmGrpcProvider, WasmProvider}, - payloads::aggregate_ism::{ - ModulesAndThresholdRequest, ModulesAndThresholdRequestInner, ModulesAndThresholdResponse, - }, + payloads::aggregate_ism::{ModulesAndThresholdRequest, ModulesAndThresholdResponse}, verify::bech32_decode, ConnectionConf, CosmosProvider, Signer, }; use async_trait::async_trait; use hyperlane_core::{ AggregationIsm, ChainResult, ContractLocator, HyperlaneChain, HyperlaneContract, - HyperlaneDomain, HyperlaneMessage, HyperlaneProvider, RawHyperlaneMessage, H256, + HyperlaneDomain, HyperlaneMessage, HyperlaneProvider, H256, }; use tracing::instrument; /// A reference to an AggregationIsm contract on some Cosmos chain #[derive(Debug)] pub struct CosmosAggregationIsm { - _conf: ConnectionConf, domain: HyperlaneDomain, address: H256, - _signer: Signer, provider: Box, } @@ -29,10 +25,8 @@ impl CosmosAggregationIsm { let provider = WasmGrpcProvider::new(conf.clone(), locator.clone(), signer.clone()); Self { - _conf: conf, domain: locator.domain.clone(), address: locator.address, - _signer: signer, provider: Box::new(provider), } } @@ -61,20 +55,12 @@ impl AggregationIsm for CosmosAggregationIsm { &self, message: &HyperlaneMessage, ) -> ChainResult<(Vec, u8)> { - let payload = ModulesAndThresholdRequest { - modules_and_threshold: ModulesAndThresholdRequestInner { - message: hex::encode(RawHyperlaneMessage::from(message)), - }, - }; + let payload = ModulesAndThresholdRequest::new(message); let data = self.provider.wasm_query(payload, None).await?; let response: ModulesAndThresholdResponse = serde_json::from_slice(&data)?; - let modules: Vec = response - .modules - .iter() - .map(|module| bech32_decode(module.clone())) - .collect(); + let modules: Vec = response.modules.into_iter().map(bech32_decode).collect(); Ok((modules, response.threshold)) } diff --git a/rust/chains/hyperlane-cosmos/src/interchain_gas.rs b/rust/chains/hyperlane-cosmos/src/interchain_gas.rs index 4543306469..34b881cf19 100644 --- a/rust/chains/hyperlane-cosmos/src/interchain_gas.rs +++ b/rust/chains/hyperlane-cosmos/src/interchain_gas.rs @@ -8,7 +8,6 @@ use hyperlane_core::{ }; use hyperlane_core::{HyperlaneDomain, HyperlaneProvider, InterchainGasPayment, LogMeta, H256}; use std::ops::RangeInclusive; -use tracing::info; use crate::grpc::WasmGrpcProvider; use crate::rpc::{CosmosWasmIndexer, WasmIndexer}; @@ -18,11 +17,8 @@ use crate::{ConnectionConf, CosmosProvider}; /// A reference to a InterchainGasPaymaster contract on some Cosmos chain #[derive(Debug)] pub struct CosmosInterchainGasPaymaster { - _conf: ConnectionConf, domain: HyperlaneDomain, address: H256, - _signer: Signer, - _provider: Box, } impl HyperlaneContract for CosmosInterchainGasPaymaster { @@ -49,11 +45,8 @@ impl CosmosInterchainGasPaymaster { let provider = WasmGrpcProvider::new(conf.clone(), locator.clone(), signer.clone()); Self { - _conf: conf, domain: locator.domain.clone(), address: locator.address, - _signer: signer, - _provider: Box::new(provider), } } } @@ -145,36 +138,10 @@ impl Indexer for CosmosInterchainGasPaymasterIndexer { } } -#[async_trait] -impl Indexer for CosmosInterchainGasPaymasterIndexer { - async fn fetch_logs(&self, range: RangeInclusive) -> ChainResult> { - let parser = self.get_parser(); - let result = self.indexer.get_range_event_logs(range, parser).await?; - - Ok(result - .into_iter() - .map(|(msg, meta)| (msg.message_id, meta)) - .collect()) - } - - async fn get_finalized_block_number(&self) -> ChainResult { - self.indexer.latest_block_height().await - } -} - #[async_trait] impl SequenceIndexer for CosmosInterchainGasPaymasterIndexer { async fn sequence_and_tip(&self) -> ChainResult<(Option, u32)> { - // TODO: implement when sealevel scraper support is implemented - let tip = self.indexer.latest_block_height().await?; - Ok((None, tip)) - } -} - -#[async_trait] -impl SequenceIndexer for CosmosInterchainGasPaymasterIndexer { - async fn sequence_and_tip(&self) -> ChainResult<(Option, u32)> { - // TODO: implement when sealevel scraper support is implemented + // TODO: implement when cosmwasm scraper support is implemented let tip = self.indexer.latest_block_height().await?; Ok((None, tip)) } diff --git a/rust/chains/hyperlane-cosmos/src/mailbox.rs b/rust/chains/hyperlane-cosmos/src/mailbox.rs index 5aedb4d63d..0b15896317 100644 --- a/rust/chains/hyperlane-cosmos/src/mailbox.rs +++ b/rust/chains/hyperlane-cosmos/src/mailbox.rs @@ -250,7 +250,7 @@ impl CosmosMailboxIndexer { fn get_parser(&self) -> fn(attrs: Vec) -> Option { |attrs: Vec| -> Option { - let mut res = HyperlaneMessage::default(); + let res = HyperlaneMessage::default(); for attr in attrs { let key = attr.key.as_str(); diff --git a/rust/chains/hyperlane-cosmos/src/merkle_tree_hook.rs b/rust/chains/hyperlane-cosmos/src/merkle_tree_hook.rs index 53a01f5684..2eb3f8d446 100644 --- a/rust/chains/hyperlane-cosmos/src/merkle_tree_hook.rs +++ b/rust/chains/hyperlane-cosmos/src/merkle_tree_hook.rs @@ -8,7 +8,7 @@ use hyperlane_core::{ HyperlaneChain, HyperlaneContract, HyperlaneDomain, HyperlaneProvider, Indexer, LogMeta, MerkleTreeHook, MerkleTreeInsertion, SequenceIndexer, H256, }; -use tracing::{info, instrument}; +use tracing::instrument; use crate::{ grpc::{WasmGrpcProvider, WasmProvider}, diff --git a/rust/chains/hyperlane-cosmos/src/payloads/aggregate_ism.rs b/rust/chains/hyperlane-cosmos/src/payloads/aggregate_ism.rs index a06d6379d3..7bb5d40d09 100644 --- a/rust/chains/hyperlane-cosmos/src/payloads/aggregate_ism.rs +++ b/rust/chains/hyperlane-cosmos/src/payloads/aggregate_ism.rs @@ -1,17 +1,30 @@ +use hyperlane_core::{HyperlaneMessage, RawHyperlaneMessage}; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug)] pub struct ModulesAndThresholdRequest { - pub modules_and_threshold: ModulesAndThresholdRequestInner, + modules_and_threshold: ModulesAndThresholdRequestInner, +} + +impl ModulesAndThresholdRequest { + pub fn new(message: &HyperlaneMessage) -> Self { + Self { + modules_and_threshold: ModulesAndThresholdRequestInner { + message: hex::encode(RawHyperlaneMessage::from(message)), + }, + } + } } #[derive(Serialize, Deserialize, Debug)] -pub struct ModulesAndThresholdRequestInner { - pub message: String, // hexbinary +struct ModulesAndThresholdRequestInner { + /// Hex-encoded Hyperlane message + pub message: String, } #[derive(Serialize, Deserialize, Debug)] pub struct ModulesAndThresholdResponse { pub threshold: u8, + /// Bech32-encoded module addresses pub modules: Vec, }