Skip to content

Commit

Permalink
Merge pull request #2009 from matter-labs/slumber-data-restore-duplic…
Browse files Browse the repository at this point in the history
…ated-blocks

data restore: move duplicated blocks workaround
  • Loading branch information
Deniallugo authored Nov 16, 2021
2 parents 9be62a6 + c3338f7 commit 5135a37
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions core/bin/data_restore/src/data_restore_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,8 @@ impl<T: Transport> DataRestoreDriver<T> {

// Update events
if self.update_events_state(interactor).await {
vlog::debug!("Events state");
// Update operations
let new_ops_blocks = self.update_operations_state(interactor).await;
vlog::debug!("Operations state");

if !new_ops_blocks.is_empty() {
let mut transaction = interactor.start_transaction().await;
Expand Down Expand Up @@ -442,11 +440,6 @@ impl<T: Transport> DataRestoreDriver<T> {
let mut updates = vec![];
let mut count = 0;

// TODO Fix event state and delete this code (ZKS-722)
let new_ops_blocks: Vec<RollupOpsBlock> = new_ops_blocks
.into_iter()
.filter(|bl| bl.block_num > self.tree_state.state.block_number)
.collect();
for op_block in new_ops_blocks {
// Take the contract version into account when choosing block chunk sizes.
let available_block_chunk_sizes = op_block
Expand Down Expand Up @@ -492,15 +485,19 @@ impl<T: Transport> DataRestoreDriver<T> {
new_blocks
}

/// Returns verified comitted operations blocks from verified op blocks events
/// Returns operations blocks from verified op blocks events.
pub async fn get_new_operation_blocks_from_events(&mut self) -> Vec<RollupOpsBlock> {
let mut blocks = Vec::new();

let mut last_event_tx_hash = None;
// TODO (ZKS-722): either due to Ethereum node lag or unknown
// bug in the events state, we have to additionally filter out
// already processed rollup blocks.
for event in self
.events_state
.get_only_verified_committed_events()
.iter()
.filter(|bl| bl.block_num > self.tree_state.state.block_number)
{
// We use an aggregated block in contracts, which means that several BlockEvent can include the same tx_hash,
// but for correct restore we need to generate RollupBlocks from this tx only once.
Expand All @@ -511,7 +508,7 @@ impl<T: Transport> DataRestoreDriver<T> {
}
}

let block = RollupOpsBlock::get_rollup_ops_blocks(&self.web3, &event)
let block = RollupOpsBlock::get_rollup_ops_blocks(&self.web3, event)
.await
.expect("Cant get new operation blocks from events");
blocks.extend(block);
Expand Down

0 comments on commit 5135a37

Please sign in to comment.