Skip to content

Commit 3b2258e

Browse files
starknet_os: resources test - l1 handler
1 parent ff4a53a commit 3b2258e

4 files changed

Lines changed: 41 additions & 5 deletions

File tree

crates/blockifier/resources/blockifier_versioned_constants_0_14_4.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@
547547
},
548548
"L1Handler": {
549549
"constant": {
550-
"n_steps": 1315,
550+
"n_steps": 1329,
551551
"n_memory_holes": 0,
552552
"builtin_instance_counter": {
553553
"range_check_builtin": 19,

crates/blockifier/resources/versioned_constants_diff_regression/0.14.3_0.14.4.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@
3131
~ /os_resources/execute_txs_inner/InvokeFunction/constant/builtin_instance_counter/poseidon_builtin: 11
3232
~ /os_resources/execute_txs_inner/InvokeFunction/constant/builtin_instance_counter/range_check_builtin: 110
3333
~ /os_resources/execute_txs_inner/InvokeFunction/constant/n_steps: 4779
34+
~ /os_resources/execute_txs_inner/L1Handler/constant/n_steps: 1329

crates/blockifier/src/transaction/transactions_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2850,7 +2850,7 @@ fn test_l1_handler(#[values(false, true)] use_kzg_da: bool) {
28502850
160,
28512851
),
28522852
l2_gas: GasAmount(
2853-
651775,
2853+
653175,
28542854
),
28552855
}
28562856
"#]]
@@ -2864,7 +2864,7 @@ fn test_l1_handler(#[values(false, true)] use_kzg_da: bool) {
28642864
0,
28652865
),
28662866
l2_gas: GasAmount(
2867-
600875,
2867+
602275,
28682868
),
28692869
}
28702870
"#]]

crates/starknet_os_flow_tests/src/os_resources_test.rs

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,15 +509,15 @@ async fn test_execute_txs_inner_resources() {
509509
let version = StarknetVersion::LATEST;
510510
let mut raw_vc: RawVersionedConstants =
511511
serde_json::from_str(VersionedConstants::json_str(&version).unwrap()).unwrap();
512-
// TODO(Dori): L1Handler.
513-
const N_TXS: usize = 5;
512+
const N_TXS: usize = 7;
514513

515514
// For linear factor measurements, it's not enough to just add one more calldata element; the
516515
// increase is not the same per element. The linear scale is on average.
517516
const INVOKE_SCALING_FACTOR: usize = 2;
518517
const DEPLOY_SCALING_FACTOR: usize = 2;
519518
const INVOKE_EXTRA_ARGS: usize = 10;
520519
const DEPLOY_EXTRA_ARGS: usize = 10;
520+
const L1_HANDLER_EXTRA_ARGS: usize = 10;
521521

522522
let OsResourcesTestSetup {
523523
stable_contract_address,
@@ -605,6 +605,28 @@ async fn test_execute_txs_inner_resources() {
605605
test_builder.add_deploy_account_tx(deploy_tx_first);
606606
test_builder.add_deploy_account_tx(deploy_tx_second);
607607

608+
// L1 handler.
609+
test_builder.add_l1_handler(
610+
stable_contract_address,
611+
"l1_handler",
612+
// From address, extra args length.
613+
calldata![Felt::from(100), Felt::ZERO],
614+
None,
615+
);
616+
test_builder.add_l1_handler(
617+
stable_contract_address,
618+
"l1_handler",
619+
// From address, extra args.
620+
Calldata(Arc::new(
621+
[
622+
vec![Felt::from(100), Felt::from(L1_HANDLER_EXTRA_ARGS)],
623+
vec![Felt::ZERO; L1_HANDLER_EXTRA_ARGS],
624+
]
625+
.concat(),
626+
)),
627+
None,
628+
);
629+
608630
// Execute the business logic and extract the business logic resources for each tx.
609631
let test_runner = test_builder.build().await;
610632
let business_logic_resources: [ExecutionResources; N_TXS] = test_runner
@@ -643,6 +665,8 @@ async fn test_execute_txs_inner_resources() {
643665
declare_constant,
644666
deploy_first,
645667
deploy_second,
668+
l1_handler_first,
669+
l1_handler_second,
646670
]: [ExecutionResources; N_TXS] = test_output
647671
.runner_output
648672
.txs_trace
@@ -669,6 +693,10 @@ async fn test_execute_txs_inner_resources() {
669693
let deploy_linear_factor = (&(&deploy_second - &deploy_first).filter_unused_builtins()
670694
* DEPLOY_SCALING_FACTOR)
671695
.div_ceil(DEPLOY_EXTRA_ARGS);
696+
// L1 handler linear factor is unscaled.
697+
let l1_handler_linear_factor = (&l1_handler_second - &l1_handler_first)
698+
.filter_unused_builtins()
699+
.div_ceil(L1_HANDLER_EXTRA_ARGS);
672700
raw_vc.os_resources.execute_txs_inner.extend([
673701
(
674702
TransactionType::InvokeFunction,
@@ -691,6 +719,13 @@ async fn test_execute_txs_inner_resources() {
691719
}),
692720
}),
693721
),
722+
(
723+
TransactionType::L1Handler,
724+
VariableResourceParams::WithFactor(ResourcesParams {
725+
constant: (&l1_handler_first - &l1_handler_linear_factor).filter_unused_builtins(),
726+
calldata_factor: VariableCallDataFactor::Unscaled(l1_handler_linear_factor),
727+
}),
728+
),
694729
]);
695730

696731
// Verify computation.

0 commit comments

Comments
 (0)