Skip to content

Commit

Permalink
Merge branch 'trevor/new-featv3-cosmos-oct-28' into dan/more-cw-agent…
Browse files Browse the repository at this point in the history
…-remediations
  • Loading branch information
daniel-savu committed Nov 10, 2023
2 parents 57940da + 3a55ff0 commit 4dc3fdd
Show file tree
Hide file tree
Showing 15 changed files with 373 additions and 271 deletions.
36 changes: 25 additions & 11 deletions rust/Cargo.lock

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

15 changes: 12 additions & 3 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ bech32 = "0.9.1"
elliptic-curve = "0.12.3"
getrandom = { version = "0.2", features = ["js"] }
hex = "0.4.3"
hpl-interface = "0.0.6-rc6"
hpl-interface = "=0.0.6-rc3"
hyper = "0.14"
hyper-tls = "0.5.0"
itertools = "0.11.0"
Expand Down Expand Up @@ -307,6 +307,15 @@ version = "=0.5.0"

[patch.crates-io.spl-type-length-value]
version = "=0.1.0"

branch = "hyperlane"
git = "https://github.com/hyperlane-xyz/solana-program-library.git"
branch = "hyperlane"

[patch.crates-io.tendermint]
branch = "trevor/0.32.2-fork"
git = "https://github.com/hyperlane-xyz/tendermint-rs.git"
version = "=0.32.2"

[patch.crates-io.tendermint-rpc]
branch = "trevor/0.32.2-fork"
git = "https://github.com/hyperlane-xyz/tendermint-rs.git"
version = "=0.32.2"
12 changes: 8 additions & 4 deletions rust/chains/hyperlane-cosmos/src/aggregation_ism.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@ pub struct CosmosAggregationIsm {

impl CosmosAggregationIsm {
/// create new Cosmos AggregationIsm agent
pub fn new(conf: ConnectionConf, locator: ContractLocator, signer: Option<Signer>) -> Self {
let provider = WasmGrpcProvider::new(conf.clone(), locator.clone(), signer);
pub fn new(
conf: ConnectionConf,
locator: ContractLocator,
signer: Option<Signer>,
) -> ChainResult<Self> {
let provider = WasmGrpcProvider::new(conf.clone(), locator.clone(), signer)?;

Self {
Ok(Self {
domain: locator.domain.clone(),
address: locator.address,
provider: Box::new(provider),
}
})
}
}

Expand Down
12 changes: 8 additions & 4 deletions rust/chains/hyperlane-cosmos/src/interchain_gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ impl InterchainGasPaymaster for CosmosInterchainGasPaymaster {}

impl CosmosInterchainGasPaymaster {
/// create new Cosmos InterchainGasPaymaster agent
pub fn new(conf: ConnectionConf, locator: ContractLocator, signer: Option<Signer>) -> Self {
let provider = WasmGrpcProvider::new(conf.clone(), locator.clone(), signer);
pub fn new(
conf: ConnectionConf,
locator: ContractLocator,
signer: Option<Signer>,
) -> ChainResult<Self> {
let provider = WasmGrpcProvider::new(conf.clone(), locator.clone(), signer)?;

Self {
Ok(Self {
domain: locator.domain.clone(),
address: locator.address,
}
})
}
}

Expand Down
12 changes: 8 additions & 4 deletions rust/chains/hyperlane-cosmos/src/interchain_security_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,19 @@ pub struct CosmosInterchainSecurityModule {
/// The Cosmos Interchain Security Module Implementation.
impl CosmosInterchainSecurityModule {
/// Creates a new Cosmos Interchain Security Module.
pub fn new(conf: &ConnectionConf, locator: ContractLocator, signer: Option<Signer>) -> Self {
pub fn new(
conf: &ConnectionConf,
locator: ContractLocator,
signer: Option<Signer>,
) -> ChainResult<Self> {
let provider: WasmGrpcProvider =
WasmGrpcProvider::new(conf.clone(), locator.clone(), signer);
WasmGrpcProvider::new(conf.clone(), locator.clone(), signer)?;

Self {
Ok(Self {
domain: locator.domain.clone(),
address: locator.address,
provider: Box::new(provider),
}
})
}
}

Expand Down
27 changes: 12 additions & 15 deletions rust/chains/hyperlane-cosmos/src/mailbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use crate::CosmosProvider;
use crate::{signers::Signer, utils::get_block_height_for_lag, ConnectionConf};
use async_trait::async_trait;
use cosmrs::proto::cosmos::base::abci::v1beta1::TxResponse;
use cosmrs::proto::cosmos::tx::v1beta1::SimulateResponse;
use cosmrs::tendermint::abci::EventAttribute;
use once_cell::sync::Lazy;

Expand All @@ -44,15 +43,19 @@ pub struct CosmosMailbox {
impl CosmosMailbox {
/// Create a reference to a mailbox at a specific Ethereum address on some
/// chain
pub fn new(conf: ConnectionConf, locator: ContractLocator, signer: Option<Signer>) -> Self {
let provider = WasmGrpcProvider::new(conf.clone(), locator.clone(), signer.clone());
pub fn new(
conf: ConnectionConf,
locator: ContractLocator,
signer: Option<Signer>,
) -> ChainResult<Self> {
let provider = WasmGrpcProvider::new(conf.clone(), locator.clone(), signer)?;

Self {
Ok(Self {
config: conf,
domain: locator.domain.clone(),
address: locator.address,
provider: Box::new(provider),
}
})
}

/// Prefix used in the bech32 address encoding
Expand Down Expand Up @@ -195,16 +198,10 @@ impl Mailbox for CosmosMailbox {
},
};

let response: SimulateResponse = self.provider.wasm_simulate(process_message).await?;
let gas_limit = self.provider.wasm_estimate_gas(process_message).await?;

let result = TxCostEstimate {
gas_limit: U256::from(
response
.gas_info
.ok_or(ChainCommunicationError::TxCostEstimateError(
"Failed to estimate gas limit".to_string(),
))?
.gas_used,
),
gas_limit: gas_limit.into(),
gas_price: U256::from(2500),
l2_gas_limit: None,
};
Expand Down Expand Up @@ -260,7 +257,7 @@ impl CosmosMailboxIndexer {
signer: Option<Signer>,
reorg_period: u32,
) -> ChainResult<Self> {
let mailbox = CosmosMailbox::new(conf.clone(), locator.clone(), signer.clone());
let mailbox = CosmosMailbox::new(conf.clone(), locator.clone(), signer.clone())?;
let indexer = CosmosWasmIndexer::new(
conf,
locator,
Expand Down
14 changes: 9 additions & 5 deletions rust/chains/hyperlane-cosmos/src/merkle_tree_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,18 @@ pub struct CosmosMerkleTreeHook {

impl CosmosMerkleTreeHook {
/// create new Cosmos MerkleTreeHook agent
pub fn new(conf: ConnectionConf, locator: ContractLocator, signer: Option<Signer>) -> Self {
let provider = WasmGrpcProvider::new(conf.clone(), locator.clone(), signer);
pub fn new(
conf: ConnectionConf,
locator: ContractLocator,
signer: Option<Signer>,
) -> ChainResult<Self> {
let provider = WasmGrpcProvider::new(conf.clone(), locator.clone(), signer)?;

Self {
Ok(Self {
domain: locator.domain.clone(),
address: locator.address,
provider: Box::new(provider),
}
})
}
}

Expand Down Expand Up @@ -200,7 +204,7 @@ impl CosmosMerkleTreeHookIndexer {
)?;

Ok(Self {
merkle_tree_hook: CosmosMerkleTreeHook::new(conf, locator, signer),
merkle_tree_hook: CosmosMerkleTreeHook::new(conf, locator, signer)?,
indexer: Box::new(indexer),
})
}
Expand Down
12 changes: 8 additions & 4 deletions rust/chains/hyperlane-cosmos/src/multisig_ism.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,18 @@ pub struct CosmosMultisigIsm {

impl CosmosMultisigIsm {
/// create a new instance of CosmosMultisigIsm
pub fn new(conf: ConnectionConf, locator: ContractLocator, signer: Option<Signer>) -> Self {
let provider = WasmGrpcProvider::new(conf.clone(), locator.clone(), signer);
pub fn new(
conf: ConnectionConf,
locator: ContractLocator,
signer: Option<Signer>,
) -> ChainResult<Self> {
let provider = WasmGrpcProvider::new(conf.clone(), locator.clone(), signer)?;

Self {
Ok(Self {
domain: locator.domain.clone(),
address: locator.address,
provider: Box::new(provider),
}
})
}
}

Expand Down
Loading

0 comments on commit 4dc3fdd

Please sign in to comment.