Fix contract sync heights (#1281)

* Fix contract sync heights

* Requested changesˆ
pull/1285/head
Mattie Conover 2 years ago committed by GitHub
parent 58492691c3
commit 4e76095876
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      rust/abacus-base/src/contract_sync/interchain_gas.rs
  2. 5
      rust/abacus-base/src/contract_sync/outbox.rs
  3. 10
      rust/agents/scraper/src/chain_scraper/sync.rs

@ -40,9 +40,9 @@ where
.map_or_else(|| config_from, |b| b + 1);
info!(from = from, "[GasPayments]: resuming indexer from {from}");
indexed_height.set(from as i64);
loop {
indexed_height.set(from.into());
sleep(Duration::from_secs(5)).await;
// Only index blocks considered final.
@ -84,6 +84,7 @@ where
db.store_latest_indexed_gas_payment_block(to)?;
from = to + 1;
indexed_height.set(to as i64);
}
})
.instrument(span)

@ -87,8 +87,8 @@ where
info!(from = from, "[Messages]: resuming indexer from latest valid message range start block");
loop {
indexed_height.set(from as i64);
loop {
sleep(Duration::from_secs(5)).await;
// Only index blocks considered final.
@ -160,6 +160,7 @@ where
// Move forward to the next height
from = to + 1;
indexed_height.set(to as i64);
}
// The index of the first message in sorted_messages is not the
// `last_leaf_index+1`.
@ -175,6 +176,7 @@ where
);
from = last_valid_range_start_block;
indexed_height.set(from as i64);
}
ListValidity::ContainsGaps => {
missed_messages.inc();
@ -192,6 +194,7 @@ where
// if the range was correctly indexed if there are no messages to observe their
// indices.
from = to + 1;
indexed_height.set(to as i64);
}
};
}

@ -102,10 +102,10 @@ impl Syncer {
#[instrument(skip(self), fields(chain_name = self.chain_name(), chink_size = self.chunk_size))]
pub async fn run(mut self) -> Result<()> {
info!(from = self.from, "Resuming chain sync");
loop {
self.indexed_message_height.set(self.from as i64);
self.indexed_deliveries_height.set(self.from as i64);
loop {
sleep(Duration::from_secs(5)).await;
let Ok(tip) = self.get_finalized_block_number().await else {
@ -136,10 +136,14 @@ impl Syncer {
}
self.last_valid_range_start_block = full_chunk_from;
self.from = to + 1;
self.indexed_message_height.set(to as i64);
self.indexed_deliveries_height.set(to as i64);
}
ListValidity::Empty => {
let _ = self.record_data(sorted_messages, deliveries).await?;
self.from = to + 1;
self.indexed_message_height.set(to as i64);
self.indexed_deliveries_height.set(to as i64);
}
ListValidity::InvalidContinuation => {
self.missed_messages.inc();
@ -151,6 +155,8 @@ impl Syncer {
"Found invalid continuation in range. Re-indexing from the start block of the last successful range."
);
self.from = self.last_valid_range_start_block;
self.indexed_message_height.set(self.from as i64);
self.indexed_deliveries_height.set(self.from as i64);
}
ListValidity::ContainsGaps => {
self.missed_messages.inc();

Loading…
Cancel
Save