Skip to content

Commit 2c6f87c

Browse files
apollo_integration_tests: add txs with proof
1 parent cf2b313 commit 2c6f87c

File tree

5 files changed

+73
-7
lines changed

5 files changed

+73
-7
lines changed

crates/apollo_integration_tests/src/integration_test_manager.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,13 +623,25 @@ impl IntegrationTestManager {
623623
n_invoke_txs: usize,
624624
n_l1_handler_txs: usize,
625625
wait_for_block: BlockNumber,
626+
) {
627+
self.send_txs_and_verify_with_proofs(n_invoke_txs, 0, n_l1_handler_txs, wait_for_block)
628+
.await;
629+
}
630+
631+
#[instrument(skip(self))]
632+
pub async fn send_txs_and_verify_with_proofs(
633+
&mut self,
634+
n_invoke_txs: usize,
635+
n_invoke_txs_with_proof: usize,
636+
n_l1_handler_txs: usize,
637+
wait_for_block: BlockNumber,
626638
) {
627639
info!(
628-
"Sending {} invoke + {} l1handler txs and waiting for block {}.",
629-
n_invoke_txs, n_l1_handler_txs, wait_for_block
640+
"Sending {} invoke + {} invoke with proof + {} l1handler txs and waiting for block {}.",
641+
n_invoke_txs, n_invoke_txs_with_proof, n_l1_handler_txs, wait_for_block
630642
);
631643
self.test_and_verify(
632-
ConsensusTxs { n_invoke_txs, n_l1_handler_txs },
644+
ConsensusTxs { n_invoke_txs, n_invoke_txs_with_proof, n_l1_handler_txs },
633645
DEFAULT_SENDER_ACCOUNT,
634646
wait_for_block,
635647
)

crates/apollo_integration_tests/src/sequencer_simulator_utils.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ impl SequencerSimulator {
102102
self.send_txs(
103103
tx_generator,
104104
&ConsensusTxs {
105-
n_invoke_txs: N_TXS,
105+
n_invoke_txs: N_TXS / 2,
106+
n_invoke_txs_with_proof: N_TXS / 2,
106107
// TODO(Arni): Add non-zero value.
107108
n_l1_handler_txs: 0,
108109
},

crates/apollo_integration_tests/src/utils.rs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ use starknet_api::block::BlockNumber;
7575
use starknet_api::core::{ChainId, ContractAddress};
7676
use starknet_api::execution_resources::GasAmount;
7777
use starknet_api::rpc_transaction::RpcTransaction;
78-
use starknet_api::transaction::fields::ContractAddressSalt;
78+
use starknet_api::transaction::fields::{ContractAddressSalt, Proof, ProofFacts};
7979
use starknet_api::transaction::{L1HandlerTransaction, TransactionHash, TransactionHasher};
8080
use starknet_types_core::felt::Felt;
8181
use tokio::task::JoinHandle;
@@ -110,6 +110,7 @@ pub trait TestScenario {
110110

111111
pub struct ConsensusTxs {
112112
pub n_invoke_txs: usize,
113+
pub n_invoke_txs_with_proof: usize,
113114
pub n_l1_handler_txs: usize,
114115
}
115116

@@ -120,14 +121,20 @@ impl TestScenario for ConsensusTxs {
120121
account_id: AccountId,
121122
) -> (Vec<RpcTransaction>, Vec<L1HandlerTransaction>) {
122123
const SHOULD_REVERT: bool = false;
124+
let mut invoke_txs = create_invoke_txs(tx_generator, account_id, self.n_invoke_txs);
125+
invoke_txs.extend(create_invoke_txs_with_proof(
126+
tx_generator,
127+
account_id,
128+
self.n_invoke_txs_with_proof,
129+
));
123130
(
124-
create_invoke_txs(tx_generator, account_id, self.n_invoke_txs),
131+
invoke_txs,
125132
create_l1_to_l2_messages_args(tx_generator, self.n_l1_handler_txs, SHOULD_REVERT),
126133
)
127134
}
128135

129136
fn n_txs(&self) -> usize {
130-
self.n_invoke_txs + self.n_l1_handler_txs
137+
self.n_invoke_txs + self.n_invoke_txs_with_proof + self.n_l1_handler_txs
131138
}
132139
}
133140

@@ -527,6 +534,23 @@ pub fn create_invoke_txs(
527534
.collect()
528535
}
529536

537+
pub fn create_invoke_txs_with_proof(
538+
tx_generator: &mut MultiAccountTransactionGenerator,
539+
account_id: AccountId,
540+
n_txs: usize,
541+
) -> Vec<RpcTransaction> {
542+
(0..n_txs)
543+
.map(|_| {
544+
tx_generator.account_with_id_mut(account_id).generate_trivial_rpc_invoke_tx_with_proof(
545+
1,
546+
// TODO(Avi): use valid proof facts and proof.
547+
ProofFacts::snos_proof_facts_for_testing(),
548+
Proof::proof_for_testing(),
549+
)
550+
})
551+
.collect()
552+
}
553+
530554
pub fn create_l1_to_l2_messages_args(
531555
tx_generator: &mut MultiAccountTransactionGenerator,
532556
n_txs: usize,
@@ -622,6 +646,7 @@ pub fn create_gateway_config(
622646
validate_resource_bounds: validate_non_zero_resource_bounds,
623647
max_calldata_length: 19,
624648
max_signature_length: 2,
649+
allow_client_side_proving: true,
625650
..Default::default()
626651
};
627652
let stateful_tx_validator_config = StatefulTransactionValidatorConfig {

crates/mempool_test_utils/src/starknet_api_test_utils.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,24 @@ impl AccountTransactionGenerator {
403403
rpc_invoke_tx(self.build_invoke_tx_args().tip(Tip(tip)).calldata(calldata))
404404
}
405405

406+
/// Generates a trivial invoke transaction with proof facts and proof for client-side proving.
407+
pub fn generate_trivial_rpc_invoke_tx_with_proof(
408+
&mut self,
409+
tip: u64,
410+
proof_facts: ProofFacts,
411+
proof: Proof,
412+
) -> RpcTransaction {
413+
let test_contract = FeatureContract::TestContract(self.account.cairo_version());
414+
let calldata = create_trivial_calldata(test_contract.get_instance_address(0));
415+
rpc_invoke_tx(
416+
self.build_invoke_tx_args()
417+
.tip(Tip(tip))
418+
.calldata(calldata)
419+
.proof_facts(proof_facts)
420+
.proof(proof),
421+
)
422+
}
423+
406424
fn generate_nested_call_invoke_tx(
407425
&mut self,
408426
outer_test_contract: &FeatureContract,

crates/starknet_api/src/test_utils/invoke.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,14 @@ impl InvokeTxArgs {
227227
self.nonce = nonce;
228228
self
229229
}
230+
231+
pub fn proof_facts(mut self, proof_facts: ProofFacts) -> Self {
232+
self.proof_facts = proof_facts;
233+
self
234+
}
235+
236+
pub fn proof(mut self, proof: Proof) -> Self {
237+
self.proof = proof;
238+
self
239+
}
230240
}

0 commit comments

Comments
 (0)