Skip to content

Commit

Permalink
fix: use BootloaderJobType::TransactionExecution
Browse files Browse the repository at this point in the history
  • Loading branch information
grw-ms committed Sep 18, 2023
1 parent 3f9b4bd commit 2bdd04c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
10 changes: 9 additions & 1 deletion src/hardhat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,17 @@ mod tests {

// test with custom values
let result = hardhat
.hardhat_mine(Some(U64::from(5)), Some(U64::from(10)))
.hardhat_mine(Some(U64::from(2)), Some(U64::from(10)))
.await
.expect("hardhat_mine");
assert_eq!(result, true);

let current_block = node
.get_block_by_number(zksync_types::api::BlockNumber::Latest, false)
.await
.unwrap()
.expect("block exists");
assert_eq!(start_block.number + 5, current_block.number);
assert_eq!(start_block.timestamp + 50_000, current_block.timestamp);
}
}
18 changes: 11 additions & 7 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ pub fn mine_empty_blocks<S: std::fmt::Debug + ForkSource>(

let block = Block {
hash: compute_hash(node.current_miniblock as u32, H256::zero()),
number: node.current_batch.into(),
number: node.current_miniblock.into(),
timestamp: node.current_timestamp.into(),
..Default::default()
};
Expand All @@ -182,22 +182,23 @@ pub fn mine_empty_blocks<S: std::fmt::Debug + ForkSource>(

// leave node state ready for next interaction
node.current_timestamp = node.current_timestamp.saturating_add(interval_ms);
node.current_batch = node.current_batch.saturating_add(1);
}

// roll the vm
let (keys, bytecodes) = {
let mut storage_view: StorageView<&ForkStorage<S>> = StorageView::new(&node.fork_storage);
let mut oracle_tools = OracleTools::new(&mut storage_view, HistoryEnabled);

let bootloader_code = &node.system_contracts.playground_contracts;

let bootloader_code = node
.system_contracts
.contracts(TxExecutionMode::VerifyExecute);
let block_context = BlockContext {
block_number: node.current_batch - 1,
block_number: node.current_miniblock as u32,
block_timestamp: node.current_timestamp,
..node.create_block_context()
};
let block_properties = InMemoryNodeInner::<S>::create_block_properties(bootloader_code);
let block_properties: zksync_types::zk_evm::block_properties::BlockProperties =
InMemoryNodeInner::<S>::create_block_properties(bootloader_code);

// init vm
let mut vm = init_vm_inner(
Expand All @@ -209,7 +210,7 @@ pub fn mine_empty_blocks<S: std::fmt::Debug + ForkSource>(
TxExecutionMode::VerifyExecute,
);

vm.execute_till_block_end(BootloaderJobType::BlockPostprocessing);
vm.execute_till_block_end(BootloaderJobType::TransactionExecution);

let bytecodes = vm
.state
Expand Down Expand Up @@ -239,6 +240,9 @@ pub fn mine_empty_blocks<S: std::fmt::Debug + ForkSource>(
.collect(),
)
}

// increment batch
node.current_batch = node.current_batch.saturating_add(1);
}

#[cfg(test)]
Expand Down

0 comments on commit 2bdd04c

Please sign in to comment.