Skip to content

Commit

Permalink
refactor(batcher): make versioned_constants_overrides field optional …
Browse files Browse the repository at this point in the history
…in BlockBuilderConfig
  • Loading branch information
ayeletstarkware committed Oct 28, 2024
1 parent dfc5925 commit 55bde12
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
5 changes: 5 additions & 0 deletions config/mempool/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
26 changes: 17 additions & 9 deletions crates/batcher/src/block_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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,
}
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<VersionedConstantsOverrides>,
}

pub struct BlockBuilderFactory {
Expand All @@ -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,
);

Expand Down
1 change: 0 additions & 1 deletion crates/blockifier/src/versioned_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 55bde12

Please sign in to comment.