Skip to content

Commit

Permalink
Additional logging
Browse files Browse the repository at this point in the history
  • Loading branch information
tgmichel committed Feb 16, 2023
1 parent 63d4f70 commit c50f35f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
17 changes: 16 additions & 1 deletion client/db/src/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ where
BackendConfig::Sqlite(config) => {
let config = sqlx::sqlite::SqliteConnectOptions::from_str(config.path)?
.create_if_missing(config.create_if_missing)
.busy_timeout(std::time::Duration::from_secs(8))
.journal_mode(sqlx::sqlite::SqliteJournalMode::Wal); // https://www.sqlite.org/wal.html
Ok(config)
}
Expand Down Expand Up @@ -316,6 +317,10 @@ where
e
)
});
log::debug!(
target: "frontier-sql",
"🛠️ Batch commited"
);
}

fn spawn_logs_task_inner<Client, BE>(
Expand All @@ -329,6 +334,8 @@ where
BE::State: StateBackend<BlakeTwo256>,
{
let mut logs: Vec<Log> = vec![];
let mut transaction_count: usize = 0;
let mut log_count: usize = 0;
for substrate_block_hash in hashes.iter() {
let substrate_block_number: i32 =
if let Ok(Some(number)) = client.number(*substrate_block_hash) {
Expand All @@ -349,14 +356,16 @@ where
.unwrap_or(&overrides.fallback);

let receipts = handler.current_receipts(&id).unwrap_or_default();


transaction_count += receipts.len();
for (transaction_index, receipt) in receipts.iter().enumerate() {
let receipt_logs = match receipt {
ethereum::ReceiptV3::Legacy(d)
| ethereum::ReceiptV3::EIP2930(d)
| ethereum::ReceiptV3::EIP1559(d) => &d.logs,
};
let transaction_index = transaction_index as i32;
log_count += receipt_logs.len();
for (log_index, log) in receipt_logs.iter().enumerate() {
logs.push(Log {
block_number: substrate_block_number,
Expand Down Expand Up @@ -392,6 +401,12 @@ where
}
}
}
log::debug!(
target: "frontier-sql",
"🛠️ Ready to commit {} logs from {} transactions",
log_count,
transaction_count
);
logs
}

Expand Down
5 changes: 3 additions & 2 deletions client/mapping-sync/src/sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,12 @@ where
);
current_batch.push(hash);
} else {
current_batch.push(hash);
log::debug!(
target: "frontier-sql",
"🛠️ Processing batch"
"🛠️ Processing batch starting at {:?}",
current_batch.first()
);
current_batch.push(hash);
let _ = indexer_backend
.insert_block_metadata(client.clone(), current_batch)
.await
Expand Down

0 comments on commit c50f35f

Please sign in to comment.