Skip to content

Commit

Permalink
fix: problems after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
varex83 committed Oct 29, 2024
1 parent 158863b commit 55e0f85
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn execute_entry_point_call(
Ok(res) => Ok(res),
}?;

create_call_info(call, call_result, syscall_handler)
create_callinfo(call_result, syscall_handler)
}

fn create_callinfo(
Expand Down
15 changes: 4 additions & 11 deletions crates/blockifier/src/execution/native/syscall_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ use cairo_native::starknet::{
U256,
};
use cairo_vm::vm::runners::cairo_runner::ExecutionResources;
use starknet_api::core::{
calculate_contract_address,
ClassHash,
ContractAddress,
EntryPointSelector,
};
use starknet_api::core::{calculate_contract_address, ClassHash, ContractAddress};
use starknet_api::state::StorageKey;
use starknet_api::transaction::{Calldata, ContractAddressSalt};
use starknet_types_core::felt::Felt;
Expand Down Expand Up @@ -47,8 +42,6 @@ pub struct NativeSyscallHandler<'state> {
pub l2_to_l1_messages: Vec<OrderedL2ToL1Message>,
pub inner_calls: Vec<CallInfo>,

pub syscall_counter: SyscallCounter,

// Additional information gathered during execution.
pub read_values: Vec<Felt>,
pub accessed_keys: HashSet<StorageKey, RandomState>,
Expand Down Expand Up @@ -174,7 +167,7 @@ impl<'state> StarknetSyscallHandler for &mut NativeSyscallHandler<'state> {
self.context.gas_costs().deploy_gas_cost,
)?;

let deployer_address = self.contract_address;
let deployer_address = self.call.storage_address;
let deployer_address_for_calculation =
if deploy_from_zero { ContractAddress::default() } else { deployer_address };

Expand Down Expand Up @@ -268,7 +261,7 @@ impl<'state> StarknetSyscallHandler for &mut NativeSyscallHandler<'state> {

let key = StorageKey::try_from(address).map_err(|e| encode_str_as_felts(&e.to_string()))?;

let read_result = self.state.get_storage_at(self.contract_address, key);
let read_result = self.state.get_storage_at(self.call.storage_address, key);
let value = read_result.map_err(|e| encode_str_as_felts(&e.to_string()))?;

self.accessed_keys.insert(key);
Expand All @@ -293,7 +286,7 @@ impl<'state> StarknetSyscallHandler for &mut NativeSyscallHandler<'state> {
let key = StorageKey::try_from(address).map_err(|e| encode_str_as_felts(&e.to_string()))?;
self.accessed_keys.insert(key);

let write_result = self.state.set_storage_at(self.contract_address, key, value);
let write_result = self.state.set_storage_at(self.call.storage_address, key, value);
write_result.map_err(|e| encode_str_as_felts(&e.to_string()))?;

Ok(())
Expand Down
21 changes: 17 additions & 4 deletions crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ use crate::test_utils::initial_test_state::test_state;
use crate::test_utils::{calldata_for_deploy_test, trivial_external_entry_point_new, CairoVersion};

#[test_case(FeatureContract::TestContract(CairoVersion::Cairo1), 206800;"VM")]
#[test_case(FeatureContract::TestContract(CairoVersion::Native), 216800;"Native")]
#[cfg_attr(
feature = "cairo_native",
test_case(FeatureContract::TestContract(CairoVersion::Native), 216800;"Native")
)]
fn no_constructor(deployer_contract: FeatureContract, expected_gas: u64) {
// TODO(Yoni): share the init code of the tests in this file.

Expand Down Expand Up @@ -64,7 +67,10 @@ fn no_constructor(deployer_contract: FeatureContract, expected_gas: u64) {
}

#[test_case(FeatureContract::TestContract(CairoVersion::Cairo1);"VM")]
#[test_case(FeatureContract::TestContract(CairoVersion::Native);"Native")]
#[cfg_attr(
feature = "cairo_native",
test_case(FeatureContract::TestContract(CairoVersion::Native);"Native")
)]
fn no_constructor_nonempty_calldata(deployer_contract: FeatureContract) {
let empty_contract = FeatureContract::Empty(CairoVersion::Cairo1);
let class_hash = empty_contract.get_class_hash();
Expand All @@ -89,8 +95,12 @@ fn no_constructor_nonempty_calldata(deployer_contract: FeatureContract) {
constructor."
));
}
#[test_case(FeatureContract::TestContract(CairoVersion::Native),236750, 15210;"Native")]

#[test_case(FeatureContract::TestContract(CairoVersion::Cairo1),216750, 5210;"VM")]
#[cfg_attr(
feature = "cairo_native",
test_case(FeatureContract::TestContract(CairoVersion::Native),236750, 15210;"Native")
)]
fn with_constructor(
deployer_contract: FeatureContract,
expected_gas: u64,
Expand Down Expand Up @@ -153,7 +163,10 @@ fn with_constructor(
}

#[test_case(FeatureContract::TestContract(CairoVersion::Cairo1);"VM")]
#[test_case(FeatureContract::TestContract(CairoVersion::Native);"Native")]
#[cfg_attr(
feature = "cairo_native",
test_case(FeatureContract::TestContract(CairoVersion::Native);"Native")
)]
fn to_unavailable_address(deployer_contract: FeatureContract) {
let empty_contract = FeatureContract::Empty(CairoVersion::Cairo1);
let mut state = test_state(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ use crate::test_utils::contracts::FeatureContract;
use crate::test_utils::initial_test_state::test_state;
use crate::test_utils::{trivial_external_entry_point_new, CairoVersion, BALANCE};

#[test_case(FeatureContract::TestContract(CairoVersion::Native), 27290; "Native")]
#[cfg_attr(
feature = "cairo_native",
test_case(FeatureContract::TestContract(CairoVersion::Native), 27290; "Native")
)]
#[test_case(FeatureContract::TestContract(CairoVersion::Cairo1), REQUIRED_GAS_STORAGE_READ_WRITE_TEST; "VM")]
fn test_storage_read_write(test_contract: FeatureContract, expected_gas: u64) {
let chain_info = &ChainInfo::create_for_testing();
Expand Down

0 comments on commit 55e0f85

Please sign in to comment.