From 55bde12c6d71ff679b7e2d2aaf9f45cb83d32934 Mon Sep 17 00:00:00 2001 From: Ayelet Zilber Date: Tue, 15 Oct 2024 11:13:16 +0300 Subject: [PATCH] refactor(batcher): make versioned_constants_overrides field optional in BlockBuilderConfig --- config/mempool/default_config.json | 5 ++++ crates/batcher/src/block_builder.rs | 26 +++++++++++++------- crates/blockifier/src/versioned_constants.rs | 1 - 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/config/mempool/default_config.json b/config/mempool/default_config.json index d0186816b3..7a8685e4b6 100644 --- a/config/mempool/default_config.json +++ b/config/mempool/default_config.json @@ -119,6 +119,11 @@ "privacy": "Public", "value": true }, + "batcher_config.block_builder_config.versioned_constants_overrides.#is_none": { + "description": "Flag for an optional field.", + "privacy": "TemporaryValue", + "value": true + }, "batcher_config.block_builder_config.versioned_constants_overrides.invoke_tx_max_n_steps": { "description": "Maximum number of steps the invoke function is allowed to run.", "privacy": "Public", diff --git a/crates/batcher/src/block_builder.rs b/crates/batcher/src/block_builder.rs index 1b72bd00a6..d50c8a4183 100644 --- a/crates/batcher/src/block_builder.rs +++ b/crates/batcher/src/block_builder.rs @@ -22,7 +22,12 @@ use blockifier::versioned_constants::{VersionedConstants, VersionedConstantsOver use indexmap::IndexMap; #[cfg(test)] use mockall::automock; -use papyrus_config::dumping::{append_sub_config_name, ser_param, SerializeConfig}; +use papyrus_config::dumping::{ + append_sub_config_name, + ser_optional_sub_config, + ser_param, + SerializeConfig, +}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use papyrus_storage::StorageReader; use serde::{Deserialize, Serialize}; @@ -103,7 +108,7 @@ impl Default for BlockBuilderConfig { sequencer_address: ContractAddress::default(), use_kzg_da: true, tx_chunk_size: 100, - versioned_constants_overrides: VersionedConstantsOverrides::default(), + versioned_constants_overrides: None, } } } @@ -131,8 +136,8 @@ impl SerializeConfig for BlockBuilderConfig { "The size of the transaction chunk.", ParamPrivacyInput::Public, )])); - dump.append(&mut append_sub_config_name( - self.versioned_constants_overrides.dump(), + dump.append(&mut ser_optional_sub_config( + &self.versioned_constants_overrides, "versioned_constants_overrides", )); dump @@ -239,8 +244,7 @@ pub struct BlockBuilderConfig { pub sequencer_address: ContractAddress, pub use_kzg_da: bool, pub tx_chunk_size: usize, - // TODO(Ayelet): Make this field optional. - pub versioned_constants_overrides: VersionedConstantsOverrides, + pub versioned_constants_overrides: Option, } pub struct BlockBuilderFactory { @@ -267,12 +271,16 @@ impl BlockBuilderFactory { }, use_kzg_da: block_builder_config.use_kzg_da, }; + let versioned_constants = + if let Some(overrides) = block_builder_config.versioned_constants_overrides { + VersionedConstants::get_versioned_constants(overrides) + } else { + VersionedConstants::latest_constants().clone() + }; let block_context = BlockContext::new( next_block_info, block_builder_config.chain_info, - VersionedConstants::get_versioned_constants( - block_builder_config.versioned_constants_overrides, - ), + versioned_constants, block_builder_config.bouncer_config, ); diff --git a/crates/blockifier/src/versioned_constants.rs b/crates/blockifier/src/versioned_constants.rs index d6433df961..7e6598d975 100644 --- a/crates/blockifier/src/versioned_constants.rs +++ b/crates/blockifier/src/versioned_constants.rs @@ -832,7 +832,6 @@ pub struct VersionedConstantsOverrides { } impl Default for VersionedConstantsOverrides { - // TODO: update the default values once the actual values are known. fn default() -> Self { Self { validate_max_n_steps: 1000000,