Skip to content

Commit

Permalink
chore(blockifier): rename BouncerWeights field gas to l1gas
Browse files Browse the repository at this point in the history
  • Loading branch information
avivg-starkware committed Dec 9, 2024
1 parent cbd8129 commit ac83627
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 26 deletions.
4 changes: 2 additions & 2 deletions config/sequencer/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
"privacy": "Public",
"value": 156250
},
"batcher_config.block_builder_config.bouncer_config.block_max_capacity.gas": {
"description": "An upper bound on the total gas used in a block.",
"batcher_config.block_builder_config.bouncer_config.block_max_capacity.l1_gas": {
"description": "An upper bound on the total l1_gas used in a block.",
"privacy": "Public",
"value": 2500000
},
Expand Down
1 change: 0 additions & 1 deletion crates/blockifier/src/abi/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ pub const CONSUMED_MSG_TO_L2_ENCODED_DATA_SIZE: usize =
(L1_TO_L2_MSG_HEADER_SIZE + 1) - CONSUMED_MSG_TO_L2_N_TOPICS;

// Transaction resource names.
// TODO(Amos, 1/10/2024): Rename to l1_gas_weight.
pub const L1_GAS_USAGE: &str = "gas_weight";
pub const L2_GAS_USAGE: &str = "l2_gas_weight";
pub const BLOB_GAS_USAGE: &str = "l1_blob_gas_usage";
Expand Down
24 changes: 12 additions & 12 deletions crates/blockifier/src/bouncer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl SerializeConfig for BouncerConfig {
/// Represents the execution resources counted throughout block creation.
pub struct BouncerWeights {
pub builtin_count: BuiltinCount,
pub gas: usize,
pub l1_gas: usize,
pub message_segment_length: usize,
pub n_events: usize,
pub n_steps: usize,
Expand All @@ -103,7 +103,7 @@ pub struct BouncerWeights {
impl BouncerWeights {
impl_checked_sub!(
builtin_count,
gas,
l1_gas,
message_segment_length,
n_events,
n_steps,
Expand All @@ -116,7 +116,7 @@ impl BouncerWeights {

pub fn max() -> Self {
Self {
gas: usize::MAX,
l1_gas: usize::MAX,
n_steps: usize::MAX,
message_segment_length: usize::MAX,
state_diff_size: usize::MAX,
Expand All @@ -129,7 +129,7 @@ impl BouncerWeights {
Self {
n_events: 0,
builtin_count: BuiltinCount::empty(),
gas: 0,
l1_gas: 0,
message_segment_length: 0,
n_steps: 0,
state_diff_size: 0,
Expand All @@ -141,7 +141,7 @@ impl Default for BouncerWeights {
// TODO: update the default values once the actual values are known.
fn default() -> Self {
Self {
gas: 2500000,
l1_gas: 2500000,
n_steps: 2500000,
message_segment_length: 3700,
n_events: 5000,
Expand All @@ -155,9 +155,9 @@ impl SerializeConfig for BouncerWeights {
fn dump(&self) -> BTreeMap<ParamPath, SerializedParam> {
let mut dump = append_sub_config_name(self.builtin_count.dump(), "builtin_count");
dump.append(&mut BTreeMap::from([ser_param(
"gas",
&self.gas,
"An upper bound on the total gas used in a block.",
"l1_gas",
&self.l1_gas,
"An upper bound on the total l1_gas used in a block.",
ParamPrivacyInput::Public,
)]));
dump.append(&mut BTreeMap::from([ser_param(
Expand Down Expand Up @@ -192,9 +192,9 @@ impl std::fmt::Display for BouncerWeights {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"BouncerWeights {{ gas: {}, n_steps: {}, message_segment_length: {}, n_events: {}, \
"BouncerWeights {{ l1_gas: {}, n_steps: {}, message_segment_length: {}, n_events: {}, \
state_diff_size: {}, builtin_count: {} }}",
self.gas,
self.l1_gas,
self.n_steps,
self.message_segment_length,
self.n_events,
Expand Down Expand Up @@ -524,7 +524,7 @@ pub fn get_tx_weights<S: StateReader>(
state_changes_keys: &StateChangesKeys,
) -> TransactionExecutionResult<BouncerWeights> {
let message_resources = &tx_resources.starknet_resources.messages;
let message_starknet_gas = usize_from_u64(message_resources.get_starknet_gas_cost().l1_gas.0)
let message_starknet_l1gas = usize_from_u64(message_resources.get_starknet_gas_cost().l1_gas.0)
.expect("This conversion should not fail as the value is a converted usize.");
let mut additional_os_resources =
get_casm_hash_calculation_resources(state_reader, executed_class_hashes)?;
Expand All @@ -533,7 +533,7 @@ pub fn get_tx_weights<S: StateReader>(
let vm_resources = &additional_os_resources + &tx_resources.computation.vm_resources;

Ok(BouncerWeights {
gas: message_starknet_gas,
l1_gas: message_starknet_l1gas,
message_segment_length: message_resources.message_segment_length,
n_events: tx_resources.starknet_resources.archival_data.event_summary.n_events,
n_steps: vm_resources.total_n_steps(),
Expand Down
14 changes: 7 additions & 7 deletions crates/blockifier/src/bouncer_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn test_block_weights_has_room() {
range_check: 10,
range_check96: 10,
},
gas: 10,
l1_gas: 10,
message_segment_length: 10,
n_events: 10,
n_steps: 10,
Expand All @@ -57,7 +57,7 @@ fn test_block_weights_has_room() {
range_check: 10,
range_check96: 10,
},
gas: 7,
l1_gas: 7,
message_segment_length: 10,
n_steps: 0,
n_events: 2,
Expand All @@ -79,7 +79,7 @@ fn test_block_weights_has_room() {
range_check: 5,
range_check96: 5,
},
gas: 5,
l1_gas: 5,
message_segment_length: 5,
n_steps: 5,
n_events: 5,
Expand Down Expand Up @@ -114,7 +114,7 @@ fn test_block_weights_has_room() {
range_check: 10,
range_check96: 10,
},
gas: 10,
l1_gas: 10,
message_segment_length: 10,
n_steps: 10,
n_events: 10,
Expand Down Expand Up @@ -144,7 +144,7 @@ fn test_bouncer_update(#[case] initial_bouncer: Bouncer) {
range_check: 8,
range_check96: 0,
},
gas: 9,
l1_gas: 9,
message_segment_length: 10,
n_steps: 0,
n_events: 1,
Expand Down Expand Up @@ -197,7 +197,7 @@ fn test_bouncer_try_update(#[case] added_ecdsa: usize, #[case] scenario: &'stati
range_check: 20,
range_check96: 20,
},
gas: 20,
l1_gas: 20,
message_segment_length: 20,
n_steps: 20,
n_events: 20,
Expand All @@ -218,7 +218,7 @@ fn test_bouncer_try_update(#[case] added_ecdsa: usize, #[case] scenario: &'stati
range_check: 10,
range_check96: 10,
},
gas: 10,
l1_gas: 10,
message_segment_length: 10,
n_steps: 10,
n_events: 10,
Expand Down
4 changes: 2 additions & 2 deletions crates/native_blockifier/src/py_objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ fn hash_map_into_builtin_count(
fn hash_map_into_bouncer_weights(
mut data: HashMap<String, usize>,
) -> NativeBlockifierResult<BouncerWeights> {
let gas = data.remove(constants::L1_GAS_USAGE).expect("gas_weight must be present");
let l1_gas = data.remove(constants::L1_GAS_USAGE).expect("gas_weight must be present");
let n_steps = data.remove(constants::N_STEPS_RESOURCE).expect("n_steps must be present");
let message_segment_length = data
.remove(constants::MESSAGE_SEGMENT_LENGTH)
Expand All @@ -126,7 +126,7 @@ fn hash_map_into_bouncer_weights(
data.remove(constants::STATE_DIFF_SIZE).expect("state_diff_size must be present");
let n_events = data.remove(constants::N_EVENTS).expect("n_events must be present");
Ok(BouncerWeights {
gas,
l1_gas,
n_steps,
message_segment_length,
state_diff_size,
Expand Down
2 changes: 1 addition & 1 deletion crates/starknet_batcher/src/block_builder_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn block_execution_artifacts(
execution_infos,
commitment_state_diff: Default::default(),
visited_segments_mapping: Default::default(),
bouncer_weights: BouncerWeights { gas: 100, ..BouncerWeights::empty() },
bouncer_weights: BouncerWeights { l1_gas: 100, ..BouncerWeights::empty() },
}
}

Expand Down

Large diffs are not rendered by default.

0 comments on commit ac83627

Please sign in to comment.