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

Commit

Permalink
TMP - DO NOT MERGE
Browse files Browse the repository at this point in the history
Signed-off-by: Dori Medini <dori@starkware.co>
  • Loading branch information
dorimedini-starkware committed Jun 4, 2023
1 parent b4f6cb3 commit 975fb15
Show file tree
Hide file tree
Showing 13 changed files with 734 additions and 274 deletions.
801 changes: 632 additions & 169 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ members = ["crates/blockifier", "crates/native_blockifier"]

[workspace.dependencies]
assert_matches = "1.5.0"
cairo-felt = "0.3.0-rc1"
cairo-lang-casm = { version = "1.1.0-alpha0" }
cairo-lang-runner = { version = "1.1.0-alpha0" }
cairo-lang-starknet = { version = "1.1.0-alpha0" }
cairo-vm = "0.3.0-rc1"
cairo-felt = { git = "https://github.com/lambdaclass/cairo-rs", rev = "5db2e65" }
cairo-lang-casm = { git = "https://github.com/starkware-libs/cairo", rev = "7531601" }
cairo-lang-runner = { git = "https://github.com/starkware-libs/cairo", rev = "7531601" }
cairo-lang-starknet = { git = "https://github.com/starkware-libs/cairo", rev = "7531601" }
cairo-vm = { git = "https://github.com/lambdaclass/cairo-rs", rev = "5db2e65" }
ctor = "0.2.0"
derive_more = "0.99.17"
hex = "0.4.3"
Expand All @@ -22,7 +22,7 @@ num-bigint = "0.4"
num-integer = "0.1.45"
num-traits = "0.2"
ouroboros = "0.15.6"
papyrus_storage = { git = "https://github.com/starkware-libs/papyrus", rev = "6545673" }
papyrus_storage = { git = "https://github.com/starkware-libs/papyrus", rev = "5bb23d6" }
phf = { version = "0.11", features = ["macros"] }
pretty_assertions = "1.2.1"
serde = "1.0.130"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6646,71 +6646,71 @@
"selector": "0x3c118a68e16e12e97ed25cb4901c12f4d3162818669cc44c391d8049924c14",
"offset": 556,
"builtins": [
"range_check"
"range_check_builtin"
]
},
{
"selector": "0xe7510edcf6e9f1b70f7bd1f488767b50f0363422f3c563160ab77adf62467b",
"offset": 1328,
"builtins": [
"range_check"
"range_check_builtin"
]
},
{
"selector": "0x10d2fede95e3ec06a875a67219425c27c5bd734d57f1b221d729a2337b6b556",
"offset": 1647,
"builtins": [
"range_check",
"range_check_builtin",
"segment_arena"
]
},
{
"selector": "0x169f135eddda5ab51886052d777a57f2ea9c162d713691b5e04a6d4ed71d47f",
"offset": 1761,
"builtins": [
"range_check"
"range_check_builtin"
]
},
{
"selector": "0x27c3334165536f239cfd400ed956eabff55fc60de4fb56728b6a4f6b87db01c",
"offset": 167,
"builtins": [
"range_check"
"range_check_builtin"
]
},
{
"selector": "0x2913ee03e5e3308c41e308bd391ea4faac9b9cb5062c76a6b3ab4f65397e106",
"offset": 365,
"builtins": [
"range_check"
"range_check_builtin"
]
},
{
"selector": "0x2d7cf5d5a324a320f9f37804b1615a533fde487400b41af80f13f7ac5581325",
"offset": 1469,
"builtins": [
"range_check"
"range_check_builtin"
]
},
{
"selector": "0x3604cea1cdb094a73a31144f14a3e5861613c008e1e879939ebc4827d10cd50",
"offset": 907,
"builtins": [
"range_check"
"range_check_builtin"
]
},
{
"selector": "0x3a6a8bae4c51d5959683ae246347ffdd96aa5b2bfa68cc8c3a6a7c2ed0be331",
"offset": 1105,
"builtins": [
"range_check"
"range_check_builtin"
]
},
{
"selector": "0x3b097c62d3e4b85742aadd0dfb823f96134b886ec13bda57b68faf86f294d97",
"offset": 0,
"builtins": [
"range_check"
"range_check_builtin"
]
}
],
Expand All @@ -6719,7 +6719,7 @@
"selector": "0x39edbbb129ad752107a94d40c3873cae369a46fd2fc578d075679aa67e85d12",
"offset": 1982,
"builtins": [
"range_check"
"range_check_builtin"
]
}
],
Expand All @@ -6728,9 +6728,9 @@
"selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194",
"offset": 2136,
"builtins": [
"range_check"
"range_check_builtin"
]
}
]
}
}
}
4 changes: 2 additions & 2 deletions crates/blockifier/src/execution/cairo1_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,13 @@ fn prepare_builtin_costs(

// Put a pointer to the builtin cost segment at the end of the program (after the
// additional `ret` statement).
let mut ptr = (vm.get_pc() + contract_class.program.data.len())?;
let mut ptr = (vm.get_pc() + contract_class.program.data_len())?;
// Push a `ret` opcode.
write_stark_felt(vm, &mut ptr, stark_felt!("0x208b7fff7fff7ffe"))?;
// Push a pointer to the builtin cost segment.
write_maybe_relocatable(vm, &mut ptr, builtin_cost_segment_start)?;

Ok(contract_class.program.data.len() + 2)
Ok(contract_class.program.data_len() + 2)
}

pub fn prepare_call_arguments(
Expand Down
1 change: 0 additions & 1 deletion crates/blockifier/src/execution/contract_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ impl TryFrom<CasmContractClass> for ContractClassV1 {

let program = Program::new(
builtins,
Felt252::prime().to_str_radix(16),
data,
main,
hints,
Expand Down
5 changes: 4 additions & 1 deletion crates/blockifier/src/execution/entry_point_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,17 +524,20 @@ Got an exception while executing a hint.
Cairo traceback (most recent call last):
Unknown location (pc=0:629)
Unknown location (pc=0:612)
Error in the called contract ({}):
Error at pc=0:19:
Got an exception while executing a hint.
Cairo traceback (most recent call last):
Unknown location (pc=0:629)
Unknown location (pc=0:612)
Error in the called contract ({}):
Error at pc=0:58:
An ASSERT_EQ instruction failed: 1 != 0.
Cairo traceback (most recent call last):
Unknown location (pc=0:62)",
Unknown location (pc=0:62)
",
pad_address_to_64(TEST_CONTRACT_ADDRESS),
pad_address_to_64(TEST_CONTRACT_ADDRESS_2),
pad_address_to_64(SECURITY_TEST_CONTRACT_ADDRESS)
Expand Down
1 change: 0 additions & 1 deletion crates/blockifier/src/execution/execution_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ pub fn sn_api_to_cairo_vm_program(program: DeprecatedProgram) -> Result<Program,

let program = Program::new(
builtins,
Felt252::prime().to_str_radix(16),
data,
main,
hints,
Expand Down
19 changes: 12 additions & 7 deletions crates/blockifier/src/fee/fee_test.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
use std::collections::HashMap;

use assert_matches::assert_matches;
use cairo_vm::vm::runners::builtin_runner::{
BITWISE_BUILTIN_NAME, HASH_BUILTIN_NAME, POSEIDON_BUILTIN_NAME, RANGE_CHECK_BUILTIN_NAME,
SIGNATURE_BUILTIN_NAME,
};

use crate::abi::constants::N_STEPS_RESOURCE;
use crate::block_context::BlockContext;
use crate::fee::fee_utils::calculate_l1_gas_by_vm_usage;
use crate::transaction::errors::TransactionExecutionError;
use crate::transaction::objects::ResourcesMapping;

fn get_vm_resource_usage() -> ResourcesMapping {
ResourcesMapping(HashMap::from([
(String::from("n_steps"), 1800),
(String::from("pedersen"), 10),
(String::from("range_check"), 24),
(String::from("ecdsa"), 1),
(String::from("bitwise"), 1),
(String::from("poseidon"), 1),
(String::from(N_STEPS_RESOURCE), 1800),
(String::from(HASH_BUILTIN_NAME), 10),
(String::from(RANGE_CHECK_BUILTIN_NAME), 24),
(String::from(SIGNATURE_BUILTIN_NAME), 1),
(String::from(BITWISE_BUILTIN_NAME), 1),
(String::from(POSEIDON_BUILTIN_NAME), 1),
]))
}

Expand All @@ -25,7 +30,7 @@ fn test_calculate_l1_gas_by_vm_usage() {

// Positive flow.
// Verify calculation - in our case, n_steps is the heaviest resource.
let l1_gas_by_vm_usage = vm_resource_usage.0.get("n_steps").unwrap();
let l1_gas_by_vm_usage = vm_resource_usage.0.get(N_STEPS_RESOURCE).unwrap();
assert_eq!(
*l1_gas_by_vm_usage as f64,
calculate_l1_gas_by_vm_usage(&block_context, &vm_resource_usage).unwrap()
Expand Down
Loading

0 comments on commit 975fb15

Please sign in to comment.