Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yoni/debug/rm stacker #3267

Open
wants to merge 1 commit into
base: main-v0.13.4
Choose a base branch
from
Open
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
14 changes: 7 additions & 7 deletions crates/blockifier/src/execution/execution_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ pub fn execute_entry_point_call(
context,
)
} else {
log::debug!(
"Using Cairo Native execution. Block Number: {}, Transaction Hash: {}, Class \
Hash: {}.",
context.tx_context.block_context.block_info.block_number,
context.tx_context.tx_info.transaction_hash(),
call.class_hash.expect("Missing Class Hash")
);
// log::debug!(
// "Using Cairo Native execution. Block Number: {}, Transaction Hash: {}, Class
// \ Hash: {}.",
// context.tx_context.block_context.block_info.block_number,
// context.tx_context.tx_info.transaction_hash(),
// call.class_hash.expect("Missing Class Hash")
// );
native_entry_point_execution::execute_entry_point_call(
call,
compiled_class,
Expand Down
48 changes: 23 additions & 25 deletions crates/blockifier/src/execution/native/entry_point_execution.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use cairo_native::execution_result::ContractExecutionResult;
use cairo_native::utils::BuiltinCosts;
use num_rational::Ratio;
use stacker;

// use num_rational::Ratio;
// use stacker;
use crate::execution::call_info::{CallExecution, CallInfo, Retdata};
use crate::execution::contract_class::TrackedResource;
use crate::execution::entry_point::{
Expand All @@ -14,7 +14,7 @@ use crate::execution::errors::{EntryPointExecutionError, PostExecutionError, Pre
use crate::execution::native::contract_class::NativeCompiledClassV1;
use crate::execution::native::syscall_handler::NativeSyscallHandler;
use crate::state::state_api::State;
use crate::versioned_constants::CairoNativeStackConfig;
// use crate::versioned_constants::CairoNativeStackConfig;

// todo(rodrigo): add an `entry point not found` test for Native
pub fn execute_entry_point_call(
Expand Down Expand Up @@ -66,30 +66,28 @@ pub fn execute_entry_point_call(
// This also limits multi-threading, since each thread has its own stack.
// If the the free stack size is in the red zone, We will grow the stack to the
// target size, relative to reaming gas.
let stack_config = CairoNativeStackConfig {
// TODO(Aviv): Take it from VC.
gas_to_stack_ratio: Ratio::new(1, 20),
max_stack_size: 200 * 1024 * 1024,
min_stack_red_zone: 2 * 1024 * 1024,
buffer_size: 5 * 1024 * 1024,
};
let stack_size_red_zone = stack_config.get_stack_size_red_zone(call_initial_gas);
let target_stack_size =
usize::try_from(stack_config.get_target_stack_size(stack_size_red_zone))
.unwrap_or_else(|e| panic!("Failed to convert target stack size to usize: {}", e));
let stack_size_red_zone = usize::try_from(stack_size_red_zone)
.unwrap_or_else(|e| panic!("Failed to convert stack size red zone to usize: {}", e));
// let stack_config = CairoNativeStackConfig {
// // TODO(Aviv): Take it from VC.
// gas_to_stack_ratio: Ratio::new(1, 20),
// max_stack_size: 200 * 1024 * 1024,
// min_stack_red_zone: 2 * 1024 * 1024,
// buffer_size: 5 * 1024 * 1024,
// };
// let stack_size_red_zone = stack_config.get_stack_size_red_zone(call_initial_gas);
// let target_stack_size =
// usize::try_from(stack_config.get_target_stack_size(stack_size_red_zone))
// .unwrap_or_else(|e| panic!("Failed to convert target stack size to usize: {}", e));
// let stack_size_red_zone = usize::try_from(stack_size_red_zone)
// .unwrap_or_else(|e| panic!("Failed to convert stack size red zone to usize: {}", e));
// Use `maybe_grow` and not `grow` for performance, since in happy flows, only the main call
// should trigger the growth.
let execution_result = stacker::maybe_grow(stack_size_red_zone, target_stack_size, || {
compiled_class.executor.run(
entry_point.selector.0,
&syscall_handler.base.call.calldata.0.clone(),
call_initial_gas,
Some(builtin_costs),
&mut syscall_handler,
)
});
let execution_result = compiled_class.executor.run(
entry_point.selector.0,
&syscall_handler.base.call.calldata.0.clone(),
call_initial_gas,
Some(builtin_costs),
&mut syscall_handler,
);
syscall_handler.finalize();

let call_result = execution_result.map_err(EntryPointExecutionError::NativeUnexpectedError)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ fn test_total_tx_limits_less_than_max_sierra_gas() {

#[cfg(feature = "cairo_native")]
#[rstest::rstest]
#[case(MAX_POSSIBLE_SIERRA_GAS, MAX_POSSIBLE_SIERRA_GAS - 2681170910)]
#[case(MAX_POSSIBLE_SIERRA_GAS / 10, 81886490)]
#[case(MAX_POSSIBLE_SIERRA_GAS / 100, 8190940)]
#[case(MAX_POSSIBLE_SIERRA_GAS / 1000, 822890)]
#[case(MAX_POSSIBLE_SIERRA_GAS / 10000, 85440)]
#[case(MAX_POSSIBLE_SIERRA_GAS / 100000, 12340)]
#[case(MAX_POSSIBLE_SIERRA_GAS / 1000000, 0)]
// #[case(MAX_POSSIBLE_SIERRA_GAS, MAX_POSSIBLE_SIERRA_GAS - 2681170910)]
// #[case(MAX_POSSIBLE_SIERRA_GAS / 10, 81886490)]
// #[case(MAX_POSSIBLE_SIERRA_GAS / 100, 8190940)]
// #[case(MAX_POSSIBLE_SIERRA_GAS / 1000, 822890)]
// #[case(MAX_POSSIBLE_SIERRA_GAS / 10000, 85440)]
// #[case(MAX_POSSIBLE_SIERRA_GAS / 100000, 12340)]
// #[case(MAX_POSSIBLE_SIERRA_GAS / 1000000, 0)]
#[case(350, 0)]
#[case(35, 0)]
#[case(0, 0)]
Expand Down
Loading