Skip to content

Commit

Permalink
data restore: move duplicated blocks workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
slumber committed Nov 15, 2021
1 parent 9be62a6 commit 8bacd33
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 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,7 +485,7 @@ 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();

Expand All @@ -501,6 +494,8 @@ impl<T: Transport> DataRestoreDriver<T> {
.events_state
.get_only_verified_committed_events()
.iter()
.filter(|bl| bl.block_num > self.tree_state.state.block_number)
// TODO Fix event state and delete this code (ZKS-722)
{
// 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 +506,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 8bacd33

Please sign in to comment.