From edb91702846f16e1ff363ec315ddb9a4b66915c8 Mon Sep 17 00:00:00 2001 From: dorimedini-starkware Date: Tue, 2 Jul 2024 18:08:50 +0300 Subject: [PATCH 01/10] fix: merge paths (#2026) Signed-off-by: Dori Medini --- scripts/merge_paths.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/merge_paths.json b/scripts/merge_paths.json index 34de885559..5fa5c408d2 100644 --- a/scripts/merge_paths.json +++ b/scripts/merge_paths.json @@ -1,3 +1,4 @@ { - "main-v0.13.1": "main" + "main-v0.13.1": "main-v0.13.2", + "main-v0.13.2": "main" } From 50ffbce474eaf7cf991d2af879ec0b492957ff9a Mon Sep 17 00:00:00 2001 From: dorimedini-starkware Date: Tue, 2 Jul 2024 18:18:23 +0300 Subject: [PATCH 02/10] fix: verify dependencies CI phase (#2027) Signed-off-by: Dori Medini --- .github/workflows/verify-deps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify-deps.yml b/.github/workflows/verify-deps.yml index 3d77332173..5e11b67b97 100644 --- a/.github/workflows/verify-deps.yml +++ b/.github/workflows/verify-deps.yml @@ -7,7 +7,7 @@ on: jobs: latest_deps: name: Latest Dependencies - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 continue-on-error: true steps: - uses: actions/checkout@v4 From 981a64662305aac995ad328d287d2663a89bfe91 Mon Sep 17 00:00:00 2001 From: dorimedini-starkware Date: Wed, 3 Jul 2024 12:30:31 +0300 Subject: [PATCH 03/10] fix: cargo build without testing feature (#2032) Signed-off-by: Dori Medini --- .github/workflows/ci.yml | 10 ++++++++++ crates/blockifier/src/blockifier/config.rs | 1 + 2 files changed, 11 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9e538ae99e..bf4b7e8f3d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,6 +76,16 @@ jobs: - run: scripts/clippy.sh + featureless-build: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + prefix-key: "v0-rust-ubuntu-20.04" + - run: cargo build -p blockifier + run-python-tests: runs-on: ubuntu-20.04 steps: diff --git a/crates/blockifier/src/blockifier/config.rs b/crates/blockifier/src/blockifier/config.rs index c77b3495c3..43cb352c27 100644 --- a/crates/blockifier/src/blockifier/config.rs +++ b/crates/blockifier/src/blockifier/config.rs @@ -3,6 +3,7 @@ pub struct TransactionExecutorConfig { pub concurrency_config: ConcurrencyConfig, } impl TransactionExecutorConfig { + #[cfg(feature = "testing")] pub fn create_for_testing() -> Self { Self { concurrency_config: ConcurrencyConfig::create_for_testing() } } From b8b152e18ec66853819540daf6ac142442064689 Mon Sep 17 00:00:00 2001 From: dorimedini-starkware Date: Wed, 3 Jul 2024 18:49:18 +0300 Subject: [PATCH 04/10] fix: featureless testing (#2033) Signed-off-by: Dori Medini --- .github/workflows/ci.yml | 1 + crates/blockifier/Cargo.toml | 5 +++++ crates/blockifier/src/blockifier/config.rs | 6 +++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf4b7e8f3d..e4c161921f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,6 +85,7 @@ jobs: with: prefix-key: "v0-rust-ubuntu-20.04" - run: cargo build -p blockifier + - run: cargo test -p blockifier run-python-tests: runs-on: ubuntu-20.04 diff --git a/crates/blockifier/Cargo.toml b/crates/blockifier/Cargo.toml index bf35900c7f..6baafab7da 100644 --- a/crates/blockifier/Cargo.toml +++ b/crates/blockifier/Cargo.toml @@ -66,3 +66,8 @@ test-case.workspace = true harness = false name = "blockifier_bench" path = "bench/blockifier_bench.rs" + +[[test]] +name = "feature_contracts_compatibility_test" +path = "tests/feature_contracts_compatibility_test.rs" +required-features = ["testing"] diff --git a/crates/blockifier/src/blockifier/config.rs b/crates/blockifier/src/blockifier/config.rs index 43cb352c27..6de9f5ab71 100644 --- a/crates/blockifier/src/blockifier/config.rs +++ b/crates/blockifier/src/blockifier/config.rs @@ -3,7 +3,7 @@ pub struct TransactionExecutorConfig { pub concurrency_config: ConcurrencyConfig, } impl TransactionExecutorConfig { - #[cfg(feature = "testing")] + #[cfg(any(test, feature = "testing"))] pub fn create_for_testing() -> Self { Self { concurrency_config: ConcurrencyConfig::create_for_testing() } } @@ -15,14 +15,14 @@ pub struct ConcurrencyConfig { pub n_workers: usize, pub chunk_size: usize, } -#[cfg(all(feature = "testing", not(feature = "concurrency")))] +#[cfg(all(any(test, feature = "testing"), not(feature = "concurrency")))] impl ConcurrencyConfig { pub fn create_for_testing() -> Self { Self { enabled: false, n_workers: 0, chunk_size: 0 } } } -#[cfg(all(feature = "testing", feature = "concurrency"))] +#[cfg(all(any(test, feature = "testing"), feature = "concurrency"))] impl ConcurrencyConfig { pub fn create_for_testing() -> Self { Self { enabled: true, n_workers: 4, chunk_size: 64 } From 1494fca910a3ab1536730d90f95b97afafb6dc65 Mon Sep 17 00:00:00 2001 From: OriStarkware <76900983+OriStarkware@users.noreply.github.com> Date: Thu, 4 Jul 2024 10:01:21 +0300 Subject: [PATCH 05/10] refactor(concurrency): add execution flags struct (#2024) --- .../src/blockifier/transaction_executor.rs | 17 +++------ .../blockifier/src/concurrency/test_utils.rs | 16 +++------ .../src/concurrency/worker_logic.rs | 17 +++------ .../src/transaction/account_transaction.rs | 26 +++++++++----- .../transaction/account_transactions_test.rs | 35 +++++++------------ .../src/transaction/transaction_execution.rs | 23 +++++------- .../src/transaction/transactions.rs | 22 ++++++------ 7 files changed, 62 insertions(+), 94 deletions(-) diff --git a/crates/blockifier/src/blockifier/transaction_executor.rs b/crates/blockifier/src/blockifier/transaction_executor.rs index 0765aca58b..7e2941fc79 100644 --- a/crates/blockifier/src/blockifier/transaction_executor.rs +++ b/crates/blockifier/src/blockifier/transaction_executor.rs @@ -21,7 +21,7 @@ use crate::state::state_api::StateReader; use crate::transaction::errors::TransactionExecutionError; use crate::transaction::objects::TransactionExecutionInfo; use crate::transaction::transaction_execution::Transaction; -use crate::transaction::transactions::ExecutableTransaction; +use crate::transaction::transactions::{ExecutableTransaction, ExecutionFlags}; #[cfg(test)] #[path = "transaction_executor_test.rs"] @@ -88,18 +88,11 @@ impl TransactionExecutor { let mut transactional_state = TransactionalState::create_transactional( self.block_state.as_mut().expect(BLOCK_STATE_ACCESS_ERR), ); - let validate = true; - let charge_fee = true; // Executing a single transaction cannot be done in a concurrent mode. - let concurrency_mode = false; - - let tx_execution_result = tx.execute_raw( - &mut transactional_state, - &self.block_context, - charge_fee, - validate, - concurrency_mode, - ); + let execution_flags = + ExecutionFlags { charge_fee: true, validate: true, concurrency_mode: false }; + let tx_execution_result = + tx.execute_raw(&mut transactional_state, &self.block_context, execution_flags); match tx_execution_result { Ok(tx_execution_info) => { let tx_state_changes_keys = diff --git a/crates/blockifier/src/concurrency/test_utils.rs b/crates/blockifier/src/concurrency/test_utils.rs index e3918c3ef8..87722b1171 100644 --- a/crates/blockifier/src/concurrency/test_utils.rs +++ b/crates/blockifier/src/concurrency/test_utils.rs @@ -9,7 +9,7 @@ use crate::state::cached_state::{CachedState, TransactionalState}; use crate::state::state_api::StateReader; use crate::test_utils::dict_state_reader::DictStateReader; use crate::transaction::account_transaction::AccountTransaction; -use crate::transaction::transactions::ExecutableTransaction; +use crate::transaction::transactions::{ExecutableTransaction, ExecutionFlags}; // Public Consts. @@ -76,17 +76,9 @@ pub fn create_fee_transfer_call_info( ) -> CallInfo { let block_context = BlockContext::create_for_account_testing(); let mut transactional_state = TransactionalState::create_transactional(state); - let charge_fee = true; - let validate = true; - let execution_info = account_tx - .execute_raw( - &mut transactional_state, - &block_context, - charge_fee, - validate, - concurrency_mode, - ) - .unwrap(); + let execution_flags = ExecutionFlags { charge_fee: true, validate: true, concurrency_mode }; + let execution_info = + account_tx.execute_raw(&mut transactional_state, &block_context, execution_flags).unwrap(); let execution_info = execution_info.fee_transfer_call_info.unwrap(); transactional_state.abort(); diff --git a/crates/blockifier/src/concurrency/worker_logic.rs b/crates/blockifier/src/concurrency/worker_logic.rs index c4214eb5a0..60d5b19e71 100644 --- a/crates/blockifier/src/concurrency/worker_logic.rs +++ b/crates/blockifier/src/concurrency/worker_logic.rs @@ -21,7 +21,7 @@ use crate::state::cached_state::{ use crate::state::state_api::{StateReader, UpdatableState}; use crate::transaction::objects::{TransactionExecutionInfo, TransactionExecutionResult}; use crate::transaction::transaction_execution::Transaction; -use crate::transaction::transactions::ExecutableTransaction; +use crate::transaction::transactions::{ExecutableTransaction, ExecutionFlags}; #[cfg(test)] #[path = "worker_logic_test.rs"] @@ -126,17 +126,10 @@ impl<'a, S: StateReader> WorkerExecutor<'a, S> { let tx = &self.chunk[tx_index]; let mut transactional_state = TransactionalState::create_transactional(&mut tx_versioned_state); - let validate = true; - let charge_fee = true; - let concurrency_mode = true; - - let execution_result = tx.execute_raw( - &mut transactional_state, - self.block_context, - charge_fee, - validate, - concurrency_mode, - ); + let execution_flags = + ExecutionFlags { charge_fee: true, validate: true, concurrency_mode: true }; + let execution_result = + tx.execute_raw(&mut transactional_state, self.block_context, execution_flags); if execution_result.is_ok() { // TODO(Noa, 15/05/2024): use `tx_versioned_state` when we add support to transactional diff --git a/crates/blockifier/src/transaction/account_transaction.rs b/crates/blockifier/src/transaction/account_transaction.rs index 4e23854fd4..51ee47b660 100644 --- a/crates/blockifier/src/transaction/account_transaction.rs +++ b/crates/blockifier/src/transaction/account_transaction.rs @@ -34,7 +34,7 @@ use crate::transaction::transaction_types::TransactionType; use crate::transaction::transaction_utils::update_remaining_gas; use crate::transaction::transactions::{ DeclareTransaction, DeployAccountTransaction, Executable, ExecutableTransaction, - InvokeTransaction, ValidatableTransaction, + ExecutionFlags, InvokeTransaction, ValidatableTransaction, }; #[cfg(test)] @@ -636,16 +636,19 @@ impl ExecutableTransaction for AccountTransaction { &self, state: &mut TransactionalState<'_, U>, block_context: &BlockContext, - charge_fee: bool, - validate: bool, - concurrency_mode: bool, + execution_flags: ExecutionFlags, ) -> TransactionExecutionResult { let tx_context = Arc::new(block_context.to_tx_context(self)); self.verify_tx_version(tx_context.tx_info.version())?; // Nonce and fee check should be done before running user code. let strict_nonce_check = true; - self.perform_pre_validation_stage(state, &tx_context, charge_fee, strict_nonce_check)?; + self.perform_pre_validation_stage( + state, + &tx_context, + execution_flags.charge_fee, + strict_nonce_check, + )?; // Run validation and execution. let mut remaining_gas = block_context.versioned_constants.tx_initial_gas(); @@ -664,11 +667,16 @@ impl ExecutableTransaction for AccountTransaction { state, &mut remaining_gas, tx_context.clone(), - validate, - charge_fee, + execution_flags.validate, + execution_flags.charge_fee, + )?; + let fee_transfer_call_info = self.handle_fee( + state, + tx_context, + final_fee, + execution_flags.charge_fee, + execution_flags.concurrency_mode, )?; - let fee_transfer_call_info = - self.handle_fee(state, tx_context, final_fee, charge_fee, concurrency_mode)?; let tx_execution_info = TransactionExecutionInfo { validate_call_info, diff --git a/crates/blockifier/src/transaction/account_transactions_test.rs b/crates/blockifier/src/transaction/account_transactions_test.rs index 69a635e8e1..4abd1eafa4 100644 --- a/crates/blockifier/src/transaction/account_transactions_test.rs +++ b/crates/blockifier/src/transaction/account_transactions_test.rs @@ -44,7 +44,7 @@ use crate::transaction::test_utils::{ TestInitData, INVALID, }; use crate::transaction::transaction_types::TransactionType; -use crate::transaction::transactions::{DeclareTransaction, ExecutableTransaction}; +use crate::transaction::transactions::{DeclareTransaction, ExecutableTransaction, ExecutionFlags}; use crate::{ check_transaction_execution_error_for_invalid_scenario, declare_tx_args, deploy_account_tx_args, invoke_tx_args, nonce, storage_key, @@ -1042,8 +1042,10 @@ fn test_count_actual_storage_changes( nonce: nonce_manager.next(account_address), }; let account_tx = account_invoke_tx(invoke_args.clone()); + let execution_flags = + ExecutionFlags { charge_fee: true, validate: true, concurrency_mode: false }; let execution_info = - account_tx.execute_raw(&mut state, &block_context, true, true, false).unwrap(); + account_tx.execute_raw(&mut state, &block_context, execution_flags).unwrap(); let fee_1 = execution_info.transaction_receipt.fee; let state_changes_1 = state.get_actual_state_changes().unwrap(); @@ -1086,7 +1088,7 @@ fn test_count_actual_storage_changes( ..invoke_args.clone() }); let execution_info = - account_tx.execute_raw(&mut state, &block_context, true, true, false).unwrap(); + account_tx.execute_raw(&mut state, &block_context, execution_flags).unwrap(); let fee_2 = execution_info.transaction_receipt.fee; let state_changes_2 = state.get_actual_state_changes().unwrap(); @@ -1124,7 +1126,7 @@ fn test_count_actual_storage_changes( ..invoke_args }); let execution_info = - account_tx.execute_raw(&mut state, &block_context, true, true, false).unwrap(); + account_tx.execute_raw(&mut state, &block_context, execution_flags).unwrap(); let fee_transfer = execution_info.transaction_receipt.fee; let state_changes_transfer = state.get_actual_state_changes().unwrap(); @@ -1199,18 +1201,10 @@ fn test_concurrency_execute_fee_transfer( // Case 1: The transaction did not read form/ write to the sequenser balance before executing // fee transfer. let mut transactional_state = TransactionalState::create_transactional(state); - let charge_fee = true; - let validate = true; - let concurrency_mode = true; - let result = account_tx - .execute_raw( - &mut transactional_state, - &block_context, - charge_fee, - validate, - concurrency_mode, - ) - .unwrap(); + let execution_flags = + ExecutionFlags { charge_fee: true, validate: true, concurrency_mode: true }; + let result = + account_tx.execute_raw(&mut transactional_state, &block_context, execution_flags).unwrap(); assert!(!result.is_reverted()); let transactional_cache = transactional_state.cache.borrow(); for storage in [ @@ -1248,13 +1242,8 @@ fn test_concurrency_execute_fee_transfer( resource_bounds: max_resource_bounds, }); - let execution_result = account_tx.execute_raw( - &mut transactional_state, - &block_context, - charge_fee, - validate, - concurrency_mode, - ); + let execution_result = + account_tx.execute_raw(&mut transactional_state, &block_context, execution_flags); let result = execution_result.unwrap(); assert!(!result.is_reverted()); // Check that the sequencer balance was not updated. diff --git a/crates/blockifier/src/transaction/transaction_execution.rs b/crates/blockifier/src/transaction/transaction_execution.rs index 554512f287..e617ad1c5f 100644 --- a/crates/blockifier/src/transaction/transaction_execution.rs +++ b/crates/blockifier/src/transaction/transaction_execution.rs @@ -18,7 +18,7 @@ use crate::transaction::objects::{ }; use crate::transaction::transactions::{ DeclareTransaction, DeployAccountTransaction, Executable, ExecutableTransaction, - InvokeTransaction, L1HandlerTransaction, + ExecutionFlags, InvokeTransaction, L1HandlerTransaction, }; // TODO: Move into transaction.rs, makes more sense to be defined there. @@ -105,9 +105,7 @@ impl ExecutableTransaction for L1HandlerTransaction { &self, state: &mut TransactionalState<'_, U>, block_context: &BlockContext, - _charge_fee: bool, - _validate: bool, - _concurrency_mode: bool, + _execution_flags: ExecutionFlags, ) -> TransactionExecutionResult { let tx_context = Arc::new(block_context.to_tx_context(self)); @@ -158,23 +156,18 @@ impl ExecutableTransaction for Transaction { &self, state: &mut TransactionalState<'_, U>, block_context: &BlockContext, - charge_fee: bool, - validate: bool, - concurrency_mode: bool, + execution_flags: ExecutionFlags, ) -> TransactionExecutionResult { // TODO(Yoni, 1/8/2024): consider unimplementing the ExecutableTransaction trait for inner // types, since now running Transaction::execute_raw is not identical to // AccountTransaction::execute_raw. + let concurrency_mode = execution_flags.concurrency_mode; let tx_execution_info = match self { - Self::AccountTransaction(account_tx) => account_tx.execute_raw( - state, - block_context, - charge_fee, - validate, - concurrency_mode, - )?, + Self::AccountTransaction(account_tx) => { + account_tx.execute_raw(state, block_context, execution_flags)? + } Self::L1HandlerTransaction(tx) => { - tx.execute_raw(state, block_context, charge_fee, validate, concurrency_mode)? + tx.execute_raw(state, block_context, execution_flags)? } }; diff --git a/crates/blockifier/src/transaction/transactions.rs b/crates/blockifier/src/transaction/transactions.rs index a47e0c9cf6..b24e202b62 100644 --- a/crates/blockifier/src/transaction/transactions.rs +++ b/crates/blockifier/src/transaction/transactions.rs @@ -41,6 +41,13 @@ macro_rules! implement_inner_tx_getter_calls { }; } +#[derive(Clone, Copy, Debug)] +pub struct ExecutionFlags { + pub charge_fee: bool, + pub validate: bool, + pub concurrency_mode: bool, +} + pub trait ExecutableTransaction: Sized { /// Executes the transaction in a transactional manner /// (if it fails, given state does not modify). @@ -53,14 +60,9 @@ pub trait ExecutableTransaction: Sized { ) -> TransactionExecutionResult { log::debug!("Executing Transaction..."); let mut transactional_state = TransactionalState::create_transactional(state); - let concurrency_mode = false; - let execution_result = self.execute_raw( - &mut transactional_state, - block_context, - charge_fee, - validate, - concurrency_mode, - ); + let execution_flags = ExecutionFlags { charge_fee, validate, concurrency_mode: false }; + let execution_result = + self.execute_raw(&mut transactional_state, block_context, execution_flags); match execution_result { Ok(value) => { @@ -84,9 +86,7 @@ pub trait ExecutableTransaction: Sized { &self, state: &mut TransactionalState<'_, U>, block_context: &BlockContext, - charge_fee: bool, - validate: bool, - concurrency_mode: bool, + execution_flags: ExecutionFlags, ) -> TransactionExecutionResult; } From b846fd119d80ec8dbbdf9161c5a0a6c879376488 Mon Sep 17 00:00:00 2001 From: Yoni <78365039+Yoni-Starkware@users.noreply.github.com> Date: Thu, 4 Jul 2024 11:13:48 +0300 Subject: [PATCH 06/10] feat(execution): remove special handling of keccak in bouncer (#2035) --- crates/blockifier/src/bouncer.rs | 23 +++--------- crates/blockifier/src/bouncer_test.rs | 37 +++---------------- .../blockifier/src/test_utils/struct_impls.rs | 3 +- .../src/py_block_executor.rs | 6 +-- crates/native_blockifier/src/py_objects.rs | 4 -- 5 files changed, 14 insertions(+), 59 deletions(-) diff --git a/crates/blockifier/src/bouncer.rs b/crates/blockifier/src/bouncer.rs index 417b2ddc27..e02eb01d29 100644 --- a/crates/blockifier/src/bouncer.rs +++ b/crates/blockifier/src/bouncer.rs @@ -40,15 +40,11 @@ pub type HashMapWrapper = HashMap; #[derive(Clone, Debug, Default, PartialEq)] pub struct BouncerConfig { pub block_max_capacity: BouncerWeights, - pub block_max_capacity_with_keccak: BouncerWeights, } impl BouncerConfig { pub fn max() -> Self { - Self { - block_max_capacity_with_keccak: BouncerWeights::max(true), - block_max_capacity: BouncerWeights::max(false), - } + Self { block_max_capacity: BouncerWeights::max() } } pub fn empty() -> Self { @@ -56,13 +52,7 @@ impl BouncerConfig { } pub fn has_room(&self, weights: BouncerWeights) -> bool { - let max_capacity = if weights.builtin_count.keccak > 0 { - self.block_max_capacity_with_keccak - } else { - self.block_max_capacity - }; - - max_capacity.has_room(weights) + self.block_max_capacity.has_room(weights) } } @@ -102,14 +92,14 @@ impl BouncerWeights { self.checked_sub(other).is_some() } - pub fn max(with_keccak: bool) -> Self { + pub fn max() -> Self { Self { gas: usize::MAX, n_steps: usize::MAX, message_segment_length: usize::MAX, state_diff_size: usize::MAX, n_events: usize::MAX, - builtin_count: BuiltinCount::max(with_keccak), + builtin_count: BuiltinCount::max(), } } } @@ -139,13 +129,12 @@ pub struct BuiltinCount { impl BuiltinCount { impl_checked_sub!(bitwise, ecdsa, ec_op, keccak, pedersen, poseidon, range_check); - pub fn max(with_keccak: bool) -> Self { - let keccak = if with_keccak { usize::MAX } else { 0 }; + pub fn max() -> Self { Self { bitwise: usize::MAX, ecdsa: usize::MAX, ec_op: usize::MAX, - keccak, + keccak: usize::MAX, pedersen: usize::MAX, poseidon: usize::MAX, range_check: usize::MAX, diff --git a/crates/blockifier/src/bouncer_test.rs b/crates/blockifier/src/bouncer_test.rs index 1b0dbb9e98..d2ba46c1f0 100644 --- a/crates/blockifier/src/bouncer_test.rs +++ b/crates/blockifier/src/bouncer_test.rs @@ -155,39 +155,16 @@ fn test_bouncer_update(#[case] initial_bouncer: Bouncer) { } #[rstest] -#[case::positive_flow(0, 1, 0, Ok(()))] -#[case::block_full(0, 11, 0, Err(TransactionExecutorError::BlockFull))] +#[case::positive_flow(1, Ok(()))] +#[case::block_full(11, Err(TransactionExecutorError::BlockFull))] #[case::transaction_too_large( - 0, 21, - 0, - Err(TransactionExecutorError::TransactionExecutionError( - TransactionExecutionError::TransactionTooLarge - )) -)] -#[case::positive_flow_with_keccak(0, 0, 1, Ok(()))] -#[case::block_full_with_keccak(1, 0, 1, Err(TransactionExecutorError::BlockFull))] -#[case::transaction_too_large_with_keccak( - 0, - 0, - 2, - Err(TransactionExecutorError::TransactionExecutionError( - TransactionExecutionError::TransactionTooLarge - )) -)] -#[case::block_full_with_keccak_ecdsa_exceeds(0, 11, 1, Err(TransactionExecutorError::BlockFull))] -#[case::transaction_too_large_with_keccak_ecdsa_too_large( - 0, - 21, - 1, Err(TransactionExecutorError::TransactionExecutionError( TransactionExecutionError::TransactionTooLarge )) )] fn test_bouncer_try_update( - #[case] initial_keccak: usize, #[case] added_ecdsa: usize, - #[case] added_keccak: usize, #[case] expected_result: TransactionExecutorResult<()>, ) { use cairo_vm::vm::runners::cairo_runner::ExecutionResources; @@ -203,7 +180,7 @@ fn test_bouncer_try_update( bitwise: 20, ecdsa: 20, ec_op: 20, - keccak: 0, + keccak: 20, pedersen: 20, poseidon: 20, range_check: 20, @@ -214,16 +191,14 @@ fn test_bouncer_try_update( n_events: 20, state_diff_size: 20, }; - let mut block_max_capacity_with_keccak = block_max_capacity; - block_max_capacity_with_keccak.builtin_count.keccak = 1; - let bouncer_config = BouncerConfig { block_max_capacity, block_max_capacity_with_keccak }; + let bouncer_config = BouncerConfig { block_max_capacity }; let accumulated_weights = BouncerWeights { builtin_count: BuiltinCount { bitwise: 10, ecdsa: 10, ec_op: 10, - keccak: initial_keccak, + keccak: 10, pedersen: 10, poseidon: 10, range_check: 10, @@ -243,7 +218,7 @@ fn test_bouncer_try_update( (BuiltinName::bitwise, 1), (BuiltinName::ecdsa, added_ecdsa), (BuiltinName::ec_op, 1), - (BuiltinName::keccak, added_keccak), + (BuiltinName::keccak, 1), (BuiltinName::pedersen, 1), (BuiltinName::poseidon, 1), (BuiltinName::range_check, 1), diff --git a/crates/blockifier/src/test_utils/struct_impls.rs b/crates/blockifier/src/test_utils/struct_impls.rs index 3f36461f29..52cbd67adb 100644 --- a/crates/blockifier/src/test_utils/struct_impls.rs +++ b/crates/blockifier/src/test_utils/struct_impls.rs @@ -177,9 +177,8 @@ impl BlockContext { bouncer_config: BouncerConfig { block_max_capacity: BouncerWeights { n_events: max_n_events_in_block, - ..BouncerWeights::max(false) + ..BouncerWeights::max() }, - ..BouncerConfig::empty() }, ..Self::create_for_account_testing() } diff --git a/crates/native_blockifier/src/py_block_executor.rs b/crates/native_blockifier/src/py_block_executor.rs index 3884db72cf..fe0a367ee2 100644 --- a/crates/native_blockifier/src/py_block_executor.rs +++ b/crates/native_blockifier/src/py_block_executor.rs @@ -347,11 +347,7 @@ impl PyBlockExecutor { bouncer_config: BouncerConfig { block_max_capacity: BouncerWeights { state_diff_size: max_state_diff_size, - ..BouncerWeights::max(false) - }, - block_max_capacity_with_keccak: BouncerWeights { - state_diff_size: max_state_diff_size, - ..BouncerWeights::max(true) + ..BouncerWeights::max() }, }, tx_executor_config: TransactionExecutorConfig { diff --git a/crates/native_blockifier/src/py_objects.rs b/crates/native_blockifier/src/py_objects.rs index cb2c0cdb67..866f9734f1 100644 --- a/crates/native_blockifier/src/py_objects.rs +++ b/crates/native_blockifier/src/py_objects.rs @@ -94,7 +94,6 @@ impl From for VersionedConstantsOverrides { #[derive(Clone, Debug, FromPyObject)] pub struct PyBouncerConfig { - pub full_total_weights_with_keccak: HashMap, pub full_total_weights: HashMap, } @@ -105,9 +104,6 @@ impl TryFrom for BouncerConfig { block_max_capacity: hash_map_into_bouncer_weights( py_bouncer_config.full_total_weights.clone(), )?, - block_max_capacity_with_keccak: hash_map_into_bouncer_weights( - py_bouncer_config.full_total_weights_with_keccak.clone(), - )?, }) } } From 8bf92b676261616e5a9d6a0b25d3e868b2a9aa0e Mon Sep 17 00:00:00 2001 From: dorimedini-starkware Date: Thu, 4 Jul 2024 13:25:42 +0300 Subject: [PATCH 07/10] chore: bump package dev version (#2036) Signed-off-by: Dori Medini --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index afb622cb0b..9e8ba763c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -404,7 +404,7 @@ dependencies = [ [[package]] name = "blockifier" -version = "0.8.0-dev.1" +version = "0.8.0-dev.2" dependencies = [ "anyhow", "ark-ec", @@ -2282,7 +2282,7 @@ dependencies = [ [[package]] name = "native_blockifier" -version = "0.8.0-dev.1" +version = "0.8.0-dev.2" dependencies = [ "blockifier", "cached", diff --git a/Cargo.toml b/Cargo.toml index 81fe6644ae..4b83ddd358 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ resolver = "2" members = ["crates/blockifier", "crates/native_blockifier"] [workspace.package] -version = "0.8.0-dev.1" +version = "0.8.0-dev.2" edition = "2021" repository = "https://github.com/starkware-libs/blockifier/" license = "Apache-2.0" From d9bc03bd546a6c8ef7100b64ae920ea267e8e96a Mon Sep 17 00:00:00 2001 From: dorimedini-starkware Date: Thu, 4 Jul 2024 14:08:10 +0300 Subject: [PATCH 08/10] chore: bump compiler version to RC (#2019) Signed-off-by: Dori Medini --- Cargo.lock | 112 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 8 ++-- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9e8ba763c0..70362f9be9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -541,9 +541,9 @@ checksum = "3a4f925191b4367301851c6d99b09890311d74b0d43f274c0b34c86d308a3663" [[package]] name = "cairo-lang-casm" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2faefea599ed16d71262ad60b66c8b8e081b83e08d141ae9f8da98240a3dabd" +checksum = "4e67d781fe3f8a8edfeb308e012b1e1a575bc2f1818e264b98758699602826e5" dependencies = [ "cairo-lang-utils", "indoc 2.0.5", @@ -555,9 +555,9 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cf77e43ec3e249676db8d10de69c0013a01b5bd898b003e53b7477fe4a257f4" +checksum = "1d1b91df87775298a32faca8683da42fafe12bac4bd659755fe8ad0852a2ca65" dependencies = [ "anyhow", "cairo-lang-defs", @@ -579,18 +579,18 @@ dependencies = [ [[package]] name = "cairo-lang-debug" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69a2ccc456d6d6be5c45b94d7f0da5da573e888adf4dece38fe5768910d4c4fd" +checksum = "6d98288c8967adbe12b97d2b6c87db240728899af9f22e0eeb1d8b90262a5d0f" dependencies = [ "cairo-lang-utils", ] [[package]] name = "cairo-lang-defs" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70270a8df40452784d2b9943f09bb17e0241f0d2d5b51e80e43bbab0f09d43fe" +checksum = "60176d0dbf4edc0afe75343ef6460e8544b92c298c829ed9a0e04271296438d5" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -605,9 +605,9 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf54b7d11b9c4be3f7b9fa15ae6912c2b830a404983b21dbfea7503cc7a0a96d" +checksum = "2617a46069a30f6616b3b2ac61f2f84102aadf0a890c361e835ae89ed680bb6c" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -617,9 +617,9 @@ dependencies = [ [[package]] name = "cairo-lang-eq-solver" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83adfb83ff9c2f2b2df81f80ac0c4c0ee4f23a3ee2898e186bddf838f0d76896" +checksum = "70bcca24edb847fc14242ce89e5e942dbca3db7cd8270d44cf4b6296998b8bcc" dependencies = [ "cairo-lang-utils", "good_lp", @@ -627,9 +627,9 @@ dependencies = [ [[package]] name = "cairo-lang-filesystem" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56daeeed88b6d8358701a3d47b33374fd2a019596bb9a0864d0278cd41004fc8" +checksum = "29e2126b984e05a531cabdf0f8ab7fbdbeb1853202e76784256373b76588f89c" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -641,9 +641,9 @@ dependencies = [ [[package]] name = "cairo-lang-formatter" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "402ff59d648ad1cf57d654c9ec3fed1e98f409b0f3d1474679dec6ee84f46457" +checksum = "3c8551db414f1ab22f94a47d5cfb213e3bbd0e096d500990e5e4518d48822dfa" dependencies = [ "anyhow", "cairo-lang-diagnostics", @@ -662,9 +662,9 @@ dependencies = [ [[package]] name = "cairo-lang-lowering" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1913e4071758d226f6592db1f12f515d74616b8b5259f59523801c3481d9c3b" +checksum = "4d7820cef63a4f9e3c380b29e1a90b01687e2e36e172ce59c7f7c0888a386a7f" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -687,9 +687,9 @@ dependencies = [ [[package]] name = "cairo-lang-parser" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7f06b6c7da1ba98371ec39f0928ea4a190e24e783c5f0b429e1fbe64ee672ee" +checksum = "8724e5c3ddf632a61f096d6073b4b94e4b77925cb4ccd5b3e59e738fad0885ec" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -707,9 +707,9 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36fce40856d2c6415dc597cdc4e2f92885f9aab7288f4cdf95e15cb25274c820" +checksum = "4e27d87f738d77895a5601c3451cfac3c998c45cab75b99b98ae4074369614fc" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -726,9 +726,9 @@ dependencies = [ [[package]] name = "cairo-lang-proc-macros" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bf12b18566bbca35cd36750c4d15bed56c998ff5367eb649975334256983053" +checksum = "70f8c9a7127bff999715ce632fa1c96fdafecf1ad401b9739d5af530a7b33adf" dependencies = [ "cairo-lang-debug", "quote", @@ -737,9 +737,9 @@ dependencies = [ [[package]] name = "cairo-lang-project" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74a9759131a1d59a58c775a980ad514e243addb334b95556cd23266d774587a2" +checksum = "dc4ddd050058e7b08b6de3d7d0160aa9f8dd6c16f2a5b4da6e1429a9e143eb47" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", @@ -751,9 +751,9 @@ dependencies = [ [[package]] name = "cairo-lang-runner" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbe20f518b01a596b1dab5cecc611dc556771fad60e88b32e84cc9d8044a4023" +checksum = "26d8ba0a0ad648f80cc008aa7f386c3058afbff99284c8accdbecb114b84dc8d" dependencies = [ "ark-ff", "ark-secp256k1", @@ -776,16 +776,15 @@ dependencies = [ "rand", "sha2", "smol_str", - "starknet-crypto 0.6.2", "starknet-types-core", "thiserror", ] [[package]] name = "cairo-lang-semantic" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffd46d20af4285271fdda6c815831ea95c2dfa0fbfb07b65633f3ef84c1bbe23" +checksum = "4fd5d4e1531db649593e14cc0f038ceaf0b355b0b538c45874d7fe8b8fef7169" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -810,9 +809,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5022f62ac3a430e4d52d55b62080cbd88e8587b43a7e5c0569feb02c5eb63443" +checksum = "89b56bc9e96b479ae74e30b1004a7599480e3850b5d7a492788036807568eebe" dependencies = [ "anyhow", "cairo-lang-utils", @@ -823,7 +822,9 @@ dependencies = [ "lalrpop", "lalrpop-util", "num-bigint", + "num-integer", "num-traits 0.2.19", + "once_cell", "regex", "salsa", "serde", @@ -836,9 +837,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f5cd352c120ffc20eecfbd7691652ca4a6ca7231567377939d6fac3dc35da99" +checksum = "c80caa2c4202dfc58bba56e4b0bebc8152dc06f979342aea6c5310566bcfa26d" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -852,9 +853,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59aa1123fc8a6d08f80c2f12d1f72807597c32f2d75ca19696013824af263cb8" +checksum = "40eebf3d027a5663a47679319cf9aad312cd417a47afb638f34bf83ba2e45944" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -868,9 +869,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bad0c6e76d2097e93129c19c5602ddfd4300173c240cf336bc50f1f0b85df8c" +checksum = "cd35fc261cc700d02698aa2d95654a0ed9cfb543cb152c618906367f899e1cde" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -893,9 +894,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f51aab0d040f6c2c49eba5bbebd1ac7d66e87db24c5587ac8c759247c295a11" +checksum = "f3af5f65598f90160754c7d9e277ec6eb187b6f4fa018676109666c1f6cb3024" dependencies = [ "assert_matches", "cairo-lang-casm", @@ -914,9 +915,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-type-size" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eab42a1cda2bae4adf612985080e7ecb88ceb83c9c069f1bfef9ae76c408eec" +checksum = "d1f5b3fab76e649246e17f5c12b584a2e0b729fecafbf23f24b86a8250df8849" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -924,9 +925,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02a4284dad726fdcb601be5ada83486eed53b46988dbdeef90bc2e5630570c2f" +checksum = "c85460aed78bc233a089aeecd27a1ed3d82a2eb079e4b2d7dc62d50ad7326b1a" dependencies = [ "anyhow", "cairo-lang-compiler", @@ -955,9 +956,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet-classes" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc7fdcbbba52cf3daedd2a2b3dde6403bc4c0bf679e5fbfd330a73d693fc9158" +checksum = "167f3754129e279fa1759a990bfec1f8b48d8acee9f1d46862ec5d298d3de171" dependencies = [ "cairo-lang-casm", "cairo-lang-sierra", @@ -973,16 +974,15 @@ dependencies = [ "serde_json", "sha3", "smol_str", - "starknet-crypto 0.6.2", "starknet-types-core", "thiserror", ] [[package]] name = "cairo-lang-syntax" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a794b8c7b14cb8134f5c710c35014f087ea27d981618d26441e3b07830120de" +checksum = "fff58f236a630117b382039701cb94186a054a32132149d6ceddf7f5f3ce673b" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -996,9 +996,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax-codegen" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a84a680a70dbb0ed98cd4e10e461cb989bf0f92c9d79ad6e311cb08f7a0a91ec" +checksum = "654c66a6408f85a1118f37f8f818c61dd1e0f5623901cba7c87b290703285e43" dependencies = [ "genco", "xshell", @@ -1006,9 +1006,9 @@ dependencies = [ [[package]] name = "cairo-lang-test-utils" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b49fd5ec4786f5a088219ac672db55e1ffad03603c95069626d93f9391ab2cc" +checksum = "1bcefb85292f9fb18b03f47e2fcc56b3b02945485495c7d75ae2c85e17295c63" dependencies = [ "cairo-lang-formatter", "cairo-lang-utils", @@ -1019,9 +1019,9 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "2.7.0-dev.0" +version = "2.7.0-rc.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81ce0c5fd767c01cba2abcb7d46428d31c92ca4d006fa42d442ee7884bc20764" +checksum = "d7c6907351815be936e9aad13437604391264067789d4d1e9ef15c099258a08a" dependencies = [ "hashbrown 0.14.5", "indexmap 2.2.6", diff --git a/Cargo.toml b/Cargo.toml index 4b83ddd358..9e9c6cf2e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,10 +20,10 @@ ark-secp256k1 = "0.4.0" ark-secp256r1 = "0.4.0" assert_matches = "1.5.0" cached = "0.44.0" -cairo-lang-casm = "2.7.0-dev.0" -cairo-lang-runner = "2.7.0-dev.0" -cairo-lang-starknet-classes = "2.7.0-dev.0" -cairo-lang-utils = "2.7.0-dev.0" +cairo-lang-casm = "2.7.0-rc.0" +cairo-lang-runner = "2.7.0-rc.0" +cairo-lang-starknet-classes = "2.7.0-rc.0" +cairo-lang-utils = "2.7.0-rc.0" cairo-vm = "1.0.0-rc3" criterion = "0.3" derive_more = "0.99.17" From bb88a6f0a7bdee3eee63ec42fad0527be7d3fc3c Mon Sep 17 00:00:00 2001 From: dorimedini-starkware Date: Thu, 4 Jul 2024 14:14:30 +0300 Subject: [PATCH 09/10] fix: post merge action (#2037) Signed-off-by: Dori Medini --- .github/workflows/post-merge.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/post-merge.yml b/.github/workflows/post-merge.yml index 0d0364b670..116a2d6048 100644 --- a/.github/workflows/post-merge.yml +++ b/.github/workflows/post-merge.yml @@ -10,10 +10,7 @@ jobs: runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@master - with: - components: rustfmt - toolchain: nightly-2024-01-12 + - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 with: prefix-key: "v0-rust-ubuntu-20.04" From a98187bd216d2cb13d36ce0e2ba8046f3e8b25ab Mon Sep 17 00:00:00 2001 From: Dori Medini Date: Thu, 4 Jul 2024 14:25:06 +0300 Subject: [PATCH 10/10] Merge main-v0.13.2 -> main merge (no conflits), this commit is for any change needed to pass the CI.