-
Notifications
You must be signed in to change notification settings - Fork 388
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
Cosmos / CosmWasm agents #2865
Conversation
336da71
to
b7c4e2f
Compare
|
||
impl Debug for CosmosMailbox { | ||
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { | ||
// Debug::fmt(&(self as &dyn HyperlaneContract), f) |
There was a problem hiding this comment.
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
There was a problem hiding this 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
There was a problem hiding this 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
/// 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 { |
There was a problem hiding this comment.
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
impl Mailbox for CosmosMailbox { | ||
#[instrument(level = "debug", err, ret, skip(self))] | ||
async fn count(&self, lag: Option<NonZeroU64>) -> ChainResult<u32> { | ||
let payload = mailbox::NonceRequest { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
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), |
There was a problem hiding this comment.
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
There was a problem hiding this 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment looks stale
### 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 --------- |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 --------- |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
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}; |
There was a problem hiding this comment.
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
@@ -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? |
There was a problem hiding this comment.
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
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> { |
There was a problem hiding this comment.
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
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 { |
There was a problem hiding this comment.
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>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can remove
// let output: CliWasmQueryResponse<U> = serde_json::from_str(output).unwrap(); | ||
|
||
// output.data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove
// cli.wasm_execute( | ||
// &network.launch_resp.endpoint, | ||
// linker, | ||
// &network.deployments.va, | ||
// va::ExecuteMsg::Announce { | ||
// validator: (), | ||
// storage_location: (), | ||
// signature: (), | ||
// }, | ||
// vec![], | ||
// ); | ||
} |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rm if not used
|
||
impl CodeSource { | ||
fn install_local(src: String) -> BTreeMap<String, PathBuf> { | ||
// make contract_name => path map |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to install_cli
?
message: &HyperlaneMessage, | ||
metadata: &[u8], | ||
) -> ChainResult<Option<U256>> { | ||
Ok(Some(U256::from(1000))) // TODO |
There was a problem hiding this comment.
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
#[instrument(level = "debug", err, ret, skip(self))] | ||
async fn delivered(&self, id: H256) -> ChainResult<bool> { | ||
let id = hex::encode(id); | ||
let payload = mailbox::DeliveredRequest { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
rust/hyperlane-core/src/error.rs
Outdated
@@ -78,6 +84,51 @@ pub enum ChainCommunicationError { | |||
/// Failed to parse strings or integers | |||
#[error("Data parsing error {0:?}")] | |||
StrOrIntParseError(#[from] StrOrIntParseError), | |||
/// Tendermint RPC Error |
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this
rust/neutron_relayer_config.json
Outdated
@@ -0,0 +1,30 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rm
rust/neutron_validator_config.json
Outdated
@@ -0,0 +1,12 @@ | |||
{ |
There was a problem hiding this comment.
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}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe unnencessary here
### 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 -->
|
Description
Drive-by changes
Related issues
Backward compatibility
Testing