Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
refactor(concurrency, execution): add concurrency_mode parameter to T…
Browse files Browse the repository at this point in the history
…ransfersGenerator::new (#1966)
  • Loading branch information
barak-b-starkware authored Jun 10, 2024
1 parent ba7927a commit 441c27f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
3 changes: 2 additions & 1 deletion crates/blockifier/bench/blockifier_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ use blockifier::test_utils::transfers_generator::TransfersGenerator;
use criterion::{criterion_group, criterion_main, Criterion};

pub fn transfers_benchmark(c: &mut Criterion) {
let mut transfers_generator = TransfersGenerator::new();
let concurrency_mode = false;
let mut transfers_generator = TransfersGenerator::new(concurrency_mode);
// Create a benchmark group called "transfers", which iterates over the accounts round-robin
// and performs transfers.
c.bench_function("transfers", |benchmark| {
Expand Down
3 changes: 2 additions & 1 deletion crates/blockifier/src/blockifier/transfers_flow_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::test_utils::transfers_generator::TransfersGenerator;

#[test]
pub fn transfers_flow_test() {
let mut transfers_generator = TransfersGenerator::new();
let concurrency_mode = true;
let mut transfers_generator = TransfersGenerator::new(concurrency_mode);
transfers_generator.execute_chunk_of_transfers();
}
11 changes: 3 additions & 8 deletions crates/blockifier/src/test_utils/transfers_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ pub struct TransfersGenerator {
}

impl TransfersGenerator {
pub fn new() -> Self {
pub fn new(concurrency_mode: bool) -> Self {
let account_contract = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo0);
let block_context = BlockContext::create_for_account_testing();
let block_context =
BlockContext::create_for_account_testing_with_concurrency_mode(concurrency_mode);
let chain_info = block_context.chain_info().clone();
let state = test_state(&chain_info, BALANCE * 1000, &[(account_contract, N_ACCOUNTS)]);
// TODO(Avi, 20/05/2024): Enable concurrency.
Expand Down Expand Up @@ -115,9 +116,3 @@ impl TransfersGenerator {
AccountTransaction::Invoke(tx)
}
}

impl Default for TransfersGenerator {
fn default() -> Self {
Self::new()
}
}

0 comments on commit 441c27f

Please sign in to comment.