Skip to content

Commit e9193f4

Browse files
starknet_os: resources test - l1 handler
1 parent 0906746 commit e9193f4

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
@@ -30,3 +30,4 @@
3030
~ /os_resources/execute_txs_inner/InvokeFunction/constant/builtin_instance_counter/poseidon_builtin: 11
3131
~ /os_resources/execute_txs_inner/InvokeFunction/constant/builtin_instance_counter/range_check_builtin: 110
3232
~ /os_resources/execute_txs_inner/InvokeFunction/constant/n_steps: 4779
33+
~ /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
@@ -504,15 +504,15 @@ async fn test_execute_txs_inner_resources() {
504504
let version = StarknetVersion::LATEST;
505505
let mut raw_vc: RawVersionedConstants =
506506
serde_json::from_str(VersionedConstants::json_str(&version).unwrap()).unwrap();
507-
// TODO(Dori): L1Handler.
508-
const N_TXS: usize = 5;
507+
const N_TXS: usize = 7;
509508

510509
// For linear factor measurements, it's not enough to just add one more calldata element; the
511510
// increase is not the same per element. The linear scale is on average.
512511
const INVOKE_SCALING_FACTOR: usize = 2;
513512
const DEPLOY_SCALING_FACTOR: usize = 2;
514513
const INVOKE_EXTRA_ARGS: usize = 10;
515514
const DEPLOY_EXTRA_ARGS: usize = 10;
515+
const L1_HANDLER_EXTRA_ARGS: usize = 10;
516516

517517
let OsResourcesTestSetup {
518518
stable_contract_address,
@@ -600,6 +600,28 @@ async fn test_execute_txs_inner_resources() {
600600
test_builder.add_deploy_account_tx(deploy_tx_first);
601601
test_builder.add_deploy_account_tx(deploy_tx_second);
602602

603+
// L1 handler.
604+
test_builder.add_l1_handler(
605+
stable_contract_address,
606+
"l1_handler",
607+
// From address, extra args length.
608+
calldata![Felt::from(100), Felt::ZERO],
609+
None,
610+
);
611+
test_builder.add_l1_handler(
612+
stable_contract_address,
613+
"l1_handler",
614+
// From address, extra args.
615+
Calldata(Arc::new(
616+
[
617+
vec![Felt::from(100), Felt::from(L1_HANDLER_EXTRA_ARGS)],
618+
vec![Felt::ZERO; L1_HANDLER_EXTRA_ARGS],
619+
]
620+
.concat(),
621+
)),
622+
None,
623+
);
624+
603625
// Execute the business logic and extract the business logic resources for each tx.
604626
let test_runner = test_builder.build().await;
605627
let business_logic_resources: [ExecutionResources; N_TXS] = test_runner
@@ -638,6 +660,8 @@ async fn test_execute_txs_inner_resources() {
638660
declare_constant,
639661
deploy_first,
640662
deploy_second,
663+
l1_handler_first,
664+
l1_handler_second,
641665
]: [ExecutionResources; N_TXS] = test_output
642666
.runner_output
643667
.txs_trace
@@ -664,6 +688,10 @@ async fn test_execute_txs_inner_resources() {
664688
let deploy_linear_factor = (&(&deploy_second - &deploy_first).filter_unused_builtins()
665689
* DEPLOY_SCALING_FACTOR)
666690
.div_ceil(DEPLOY_EXTRA_ARGS);
691+
// L1 handler linear factor is unscaled.
692+
let l1_handler_linear_factor = (&l1_handler_second - &l1_handler_first)
693+
.filter_unused_builtins()
694+
.div_ceil(L1_HANDLER_EXTRA_ARGS);
667695
raw_vc.os_resources.execute_txs_inner.extend([
668696
(
669697
TransactionType::InvokeFunction,
@@ -686,6 +714,13 @@ async fn test_execute_txs_inner_resources() {
686714
}),
687715
}),
688716
),
717+
(
718+
TransactionType::L1Handler,
719+
VariableResourceParams::WithFactor(ResourcesParams {
720+
constant: (&l1_handler_first - &l1_handler_linear_factor).filter_unused_builtins(),
721+
calldata_factor: VariableCallDataFactor::Unscaled(l1_handler_linear_factor),
722+
}),
723+
),
689724
]);
690725

691726
// Verify computation.

0 commit comments

Comments
 (0)