From 41b5c3115792f6f47ae9042fd51069bfb5d50e2e Mon Sep 17 00:00:00 2001 From: Mattie Conover Date: Wed, 9 Nov 2022 14:44:55 -0800 Subject: [PATCH] Add sleeps to indexing loops (#1254) * Add sleeps to indexing loops * Fix issue after testing * Re-order metrics and sleep * Fix bug * Change consts --- rust/abacus-base/src/contract_sync/interchain_gas.rs | 5 +++-- rust/abacus-base/src/contract_sync/outbox.rs | 5 +++-- rust/abacus-base/src/settings/chains.rs | 6 +++--- rust/agents/scraper/src/scraper/mod.rs | 4 +++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/rust/abacus-base/src/contract_sync/interchain_gas.rs b/rust/abacus-base/src/contract_sync/interchain_gas.rs index 6fab085ac..f2b6fd24e 100644 --- a/rust/abacus-base/src/contract_sync/interchain_gas.rs +++ b/rust/abacus-base/src/contract_sync/interchain_gas.rs @@ -43,6 +43,7 @@ where loop { indexed_height.set(from.into()); + sleep(Duration::from_secs(5)).await; // Only index blocks considered final. // If there's an error getting the block number, just start the loop over @@ -52,9 +53,9 @@ where continue; }; if tip <= from { - debug!(tip=?tip, from=?from, "[GasPayments]: caught up to tip, waiting for new block"); // Sleep if caught up to tip - sleep(Duration::from_secs(1)).await; + debug!(tip=?tip, from=?from, "[GasPayments]: caught up to tip, waiting for new block"); + sleep(Duration::from_secs(10)).await; continue; } diff --git a/rust/abacus-base/src/contract_sync/outbox.rs b/rust/abacus-base/src/contract_sync/outbox.rs index 94cceaecb..0b70300ea 100644 --- a/rust/abacus-base/src/contract_sync/outbox.rs +++ b/rust/abacus-base/src/contract_sync/outbox.rs @@ -89,6 +89,7 @@ where loop { indexed_height.set(from as i64); + sleep(Duration::from_secs(5)).await; // Only index blocks considered final. // If there's an error getting the block number, just start the loop over @@ -99,7 +100,7 @@ where }; if tip <= from { // Sleep if caught up to tip - sleep(Duration::from_secs(1)).await; + sleep(Duration::from_secs(10)).await; continue; } @@ -462,7 +463,7 @@ mod test { ); let sync_task = contract_sync.sync_outbox_messages(); - let test_pass_fut = timeout(Duration::from_secs(30), async move { + let test_pass_fut = timeout(Duration::from_secs(90), async move { let mut interval = interval(Duration::from_millis(20)); loop { if abacus_db.message_by_leaf_index(0).expect("!db").is_some() diff --git a/rust/abacus-base/src/settings/chains.rs b/rust/abacus-base/src/settings/chains.rs index f386c7840..76839ef13 100644 --- a/rust/abacus-base/src/settings/chains.rs +++ b/rust/abacus-base/src/settings/chains.rs @@ -1,4 +1,3 @@ -use ethers::abi::AbiEncode; use ethers::signers::Signer; use eyre::Context; use serde::Deserialize; @@ -131,10 +130,11 @@ impl ChainSetup { }; let address = match &self.chain { - ChainConf::Ethereum(_) => ethers::types::Address::zero().encode_hex(), + ChainConf::Ethereum(_) => "0x0000000000000000000000000000000000000000", }; - self.build(&address, None, metrics, metrics_conf, builder) + self.build(address, None, metrics, metrics_conf, builder) .await + .context("Building provider") } async fn build( diff --git a/rust/agents/scraper/src/scraper/mod.rs b/rust/agents/scraper/src/scraper/mod.rs index acd83a00c..4b0ad7710 100644 --- a/rust/agents/scraper/src/scraper/mod.rs +++ b/rust/agents/scraper/src/scraper/mod.rs @@ -339,6 +339,7 @@ impl SqlChainScraper { loop { indexed_message_height.set(from as i64); indexed_deliveries_height.set(from as i64); + sleep(Duration::from_secs(5)).await; let tip = if let Ok(num) = self.get_finalized_block_number().await { num @@ -346,7 +347,8 @@ impl SqlChainScraper { continue; }; if tip <= from { - sleep(Duration::from_secs(1)).await; + // Sleep if caught up to tip + sleep(Duration::from_secs(10)).await; continue; }