Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/apollo_compile_to_casm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ apollo_compilation_utils = { workspace = true, features = ["testing"] }
apollo_infra_utils.workspace = true
assert_matches.workspace = true
mempool_test_utils.workspace = true
regex.workspace = true

[build-dependencies]
apollo_compilation_utils.workspace = true
Expand Down
4 changes: 3 additions & 1 deletion crates/apollo_compile_to_casm/src/compile_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use cairo_lang_starknet_classes::allowed_libfuncs::{
use cairo_lang_starknet_classes::contract_class::ContractClass as CairoLangContractClass;
use mempool_test_utils::{FAULTY_ACCOUNT_CLASS_FILE, TEST_FILES_FOLDER};
use pretty_assertions::assert_eq;
use regex::Regex;
use starknet_api::contract_class::ContractClass;
use starknet_api::state::SierraContractClass;

Expand Down Expand Up @@ -161,8 +162,9 @@ fn test_max_memory_usage() {
audited_libfuncs_only: false,
});
let compilation_result = compiler.compile(contract_class);
let expected_error_pattern = Regex::new(r"memory allocation .* fail").unwrap();
assert_matches!(compilation_result, Err(CompilationUtilError::CompilationError(string))
if string.contains("memory allocation failure")
if expected_error_pattern.is_match(&string)
);
}

Expand Down
8 changes: 4 additions & 4 deletions crates/apollo_consensus/src/single_height_consensus_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ async fn proposer() {
Ok(ShcReturn::Tasks(vec![timeout_prevote_task(0), precommit_task(Some(BLOCK.id.0), 0),]))
);

let precommits = vec![
let precommits = [
precommit(Some(BLOCK.id.0), 0, 0, *VALIDATOR_ID_1),
precommit(Some(Felt::TWO), 0, 0, *VALIDATOR_ID_3),
precommit(Some(BLOCK.id.0), 0, 0, *VALIDATOR_ID_2),
Expand Down Expand Up @@ -218,7 +218,7 @@ async fn validator(repeat_proposal: bool) {
Ok(ShcReturn::Tasks(vec![timeout_prevote_task(0), precommit_task(Some(BLOCK.id.0), 0)]))
);

let precommits = vec![
let precommits = [
precommit(Some(BLOCK.id.0), HEIGHT.0, 0, *PROPOSER_ID),
precommit(Some(BLOCK.id.0), HEIGHT.0, 0, *VALIDATOR_ID_2),
precommit(Some(BLOCK.id.0), HEIGHT.0, 0, *VALIDATOR_ID_1),
Expand Down Expand Up @@ -413,7 +413,7 @@ async fn repropose() {
Ok(ShcReturn::Tasks(vec![timeout_prevote_task(0), precommit_task(Some(BLOCK.id.0), 0),]))
);
// Advance to the next round.
let precommits = vec![
let precommits = [
precommit(None, 0, 0, *VALIDATOR_ID_1),
precommit(None, 0, 0, *VALIDATOR_ID_2),
precommit(None, 0, 0, *VALIDATOR_ID_3),
Expand All @@ -433,7 +433,7 @@ async fn repropose() {
shc.handle_vote(&mut context, precommits[2].clone()).await.unwrap();
shc.handle_event(&mut context, StateMachineEvent::TimeoutPrecommit(0)).await.unwrap();

let precommits = vec![
let precommits = [
precommit(Some(BLOCK.id.0), 0, 1, *VALIDATOR_ID_1),
precommit(Some(BLOCK.id.0), 0, 1, *VALIDATOR_ID_2),
precommit(Some(BLOCK.id.0), 0, 1, *VALIDATOR_ID_3),
Expand Down
2 changes: 1 addition & 1 deletion crates/apollo_l1_provider/tests/flow_test_consumed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async fn l1_handler_tx_consumed_txs() {
// First we get the message sent. Then we get the consumed event (should be scraped on the
// second iteration of the scraper loop). On the third iteration, we get the second consumed
// event (to trigger deletion on the provider records).
let all_events = vec![
let all_events = [
message_to_l2_event.clone(),
message_consumed_event.clone(),
message_consumed_event_2.clone(),
Expand Down
2 changes: 1 addition & 1 deletion crates/apollo_p2p_sync/src/client/state_diff_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async fn state_diff_basic_flow() {
let value1 = ascii_as_felt("value1").unwrap();
let nonce0 = Nonce(ascii_as_felt("nonce0").unwrap());

let state_diffs_and_chunks = vec![
let state_diffs_and_chunks = [
(
ThinStateDiff {
deployed_contracts: indexmap!(address0 => class_hash0),
Expand Down
4 changes: 2 additions & 2 deletions crates/apollo_staking/src/staking_manager_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ async fn get_proposer_success(
// - [7000–8999] → STAKER_2
// - [9000–9999] → STAKER_1

set_stakers(&mut state, &block_context, &vec![STAKER_1, STAKER_2, STAKER_3, STAKER_4]);
set_stakers(&mut state, &block_context, &[STAKER_1, STAKER_2, STAKER_3, STAKER_4]);

let mut random_generator = MockBlockRandomGenerator::new();
random_generator.expect_generate().returning(move |_, _, _, _| random_value);
Expand Down Expand Up @@ -259,7 +259,7 @@ async fn get_proposer_random_value_exceeds_total_weight(
block_context: Context,
) {
// Stakers with total weight 10000.
set_stakers(&mut state, &block_context, &vec![STAKER_1, STAKER_2, STAKER_3, STAKER_4]);
set_stakers(&mut state, &block_context, &[STAKER_1, STAKER_2, STAKER_3, STAKER_4]);

// Random value is out of range. Valid range is [0, 10000).
let mut random_generator = MockBlockRandomGenerator::new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ fn test_stack_overflow(#[values(true, false)] concurrency_enabled: bool) {
// Run.
let config = TransactionExecutorConfig::create_for_testing(concurrency_enabled);
let mut executor = TransactionExecutor::new(state, block_context, config);
let results = executor.execute_txs(&vec![account_tx.into()], None);
let results = executor.execute_txs(&[account_tx.into()], None);

let (tx_execution_info, _state_diff) = results[0].as_ref().unwrap();
assert!(tx_execution_info.is_reverted());
Expand Down
18 changes: 4 additions & 14 deletions crates/blockifier_test_utils/src/cairo_versions.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
use starknet_api::transaction::TransactionVersion;
use strum_macros::EnumIter;

#[derive(Clone, Hash, PartialEq, EnumIter, Eq, Copy, Debug)]
#[derive(Clone, Default, Hash, PartialEq, EnumIter, Eq, Copy, Debug)]
pub enum RunnableCairo1 {
#[default]
Casm,
#[cfg(feature = "cairo_native")]
Native,
}

impl Default for RunnableCairo1 {
fn default() -> Self {
Self::Casm
}
}

impl RunnableCairo1 {
pub fn is_cairo_native(&self) -> bool {
match self {
Expand All @@ -27,18 +22,13 @@ impl RunnableCairo1 {

// TODO(Aviv, 14/7/2024): Move from test utils module, and use it in ContractClassVersionMismatch
// error.
#[derive(Clone, Hash, PartialEq, Eq, Copy, Debug)]
#[derive(Clone, Default, Hash, PartialEq, Eq, Copy, Debug)]
pub enum CairoVersion {
#[default]
Cairo0,
Cairo1(RunnableCairo1),
}

impl Default for CairoVersion {
fn default() -> Self {
Self::Cairo0
}
}

impl CairoVersion {
// A declare transaction of the given version, can be used to declare contracts of the returned
// cairo version.
Expand Down
9 changes: 2 additions & 7 deletions crates/starknet_api/src/data_availability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,14 @@ use crate::StarknetApiError;
#[derive(
Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize, SizeOf,
)]
#[cfg_attr(any(test, feature = "testing"), derive(Default))]
#[serde(try_from = "Deserializer")]
pub enum DataAvailabilityMode {
#[cfg_attr(any(test, feature = "testing"), default)]
L1 = 0,
L2 = 1,
}

#[cfg(any(test, feature = "testing"))]
impl Default for DataAvailabilityMode {
fn default() -> Self {
Self::L1
}
}

/// Deserialize a `DataAvailabilityMode` from a given `Deserializer`.
///
/// This implementation supports deserializing the `DataAvailabilityMode` enum from both numerical
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "1.90"
channel = "1.91.1"
components = ["rustc-dev"]
profile = "default"
targets = ["x86_64-unknown-linux-gnu"]
Loading