From 1d1b7957511945bf6c0cfaad86b1ed1a36f655a9 Mon Sep 17 00:00:00 2001 From: eyusufatik Date: Thu, 18 Jul 2024 12:07:36 +0300 Subject: [PATCH] fix order of db commits --- crates/fullnode/src/runner.rs | 6 +++--- crates/prover/src/runner.rs | 4 ++-- crates/sequencer/src/sequencer.rs | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/fullnode/src/runner.rs b/crates/fullnode/src/runner.rs index 7c3f11e3f..38c9d9d22 100644 --- a/crates/fullnode/src/runner.rs +++ b/crates/fullnode/src/runner.rs @@ -458,14 +458,14 @@ where self.storage_manager.finalize_l2(l2_height)?; + self.ledger_db + .commit_soft_batch(soft_batch_receipt, self.include_tx_body)?; + self.ledger_db.extend_l2_range_of_l1_slot( SlotNumber(current_l1_block.header().height()), BatchNumber(l2_height), )?; - self.ledger_db - .commit_soft_batch(soft_batch_receipt, self.include_tx_body)?; - self.state_root = next_state_root; self.batch_hash = soft_batch.hash; diff --git a/crates/prover/src/runner.rs b/crates/prover/src/runner.rs index 512e15e6d..d9b516eae 100644 --- a/crates/prover/src/runner.rs +++ b/crates/prover/src/runner.rs @@ -346,6 +346,8 @@ where self.storage_manager .save_change_set_l2(l2_height, slot_result.change_set)?; + self.storage_manager.finalize_l2(l2_height)?; + let batch_receipt = data_to_commit.batch_receipts()[0].clone(); let soft_batch_receipt = SoftBatchReceipt::<_, _, Da::Spec> { @@ -379,8 +381,6 @@ where l2_height, self.state_root ); - self.storage_manager.finalize_l2(l2_height)?; - Ok(()) } diff --git a/crates/sequencer/src/sequencer.rs b/crates/sequencer/src/sequencer.rs index 52deae541..79bdff3bf 100644 --- a/crates/sequencer/src/sequencer.rs +++ b/crates/sequencer/src/sequencer.rs @@ -510,23 +510,23 @@ where timestamp: signed_soft_batch.timestamp(), }; + self.storage_manager + .save_change_set_l2(l2_height, slot_result.change_set)?; + // TODO: this will only work for mock da // when https://github.com/Sovereign-Labs/sovereign-sdk/issues/1218 // is merged, rpc will access up to date storage then we won't need to finalize rigth away. // however we need much better DA + finalization logic here - self.storage_manager - .save_change_set_l2(l2_height, slot_result.change_set)?; - self.storage_manager.finalize_l2(l2_height)?; + self.ledger_db.commit_soft_batch(soft_batch_receipt, true)?; + // connect L1 and L2 height self.ledger_db.extend_l2_range_of_l1_slot( SlotNumber(da_block.header().height()), BatchNumber(l2_height), )?; - self.ledger_db.commit_soft_batch(soft_batch_receipt, true)?; - let l1_height = da_block.header().height(); info!( "New block #{}, DA #{}, Tx count: #{}",