From 9da6baaa967c75ac320f1173bf14bd4126fa35c6 Mon Sep 17 00:00:00 2001 From: akhercha Date: Fri, 28 Jun 2024 11:49:15 +0200 Subject: [PATCH] feat(state_update_job): Simple comments for context --- crates/orchestrator/src/jobs/state_update_job/mod.rs | 2 +- .../settlement-clients/settlement-client-interface/src/lib.rs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/orchestrator/src/jobs/state_update_job/mod.rs b/crates/orchestrator/src/jobs/state_update_job/mod.rs index cca967f2..9062d5e1 100644 --- a/crates/orchestrator/src/jobs/state_update_job/mod.rs +++ b/crates/orchestrator/src/jobs/state_update_job/mod.rs @@ -117,6 +117,7 @@ impl Job for StateUpdateJob { job.metadata.insert(JOB_METADATA_STATE_UPDATE_LAST_FAILED_BLOCK_NO.into(), block_no.to_string()); return Ok(tx_inclusion_status.into()); } + // If the tx is still pending, we wait for it to be finalized and check again the status. SettlementVerificationStatus::Pending => { settlement_client.wait_for_tx_finality(tx_hash).await?; let new_status = settlement_client.verify_tx_inclusion(tx_hash).await?; @@ -137,7 +138,6 @@ impl Job for StateUpdateJob { } // verify that the last settled block is indeed the one we expect to be let expected_last_block_number = block_numbers.last().expect("Block numbers list should not be empty."); - let out_last_block_number = settlement_client.get_last_settled_block().await?; let block_status = if out_last_block_number == *expected_last_block_number { SettlementVerificationStatus::Verified diff --git a/crates/settlement-clients/settlement-client-interface/src/lib.rs b/crates/settlement-clients/settlement-client-interface/src/lib.rs index e718cf74..2ea25708 100644 --- a/crates/settlement-clients/settlement-client-interface/src/lib.rs +++ b/crates/settlement-clients/settlement-client-interface/src/lib.rs @@ -34,8 +34,10 @@ pub trait SettlementClient: Send + Sync { /// Should verify the inclusion of a tx in the settlement layer async fn verify_tx_inclusion(&self, tx_hash: &str) -> Result; + /// Should wait that the pending tx_hash is finalized async fn wait_for_tx_finality(&self, tx_hash: &str) -> Result<()>; + /// Should retrieves the last settled block in the settlement layer async fn get_last_settled_block(&self) -> Result; }