Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@
"syscall_base_gas_cost": 1,
"memory_hole_gas_cost": 0
},
"DeployV2": {
"step_gas_cost": 0,
"range_check": 0,
"bitwise": 0,
"syscall_base_gas_cost": 0,
"memory_hole_gas_cost": 0
},
"EmitEvent": {
"step_gas_cost": 10,
"range_check": 0,
Expand Down Expand Up @@ -409,6 +416,11 @@
"pedersen_builtin": 7
}
},
"DeployV2": {
"n_steps": 0,
"n_memory_holes": 0,
"builtin_instance_counter": {}
},
"EmitEvent": {
"n_steps": 19,
"n_memory_holes": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@
"syscall_base_gas_cost": 1,
"memory_hole_gas_cost": 0
},
"DeployV2": {
"step_gas_cost": 0,
"range_check": 0,
"bitwise": 0,
"syscall_base_gas_cost": 0,
"memory_hole_gas_cost": 0
},
"EmitEvent": {
"step_gas_cost": 10,
"range_check": 0,
Expand Down Expand Up @@ -409,6 +416,11 @@
"pedersen_builtin": 7
}
},
"DeployV2": {
"n_steps": 0,
"n_memory_holes": 0,
"builtin_instance_counter": {}
},
"EmitEvent": {
"n_steps": 61,
"n_memory_holes": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@
"syscall_base_gas_cost": 1,
"memory_hole_gas_cost": 0
},
"DeployV2": {
"step_gas_cost": 0,
"range_check": 0,
"bitwise": 0,
"syscall_base_gas_cost": 0,
"memory_hole_gas_cost": 0
},
"EmitEvent": {
"step_gas_cost": 10,
"range_check": 0,
Expand Down Expand Up @@ -409,6 +416,11 @@
"pedersen_builtin": 7
}
},
"DeployV2": {
"n_steps": 0,
"n_memory_holes": 0,
"builtin_instance_counter": {}
},
"EmitEvent": {
"n_steps": 61,
"n_memory_holes": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@
"syscall_base_gas_cost": 1,
"memory_hole_gas_cost": 0
},
"DeployV2": {
"step_gas_cost": 0,
"range_check": 0,
"bitwise": 0,
"syscall_base_gas_cost": 0,
"memory_hole_gas_cost": 0
},
"EmitEvent": {
"step_gas_cost": 10,
"range_check": 0,
Expand Down Expand Up @@ -409,6 +416,11 @@
"pedersen_builtin": 7
}
},
"DeployV2": {
"n_steps": 0,
"n_memory_holes": 0,
"builtin_instance_counter": {}
},
"EmitEvent": {
"n_steps": 61,
"n_memory_holes": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@
"syscall_base_gas_cost": 1,
"memory_hole_gas_cost": 0
},
"DeployV2": {
"step_gas_cost": 0,
"range_check": 0,
"bitwise": 0,
"syscall_base_gas_cost": 0,
"memory_hole_gas_cost": 0
},
"EmitEvent": {
"step_gas_cost": 10,
"range_check": 0,
Expand Down Expand Up @@ -409,6 +416,11 @@
"pedersen_builtin": 7
}
},
"DeployV2": {
"n_steps": 0,
"n_memory_holes": 0,
"builtin_instance_counter": {}
},
"EmitEvent": {
"n_steps": 61,
"n_memory_holes": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@
"syscall_base_gas_cost": 1,
"memory_hole_gas_cost": 0
},
"DeployV2": {
"step_gas_cost": 0,
"range_check": 0,
"bitwise": 0,
"syscall_base_gas_cost": 0,
"memory_hole_gas_cost": 0
},
"EmitEvent": {
"step_gas_cost": 10,
"range_check": 0,
Expand Down Expand Up @@ -409,6 +416,11 @@
"pedersen_builtin": 7
}
},
"DeployV2": {
"n_steps": 0,
"n_memory_holes": 0,
"builtin_instance_counter": {}
},
"EmitEvent": {
"n_steps": 61,
"n_memory_holes": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@
"pedersen_builtin": 7
}
},
"DeployV2": {
"n_steps": 0,
"n_memory_holes": 0,
"builtin_instance_counter": {}
},
"EmitEvent": {
"n_steps": 61,
"n_memory_holes": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@
}
}
},
"DeployV2": {
"n_steps": 0,
"n_memory_holes": 0,
"builtin_instance_counter": {}
},
"EmitEvent": {
"n_steps": 61,
"n_memory_holes": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@
}
}
},
"DeployV2": {
"n_steps": 0,
"n_memory_holes": 0,
"builtin_instance_counter": {}
},
"EmitEvent": {
"n_steps": 61,
"n_memory_holes": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@
}
}
},
"DeployV2": {
"n_steps": 0,
"n_memory_holes": 0,
"builtin_instance_counter": {}
},
"EmitEvent": {
"n_steps": 61,
"n_memory_holes": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@
}
}
},
"DeployV2": {
"n_steps": 0,
"n_memory_holes": 0,
"builtin_instance_counter": {}
},
"EmitEvent": {
"n_steps": 61,
"n_memory_holes": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@
}
}
},
"DeployV2": {
"n_steps": 0,
"n_memory_holes": 0,
"builtin_instance_counter": {}
},
"EmitEvent": {
"n_steps": 61,
"n_memory_holes": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,14 @@
}
}
},
"DeployV2": {
"n_steps": 0,
"n_memory_holes": 0,
"builtin_instance_counter": {
"range_check_builtin": 0,
"bitwise_builtin": 0
}
},
"EmitEvent": {
"n_steps": 61,
"n_memory_holes": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,23 @@
}
}
},
"DeployV2": {
"constant": {
"n_steps": 1173,
"n_memory_holes": 0,
"builtin_instance_counter": {
"range_check_builtin": 21,
"pedersen_builtin": 7
}
},
"calldata_factor": {
"n_steps": 8,
"n_memory_holes": 0,
"builtin_instance_counter": {
"pedersen_builtin": 1
}
}
},
"EmitEvent": {
"n_steps": 47,
"n_memory_holes": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
~ /os_constants/allowed_proof_versions/0: "0x50524f4f4631"
~ /os_constants/allowed_virtual_os_program_hashes/0: "0x53f6c9fcfd31d27279ff7d7e422b44623550a732b59fe193354a7316a96daa1"
~ /os_constants/execute_max_sierra_gas: 1110000000
+ /os_resources/execute_syscalls/DeployV2/builtin_instance_counter/bitwise_builtin: 0
+ /os_resources/execute_syscalls/DeployV2/builtin_instance_counter/range_check_builtin: 0
+ /os_resources/execute_syscalls/Sha512ProcessBlock/builtin_instance_counter/bitwise_builtin: 3320
+ /os_resources/execute_syscalls/Sha512ProcessBlock/builtin_instance_counter/range_check_builtin: 65
~ /os_resources/execute_syscalls/Sha512ProcessBlock/n_steps: 4737
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
~ /os_constants/allowed_virtual_os_program_hashes/0: "0x1c7be3225dfb33359b3ba9ffbe1542b7da27879b6d89f47b967e512463fd324"
+ /os_constants/allowed_virtual_os_program_hashes/1: "0xfedbf2b6504b9217026ba2bf9b2a33e8e28ed38e5b0f84eef59075b02174b8"
~ /os_resources/execute_syscalls/CallContract/n_steps: 901
+ /os_resources/execute_syscalls/DeployV2/calldata_factor: {"builtin_instance_counter":{"pedersen_builtin":1},"n_memory_holes":0,"n_steps":8}
+ /os_resources/execute_syscalls/DeployV2/constant: {"builtin_instance_counter":{"pedersen_builtin":7,"range_check_builtin":21},"n_memory_holes":0,"n_steps":1173}
- /os_resources/execute_syscalls/DeployV2/builtin_instance_counter
- /os_resources/execute_syscalls/DeployV2/n_memory_holes
- /os_resources/execute_syscalls/DeployV2/n_steps
~ /os_resources/execute_syscalls/EmitEvent/n_steps: 47
~ /os_resources/execute_syscalls/GetBlockHash/builtin_instance_counter/range_check_builtin: 3
~ /os_resources/execute_syscalls/GetBlockHash/n_steps: 106
Expand Down
3 changes: 3 additions & 0 deletions crates/blockifier/src/blockifier_versioned_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,7 @@ impl SyscallGasCost {
pub struct SyscallGasCosts {
pub call_contract: SyscallGasCost,
pub deploy: SyscallGasCost,
pub deploy_v2: SyscallGasCost,
pub get_block_hash: SyscallGasCost,
pub get_execution_info: SyscallGasCost,
pub library_call: SyscallGasCost,
Expand Down Expand Up @@ -938,6 +939,7 @@ impl SyscallGasCosts {
let gas_cost = match *selector {
SyscallSelector::CallContract => self.call_contract,
SyscallSelector::Deploy => self.deploy,
SyscallSelector::DeployV2 => self.deploy_v2,
SyscallSelector::EmitEvent => self.emit_event,
SyscallSelector::GetBlockHash => self.get_block_hash,
SyscallSelector::GetExecutionInfo => self.get_execution_info,
Expand Down Expand Up @@ -1108,6 +1110,7 @@ impl GasCosts {
let syscalls = SyscallGasCosts {
call_contract: summarize(SyscallSelector::CallContract),
deploy: summarize(SyscallSelector::Deploy),
deploy_v2: summarize(SyscallSelector::DeployV2),
get_block_hash: summarize(SyscallSelector::GetBlockHash),
get_execution_info: summarize(SyscallSelector::GetExecutionInfo),
library_call: summarize(SyscallSelector::LibraryCall),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ pub fn execute_deprecated_syscall_from_selector<T: DeprecatedSyscallExecutor>(
// Explicitly list unsupported syscalls, so compiler can catch if a syscall is missing.
DeprecatedSyscallSelector::GetBlockHash
| DeprecatedSyscallSelector::GetClassHashAt
| DeprecatedSyscallSelector::DeployV2
| DeprecatedSyscallSelector::GetExecutionInfo
| DeprecatedSyscallSelector::Keccak
| DeprecatedSyscallSelector::KeccakRound
Expand Down
2 changes: 2 additions & 0 deletions crates/blockifier/src/execution/deprecated_syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub enum DeprecatedSyscallSelector {
DelegateCall,
DelegateL1Handler,
Deploy,
DeployV2,
EmitEvent,
GetBlockHash,
GetBlockNumber,
Expand Down Expand Up @@ -108,6 +109,7 @@ impl TryFrom<Felt> for DeprecatedSyscallSelector {
b"DelegateCall" => Ok(Self::DelegateCall),
b"DelegateL1Handler" => Ok(Self::DelegateL1Handler),
b"Deploy" => Ok(Self::Deploy),
b"DeployV2" => Ok(Self::DeployV2),
b"EmitEvent" => Ok(Self::EmitEvent),
b"GetBlockHash" => Ok(Self::GetBlockHash),
b"GetBlockNumber" => Ok(Self::GetBlockNumber),
Expand Down
11 changes: 10 additions & 1 deletion crates/blockifier/src/execution/native/syscall_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ use cairo_native::starknet::{
use num_bigint::BigUint;
use starknet_api::block::BlockNumber;
use starknet_api::contract_class::EntryPointType;
use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector, L1Address};
use starknet_api::core::{
AddressDerivationHash,
ClassHash,
ContractAddress,
EntryPointSelector,
L1Address,
};
use starknet_api::execution_resources::GasAmount;
use starknet_api::state::StorageKey;
use starknet_api::transaction::fields::{
Expand Down Expand Up @@ -388,6 +394,9 @@ impl StarknetSyscallHandler for &mut NativeSyscallHandler<'_> {
Calldata(Arc::new(calldata.to_vec())),
deploy_from_zero,
remaining_gas,
// The deploy_v2 syscall (Blake2 derivation) has no cairo-native handler until the
// upstream `StarknetSyscallHandler` trait exposes it.
AddressDerivationHash::Pedersen,
)
.map_err(|err| self.handle_error(remaining_gas, err))?;

Expand Down
24 changes: 23 additions & 1 deletion crates/blockifier/src/execution/syscalls/hint_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use cairo_vm::vm::runners::cairo_runner::{ResourceTracker, RunResources};
use cairo_vm::vm::vm_core::VirtualMachine;
use starknet_api::block::BlockHash;
use starknet_api::contract_class::EntryPointType;
use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector};
use starknet_api::core::{AddressDerivationHash, ClassHash, ContractAddress, EntryPointSelector};
use starknet_api::execution_resources::GasAmount;
use starknet_api::transaction::fields::{
valid_resource_bounds_as_felts,
Expand Down Expand Up @@ -575,6 +575,28 @@ impl SyscallExecutor for SyscallHintProcessor<'_> {
request.constructor_calldata,
request.deploy_from_zero,
remaining_gas,
AddressDerivationHash::Pedersen,
)?;
let constructor_retdata =
create_retdata_segment(vm, syscall_handler, &call_info.execution.retdata.0)?;
syscall_handler.base.inner_calls.push(call_info);

Ok(DeployResponse { contract_address: deployed_contract_address, constructor_retdata })
}

fn deploy_v2(
request: DeployRequest,
vm: &mut VirtualMachine,
syscall_handler: &mut Self,
remaining_gas: &mut u64,
) -> Result<DeployResponse, Self::Error> {
let (deployed_contract_address, call_info) = syscall_handler.base.deploy(
request.class_hash,
request.contract_address_salt,
request.constructor_calldata,
request.deploy_from_zero,
remaining_gas,
AddressDerivationHash::Blake2,
)?;
let constructor_retdata =
create_retdata_segment(vm, syscall_handler, &call_info.execution.retdata.0)?;
Expand Down
Loading
Loading