Skip to content

Commit 3c95779

Browse files
blockifier: change gas weights of blake and pedersen (#10474)
1 parent 3f4cacd commit 3c95779

File tree

6 files changed

+22
-21
lines changed

6 files changed

+22
-21
lines changed

crates/apollo_deployments/resources/app_configs/batcher_config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"batcher_config.block_builder_config.bouncer_config.block_max_capacity.sierra_gas": 6000000000,
77
"batcher_config.block_builder_config.bouncer_config.block_max_capacity.proving_gas": 6000000000,
88
"batcher_config.block_builder_config.bouncer_config.block_max_capacity.state_diff_size": 4000,
9-
"batcher_config.block_builder_config.bouncer_config.builtin_weights.gas_costs.pedersen": 5723,
9+
"batcher_config.block_builder_config.bouncer_config.builtin_weights.gas_costs.pedersen": 4000,
1010
"batcher_config.block_builder_config.bouncer_config.builtin_weights.gas_costs.range_check": 90,
1111
"batcher_config.block_builder_config.bouncer_config.builtin_weights.gas_costs.ecdsa": 2000000,
1212
"batcher_config.block_builder_config.bouncer_config.builtin_weights.gas_costs.ecop": 857850,
@@ -16,7 +16,7 @@
1616
"batcher_config.block_builder_config.bouncer_config.builtin_weights.gas_costs.add_mod": 358,
1717
"batcher_config.block_builder_config.bouncer_config.builtin_weights.gas_costs.mul_mod": 358,
1818
"batcher_config.block_builder_config.bouncer_config.builtin_weights.gas_costs.range_check96": 179,
19-
"batcher_config.block_builder_config.bouncer_config.blake_weight": 6320,
19+
"batcher_config.block_builder_config.bouncer_config.blake_weight": 3750,
2020
"batcher_config.block_builder_config.execute_config.n_workers": 28,
2121
"batcher_config.block_builder_config.execute_config.stack_size": 62914560,
2222
"batcher_config.block_builder_config.n_concurrent_txs": 100,

crates/apollo_deployments/resources/app_configs/replacer_batcher_config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"batcher_config.block_builder_config.bouncer_config.blake_weight": 6320,
2+
"batcher_config.block_builder_config.bouncer_config.blake_weight": 3750,
33
"batcher_config.block_builder_config.bouncer_config.block_max_capacity.l1_gas": 4400000,
44
"batcher_config.block_builder_config.bouncer_config.block_max_capacity.message_segment_length": 3700,
55
"batcher_config.block_builder_config.bouncer_config.block_max_capacity.n_events": "$$$_BATCHER_CONFIG-BLOCK_BUILDER_CONFIG-BOUNCER_CONFIG-BLOCK_MAX_CAPACITY-N_EVENTS_$$$",
@@ -13,7 +13,7 @@
1313
"batcher_config.block_builder_config.bouncer_config.builtin_weights.gas_costs.ecop": 857850,
1414
"batcher_config.block_builder_config.bouncer_config.builtin_weights.gas_costs.keccak": 600000,
1515
"batcher_config.block_builder_config.bouncer_config.builtin_weights.gas_costs.mul_mod": 358,
16-
"batcher_config.block_builder_config.bouncer_config.builtin_weights.gas_costs.pedersen": 5723,
16+
"batcher_config.block_builder_config.bouncer_config.builtin_weights.gas_costs.pedersen": 4000,
1717
"batcher_config.block_builder_config.bouncer_config.builtin_weights.gas_costs.poseidon": 11450,
1818
"batcher_config.block_builder_config.bouncer_config.builtin_weights.gas_costs.range_check": 90,
1919
"batcher_config.block_builder_config.bouncer_config.builtin_weights.gas_costs.range_check96": 179,

crates/apollo_integration_tests/tests/test_many.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async fn many_txs_fill_at_least_one_block() {
1717
EndToEndFlowArgs::new(
1818
TestIdentifier::EndToEndFlowTestManyTxs,
1919
create_many_txs_scenario(),
20-
GasAmount(40000000),
20+
GasAmount(35000000),
2121
)
2222
.expecting_full_blocks(),
2323
)

crates/apollo_node/resources/config_schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"batcher_config.block_builder_config.bouncer_config.blake_weight": {
4343
"description": "blake opcode gas weight.",
4444
"privacy": "Public",
45-
"value": 6320
45+
"value": 3750
4646
},
4747
"batcher_config.block_builder_config.bouncer_config.block_max_capacity.l1_gas": {
4848
"description": "An upper bound on the total l1_gas used in a block.",
@@ -112,7 +112,7 @@
112112
"batcher_config.block_builder_config.bouncer_config.builtin_weights.gas_costs.pedersen": {
113113
"description": "Pedersen gas weight.",
114114
"privacy": "Public",
115-
"value": 5723
115+
"value": 4000
116116
},
117117
"batcher_config.block_builder_config.bouncer_config.builtin_weights.gas_costs.poseidon": {
118118
"description": "Poseidon gas weight.",

crates/blockifier/src/bouncer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl Default for BouncerConfig {
7676
Self {
7777
block_max_capacity: BouncerWeights::default(),
7878
builtin_weights: BuiltinWeights::default(),
79-
blake_weight: 6320,
79+
blake_weight: 3750,
8080
}
8181
}
8282
}
@@ -423,7 +423,7 @@ impl Default for BuiltinWeights {
423423
fn default() -> Self {
424424
Self {
425425
gas_costs: BuiltinGasCosts {
426-
pedersen: 5723,
426+
pedersen: 4000,
427427
range_check: 90,
428428
ecdsa: 2000000,
429429
ecop: 857850,

crates/blockifier/src/bouncer_test.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ fn test_bouncer_try_update_n_txs(
452452
),
453453
n_txs: 20,
454454
proving_gas: GasAmount(
455-
527266,
455+
403210,
456456
),
457457
}
458458
"#
@@ -670,8 +670,8 @@ fn test_proving_gas_minus_sierra_gas_equals_builtin_gas(
670670
add_maps(&mut tx_builtin_counters, &os_vm_resources.builtin_instance_counter);
671671
add_maps(&mut tx_builtin_counters, &additional_os_resources);
672672

673-
// Compute expected gas delta from builtin delta (Stwo - Stone).
674-
let expected_builtin_gas_delta = tx_builtin_counters
673+
// Compute expected gas delta from builtin delta (absolute difference between Stwo and Stone).
674+
let (total_stwo_gas, total_stone_gas) = tx_builtin_counters
675675
.iter()
676676
.map(|(name, count)| {
677677
let stwo_gas = block_context
@@ -690,18 +690,19 @@ fn test_proving_gas_minus_sierra_gas_equals_builtin_gas(
690690

691691
let stwo_total = stwo_gas.checked_mul(u64_from_usize(*count)).expect("overflow");
692692
let stone_total = u64_from_usize(*count).checked_mul(stone_gas).expect("overflow");
693-
694-
// This assumes that the Stone gas is always less than or equal to Stwo gas.
695-
stwo_total.checked_sub(stone_total).expect("underflow")
693+
(stwo_total, stone_total)
694+
})
695+
// Sum stwo and stone gas separately.
696+
.try_fold((0u64, 0u64), |(acc_stwo, acc_stone), (stwo, stone)| {
697+
Some((acc_stwo.checked_add(stwo)?, acc_stone.checked_add(stone)?))
696698
})
697-
// Sum the deltas.
698-
.try_fold(0u64, |acc, val| acc.checked_add(val))
699699
.expect("overflow in sum");
700+
let expected_builtin_gas_delta = total_stwo_gas.abs_diff(total_stone_gas);
700701

701702
assert_eq!(
702-
result.bouncer_weights.proving_gas.0 - result.bouncer_weights.sierra_gas.0,
703+
result.bouncer_weights.proving_gas.0.abs_diff(result.bouncer_weights.sierra_gas.0),
703704
expected_builtin_gas_delta,
704-
"Proving gas: {} - Sierra gas: {} ≠ builtins gap: {}",
705+
"|Proving gas: {} - Sierra gas: {}| ≠ builtins gap: {}",
705706
result.bouncer_weights.proving_gas.0,
706707
result.bouncer_weights.sierra_gas.0,
707708
expected_builtin_gas_delta
@@ -776,11 +777,11 @@ fn class_hash_migration_data_from_state(
776777

777778
if should_migrate {
778779
expect![[r#"
779-
89883372
780+
80595392
780781
"#]]
781782
.assert_debug_eq(&migration_sierra_gas.0);
782783
expect![[r#"
783-
218272460
784+
208984480
784785
"#]]
785786
.assert_debug_eq(&migration_proving_gas.0);
786787
} else {

0 commit comments

Comments
 (0)