Skip to content

Commit

Permalink
dev: update makefile (#739)
Browse files Browse the repository at this point in the history
* dev: update ssj artifact name

* remove unused items

* clippy

* update makefile

* fmt: trunk check fix

* remove useless build/temp erasing
  • Loading branch information
enitrat authored Aug 22, 2024
1 parent 7139f02 commit 1699f47
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 32 deletions.
12 changes: 4 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 2 additions & 4 deletions crates/ef-testing/src/evm_sequencer/account/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
26 changes: 7 additions & 19 deletions crates/ef-testing/src/evm_sequencer/evm_state/v1.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
},
Expand Down Expand Up @@ -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::*;
Expand All @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion crates/ef-testing/src/evm_sequencer/sequencer/v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1699f47

Please sign in to comment.