Add sleeps to indexing loops (#1254)

* Add sleeps to indexing loops

* Fix issue after testing

* Re-order metrics and sleep

* Fix bug

* Change consts
pull/1262/head
Mattie Conover 2 years ago committed by GitHub
parent 05e10b656d
commit 41b5c31157
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      rust/abacus-base/src/contract_sync/interchain_gas.rs
  2. 5
      rust/abacus-base/src/contract_sync/outbox.rs
  3. 6
      rust/abacus-base/src/settings/chains.rs
  4. 4
      rust/agents/scraper/src/scraper/mod.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;
}

@ -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()

@ -1,4 +1,3 @@
use ethers::abi::AbiEncode;
use ethers::signers::Signer;
use eyre::Context;
use serde::Deserialize;
@ -131,10 +130,11 @@ impl<T> ChainSetup<T> {
};
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<B: MakeableWithProvider + Sync>(

@ -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;
}

Loading…
Cancel
Save