Skip to content

Commit

Permalink
chore(cairo_native): update to v0.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoni-Starkware committed Nov 27, 2024
1 parent 9617c00 commit 82c4263
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 29 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ cairo-lang-sierra-to-casm = "2.9.0-dev.0"
cairo-lang-starknet-classes = "2.9.0-dev.0"
cairo-lang-utils = "2.9.0-dev.0"
# Important: when updated, make sure to update the cairo-native submodule as well.
cairo-native = "0.2.3"
cairo-native = "0.2.4"
cairo-vm = "=1.0.1"
camelpaste = "0.1.0"
chrono = "0.4.26"
Expand Down
4 changes: 2 additions & 2 deletions crates/bin/starknet-native-compile/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "starknet-native-compile"
# The version of this crate should equal the version of cairo-native.
version = "0.2.1-alpha.0"
version = "0.2.4"
edition = "2021"
repository = "https://github.com/starkware-libs/sequencer/"
license = "Apache-2.0"
Expand All @@ -10,6 +10,6 @@ license = "Apache-2.0"
# TODO(Avi, 01/02/2025): Check consistency with the blockifier.
cairo-lang-sierra = "2.9.0-dev.0"
cairo-lang-starknet-classes = "2.9.0-dev.0"
cairo-native = "0.2.3"
cairo-native = "0.2.4"
clap = { version = "4.5.4", features = ["derive"] }
serde_json = "1.0.116"
2 changes: 1 addition & 1 deletion crates/blockifier/cairo_native
Submodule cairo_native updated 99 files
+78 −63 .github/workflows/bench-hyperfine.yml
+1 −1 .github/workflows/publish.yml
+56 −11 .github/workflows/release.yml
+2 −2 .github/workflows/starknet-blocks.yml
+1 −1 CODEOWNERS
+193 −182 Cargo.lock
+2 −2 Cargo.toml
+15 −5 benches/compile_time.rs
+20 −8 benches/libfuncs.rs
+1 −1 benches/util.rs
+2 −2 env.sh
+6 −3 examples/easy_api.rs
+6 −3 examples/erc20.rs
+6 −3 examples/invoke.rs
+6 −3 examples/starknet.rs
+1 −1 runtime/Cargo.toml
+9 −5 runtime/src/lib.rs
+11 −8 src/arch.rs
+13 −26 src/arch/aarch64.rs
+15 −26 src/arch/x86_64.rs
+4 −2 src/bin/cairo-native-compile.rs
+1 −1 src/bin/cairo-native-dump.rs
+5 −3 src/bin/cairo-native-run.rs
+1 −1 src/bin/cairo-native-stress/main.rs
+5 −1 src/bin/scarb-native-dump.rs
+5 −3 src/bin/utils/test.rs
+3 −1 src/cache/aot.rs
+4 −2 src/cache/jit.rs
+4 −8 src/compiler.rs
+14 −25 src/context.rs
+1 −1 src/debug.rs
+3 −2 src/error.rs
+13 −17 src/executor.rs
+31 −30 src/executor/aot.rs
+70 −71 src/executor/contract.rs
+19 −13 src/executor/jit.rs
+98 −52 src/libfuncs.rs
+0 −87 src/libfuncs/ap_tracking.rs
+107 −244 src/libfuncs/array.rs
+3 −4 src/libfuncs/bitwise.rs
+5 −5 src/libfuncs/bool.rs
+74 −77 src/libfuncs/bounded_int.rs
+13 −24 src/libfuncs/box.rs
+0 −33 src/libfuncs/branch_align.rs
+6 −12 src/libfuncs/bytes31.rs
+27 −39 src/libfuncs/cast.rs
+98 −185 src/libfuncs/circuit.rs
+1 −1 src/libfuncs/const.rs
+8 −22 src/libfuncs/debug.rs
+2 −2 src/libfuncs/drop.rs
+2 −2 src/libfuncs/dup.rs
+19 −23 src/libfuncs/ec.rs
+13 −12 src/libfuncs/enum.rs
+40 −74 src/libfuncs/felt252.rs
+7 −16 src/libfuncs/felt252_dict.rs
+6 −11 src/libfuncs/felt252_dict_entry.rs
+18 −31 src/libfuncs/gas.rs
+9 −9 src/libfuncs/int_range.rs
+28 −59 src/libfuncs/mem.rs
+16 −42 src/libfuncs/nullable.rs
+6 −7 src/libfuncs/pedersen.rs
+8 −8 src/libfuncs/poseidon.rs
+24 −56 src/libfuncs/sint128.rs
+29 −61 src/libfuncs/sint16.rs
+29 −61 src/libfuncs/sint32.rs
+29 −61 src/libfuncs/sint64.rs
+29 −61 src/libfuncs/sint8.rs
+0 −29 src/libfuncs/snapshot_take.rs
+129 −365 src/libfuncs/starknet.rs
+1 −1 src/libfuncs/struct.rs
+47 −102 src/libfuncs/uint128.rs
+42 −98 src/libfuncs/uint16.rs
+23 −46 src/libfuncs/uint256.rs
+40 −84 src/libfuncs/uint32.rs
+19 −39 src/libfuncs/uint512.rs
+42 −101 src/libfuncs/uint64.rs
+39 −83 src/libfuncs/uint8.rs
+0 −30 src/libfuncs/unconditional_jump.rs
+0 −30 src/libfuncs/unwrap_non_zero.rs
+1 −1 src/metadata/debug_utils.rs
+1 −1 src/metadata/gas.rs
+4 −4 src/module.rs
+5 −5 src/starknet.rs
+3 −3 src/types.rs
+18 −39 src/types/array.rs
+2 −2 src/types/box.rs
+2 −2 src/types/circuit.rs
+4 −16 src/types/enum.rs
+4 −11 src/types/felt252_dict.rs
+3 −6 src/types/nullable.rs
+3 −15 src/types/snapshot.rs
+3 −10 src/types/starknet.rs
+2 −2 src/types/struct.rs
+17 −18 src/utils.rs
+154 −2 src/utils/block_ext.rs
+90 −65 src/values.rs
+17 −6 tests/common.rs
+1 −1 tests/tests/compile_library.rs
+4 −2 tests/tests/trampoline.rs
31 changes: 10 additions & 21 deletions crates/blockifier/src/execution/native/entry_point_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ pub fn execute_entry_point_call(
let mut syscall_handler: NativeSyscallHandler<'_> =
NativeSyscallHandler::new(call, state, context);

let gas_costs = &syscall_handler.base.context.versioned_constants().os_constants.gas_costs;
let gas_costs = &syscall_handler.base.context.gas_costs();
let builtin_costs = BuiltinCosts {
// todo(rodrigo): Unsure of what value `const` means, but 1 is the right value
// todo(rodrigo): Unsure of what value `const` means, but 1 is the right value.
r#const: 1,
pedersen: gas_costs.pedersen_gas_cost,
bitwise: gas_costs.bitwise_builtin_gas_cost,
Expand All @@ -39,13 +39,10 @@ pub fn execute_entry_point_call(
mul_mod: gas_costs.mul_mod_gas_cost,
};

// Fund the initial budget since the native executor charges it before the run.
// TODO(Yoni): revert once the VM is aligned with this.
let gas = syscall_handler.base.call.initial_gas + gas_costs.entry_point_initial_budget;
let execution_result = contract_class.executor.run(
entry_point.selector.0,
&syscall_handler.base.call.calldata.0.clone(),
Some(gas),
syscall_handler.base.call.initial_gas,
Some(builtin_costs),
&mut syscall_handler,
);
Expand All @@ -64,24 +61,16 @@ fn create_callinfo(
call_result: ContractExecutionResult,
syscall_handler: NativeSyscallHandler<'_>,
) -> Result<CallInfo, EntryPointExecutionError> {
let mut remaining_gas = call_result.remaining_gas;
let remaining_gas = call_result.remaining_gas;

if remaining_gas > syscall_handler.base.call.initial_gas {
if remaining_gas - syscall_handler.base.call.initial_gas
<= syscall_handler.base.context.gas_costs().entry_point_initial_budget
{
// Revert the refund.
// TODO(Yoni): temporary hack - this is probably a bug. Investigate and fix native.
remaining_gas = syscall_handler.base.call.initial_gas;
} else {
return Err(PostExecutionError::MalformedReturnData {
error_message: format!(
"Unexpected remaining gas. Used gas is greater than initial gas: {} > {}",
remaining_gas, syscall_handler.base.call.initial_gas
),
}
.into());
return Err(PostExecutionError::MalformedReturnData {
error_message: format!(
"Unexpected remaining gas. Used gas is greater than initial gas: {} > {}",
remaining_gas, syscall_handler.base.call.initial_gas
),
}
.into());
}

let gas_consumed = syscall_handler.base.call.initial_gas - remaining_gas;
Expand Down

0 comments on commit 82c4263

Please sign in to comment.