From 1699f47201a7060c115e401d5f5f6e7599d220c3 Mon Sep 17 00:00:00 2001 From: Mathieu <60658558+enitrat@users.noreply.github.com> Date: Thu, 22 Aug 2024 14:43:15 +0200 Subject: [PATCH] dev: update makefile (#739) * dev: update ssj artifact name * remove unused items * clippy * update makefile * fmt: trunk check fix * remove useless build/temp erasing --- Makefile | 12 +++------ .../src/evm_sequencer/account/v1.rs | 6 ++--- .../src/evm_sequencer/evm_state/v1.rs | 26 +++++-------------- .../src/evm_sequencer/sequencer/v0.rs | 2 +- 4 files changed, 14 insertions(+), 32 deletions(-) diff --git a/Makefile b/Makefile index 9fdfb8b3..b20fde1e 100644 --- a/Makefile +++ b/Makefile @@ -37,14 +37,10 @@ setup-kakarot-v0: clean-kakarot-v0 rm -f kakarot-build.zip setup-kakarot-v1: clean-kakarot-v1 - @curl -sL -o dev-artifacts.zip "$(KKRT_SSJ_BUILD_ARTIFACT_URL)" - unzip -o dev-artifacts.zip -d build/temp - mv build/temp/contracts_AccountContract.compiled_contract_class.json build/v1 - mv build/temp/contracts_KakarotCore.compiled_contract_class.json build/v1 - mv build/temp/contracts_UninitializedAccount.compiled_contract_class.json build/v1 - mv build/temp/contracts_Cairo1Helpers.compiled_contract_class.json build/common/cairo1_helpers.json - rm -fr build/temp - rm -f dev-artifacts.zip + @curl -sL -o kakarot-ssj-build.zip "$(KKRT_SSJ_BUILD_ARTIFACT_URL)" + unzip -o kakarot-ssj-build.zip -d build/v1 + mv build/v1/contracts_Cairo1Helpers.compiled_contract_class.json build/common/cairo1_helpers.json + rm -f kakarot-ssj-build.zip setup-kakarot: clean-common setup-kakarot-v0 setup-kakarot-v1 diff --git a/crates/ef-testing/src/evm_sequencer/account/v1.rs b/crates/ef-testing/src/evm_sequencer/account/v1.rs index 2bca3ad6..2a2dad65 100644 --- a/crates/ef-testing/src/evm_sequencer/account/v1.rs +++ b/crates/ef-testing/src/evm_sequencer/account/v1.rs @@ -6,15 +6,13 @@ use revm_primitives::Bytecode; use starknet::core::types::Felt; use starknet_api::{core::Nonce, state::StorageKey, StarknetApiError}; +use super::pack_byte_array_to_starkfelt_array; use super::KakarotAccount; -use super::{inner_byte_array_pointer, pack_byte_array_to_starkfelt_array}; use crate::evm_sequencer::constants::storage_variables::{ ACCOUNT_BYTECODE_LEN, ACCOUNT_CODE_HASH, ACCOUNT_EVM_ADDRESS, ACCOUNT_IS_INITIALIZED, ACCOUNT_NONCE, ACCOUNT_STORAGE, ACCOUNT_VALID_JUMPDESTS, }; -use crate::evm_sequencer::{ - constants::storage_variables::ACCOUNT_BYTECODE, types::felt::FeltSequencer, utils::split_u256, -}; +use crate::evm_sequencer::{types::felt::FeltSequencer, utils::split_u256}; use crate::starknet_storage; impl KakarotAccount { diff --git a/crates/ef-testing/src/evm_sequencer/evm_state/v1.rs b/crates/ef-testing/src/evm_sequencer/evm_state/v1.rs index 844ba177..d59336fa 100644 --- a/crates/ef-testing/src/evm_sequencer/evm_state/v1.rs +++ b/crates/ef-testing/src/evm_sequencer/evm_state/v1.rs @@ -1,6 +1,6 @@ use blockifier::{ abi::{ - abi_utils::{get_fee_token_var_address, get_storage_var_address, starknet_keccak}, + abi_utils::{get_fee_token_var_address, get_storage_var_address}, sierra_types::next_storage_key, }, execution::errors::EntryPointExecutionError, @@ -10,24 +10,23 @@ use blockifier::{ objects::{TransactionExecutionInfo, TransactionExecutionResult}, }, }; -use num_integer::Integer; use reth_primitives::{Address, Bytes, TransactionSigned, U256}; use sequencer::{execution::Execution as _, transaction::BroadcastedTransactionWrapper}; use starknet::core::types::BroadcastedTransaction; -use starknet_api::{core::L2_ADDRESS_UPPER_BOUND, state::StorageKey}; -use starknet_crypto::{poseidon_hash_many, Felt}; +use starknet_api::state::StorageKey; +use starknet_crypto::Felt; use super::Evm; use crate::evm_sequencer::constants::storage_variables::ACCOUNT_BYTECODE_LEN; use crate::evm_sequencer::utils::felt_to_bytes; use crate::{ evm_sequencer::{ - account::{inner_byte_array_pointer, KakarotAccount}, + account::KakarotAccount, constants::{ storage_variables::{ - ACCOUNT_BYTECODE, ACCOUNT_IMPLEMENTATION, ACCOUNT_NONCE, ACCOUNT_STORAGE, - KAKAROT_BASE_FEE, KAKAROT_BLOCK_GAS_LIMIT, KAKAROT_COINBASE, - KAKAROT_EVM_TO_STARKNET_ADDRESS, KAKAROT_PREV_RANDAO, OWNABLE_OWNER, + ACCOUNT_IMPLEMENTATION, ACCOUNT_NONCE, ACCOUNT_STORAGE, KAKAROT_BASE_FEE, + KAKAROT_BLOCK_GAS_LIMIT, KAKAROT_COINBASE, KAKAROT_EVM_TO_STARKNET_ADDRESS, + KAKAROT_PREV_RANDAO, OWNABLE_OWNER, }, ETH_FEE_TOKEN_ADDRESS, KAKAROT_ADDRESS, }, @@ -292,16 +291,6 @@ impl Evm for KakarotSequencer { } } -pub(crate) fn compute_storage_base_address(storage_var_name: &str, keys: &[Felt]) -> StorageKey { - let selector = starknet_keccak(storage_var_name.as_bytes()); - - let data = [&[selector], keys].concat(); - let key: Felt = poseidon_hash_many(&data); - let key_floored = key.mod_floor(&L2_ADDRESS_UPPER_BOUND); - - key_floored.try_into().unwrap() // infallible -} - #[cfg(test)] mod tests { use super::*; @@ -317,7 +306,6 @@ mod tests { models::result::extract_output_and_log_execution_result, }; use reth_primitives::{sign_message, Signature, TransactionSigned, TxLegacy, B256}; - use starknet::core::types::Felt; #[test] fn test_store_bytecode() { diff --git a/crates/ef-testing/src/evm_sequencer/sequencer/v0.rs b/crates/ef-testing/src/evm_sequencer/sequencer/v0.rs index 4cff2392..2050e4d9 100644 --- a/crates/ef-testing/src/evm_sequencer/sequencer/v0.rs +++ b/crates/ef-testing/src/evm_sequencer/sequencer/v0.rs @@ -66,7 +66,7 @@ lazy_static! { convert_contract_class_v0(&OPENZEPPELIN_ACCOUNT_CLASS).expect("failed to convert OPENZEPPELIN ACCOUNT CLASS to contract class") ).expect("failed to set openzeppelin account contract class"); (&mut state).set_class_hash_at(*RELAYER_ADDRESS, *OPENZEPPELIN_ACCOUNT_CLASS_HASH).expect("failed to set relayer class hash"); - (&mut state).set_storage_at(*RELAYER_ADDRESS, get_storage_var_address(ACCOUNT_PUBLIC_KEY, &[]), RELAYER_VERIFYING_KEY.scalar().into()).expect("failed to set relayer public key"); + (&mut state).set_storage_at(*RELAYER_ADDRESS, get_storage_var_address(ACCOUNT_PUBLIC_KEY, &[]), RELAYER_VERIFYING_KEY.scalar()).expect("failed to set relayer public key"); (&mut state).set_storage_at(*ETH_FEE_TOKEN_ADDRESS, get_storage_var_address(ERC20_BALANCES, &[*RELAYER_ADDRESS.0.key()]), *RELAYER_BALANCE).expect("failed to set relayer balance"); state