Skip to content

Commit 18edaf1

Browse files
starknet_api: add BlockHashVersion::V0_14_3 variant
1 parent b86e80e commit 18edaf1

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

crates/starknet_api/src/block_hash/block_hash_calculator.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ static STARKNET_BLOCK_HASH0: LazyLock<Felt> = LazyLock::new(|| {
4747
pub static STARKNET_BLOCK_HASH1: LazyLock<Felt> = LazyLock::new(|| {
4848
ascii_as_felt("STARKNET_BLOCK_HASH1").expect("ascii_as_felt failed for 'STARKNET_BLOCK_HASH1'")
4949
});
50+
pub static STARKNET_BLOCK_HASH2: LazyLock<Felt> = LazyLock::new(|| {
51+
ascii_as_felt("STARKNET_BLOCK_HASH2").expect("ascii_as_felt failed for 'STARKNET_BLOCK_HASH2'")
52+
});
5053
pub static STARKNET_GAS_PRICES0: LazyLock<Felt> = LazyLock::new(|| {
5154
ascii_as_felt("STARKNET_GAS_PRICES0").expect("ascii_as_felt failed for 'STARKNET_GAS_PRICES0'")
5255
});
@@ -56,13 +59,15 @@ pub static STARKNET_GAS_PRICES0: LazyLock<Felt> = LazyLock::new(|| {
5659
pub enum BlockHashVersion {
5760
V0_13_2,
5861
V0_13_4,
62+
V0_14_3,
5963
}
6064

6165
impl From<BlockHashVersion> for StarknetVersion {
6266
fn from(value: BlockHashVersion) -> Self {
6367
match value {
6468
BlockHashVersion::V0_13_2 => StarknetVersion::V0_13_2,
6569
BlockHashVersion::V0_13_4 => StarknetVersion::V0_13_4,
70+
BlockHashVersion::V0_14_3 => StarknetVersion::V0_14_3,
6671
}
6772
}
6873
}
@@ -76,8 +81,10 @@ impl TryFrom<StarknetVersion> for BlockHashVersion {
7681
} else if value < Self::V0_13_4.into() {
7782
// Starknet versions 0.13.2 and 0.13.3 both have the same block hash mechanism.
7883
Ok(Self::V0_13_2)
79-
} else {
84+
} else if value < Self::V0_14_3.into() {
8085
Ok(Self::V0_13_4)
86+
} else {
87+
Ok(Self::V0_14_3)
8188
}
8289
}
8390
}
@@ -90,6 +97,7 @@ impl From<BlockHashVersion> for BlockHashConstant {
9097
match block_hash_version {
9198
BlockHashVersion::V0_13_2 => *STARKNET_BLOCK_HASH0,
9299
BlockHashVersion::V0_13_4 => *STARKNET_BLOCK_HASH1,
100+
BlockHashVersion::V0_14_3 => *STARKNET_BLOCK_HASH2,
93101
}
94102
}
95103
}

crates/starknet_os/src/hints/hint_implementation/block_hash/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use starknet_api::block_hash::block_hash_calculator::{
1919
BlockHashVersion,
2020
BlockHeaderCommitments,
2121
PartialBlockHashComponents,
22-
STARKNET_BLOCK_HASH1,
22+
STARKNET_BLOCK_HASH2,
2323
};
2424
use starknet_api::core::{
2525
EventCommitment,
@@ -161,7 +161,7 @@ fn test_block_hash_version() {
161161
// NOTE: if these checks fail, it means the block hash version in the OS program is not the
162162
// latest, and a backward-compatibility flow must be added for the transition.
163163
assert_eq!(
164-
*STARKNET_BLOCK_HASH1, latest_block_hash_version,
164+
*STARKNET_BLOCK_HASH2, latest_block_hash_version,
165165
"Latest block hash version constant mismatch"
166166
);
167167
assert_eq!(

0 commit comments

Comments
 (0)