From f73ee0b273b470be4443c9c0f63256ce202b74ce Mon Sep 17 00:00:00 2001 From: Daniel Savu <23065004+daniel-savu@users.noreply.github.com> Date: Wed, 20 Dec 2023 15:44:29 +0000 Subject: [PATCH] last round of PR remediations (#2791) Remediations for https://github.com/hyperlane-xyz/hyperlane-monorepo/pull/2746, in addition to https://github.com/hyperlane-xyz/hyperlane-monorepo/pull/2780 --- rust/agents/relayer/src/processor.rs | 7 +- rust/config/test_sealevel_config.json | 92 ++++++++++--------- rust/hyperlane-base/src/settings/chains.rs | 28 ++---- .../hyperlane-base/src/settings/parser/mod.rs | 4 +- 4 files changed, 60 insertions(+), 71 deletions(-) diff --git a/rust/agents/relayer/src/processor.rs b/rust/agents/relayer/src/processor.rs index d18397be0..122d96a5b 100644 --- a/rust/agents/relayer/src/processor.rs +++ b/rust/agents/relayer/src/processor.rs @@ -5,7 +5,7 @@ use derive_new::new; use eyre::Result; use hyperlane_core::HyperlaneDomain; use tokio::task::JoinHandle; -use tracing::{info_span, instrument, instrument::Instrumented, Instrument}; +use tracing::instrument; #[async_trait] pub trait ProcessorExt: Send + Debug { @@ -23,9 +23,8 @@ pub struct Processor { } impl Processor { - pub fn spawn(self) -> Instrumented>> { - let span = info_span!("MessageProcessor"); - tokio::spawn(async move { self.main_loop().await }).instrument(span) + pub fn spawn(self) -> JoinHandle> { + tokio::spawn(async move { self.main_loop().await }) } #[instrument(ret, err, skip(self), level = "info", fields(domain=%self.ticker.domain()))] diff --git a/rust/config/test_sealevel_config.json b/rust/config/test_sealevel_config.json index af814bd46..5eebd592a 100644 --- a/rust/config/test_sealevel_config.json +++ b/rust/config/test_sealevel_config.json @@ -1,48 +1,50 @@ { - "chains": { - "sealeveltest1": { - "name": "sealeveltest1", - "chainId": 13375, - "domainId": 13375, - "mailbox": "692KZJaoe2KRcD6uhCQDLLXnLNA5ZLnfvdqjE4aX9iu1", - "interchainGasPaymaster": "DrFtxirPPsfdY4HQiNZj2A9o4Ux7JaL3gELANgAoihhp", - "validatorAnnounce": "DH43ae1LwemXAboWwSh8zc9pG8j72gKUEXNi57w8fEnn", - "protocol": "sealevel", - "blocks": { - "reorgPeriod": 0, - "confirmations": 0 - }, - "rpcUrls": [ - { - "http": "http://localhost:8899" - } - ], - "index": { - "from": 1, - "mode": "sequence" - } - }, - "sealeveltest2": { - "name": "sealeveltest2", - "chainId": 13376, - "domainId": 13376, - "mailbox": "9tCUWNjpqcf3NUSrtp7vquYVCwbEByvLjZUrhG5dgvhj", - "interchainGasPaymaster": "G5rGigZBL8NmxCaukK2CAKr9Jq4SUfAhsjzeri7GUraK", - "validatorAnnounce": "3Uo5j2Bti9aZtrDqJmAyuwiFaJFPFoNL5yxTpVCNcUhb", - "protocol": "sealevel", - "blocks": { - "reorgPeriod": 0, - "confirmations": 0 - }, - "rpcUrls": [ - { - "http": "http://localhost:8899" - } - ], - "index": { - "from": 1, - "mode": "sequence" - } + "chains": { + "sealeveltest1": { + "name": "sealeveltest1", + "chainId": 13375, + "domainId": 13375, + "mailbox": "692KZJaoe2KRcD6uhCQDLLXnLNA5ZLnfvdqjE4aX9iu1", + "merkleTreeHook": "692KZJaoe2KRcD6uhCQDLLXnLNA5ZLnfvdqjE4aX9iu1", + "interchainGasPaymaster": "DrFtxirPPsfdY4HQiNZj2A9o4Ux7JaL3gELANgAoihhp", + "validatorAnnounce": "DH43ae1LwemXAboWwSh8zc9pG8j72gKUEXNi57w8fEnn", + "protocol": "sealevel", + "blocks": { + "reorgPeriod": 0, + "confirmations": 0 + }, + "rpcUrls": [ + { + "http": "http://localhost:8899" } + ], + "index": { + "from": 1, + "mode": "sequence" + } + }, + "sealeveltest2": { + "name": "sealeveltest2", + "chainId": 13376, + "domainId": 13376, + "mailbox": "9tCUWNjpqcf3NUSrtp7vquYVCwbEByvLjZUrhG5dgvhj", + "merkleTreeHook": "9tCUWNjpqcf3NUSrtp7vquYVCwbEByvLjZUrhG5dgvhj", + "interchainGasPaymaster": "G5rGigZBL8NmxCaukK2CAKr9Jq4SUfAhsjzeri7GUraK", + "validatorAnnounce": "3Uo5j2Bti9aZtrDqJmAyuwiFaJFPFoNL5yxTpVCNcUhb", + "protocol": "sealevel", + "blocks": { + "reorgPeriod": 0, + "confirmations": 0 + }, + "rpcUrls": [ + { + "http": "http://localhost:8899" + } + ], + "index": { + "from": 1, + "mode": "sequence" + } } -} \ No newline at end of file + } +} diff --git a/rust/hyperlane-base/src/settings/chains.rs b/rust/hyperlane-base/src/settings/chains.rs index 46379718c..a5bb21de3 100644 --- a/rust/hyperlane-base/src/settings/chains.rs +++ b/rust/hyperlane-base/src/settings/chains.rs @@ -85,7 +85,7 @@ pub struct CoreContractAddresses { /// Address of the ValidatorAnnounce contract pub validator_announce: H256, /// Address of the MerkleTreeHook contract - pub merkle_tree_hook: Option, + pub merkle_tree_hook: H256, } /// Indexing settings @@ -173,13 +173,7 @@ impl ChainConf { metrics: &CoreMetrics, ) -> Result> { let ctx = "Building merkle tree hook"; - // TODO: if the merkle tree hook is set for sealevel, it's still a mailbox program - // that the connection is made to using the pda seeds, which will not be usable. - let address = self - .addresses - .merkle_tree_hook - .unwrap_or(self.addresses.mailbox); - let locator = self.locator(address); + let locator = self.locator(self.addresses.merkle_tree_hook); match &self.connection { ChainConnectionConf::Ethereum(conf) => { @@ -368,11 +362,7 @@ impl ChainConf { metrics: &CoreMetrics, ) -> Result>> { let ctx = "Building merkle tree hook indexer"; - let address = self - .addresses - .merkle_tree_hook - .unwrap_or(self.addresses.mailbox); - let locator = self.locator(address); + let locator = self.locator(self.addresses.merkle_tree_hook); match &self.connection { ChainConnectionConf::Ethereum(conf) => { @@ -704,13 +694,11 @@ impl ChainConf { self.addresses.interchain_gas_paymaster, EthereumInterchainGasPaymasterAbi::fn_map_owned(), ); - if let Some(address) = self.addresses.merkle_tree_hook { - register_contract( - "merkle_tree_hook", - address, - EthereumInterchainGasPaymasterAbi::fn_map_owned(), - ); - } + register_contract( + "merkle_tree_hook", + self.addresses.merkle_tree_hook, + EthereumInterchainGasPaymasterAbi::fn_map_owned(), + ); cfg } diff --git a/rust/hyperlane-base/src/settings/parser/mod.rs b/rust/hyperlane-base/src/settings/parser/mod.rs index aad2e8735..76c88fe1b 100644 --- a/rust/hyperlane-base/src/settings/parser/mod.rs +++ b/rust/hyperlane-base/src/settings/parser/mod.rs @@ -221,7 +221,7 @@ fn parse_chain( .end(); let merkle_tree_hook = chain .chain(&mut err) - .get_opt_key("merkleTreeHook") + .get_key("merkleTreeHook") .parse_address_hash() .end(); @@ -234,7 +234,7 @@ fn parse_chain( default_rpc_consensus_type, ); - cfg_unwrap_all!(&chain.cwp, err: [connection, mailbox, interchain_gas_paymaster, validator_announce]); + cfg_unwrap_all!(&chain.cwp, err: [connection, mailbox, interchain_gas_paymaster, validator_announce, merkle_tree_hook]); err.into_result(ChainConf { domain, signer,