Skip to content

Commit

Permalink
test(native_blockifier): move alias constants to python
Browse files Browse the repository at this point in the history
  • Loading branch information
yoavGrs committed Dec 18, 2024
1 parent c8f73c0 commit ebcae84
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/blockifier/src/state/stateful_compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ const INITIAL_AVAILABLE_ALIAS: Felt = Felt::from_hex_unchecked("0x80");
const ALIAS_COUNTER_STORAGE_KEY: StorageKey = StorageKey(PatriciaKey::ZERO);
// The maximal contract address for which aliases are not used and all keys are serialized as is,
// without compression.
static MAX_NON_COMPRESSED_CONTRACT_ADDRESS: LazyLock<ContractAddress> = LazyLock::new(|| {
pub static MAX_NON_COMPRESSED_CONTRACT_ADDRESS: LazyLock<ContractAddress> = LazyLock::new(|| {
ContractAddress(PatriciaKey::try_from(Felt::from_hex_unchecked("0xf")).unwrap())
});
// The minimal value for a key to be allocated an alias. Smaller keys are serialized as is (their
// alias is identical to the key).
static MIN_VALUE_FOR_ALIAS_ALLOC: LazyLock<PatriciaKey> =
pub static MIN_VALUE_FOR_ALIAS_ALLOC: LazyLock<PatriciaKey> =
LazyLock::new(|| PatriciaKey::try_from(INITIAL_AVAILABLE_ALIAS).unwrap());

/// Allocates aliases for the new addresses and storage keys in the alias contract.
Expand Down
11 changes: 11 additions & 0 deletions crates/native_blockifier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ pub mod state_readers;
pub mod storage;
pub mod test_utils;

use blockifier::state::stateful_compression::{
ALIAS_COUNTER_STORAGE_KEY,
MAX_NON_COMPRESSED_CONTRACT_ADDRESS,
MIN_VALUE_FOR_ALIAS_ALLOC,
};
use errors::{add_py_exceptions, UndeclaredClassHashError};
use py_block_executor::PyBlockExecutor;
use py_objects::PyExecutionResources;
Expand Down Expand Up @@ -64,6 +69,12 @@ fn native_blockifier(py: Python<'_>, py_module: &PyModule) -> PyResult<()> {
estimate_casm_hash_computation_resources_for_testing_single,
py
)?)?;
py_module.add("ALIAS_COUNTER_STORAGE_KEY", ALIAS_COUNTER_STORAGE_KEY.to_string())?;
py_module.add(
"MAX_NON_COMPRESSED_CONTRACT_ADDRESS",
MAX_NON_COMPRESSED_CONTRACT_ADDRESS.to_string(),
)?;
py_module.add("INITIAL_AVAILABLE_ALIAS", MIN_VALUE_FOR_ALIAS_ALLOC.to_string())?;

Ok(())
}
Expand Down

0 comments on commit ebcae84

Please sign in to comment.