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

Commit

Permalink
Merge main-v0.13.0-hotfix into main-v0.13.1 (resolve conflicts).
Browse files Browse the repository at this point in the history
  • Loading branch information
elintul committed Feb 13, 2024
1 parent dfafe50 commit 4c55b4a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,9 @@ use crate::execution::entry_point::{CallEntryPoint, CallType};
use crate::execution::errors::EntryPointExecutionError;
use crate::execution::execution_utils::felt_to_stark_felt;
use crate::execution::syscalls::hint_processor::EmitEventError;
<<<<<<< HEAD
use crate::execution::syscalls::{
SYSCALL_MAX_EVENT_DATA, SYSCALL_MAX_EVENT_KEYS, SYSCALL_MAX_N_EMITTED_EVENTS,
};
||||||| d1b5bb4f
use crate::execution::syscalls::{
SYSCALL_MAX_EVENT_DATA, SYSCALL_MAX_EVENT_KEYS, SYSCALL_MAX_N_EMITTED_EVENTS,
};
use crate::retdata;
=======
use crate::execution::syscalls::{SYSCALL_MAX_EVENT_DATA, SYSCALL_MAX_EVENT_KEYS};
use crate::retdata;
>>>>>>> origin/main-v0.13.0-hotfix
use crate::state::state_api::StateReader;
use crate::test_utils::cached_state::{
deprecated_create_deploy_test_state, deprecated_create_test_state,
Expand Down Expand Up @@ -554,7 +544,6 @@ fn test_emit_event() {
max_keys_length: SYSCALL_MAX_EVENT_KEYS,
};
assert!(error.to_string().contains(format!("{}", expected_error).as_str()));
<<<<<<< HEAD

// Negative flow, the number of events exceeds the limit.
let n_emitted_events_too_big = vec![stark_felt!(
Expand All @@ -566,18 +555,6 @@ fn test_emit_event() {
max_n_emitted_events: SYSCALL_MAX_N_EMITTED_EVENTS,
};
assert!(error.to_string().contains(format!("{}", expected_error).as_str()));
||||||| d1b5bb4f

// Negative flow, the number of events exceeds the limit.
let n_emitted_events_too_big = vec![stark_felt!((SYSCALL_MAX_N_EMITTED_EVENTS + 1) as u16)];
let error = emit_events(&n_emitted_events_too_big, &keys, &data).unwrap_err();
let expected_error = EmitEventError::ExceedsMaxNumberOfEmittedEvents {
n_emitted_events: SYSCALL_MAX_N_EMITTED_EVENTS + 1,
max_n_emitted_events: SYSCALL_MAX_N_EMITTED_EVENTS,
};
assert!(error.to_string().contains(format!("{}", expected_error).as_str()));
=======
>>>>>>> origin/main-v0.13.0-hotfix
}

fn emit_events(
Expand All @@ -589,22 +566,10 @@ fn emit_events(
let calldata = Calldata(
concat(vec![
n_emitted_events.to_owned(),
<<<<<<< HEAD
vec![stark_felt!(u16::try_from(keys.len()).expect("Failed to convert usize to u16."))],
keys.to_vec(),
vec![stark_felt!(u16::try_from(data.len()).expect("Failed to convert usize to u16."))],
data.to_vec(),
||||||| d1b5bb4f
vec![stark_felt!(keys.len() as u16)],
keys.clone(),
vec![stark_felt!(data.len() as u16)],
data.clone(),
=======
vec![stark_felt!(keys.len() as u16)],
keys.to_owned(),
vec![stark_felt!(data.len() as u16)],
data.to_owned(),
>>>>>>> origin/main-v0.13.0-hotfix
])
.into(),
);
Expand Down
10 changes: 0 additions & 10 deletions crates/blockifier/src/execution/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,9 @@ pub type WriteResponseResult = SyscallResult<()>;

type SyscallSelector = DeprecatedSyscallSelector;

<<<<<<< HEAD
pub const SYSCALL_MAX_EVENT_KEYS: usize = 40;
pub const SYSCALL_MAX_EVENT_DATA: usize = 40;
pub const SYSCALL_MAX_N_EMITTED_EVENTS: usize = 1000;
||||||| d1b5bb4f
pub const SYSCALL_MAX_EVENT_KEYS: usize = 256;
pub const SYSCALL_MAX_EVENT_DATA: usize = 256;
pub const SYSCALL_MAX_N_EMITTED_EVENTS: usize = 128;
=======
pub const SYSCALL_MAX_EVENT_KEYS: usize = 40;
pub const SYSCALL_MAX_EVENT_DATA: usize = 40;
pub const SYSCALL_MAX_N_EMITTED_EVENTS: usize = 1_000_000_000;
>>>>>>> origin/main-v0.13.0-hotfix

pub trait SyscallRequest: Sized {
fn read(_vm: &VirtualMachine, _ptr: &mut Relocatable) -> SyscallResult<Self>;
Expand Down
35 changes: 0 additions & 35 deletions crates/blockifier/src/execution/syscalls/syscalls_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,9 @@ use crate::execution::execution_utils::{felt_to_stark_felt, stark_felt_to_felt};
use crate::execution::syscalls::hint_processor::{
EmitEventError, BLOCK_NUMBER_OUT_OF_RANGE_ERROR, L1_GAS, L2_GAS, OUT_OF_GAS_ERROR,
};
<<<<<<< HEAD
use crate::execution::syscalls::{
SYSCALL_MAX_EVENT_DATA, SYSCALL_MAX_EVENT_KEYS, SYSCALL_MAX_N_EMITTED_EVENTS,
};
||||||| d1b5bb4f
use crate::execution::syscalls::{
SYSCALL_MAX_EVENT_DATA, SYSCALL_MAX_EVENT_KEYS, SYSCALL_MAX_N_EMITTED_EVENTS,
};
use crate::retdata;
=======
use crate::execution::syscalls::{SYSCALL_MAX_EVENT_DATA, SYSCALL_MAX_EVENT_KEYS};
use crate::retdata;
>>>>>>> origin/main-v0.13.0-hotfix
use crate::state::state_api::{State, StateReader};
use crate::test_utils::cached_state::{create_deploy_test_state, create_test_state};
use crate::test_utils::contracts::FeatureContract;
Expand Down Expand Up @@ -162,7 +152,6 @@ fn test_emit_event() {
max_keys_length: SYSCALL_MAX_EVENT_KEYS,
};
assert!(error.to_string().contains(format!("{}", expected_error).as_str()));
<<<<<<< HEAD

// Negative flow, the number of events exceeds the limit.
let n_emitted_events_too_big = vec![stark_felt!(
Expand All @@ -174,18 +163,6 @@ fn test_emit_event() {
max_n_emitted_events: SYSCALL_MAX_N_EMITTED_EVENTS,
};
assert!(error.to_string().contains(format!("{}", expected_error).as_str()));
||||||| d1b5bb4f

// Negative flow, the number of events exceeds the limit.
let n_emitted_events_too_big = vec![stark_felt!((SYSCALL_MAX_N_EMITTED_EVENTS + 1) as u16)];
let error = emit_events(&n_emitted_events_too_big, &keys, &data).unwrap_err();
let expected_error = EmitEventError::ExceedsMaxNumberOfEmittedEvents {
n_emitted_events: SYSCALL_MAX_N_EMITTED_EVENTS + 1,
max_n_emitted_events: SYSCALL_MAX_N_EMITTED_EVENTS,
};
assert!(error.to_string().contains(format!("{}", expected_error).as_str()));
=======
>>>>>>> origin/main-v0.13.0-hotfix
}

fn emit_events(
Expand All @@ -197,22 +174,10 @@ fn emit_events(
let calldata = Calldata(
concat(vec![
n_emitted_events.to_owned(),
<<<<<<< HEAD
vec![stark_felt!(u16::try_from(keys.len()).expect("Failed to convert usize to u16."))],
keys.to_vec(),
vec![stark_felt!(u16::try_from(data.len()).expect("Failed to convert usize to u16."))],
data.to_vec(),
||||||| d1b5bb4f
vec![stark_felt!(keys.len() as u16)],
keys.clone(),
vec![stark_felt!(data.len() as u16)],
data.clone(),
=======
vec![stark_felt!(keys.len() as u16)],
keys.to_owned(),
vec![stark_felt!(data.len() as u16)],
data.to_owned(),
>>>>>>> origin/main-v0.13.0-hotfix
])
.into(),
);
Expand Down
15 changes: 13 additions & 2 deletions crates/blockifier/src/transaction/transactions_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ use crate::execution::entry_point::{CallEntryPoint, CallType};
use crate::execution::errors::EntryPointExecutionError;
use crate::execution::execution_utils::{felt_to_stark_felt, stark_felt_to_felt};
use crate::execution::syscalls::hint_processor::EmitEventError;
use crate::execution::syscalls::{SYSCALL_MAX_EVENT_DATA, SYSCALL_MAX_EVENT_KEYS};
use crate::execution::syscalls::{
SYSCALL_MAX_EVENT_DATA, SYSCALL_MAX_EVENT_KEYS, SYSCALL_MAX_N_EMITTED_EVENTS,
};
use crate::fee::fee_utils::calculate_tx_fee;
use crate::fee::gas_usage::{
estimate_minimal_gas_vector, get_calldata_and_signature_gas_cost, get_code_gas_cost,
Expand Down Expand Up @@ -1706,9 +1708,18 @@ fn test_execute_tx_with_invalid_transaction_version() {
#[test_case(
vec![stark_felt!(1_u16); SYSCALL_MAX_EVENT_KEYS],
vec![stark_felt!(2_u16); SYSCALL_MAX_EVENT_DATA],
10,
SYSCALL_MAX_N_EMITTED_EVENTS,
None;
"Positive flow")]
#[test_case(
vec![stark_felt!(1_u16)],
vec![stark_felt!(2_u16)],
SYSCALL_MAX_N_EMITTED_EVENTS + 1,
Some(EmitEventError::ExceedsMaxNumberOfEmittedEvents {
n_emitted_events: SYSCALL_MAX_N_EMITTED_EVENTS + 1,
max_n_emitted_events: SYSCALL_MAX_N_EMITTED_EVENTS,
});
"exceeds max number of events")]
#[test_case(
vec![stark_felt!(3_u16); SYSCALL_MAX_EVENT_KEYS + 1],
vec![stark_felt!(4_u16)],
Expand Down

0 comments on commit 4c55b4a

Please sign in to comment.