Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/apollo_batcher/src/block_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,9 +712,9 @@ impl BlockBuilderFactory {
);
let height = block_metadata.block_info.block_number;
let block_builder_config = self.block_builder_config.clone();
let versioned_constants = VersionedConstants::get_versioned_constants(
let versioned_constants = VersionedConstants::get_versioned_constants(Some(
block_builder_config.versioned_constants_overrides,
);
));
let block_context = BlockContext::new(
block_metadata.block_info,
block_builder_config.chain_info,
Expand Down
4 changes: 2 additions & 2 deletions crates/apollo_gateway/src/stateful_transaction_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ impl StatefulTransactionValidatorFactoryTrait for StatefulTransactionValidatorFa
};

let state = CachedState::new(state_reader_and_contract_manager);
let mut versioned_constants = VersionedConstants::get_versioned_constants(
let mut versioned_constants = VersionedConstants::get_versioned_constants(Some(
self.config.versioned_constants_overrides.clone(),
);
));
// The validation of a transaction is not affected by the casm hash migration.
versioned_constants.enable_casm_hash_migration = false;

Expand Down
36 changes: 21 additions & 15 deletions crates/blockifier/src/blockifier_versioned_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,23 +437,29 @@ impl VersionedConstants {
// squashing the functions together.
/// Returns the latest versioned constants, applying the given overrides.
pub fn get_versioned_constants(
versioned_constants_overrides: VersionedConstantsOverrides,
versioned_constants_overrides: Option<VersionedConstantsOverrides>,
) -> Self {
let VersionedConstantsOverrides {
validate_max_n_steps,
max_recursion_depth,
invoke_tx_max_n_steps,
max_n_events,
} = versioned_constants_overrides;
let latest_constants = Self::latest_constants().clone();
let tx_event_limits =
EventLimits { max_n_emitted_events: max_n_events, ..latest_constants.tx_event_limits };
Self {
validate_max_n_steps,
max_recursion_depth,
invoke_tx_max_n_steps,
tx_event_limits,
..latest_constants
match versioned_constants_overrides {
None => latest_constants,
Some(VersionedConstantsOverrides {
validate_max_n_steps,
max_recursion_depth,
invoke_tx_max_n_steps,
max_n_events,
}) => {
let tx_event_limits = EventLimits {
max_n_emitted_events: max_n_events,
..latest_constants.tx_event_limits
};
Self {
validate_max_n_steps,
max_recursion_depth,
invoke_tx_max_n_steps,
tx_event_limits,
..latest_constants
}
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/blockifier/src/versioned_constants_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ fn test_versioned_constants_overrides() {
let updated_max_n_events = versioned_constants.tx_event_limits.max_n_emitted_events + 1;

// Create a versioned constants copy with overriden values.
let result = VersionedConstants::get_versioned_constants(VersionedConstantsOverrides {
let result = VersionedConstants::get_versioned_constants(Some(VersionedConstantsOverrides {
validate_max_n_steps: updated_validate_max_n_steps,
max_recursion_depth: updated_max_recursion_depth,
invoke_tx_max_n_steps: updated_invoke_tx_max_n_steps,
max_n_events: updated_max_n_events,
});
}));

// Assert the new values are used.
assert_eq!(result.invoke_tx_max_n_steps, updated_invoke_tx_max_n_steps);
Expand Down
5 changes: 3 additions & 2 deletions crates/native_blockifier/src/py_block_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ impl PyBlockExecutor {
log::debug!("Initializing Block Executor...");
let storage =
PapyrusStorage::new(target_storage_config).expect("Failed to initialize storage.");
let versioned_constants =
VersionedConstants::get_versioned_constants(py_versioned_constants_overrides.into());
let versioned_constants = VersionedConstants::get_versioned_constants(Some(
py_versioned_constants_overrides.into(),
));
log::debug!("Initialized Block Executor.");

Self {
Expand Down
5 changes: 3 additions & 2 deletions crates/native_blockifier/src/py_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ impl PyValidator {
let state = CachedState::new(state_reader);

// Create the block context.
let mut versioned_constants =
VersionedConstants::get_versioned_constants(py_versioned_constants_overrides.into());
let mut versioned_constants = VersionedConstants::get_versioned_constants(Some(
py_versioned_constants_overrides.into(),
));
// The validation of a transaction is not affected by the casm hash migration.
versioned_constants.enable_casm_hash_migration = false;
let block_context = BlockContext::new(
Expand Down
Loading