@@ -15,6 +15,7 @@ use crate::block_hash::block_hash_calculator::{
1515 calculate_block_hash,
1616 BlockHashVersion ,
1717 BlockHeaderCommitments ,
18+ PartialBlockHash ,
1819 PartialBlockHashComponents ,
1920 TransactionHashingData ,
2021} ;
@@ -252,10 +253,38 @@ fn change_field_of_hash_input() {
252253 } ,
253254 l2_gas_price: GasPricePerToken { price_in_fri: 1_u8 . into( ) , price_in_wei: 1_u8 . into( ) } ,
254255 sequencer: SequencerContractAddress ( ContractAddress :: from( 1_u128 ) ) ,
255- timestamp: BlockTimestamp ( 1 )
256+ timestamp: BlockTimestamp ( 1 ) ,
256257 } ,
257258 state_root: GlobalRoot ( Felt :: ONE ) ,
258259 previous_block_hash: BlockHash ( Felt :: ONE )
259260 )
260261 // TODO(Aviv, 10/06/2024): add tests that changes the first hash input, and the const zero.
261262}
263+
264+ /// SNIP-35: `fee_proposal_fri` must change the proposal commitment hash (`PartialBlockHash`) but
265+ /// must not change the block hash (`BlockHash`).
266+ #[ test]
267+ fn fee_proposal_fri_affects_partial_block_hash_but_not_block_hash ( ) {
268+ let base = PartialBlockHashComponents {
269+ starknet_version : BlockHashVersion :: V0_13_4 . into ( ) ,
270+ fee_proposal_fri : GasPrice ( 0 ) ,
271+ ..Default :: default ( )
272+ } ;
273+ let modified = PartialBlockHashComponents { fee_proposal_fri : GasPrice ( 1 ) , ..base. clone ( ) } ;
274+
275+ let base_block_hash =
276+ calculate_block_hash ( & base, GlobalRoot :: default ( ) , BlockHash :: default ( ) ) . unwrap ( ) ;
277+ let modified_block_hash =
278+ calculate_block_hash ( & modified, GlobalRoot :: default ( ) , BlockHash :: default ( ) ) . unwrap ( ) ;
279+ assert_eq ! (
280+ base_block_hash, modified_block_hash,
281+ "BlockHash must not depend on fee_proposal_fri"
282+ ) ;
283+
284+ let base_partial = PartialBlockHash :: from_partial_block_hash_components ( & base) . unwrap ( ) ;
285+ let modified_partial = PartialBlockHash :: from_partial_block_hash_components ( & modified) . unwrap ( ) ;
286+ assert_ne ! (
287+ base_partial, modified_partial,
288+ "PartialBlockHash (proposal commitment) must depend on fee_proposal_fri"
289+ ) ;
290+ }
0 commit comments