File tree Expand file tree Collapse file tree 6 files changed +34
-26
lines changed Expand file tree Collapse file tree 6 files changed +34
-26
lines changed Original file line number Diff line number Diff line change @@ -712,9 +712,9 @@ impl BlockBuilderFactory {
712712 ) ;
713713 let height = block_metadata. block_info . block_number ;
714714 let block_builder_config = self . block_builder_config . clone ( ) ;
715- let versioned_constants = VersionedConstants :: get_versioned_constants (
715+ let versioned_constants = VersionedConstants :: get_versioned_constants ( Some (
716716 block_builder_config. versioned_constants_overrides ,
717- ) ;
717+ ) ) ;
718718 let block_context = BlockContext :: new (
719719 block_metadata. block_info ,
720720 block_builder_config. chain_info ,
Original file line number Diff line number Diff line change @@ -72,9 +72,9 @@ impl StatefulTransactionValidatorFactoryTrait for StatefulTransactionValidatorFa
7272 let latest_block_info = get_latest_block_info ( & state_reader) ?;
7373
7474 let state = CachedState :: new ( state_reader) ;
75- let mut versioned_constants = VersionedConstants :: get_versioned_constants (
75+ let mut versioned_constants = VersionedConstants :: get_versioned_constants ( Some (
7676 self . config . versioned_constants_overrides . clone ( ) ,
77- ) ;
77+ ) ) ;
7878 // The validation of a transaction is not affected by the casm hash migration.
7979 versioned_constants. enable_casm_hash_migration = false ;
8080
Original file line number Diff line number Diff line change @@ -437,23 +437,29 @@ impl VersionedConstants {
437437 // squashing the functions together.
438438 /// Returns the latest versioned constants, applying the given overrides.
439439 pub fn get_versioned_constants (
440- versioned_constants_overrides : VersionedConstantsOverrides ,
440+ versioned_constants_overrides : Option < VersionedConstantsOverrides > ,
441441 ) -> Self {
442- let VersionedConstantsOverrides {
443- validate_max_n_steps,
444- max_recursion_depth,
445- invoke_tx_max_n_steps,
446- max_n_events,
447- } = versioned_constants_overrides;
448- let latest_constants = Self :: latest_constants ( ) . clone ( ) ;
449- let tx_event_limits =
450- EventLimits { max_n_emitted_events : max_n_events, ..latest_constants. tx_event_limits } ;
451- Self {
452- validate_max_n_steps,
453- max_recursion_depth,
454- invoke_tx_max_n_steps,
455- tx_event_limits,
456- ..latest_constants
442+ match versioned_constants_overrides {
443+ None => Self :: latest_constants ( ) . clone ( ) ,
444+ Some ( VersionedConstantsOverrides {
445+ validate_max_n_steps,
446+ max_recursion_depth,
447+ invoke_tx_max_n_steps,
448+ max_n_events,
449+ } ) => {
450+ let latest_constants = Self :: latest_constants ( ) . clone ( ) ;
451+ let tx_event_limits = EventLimits {
452+ max_n_emitted_events : max_n_events,
453+ ..latest_constants. tx_event_limits
454+ } ;
455+ Self {
456+ validate_max_n_steps,
457+ max_recursion_depth,
458+ invoke_tx_max_n_steps,
459+ tx_event_limits,
460+ ..latest_constants
461+ }
462+ }
457463 }
458464 }
459465
Original file line number Diff line number Diff line change @@ -29,12 +29,12 @@ fn test_versioned_constants_overrides() {
2929 let updated_max_n_events = versioned_constants. tx_event_limits . max_n_emitted_events + 1 ;
3030
3131 // Create a versioned constants copy with overriden values.
32- let result = VersionedConstants :: get_versioned_constants ( VersionedConstantsOverrides {
32+ let result = VersionedConstants :: get_versioned_constants ( Some ( VersionedConstantsOverrides {
3333 validate_max_n_steps : updated_validate_max_n_steps,
3434 max_recursion_depth : updated_max_recursion_depth,
3535 invoke_tx_max_n_steps : updated_invoke_tx_max_n_steps,
3636 max_n_events : updated_max_n_events,
37- } ) ;
37+ } ) ) ;
3838
3939 // Assert the new values are used.
4040 assert_eq ! ( result. invoke_tx_max_n_steps, updated_invoke_tx_max_n_steps) ;
Original file line number Diff line number Diff line change @@ -101,8 +101,9 @@ impl PyBlockExecutor {
101101 log:: debug!( "Initializing Block Executor..." ) ;
102102 let storage =
103103 PapyrusStorage :: new ( target_storage_config) . expect ( "Failed to initialize storage." ) ;
104- let versioned_constants =
105- VersionedConstants :: get_versioned_constants ( py_versioned_constants_overrides. into ( ) ) ;
104+ let versioned_constants = VersionedConstants :: get_versioned_constants ( Some (
105+ py_versioned_constants_overrides. into ( ) ,
106+ ) ) ;
106107 log:: debug!( "Initialized Block Executor." ) ;
107108
108109 Self {
Original file line number Diff line number Diff line change @@ -43,8 +43,9 @@ impl PyValidator {
4343 let state = CachedState :: new ( state_reader) ;
4444
4545 // Create the block context.
46- let mut versioned_constants =
47- VersionedConstants :: get_versioned_constants ( py_versioned_constants_overrides. into ( ) ) ;
46+ let mut versioned_constants = VersionedConstants :: get_versioned_constants ( Some (
47+ py_versioned_constants_overrides. into ( ) ,
48+ ) ) ;
4849 // The validation of a transaction is not affected by the casm hash migration.
4950 versioned_constants. enable_casm_hash_migration = false ;
5051 let block_context = BlockContext :: new (
You can’t perform that action at this time.
0 commit comments