Skip to content

Commit

Permalink
test(native_blockifier): move alias constants to python (#2675)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoavGrs authored Dec 23, 2024
1 parent a5af046 commit 34c98a0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/blockifier/src/state/stateful_compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ pub type CompressionResult<T> = Result<T, CompressionError>;

// The initial alias available for allocation.
const INITIAL_AVAILABLE_ALIAS_HEX: &str = "0x80";
const INITIAL_AVAILABLE_ALIAS: Felt = Felt::from_hex_unchecked(INITIAL_AVAILABLE_ALIAS_HEX);
pub const INITIAL_AVAILABLE_ALIAS: Felt = Felt::from_hex_unchecked(INITIAL_AVAILABLE_ALIAS_HEX);

// The storage key of the alias counter in the alias contract.
const ALIAS_COUNTER_STORAGE_KEY: StorageKey = StorageKey(PatriciaKey::ZERO);
pub 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.
const MAX_NON_COMPRESSED_CONTRACT_ADDRESS: ContractAddress =
pub const MAX_NON_COMPRESSED_CONTRACT_ADDRESS: ContractAddress =
ContractAddress(PatriciaKey::from_hex_unchecked("0xf"));
// The minimal value for a key to be allocated an alias. Smaller keys are serialized as is (their
// alias is identical to the key).
const MIN_VALUE_FOR_ALIAS_ALLOC: PatriciaKey =
pub const MIN_VALUE_FOR_ALIAS_ALLOC: PatriciaKey =
PatriciaKey::from_hex_unchecked(INITIAL_AVAILABLE_ALIAS_HEX);

/// 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 34c98a0

Please sign in to comment.