refactor: organize files in `hyperlane-ethereum` (#3633)

### Description

Some cleanup along my way to integrating with `Multicall3` in
hyp-ethereum.

- Categorizes most files from `src` into `ism`, `contracts`, `signer`
modules
- Renames the previous `contracts` dir (that held the abi interfaces) to
`interfaces`, so we can use `contracts` for the actual contracts (e.g.
mailbox, igp)
trevor/opentelemetry
Daniel Savu 6 months ago committed by GitHub
parent 2e439423e7
commit f2cb6ebc1b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      rust/chains/hyperlane-ethereum/.gitignore
  2. 2
      rust/chains/hyperlane-ethereum/build.rs
  3. 7
      rust/chains/hyperlane-ethereum/src/contracts/interchain_gas.rs
  4. 13
      rust/chains/hyperlane-ethereum/src/contracts/mailbox.rs
  5. 5
      rust/chains/hyperlane-ethereum/src/contracts/merkle_tree_hook.rs
  6. 9
      rust/chains/hyperlane-ethereum/src/contracts/mod.rs
  7. 7
      rust/chains/hyperlane-ethereum/src/contracts/validator_announce.rs
  8. 7
      rust/chains/hyperlane-ethereum/src/ism/aggregation_ism.rs
  9. 7
      rust/chains/hyperlane-ethereum/src/ism/ccip_read_ism.rs
  10. 7
      rust/chains/hyperlane-ethereum/src/ism/interchain_security_module.rs
  11. 10
      rust/chains/hyperlane-ethereum/src/ism/mod.rs
  12. 7
      rust/chains/hyperlane-ethereum/src/ism/multisig_ism.rs
  13. 9
      rust/chains/hyperlane-ethereum/src/ism/routing_ism.rs
  14. 60
      rust/chains/hyperlane-ethereum/src/lib.rs
  15. 4
      rust/chains/hyperlane-ethereum/src/rpc_clients/mod.rs
  16. 0
      rust/chains/hyperlane-ethereum/src/rpc_clients/provider.rs
  17. 4
      rust/chains/hyperlane-ethereum/src/rpc_clients/trait_builder.rs
  18. 5
      rust/chains/hyperlane-ethereum/src/signer/mod.rs
  19. 0
      rust/chains/hyperlane-ethereum/src/signer/singleton.rs

@ -1 +1 @@
src/contracts src/interfaces

@ -1,3 +1,3 @@
fn main() { fn main() {
abigen::generate_bindings_for_dir("./abis", "./src/contracts", abigen::BuildType::Ethers); abigen::generate_bindings_for_dir("./abis", "./src/interfaces", abigen::BuildType::Ethers);
} }

@ -14,11 +14,10 @@ use hyperlane_core::{
}; };
use tracing::instrument; use tracing::instrument;
use crate::contracts::i_interchain_gas_paymaster::{ use crate::interfaces::i_interchain_gas_paymaster::{
IInterchainGasPaymaster as EthereumInterchainGasPaymasterInternal, IINTERCHAINGASPAYMASTER_ABI, IInterchainGasPaymaster as EthereumInterchainGasPaymasterInternal, IINTERCHAINGASPAYMASTER_ABI,
}; };
use crate::trait_builder::BuildableWithProvider; use crate::{BuildableWithProvider, ConnectionConf, EthereumProvider};
use crate::{ConnectionConf, EthereumProvider};
impl<M> Display for EthereumInterchainGasPaymasterInternal<M> impl<M> Display for EthereumInterchainGasPaymasterInternal<M>
where where
@ -224,6 +223,6 @@ impl HyperlaneAbi for EthereumInterchainGasPaymasterAbi {
const SELECTOR_SIZE_BYTES: usize = 4; const SELECTOR_SIZE_BYTES: usize = 4;
fn fn_map() -> HashMap<Vec<u8>, &'static str> { fn fn_map() -> HashMap<Vec<u8>, &'static str> {
super::extract_fn_map(&IINTERCHAINGASPAYMASTER_ABI) crate::extract_fn_map(&IINTERCHAINGASPAYMASTER_ABI)
} }
} }

@ -19,11 +19,12 @@ use hyperlane_core::{
TxCostEstimate, TxOutcome, H160, H256, U256, TxCostEstimate, TxOutcome, H160, H256, U256,
}; };
use crate::contracts::arbitrum_node_interface::ArbitrumNodeInterface; use crate::interfaces::arbitrum_node_interface::ArbitrumNodeInterface;
use crate::contracts::i_mailbox::{IMailbox as EthereumMailboxInternal, ProcessCall, IMAILBOX_ABI}; use crate::interfaces::i_mailbox::{
use crate::trait_builder::BuildableWithProvider; IMailbox as EthereumMailboxInternal, ProcessCall, IMAILBOX_ABI,
};
use crate::tx::{call_with_lag, fill_tx_gas_params, report_tx}; use crate::tx::{call_with_lag, fill_tx_gas_params, report_tx};
use crate::{ConnectionConf, EthereumProvider, TransactionOverrides}; use crate::{BuildableWithProvider, ConnectionConf, EthereumProvider, TransactionOverrides};
impl<M> std::fmt::Display for EthereumMailboxInternal<M> impl<M> std::fmt::Display for EthereumMailboxInternal<M>
where where
@ -420,7 +421,7 @@ impl HyperlaneAbi for EthereumMailboxAbi {
const SELECTOR_SIZE_BYTES: usize = 4; const SELECTOR_SIZE_BYTES: usize = 4;
fn fn_map() -> HashMap<Vec<u8>, &'static str> { fn fn_map() -> HashMap<Vec<u8>, &'static str> {
super::extract_fn_map(&IMAILBOX_ABI) crate::extract_fn_map(&IMAILBOX_ABI)
} }
} }
@ -438,7 +439,7 @@ mod test {
TxCostEstimate, H160, H256, U256, TxCostEstimate, H160, H256, U256,
}; };
use crate::{ConnectionConf, EthereumMailbox, RpcConnectionConf}; use crate::{contracts::EthereumMailbox, ConnectionConf, RpcConnectionConf};
/// An amount of gas to add to the estimated gas /// An amount of gas to add to the estimated gas
const GAS_ESTIMATE_BUFFER: u32 = 50000; const GAS_ESTIMATE_BUFFER: u32 = 50000;

@ -14,10 +14,9 @@ use hyperlane_core::{
MerkleTreeInsertion, SequenceAwareIndexer, H256, MerkleTreeInsertion, SequenceAwareIndexer, H256,
}; };
use crate::contracts::merkle_tree_hook::{MerkleTreeHook as MerkleTreeHookContract, Tree}; use crate::interfaces::merkle_tree_hook::{MerkleTreeHook as MerkleTreeHookContract, Tree};
use crate::trait_builder::BuildableWithProvider;
use crate::tx::call_with_lag; use crate::tx::call_with_lag;
use crate::{ConnectionConf, EthereumProvider}; use crate::{BuildableWithProvider, ConnectionConf, EthereumProvider};
// We don't need the reverse of this impl, so it's ok to disable the clippy lint // We don't need the reverse of this impl, so it's ok to disable the clippy lint
#[allow(clippy::from_over_into)] #[allow(clippy::from_over_into)]

@ -0,0 +1,9 @@
pub use {interchain_gas::*, mailbox::*, merkle_tree_hook::*, validator_announce::*};
mod interchain_gas;
mod mailbox;
mod merkle_tree_hook;
mod validator_announce;

@ -13,12 +13,11 @@ use hyperlane_core::{
use tracing::{instrument, log::trace}; use tracing::{instrument, log::trace};
use crate::{ use crate::{
contracts::i_validator_announce::{ interfaces::i_validator_announce::{
IValidatorAnnounce as EthereumValidatorAnnounceInternal, IVALIDATORANNOUNCE_ABI, IValidatorAnnounce as EthereumValidatorAnnounceInternal, IVALIDATORANNOUNCE_ABI,
}, },
trait_builder::BuildableWithProvider,
tx::{fill_tx_gas_params, report_tx}, tx::{fill_tx_gas_params, report_tx},
ConnectionConf, EthereumProvider, BuildableWithProvider, ConnectionConf, EthereumProvider,
}; };
impl<M> std::fmt::Display for EthereumValidatorAnnounceInternal<M> impl<M> std::fmt::Display for EthereumValidatorAnnounceInternal<M>
@ -176,6 +175,6 @@ impl HyperlaneAbi for EthereumValidatorAnnounceAbi {
const SELECTOR_SIZE_BYTES: usize = 4; const SELECTOR_SIZE_BYTES: usize = 4;
fn fn_map() -> HashMap<Vec<u8>, &'static str> { fn fn_map() -> HashMap<Vec<u8>, &'static str> {
super::extract_fn_map(&IVALIDATORANNOUNCE_ABI) crate::extract_fn_map(&IVALIDATORANNOUNCE_ABI)
} }
} }

@ -13,11 +13,10 @@ use hyperlane_core::{
HyperlaneDomain, HyperlaneMessage, HyperlaneProvider, RawHyperlaneMessage, H256, HyperlaneDomain, HyperlaneMessage, HyperlaneProvider, RawHyperlaneMessage, H256,
}; };
use crate::contracts::i_aggregation_ism::{ use crate::interfaces::i_aggregation_ism::{
IAggregationIsm as EthereumAggregationIsmInternal, IAGGREGATIONISM_ABI, IAggregationIsm as EthereumAggregationIsmInternal, IAGGREGATIONISM_ABI,
}; };
use crate::trait_builder::BuildableWithProvider; use crate::{BuildableWithProvider, ConnectionConf, EthereumProvider};
use crate::{ConnectionConf, EthereumProvider};
pub struct AggregationIsmBuilder {} pub struct AggregationIsmBuilder {}
@ -113,6 +112,6 @@ impl HyperlaneAbi for EthereumAggregationIsmAbi {
const SELECTOR_SIZE_BYTES: usize = 4; const SELECTOR_SIZE_BYTES: usize = 4;
fn fn_map() -> HashMap<Vec<u8>, &'static str> { fn fn_map() -> HashMap<Vec<u8>, &'static str> {
super::extract_fn_map(&IAGGREGATIONISM_ABI) crate::extract_fn_map(&IAGGREGATIONISM_ABI)
} }
} }

@ -13,11 +13,10 @@ use hyperlane_core::{
HyperlaneDomain, HyperlaneProvider, H256, HyperlaneDomain, HyperlaneProvider, H256,
}; };
pub use crate::contracts::i_ccip_read_ism::{ pub use crate::interfaces::i_ccip_read_ism::{
ICcipReadIsm as EthereumCcipReadIsmInternal, OffchainLookup, ICCIPREADISM_ABI, ICcipReadIsm as EthereumCcipReadIsmInternal, OffchainLookup, ICCIPREADISM_ABI,
}; };
use crate::trait_builder::BuildableWithProvider; use crate::{BuildableWithProvider, ConnectionConf, EthereumProvider};
use crate::{ConnectionConf, EthereumProvider};
pub struct CcipReadIsmBuilder {} pub struct CcipReadIsmBuilder {}
@ -105,6 +104,6 @@ impl HyperlaneAbi for EthereumCcipReadIsmAbi {
const SELECTOR_SIZE_BYTES: usize = 4; const SELECTOR_SIZE_BYTES: usize = 4;
fn fn_map() -> HashMap<Vec<u8>, &'static str> { fn fn_map() -> HashMap<Vec<u8>, &'static str> {
super::extract_fn_map(&ICCIPREADISM_ABI) crate::extract_fn_map(&ICCIPREADISM_ABI)
} }
} }

@ -16,12 +16,11 @@ use hyperlane_core::{
}; };
use num_traits::cast::FromPrimitive; use num_traits::cast::FromPrimitive;
use crate::contracts::i_interchain_security_module::{ use crate::interfaces::i_interchain_security_module::{
IInterchainSecurityModule as EthereumInterchainSecurityModuleInternal, IInterchainSecurityModule as EthereumInterchainSecurityModuleInternal,
IINTERCHAINSECURITYMODULE_ABI, IINTERCHAINSECURITYMODULE_ABI,
}; };
use crate::trait_builder::BuildableWithProvider; use crate::{BuildableWithProvider, ConnectionConf, EthereumProvider};
use crate::{ConnectionConf, EthereumProvider};
pub struct InterchainSecurityModuleBuilder {} pub struct InterchainSecurityModuleBuilder {}
@ -135,6 +134,6 @@ impl HyperlaneAbi for EthereumInterchainSecurityModuleAbi {
const SELECTOR_SIZE_BYTES: usize = 4; const SELECTOR_SIZE_BYTES: usize = 4;
fn fn_map() -> HashMap<Vec<u8>, &'static str> { fn fn_map() -> HashMap<Vec<u8>, &'static str> {
super::extract_fn_map(&IINTERCHAINSECURITYMODULE_ABI) crate::extract_fn_map(&IINTERCHAINSECURITYMODULE_ABI)
} }
} }

@ -0,0 +1,10 @@
pub use {
aggregation_ism::*, ccip_read_ism::*, interchain_security_module::*, multisig_ism::*,
routing_ism::*,
};
mod aggregation_ism;
mod ccip_read_ism;
mod interchain_security_module;
mod multisig_ism;
mod routing_ism;

@ -13,11 +13,10 @@ use hyperlane_core::{
HyperlaneMessage, HyperlaneProvider, MultisigIsm, RawHyperlaneMessage, H256, HyperlaneMessage, HyperlaneProvider, MultisigIsm, RawHyperlaneMessage, H256,
}; };
use crate::contracts::i_multisig_ism::{ use crate::interfaces::i_multisig_ism::{
IMultisigIsm as EthereumMultisigIsmInternal, IMULTISIGISM_ABI, IMultisigIsm as EthereumMultisigIsmInternal, IMULTISIGISM_ABI,
}; };
use crate::trait_builder::BuildableWithProvider; use crate::{BuildableWithProvider, ConnectionConf, EthereumProvider};
use crate::{ConnectionConf, EthereumProvider};
impl<M> std::fmt::Display for EthereumMultisigIsmInternal<M> impl<M> std::fmt::Display for EthereumMultisigIsmInternal<M>
where where
@ -119,6 +118,6 @@ impl HyperlaneAbi for EthereumMultisigIsmAbi {
const SELECTOR_SIZE_BYTES: usize = 4; const SELECTOR_SIZE_BYTES: usize = 4;
fn fn_map() -> HashMap<Vec<u8>, &'static str> { fn fn_map() -> HashMap<Vec<u8>, &'static str> {
super::extract_fn_map(&IMULTISIGISM_ABI) crate::extract_fn_map(&IMULTISIGISM_ABI)
} }
} }

@ -13,9 +13,10 @@ use hyperlane_core::{
HyperlaneMessage, HyperlaneProvider, RawHyperlaneMessage, RoutingIsm, H256, HyperlaneMessage, HyperlaneProvider, RawHyperlaneMessage, RoutingIsm, H256,
}; };
use crate::contracts::i_routing_ism::{IRoutingIsm as EthereumRoutingIsmInternal, IROUTINGISM_ABI}; use crate::interfaces::i_routing_ism::{
use crate::trait_builder::BuildableWithProvider; IRoutingIsm as EthereumRoutingIsmInternal, IROUTINGISM_ABI,
use crate::{ConnectionConf, EthereumProvider}; };
use crate::{BuildableWithProvider, ConnectionConf, EthereumProvider};
pub struct RoutingIsmBuilder {} pub struct RoutingIsmBuilder {}
@ -104,6 +105,6 @@ impl HyperlaneAbi for EthereumRoutingIsmAbi {
const SELECTOR_SIZE_BYTES: usize = 4; const SELECTOR_SIZE_BYTES: usize = 4;
fn fn_map() -> HashMap<Vec<u8>, &'static str> { fn fn_map() -> HashMap<Vec<u8>, &'static str> {
super::extract_fn_map(&IROUTINGISM_ABI) crate::extract_fn_map(&IROUTINGISM_ABI)
} }
} }

@ -8,71 +8,21 @@ use std::collections::HashMap;
use ethers::abi::FunctionExt; use ethers::abi::FunctionExt;
use ethers::prelude::{abi, Lazy, Middleware}; use ethers::prelude::{abi, Lazy, Middleware};
#[cfg(not(doctest))] pub use self::{config::*, contracts::*, ism::*, rpc_clients::*, signer::*};
pub use self::{
aggregation_ism::*, ccip_read_ism::*, config::*, config::*, interchain_gas::*,
interchain_gas::*, interchain_security_module::*, interchain_security_module::*, mailbox::*,
mailbox::*, merkle_tree_hook::*, multisig_ism::*, provider::*, routing_ism::*, rpc_clients::*,
signers::*, singleton_signer::*, trait_builder::*, validator_announce::*,
};
#[cfg(not(doctest))]
mod tx; mod tx;
/// Mailbox abi mod contracts;
#[cfg(not(doctest))]
mod mailbox;
#[cfg(not(doctest))]
mod trait_builder;
/// Provider abi
#[cfg(not(doctest))]
mod provider;
/// InterchainGasPaymaster abi
#[cfg(not(doctest))]
mod interchain_gas;
/// interchain_security_module abi
#[cfg(not(doctest))]
mod interchain_security_module;
/// Merkle tree hook abi
#[cfg(not(doctest))]
mod merkle_tree_hook;
/// MultisigIsm abi
#[cfg(not(doctest))]
mod multisig_ism;
/// RoutingIsm abi
#[cfg(not(doctest))]
mod routing_ism;
/// CcipReadIsm abi
#[cfg(not(doctest))]
mod ccip_read_ism;
/// ValidatorAnnounce abi
#[cfg(not(doctest))]
mod validator_announce;
/// AggregationIsm abi mod ism;
#[cfg(not(doctest))]
mod aggregation_ism;
/// Generated contract bindings. /// Generated contract bindings.
#[cfg(not(doctest))] mod interfaces;
mod contracts;
/// Ethers JSONRPC Client implementations /// Ethers JSONRPC Client implementations
mod rpc_clients; mod rpc_clients;
mod signers; mod signer;
#[cfg(not(doctest))]
mod singleton_signer;
mod config; mod config;
mod error; mod error;

@ -1,10 +1,12 @@
use ethers::providers::HttpClientError; use ethers::providers::HttpClientError;
use tracing::{info, trace, warn}; use tracing::{info, trace, warn};
pub use self::{fallback::*, retrying::*}; pub use self::{fallback::*, provider::*, retrying::*, trait_builder::*};
mod fallback; mod fallback;
mod provider;
mod retrying; mod retrying;
mod trait_builder;
enum CategorizedResponse<R> { enum CategorizedResponse<R> {
IsOk(R), IsOk(R),

@ -23,8 +23,8 @@ use hyperlane_core::{
ChainCommunicationError, ChainResult, ContractLocator, HyperlaneDomain, KnownHyperlaneDomain, ChainCommunicationError, ChainResult, ContractLocator, HyperlaneDomain, KnownHyperlaneDomain,
}; };
use crate::{signers::Signers, ConnectionConf, RetryingProvider}; use crate::signer::Signers;
use crate::{EthereumFallbackProvider, RpcConnectionConf}; use crate::{ConnectionConf, EthereumFallbackProvider, RetryingProvider, RpcConnectionConf};
// This should be whatever the prometheus scrape interval is // This should be whatever the prometheus scrape interval is
const HTTP_CLIENT_TIMEOUT: Duration = Duration::from_secs(60); const HTTP_CLIENT_TIMEOUT: Duration = Duration::from_secs(60);

@ -8,6 +8,9 @@ use hyperlane_core::{
HyperlaneSigner, HyperlaneSignerError, Signature as HyperlaneSignature, H160, H256, HyperlaneSigner, HyperlaneSignerError, Signature as HyperlaneSignature, H160, H256,
}; };
mod singleton;
pub use singleton::*;
/// Ethereum-supported signer types /// Ethereum-supported signer types
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum Signers { pub enum Signers {
@ -120,7 +123,7 @@ mod test {
Checkpoint, CheckpointWithMessageId, HyperlaneSigner, HyperlaneSignerExt, H256, Checkpoint, CheckpointWithMessageId, HyperlaneSigner, HyperlaneSignerExt, H256,
}; };
use crate::signers::Signers; use super::Signers;
#[test] #[test]
fn it_sign() { fn it_sign() {
Loading…
Cancel
Save