Skip to content

Commit 27f67c6

Browse files
blockifier: add tests to get_execution_info_v3
1 parent 49416e1 commit 27f67c6

File tree

11 files changed

+11687
-11235
lines changed

11 files changed

+11687
-11235
lines changed

crates/blockifier/src/bouncer_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,11 +777,11 @@ fn class_hash_migration_data_from_state(
777777

778778
if should_migrate {
779779
expect![[r#"
780-
103123738
780+
103697877
781781
"#]]
782782
.assert_debug_eq(&migration_sierra_gas.0);
783783
expect![[r#"
784-
267987710
784+
269540840
785785
"#]]
786786
.assert_debug_eq(&migration_proving_gas.0);
787787
} else {

crates/blockifier/src/execution/syscalls/hint_processor.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,9 @@ impl<'a> SyscallHintProcessor<'a> {
462462
zero_felt.clone(), // Nonce DA mode.
463463
zero_felt.clone(), // Fee DA mode.
464464
zero_felt.clone(), // Empty segment of account deployment data (start ptr).
465-
zero_felt, // Empty segment of account deployment data (end ptr).
465+
zero_felt.clone(), // Empty segment of account deployment data (end ptr).
466+
zero_felt.clone(), // Empty segment of proof_facts (start ptr).
467+
zero_felt, // Empty segment of proof_facts (end ptr).
466468
]);
467469
}
468470
};

crates/blockifier/src/execution/syscalls/syscall_tests/get_execution_info.rs

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use starknet_api::transaction::fields::{
2222
Calldata,
2323
Fee,
2424
PaymasterData,
25-
ProofFacts,
2625
Resource,
2726
ResourceBounds,
2827
Tip,
@@ -31,7 +30,7 @@ use starknet_api::transaction::fields::{
3130
};
3231
use starknet_api::transaction::{TransactionVersion, QUERY_VERSION_BASE};
3332
use starknet_api::versioned_constants_logic::VersionedConstantsTrait;
34-
use starknet_api::{felt, nonce, tx_hash};
33+
use starknet_api::{felt, nonce, proof_facts, tx_hash};
3534
use starknet_types_core::felt::Felt;
3635
use test_case::test_case;
3736

@@ -479,8 +478,7 @@ fn test_get_execution_info(
479478
fee_data_availability_mode: DataAvailabilityMode::L1,
480479
paymaster_data: PaymasterData::default(),
481480
account_deployment_data: AccountDeploymentData::default(),
482-
// TODO(Meshi): Add proof facts.
483-
proof_facts: ProofFacts::default(),
481+
proof_facts: proof_facts![felt!(1_u16), felt!(2_u16), felt!(3_u16)],
484482
});
485483
}
486484

@@ -490,19 +488,35 @@ fn test_get_execution_info(
490488
*test_contract_address.0.key(), // Storage address.
491489
entry_point_selector.0, // Entry point selector.
492490
];
491+
492+
// Transaction V1 doesn't support proof facts.
493+
let proof_facts = if version == TransactionVersion::ONE {
494+
vec![Felt::ZERO]
495+
} else {
496+
vec![felt!(3_u16), felt!(1_u16), felt!(2_u16), felt!(3_u16)]
497+
};
498+
499+
let calldata = match test_contract {
500+
// We only changed the 'test_get_execution_info' logic in the test contract to make sure the
501+
// other tests still checks the old behavior.
502+
FeatureContract::TestContract(_) => vec![
503+
expected_block_info.to_vec(),
504+
expected_tx_info,
505+
expected_resource_bounds.into_iter().chain(expected_unsupported_fields).collect(),
506+
proof_facts,
507+
expected_call_info,
508+
],
509+
_ => vec![
510+
expected_block_info.to_vec(),
511+
expected_tx_info,
512+
expected_resource_bounds.into_iter().chain(expected_unsupported_fields).collect(),
513+
expected_call_info,
514+
],
515+
};
493516
let entry_point_call = CallEntryPoint {
494517
entry_point_selector,
495518
code_address: None,
496-
calldata: Calldata(
497-
[
498-
expected_block_info.to_vec(),
499-
expected_tx_info,
500-
expected_resource_bounds.into_iter().chain(expected_unsupported_fields).collect(),
501-
expected_call_info,
502-
]
503-
.concat()
504-
.into(),
505-
),
519+
calldata: Calldata(calldata.concat().into()),
506520
..trivial_external_entry_point_with_address(test_contract_address)
507521
};
508522
let result = entry_point_call.execute_directly_given_tx_info(

crates/blockifier/src/transaction/test_utils.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use starknet_api::transaction::fields::{
3333
Fee,
3434
GasVectorComputationMode,
3535
PaymasterData,
36+
ProofFacts,
3637
Resource,
3738
ResourceBounds,
3839
TransactionSignature,
@@ -476,6 +477,7 @@ pub struct ExpectedExecutionInfo {
476477
pub nonce_data_availability_mode: DataAvailabilityMode,
477478
pub fee_data_availability_mode: DataAvailabilityMode,
478479
pub account_deployment_data: AccountDeploymentData,
480+
pub proof_facts: ProofFacts,
479481
pub caller_address: ContractAddress,
480482
pub contract_address: ContractAddress,
481483
pub entry_point_selector: EntryPointSelector,
@@ -498,6 +500,7 @@ impl ExpectedExecutionInfo {
498500
sequencer_address: ContractAddress,
499501
resource_bounds: ValidResourceBounds,
500502
nonce: Nonce,
503+
proof_facts: ProofFacts,
501504
) -> Self {
502505
let mut version = Felt::THREE;
503506
if only_query {
@@ -515,6 +518,7 @@ impl ExpectedExecutionInfo {
515518
sequencer_address,
516519
resource_bounds,
517520
nonce,
521+
proof_facts,
518522
max_fee: Fee::default(),
519523
transaction_hash: TransactionHash::default(),
520524
paymaster_data: PaymasterData::default(),
@@ -572,12 +576,18 @@ impl ExpectedExecutionInfo {
572576
felt!(self.block_timestamp.0),
573577
**self.sequencer_address,
574578
];
579+
let mut proof_facts: Vec<Felt> = self.proof_facts.0.to_vec();
580+
581+
// For an Array in cairo function we assume the first value is the length of the field.
582+
let len: u128 = proof_facts.len().try_into().expect("proof_facts length is too large");
583+
proof_facts.insert(0, felt!(len));
575584

576585
[
577586
expected_block_info,
578587
expected_tx_info,
579588
expected_resource_bounds,
580589
expected_unsupported_fields,
590+
proof_facts,
581591
expected_call_info,
582592
]
583593
.concat()

crates/blockifier/src/transaction/transactions_test.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ use starknet_api::transaction::fields::{
5656
Calldata,
5757
Fee,
5858
GasVectorComputationMode,
59+
ProofFacts,
5960
Resource,
6061
ResourceBounds,
6162
Tip,
@@ -2647,6 +2648,7 @@ fn test_only_query_flag(
26472648
ContractAddress(felt!(TEST_SEQUENCER_ADDRESS).try_into().unwrap()),
26482649
default_all_resource_bounds,
26492650
Nonce::default(),
2651+
ProofFacts::default(),
26502652
)
26512653
.to_syscall_result();
26522654
let execute_calldata = vec![

0 commit comments

Comments
 (0)