Skip to content

Commit

Permalink
fix order of db commits (#902)
Browse files Browse the repository at this point in the history
  • Loading branch information
eyusufatik authored Jul 18, 2024
1 parent d1fea9d commit d54cf83
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions crates/fullnode/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions crates/prover/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -379,8 +381,6 @@ where
l2_height, self.state_root
);

self.storage_manager.finalize_l2(l2_height)?;

Ok(())
}

Expand Down
10 changes: 5 additions & 5 deletions crates/sequencer/src/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: #{}",
Expand Down

0 comments on commit d54cf83

Please sign in to comment.