Skip to content

Commit

Permalink
Merge pull request #826 from worldcoin/piohei/fix_off_chain_startup
Browse files Browse the repository at this point in the history
Fix off chain startup.
  • Loading branch information
piohei authored Nov 25, 2024
2 parents a4fa9eb + c2a8a6e commit 8baed78
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/identity/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,27 @@ impl IdentityProcessor for OffChainIdentityProcessor {
}

async fn tree_init_correction(&self, _initial_root_hash: &Hash) -> anyhow::Result<()> {
// For off chain mode we don't correct tree at all
// it's enough to run with read committed here
// since in the worst case another instance of the sequencer
// will try to do the same thing but with a later root
// in such a case the state will be corrected later in the program
let mut tx = self
.database
.begin_tx(IsolationLevel::ReadCommitted)
.await?;

let root_hash = tx
.get_latest_root_by_status(ProcessedStatus::Processed)
.await?;

if let Some(root_hash) = root_hash {
// This deletion is required as when tree is being initialized we do not read batches.
// Just restarting from last processed tree.
tx.delete_batches_after_root(&root_hash).await?; // TODO: We probably shouldn't do this in HA
}

tx.commit().await?;

Ok(())
}

Expand Down

0 comments on commit 8baed78

Please sign in to comment.