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

Cosmos / CosmWasm agents #2865

Merged
merged 151 commits into from
Nov 23, 2023
Merged

Cosmos / CosmWasm agents #2865

merged 151 commits into from
Nov 23, 2023

Conversation

tkporter
Copy link
Collaborator

Description

Drive-by changes

Related issues

Backward compatibility

Testing

@nambrot nambrot force-pushed the trevor/new-featv3-cosmos-oct-28 branch from 336da71 to b7c4e2f Compare October 29, 2023 19:13
@nambrot nambrot changed the base branch from v3 to mainnet3-env-switch October 30, 2023 00:40
@tkporter tkporter changed the title img pls Cosmos - CI image Oct 30, 2023
@tkporter tkporter changed the title Cosmos - CI image CosmWasm - CI image Oct 30, 2023
rust/build Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/aggregation_ism.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/aggregation_ism.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/aggregation_ism.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/interchain_gas.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/interchain_gas.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/interchain_gas.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/interchain_gas.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/interchain_gas.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/interchain_gas.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/libs/verify.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/libs/verify.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/libs/verify.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/libs/verify.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/libs/verify.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/mailbox.rs Outdated Show resolved Hide resolved

impl Debug for CosmosMailbox {
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
// Debug::fmt(&(self as &dyn HyperlaneContract), f)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should do this and remove the todo

rust/chains/hyperlane-cosmos/src/mailbox.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/mailbox.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/mailbox.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@daniel-savu daniel-savu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had a relatively brief look, will continue in the morning

.gitignore Outdated Show resolved Hide resolved
rust/Cargo.toml Outdated Show resolved Hide resolved
rust/Cargo.toml Outdated Show resolved Hide resolved
rust/Cargo.toml Show resolved Hide resolved
rust/chains/hyperlane-cosmos/Cargo.toml Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/Cargo.toml Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/aggregation_ism.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/aggregation_ism.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/interchain_gas.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/interchain_gas.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@daniel-savu daniel-savu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some more suggestions, hoping to finish reviewing tomorrow

rust/chains/hyperlane-cosmos/src/interchain_gas.rs Outdated Show resolved Hide resolved
/// Returns the module type of the ISM compliant with the corresponding
/// metadata offchain fetching and onchain formatting standard.
async fn module_type(&self) -> ChainResult<ModuleType> {
let query = QueryIsmModuleTypeRequest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should implement the Default trait for QueryIsmModuleTypeRequest (if not already done) and use it here

rust/chains/hyperlane-cosmos/src/libs/verify.rs Outdated Show resolved Hide resolved
impl Mailbox for CosmosMailbox {
#[instrument(level = "debug", err, ret, skip(self))]
async fn count(&self, lag: Option<NonZeroU64>) -> ChainResult<u32> {
let payload = mailbox::NonceRequest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any chance to use Default::default() here?

.await?;
let response: mailbox::RecipientIsmResponse = serde_json::from_slice(&data)?;

// convert Hex to H256
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment is stale

rust/chains/hyperlane-cosmos/src/mailbox.rs Outdated Show resolved Hide resolved
let response: SimulateResponse = self.provider.wasm_simulate(process_message).await?;
let result = TxCostEstimate {
gas_limit: U256::from(response.gas_info.unwrap().gas_used),
gas_price: U256::from(2500),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather have the 2500 as a constant

@tkporter tkporter mentioned this pull request Oct 31, 2023
Copy link
Contributor

@daniel-savu daniel-savu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another round of comments

}

impl CosmosMailboxIndexer {
/// Create a reference to a mailbox at a specific Ethereum address on some
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment looks stale

rust/chains/hyperlane-cosmos/src/mailbox.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/mailbox.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/mailbox.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/mailbox.rs Outdated Show resolved Hide resolved
rust/hyperlane-base/src/settings/chains.rs Outdated Show resolved Hide resolved
rust/hyperlane-base/src/settings/chains.rs Outdated Show resolved Hide resolved
rust/hyperlane-base/src/settings/parser/mod.rs Outdated Show resolved Hide resolved
rust/hyperlane-base/src/settings/signers.rs Outdated Show resolved Hide resolved
tkporter added a commit that referenced this pull request Oct 31, 2023
### Description

Addresses a handful of issues in
#2865

### Drive-by changes

<!--
Are there any minor or drive-by changes also included?
-->

### Related issues

<!--
- Fixes #[issue number here]
-->

### Backward compatibility

<!--
Are these changes backward compatible? Are there any infrastructure
implications, e.g. changes that would prohibit deploying older commits
using this infra tooling?

Yes/No
-->

### Testing

<!--
What kind of testing have these changes undergone?

None/Manual/Unit Tests
-->
pub merkle_hook: T,
}

// --------- Requests ---------
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleaner to wrap in a mod requests

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually all of these should be importable from hpl_interface, looking into it

pub check_point: EmptyStruct,
}

// --------- Responses ---------
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleaner to wrap in a mod responses


#[derive(Serialize, Deserialize, Debug)]
pub struct GetAnnounceStorageLocationsRequest {
pub get_announce_storage_locations: GetAnnounceStorageLocationsRequestInner,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do we expect the maintenance overhead of these structs to be? wondering if there's a way to generate the expected request/response shape automatically

Comment on lines 2 to 21
use cosmrs::crypto::secp256k1::SigningKey;
use cosmrs::proto::cosmos::auth::v1beta1::BaseAccount;
use cosmrs::proto::cosmos::auth::v1beta1::{
query_client::QueryClient as QueryAccountClient, QueryAccountRequest,
};
use cosmrs::proto::cosmos::base::abci::v1beta1::TxResponse;
use cosmrs::proto::cosmos::base::tendermint::v1beta1::{
service_client::ServiceClient, GetLatestBlockRequest,
};
use cosmrs::proto::cosmos::tx::v1beta1::service_client::ServiceClient as TxServiceClient;
use cosmrs::proto::cosmos::tx::v1beta1::{
BroadcastMode, BroadcastTxRequest, SimulateRequest, SimulateResponse,
};
use cosmrs::proto::cosmwasm::wasm::v1::{
query_client::QueryClient as WasmQueryClient, MsgExecuteContract,
QuerySmartContractStateRequest,
};
use cosmrs::proto::traits::Message;

use cosmrs::tx::{self, Fee, MessageExt, SignDoc, SignerInfo};
use cosmrs::{Amount, Coin};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added an issue to auto-format these later: #2877

rust/chains/hyperlane-cosmos/src/providers/grpc.rs Outdated Show resolved Hide resolved
@@ -367,7 +375,7 @@ impl HyperlaneDomain {
use HyperlaneDomainProtocol::*;
let protocol = self.domain_protocol();
many_to_one!(match protocol {
IndexMode::Block: [Ethereum],
IndexMode::Block: [Ethereum, Cosmos], // TODO: Is cosmos index-mode is correct?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the answer is yes and we should remove this comment @tkporter

rust/hyperlane-core/src/error.rs Outdated Show resolved Hide resolved
Ok(sig.recover(hash)?.into())
}

/// Recover the public key of the signer
#[cfg(feature = "ethers")]
pub fn recover_pubkey(&self) -> Result<Vec<u8>, crate::HyperlaneProtocolError> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't look like this is used anywhere

rust/neutron_relayer_config.json Outdated Show resolved Hide resolved
rust/neutron_validator_config.json Outdated Show resolved Hide resolved
@daniel-savu
Copy link
Contributor

During testing I noticed that the relayer fetches the entire events list on each block, we should look into this since it's quite inefficient

}

#[derive(Clone)]
pub struct CosmosConfig {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are codes? I know this code is just for testing but let's add some brief doc comments

}

pub fn wasm_query<T: serde::ser::Serialize>(
// U: serde::de::DeserializeOwned>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove

Comment on lines +313 to +315
// let output: CliWasmQueryResponse<U> = serde_json::from_str(output).unwrap();

// output.data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove

Comment on lines +244 to +255
// cli.wasm_execute(
// &network.launch_resp.endpoint,
// linker,
// &network.deployments.va,
// va::ExecuteMsg::Announce {
// validator: (),
// storage_location: (),
// signature: (),
// },
// vec![],
// );
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does e2e not use a multisig ism?

target_domain: u32,
) {
let validator_addr = validator.addr(hrp);
let _validator_pubkey = validator.pub_key_to_binary();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm if not used

rust/utils/run-locally/src/cosmos/mod.rs Show resolved Hide resolved
rust/utils/run-locally/src/cosmos/mod.rs Outdated Show resolved Hide resolved

impl CodeSource {
fn install_local(src: String) -> BTreeMap<String, PathBuf> {
// make contract_name => path map
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment is present repeat three times across the project, and the code it describes looks identical each time. Let's try reusing this function everywhere instead of duplicating

}

impl CLISource {
fn install_remote(dir: Option<PathBuf>, git: String, version: String) -> PathBuf {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to install_cli?

solidity/contracts/Mailbox.sol Outdated Show resolved Hide resolved
message: &HyperlaneMessage,
metadata: &[u8],
) -> ChainResult<Option<U256>> {
Ok(Some(U256::from(1000))) // TODO
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and let's double check that aggregation ISM isn't required

rust/chains/hyperlane-cosmos/src/lib.rs Outdated Show resolved Hide resolved
rust/chains/hyperlane-cosmos/src/aggregation_ism.rs Outdated Show resolved Hide resolved
#[instrument(level = "debug", err, ret, skip(self))]
async fn delivered(&self, id: H256) -> ChainResult<bool> {
let id = hex::encode(id);
let payload = mailbox::DeliveredRequest {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to constructor


let delivered = match self
.provider
.wasm_query(GeneralMailboxQuery { mailbox: payload }, None)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same should have a more ergonomic interface

@@ -78,6 +84,51 @@ pub enum ChainCommunicationError {
/// Failed to parse strings or integers
#[error("Data parsing error {0:?}")]
StrOrIntParseError(#[from] StrOrIntParseError),
/// Tendermint RPC Error
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would prefer to not put execution env specific things in here

Ok(sig.recover(hash)?.into())
}

/// Recover the public key of the signer
#[cfg(feature = "ethers")]
pub fn recover_pubkey(&self) -> Result<Vec<u8>, crate::HyperlaneProtocolError> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this

@@ -0,0 +1,30 @@
{
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm

@@ -0,0 +1,12 @@
{
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rm

@@ -0,0 +1,43 @@
use k256::ecdsa::{SigningKey, VerifyingKey};
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe unnencessary here

Base automatically changed from mainnet3-env-switch to v3 November 1, 2023 20:22
tkporter and others added 9 commits November 9, 2023 11:45
### Description

<!--
What's included in this PR?
-->

### Drive-by changes

<!--
Are there any minor or drive-by changes also included?
-->

### Related issues

<!--
- Fixes #[issue number here]
-->

### Backward compatibility

<!--
Are these changes backward compatible? Are there any infrastructure
implications, e.g. changes that would prohibit deploying older commits
using this infra tooling?

Yes/No
-->

### Testing

<!--
What kind of testing have these changes undergone?

None/Manual/Unit Tests
-->
### Description

<!--
What's included in this PR?
-->

### Drive-by changes

<!--
Are there any minor or drive-by changes also included?
-->

### Related issues

<!--
- Fixes #[issue number here]
-->

### Backward compatibility

<!--
Are these changes backward compatible? Are there any infrastructure
implications, e.g. changes that would prohibit deploying older commits
using this infra tooling?

Yes/No
-->

### Testing

<!--
What kind of testing have these changes undergone?

None/Manual/Unit Tests
-->
### Description

* Creates a single channel that's cloned (which can be done [cheaply and
is
encouraged](https://docs.rs/tonic/latest/tonic/transport/struct.Channel.html))
when creating a new client.
* general cleanup & renaming
* I believe a chain signer will not be required by e.g. the validator,
will confirm this locally

### Drive-by changes

n/a

### Related issues

n/a

### Backward compatibility

yee

### Testing

builds, local test
Size of rust build exceeds the storage space in the `ubuntu-latest`
runner. `larger-runner` has more storage, but let's see if it also has
all the system dependencies required to build
Adds "gas payment count" and "confirmed submitted messages" as
termination invariants to the cw run-locally, to get the test to
actually fail if messages are not delivered
### Description

<!--
What's included in this PR?
-->

### Drive-by changes

<!--
Are there any minor or drive-by changes also included?
-->

### Related issues

<!--
- Fixes #[issue number here]
-->

### Backward compatibility

<!--
Are these changes backward compatible? Are there any infrastructure
implications, e.g. changes that would prohibit deploying older commits
using this infra tooling?

Yes/No
-->

### Testing

<!--
What kind of testing have these changes undergone?

None/Manual/Unit Tests
-->
### Description

<!--
What's included in this PR?
-->

### Drive-by changes

<!--
Are there any minor or drive-by changes also included?
-->

### Related issues

<!--
- Fixes #[issue number here]
-->

### Backward compatibility

<!--
Are these changes backward compatible? Are there any infrastructure
implications, e.g. changes that would prohibit deploying older commits
using this infra tooling?

Yes/No
-->

### Testing

<!--
What kind of testing have these changes undergone?

None/Manual/Unit Tests
-->
Copy link

changeset-bot bot commented Nov 22, 2023

⚠️ No Changeset found

Latest commit: 43f2ac0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@daniel-savu daniel-savu changed the base branch from v3 to main November 22, 2023 13:24
@daniel-savu daniel-savu marked this pull request as ready for review November 22, 2023 13:24
@daniel-savu daniel-savu enabled auto-merge (squash) November 22, 2023 13:52
@daniel-savu daniel-savu disabled auto-merge November 22, 2023 13:57
@daniel-savu daniel-savu enabled auto-merge (squash) November 22, 2023 17:02
@tkporter tkporter disabled auto-merge November 22, 2023 17:15
@tkporter tkporter merged commit ece2be5 into main Nov 23, 2023
19 checks passed
@tkporter tkporter deleted the trevor/new-featv3-cosmos-oct-28 branch November 23, 2023 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

7 participants