Skip to content

Commit ae5c0e5

Browse files
apollo_integration_tests: add txs with proof
1 parent b833391 commit ae5c0e5

File tree

9 files changed

+98
-15
lines changed

9 files changed

+98
-15
lines changed

crates/apollo_integration_tests/src/bin/sequencer_node_end_to_end_integration_tests/integration_test_positive_flow.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ use tracing::info;
88
async fn main() {
99
integration_test_setup("positive").await;
1010
const BLOCK_TO_WAIT_FOR: BlockNumber = BlockNumber(30);
11-
const N_INVOKE_TXS: usize = 50;
11+
const N_INVOKE_TXS: usize = 25;
12+
const N_INVOKE_TXS_WITH_PROOF: usize = 25;
1213
const N_L1_HANDLER_TXS: usize = 2;
1314
/// The number of consolidated local sequencers that participate in the test.
1415
const N_CONSOLIDATED_SEQUENCERS: usize = 3;
@@ -38,7 +39,12 @@ async fn main() {
3839

3940
// Run the test.
4041
integration_test_manager
41-
.send_txs_and_verify(N_INVOKE_TXS, N_L1_HANDLER_TXS, BLOCK_TO_WAIT_FOR)
42+
.send_txs_and_verify(
43+
N_INVOKE_TXS,
44+
N_INVOKE_TXS_WITH_PROOF,
45+
N_L1_HANDLER_TXS,
46+
BLOCK_TO_WAIT_FOR,
47+
)
4248
.await;
4349

4450
info!("Shutting down nodes.");

crates/apollo_integration_tests/src/bin/sequencer_node_end_to_end_integration_tests/integration_test_restart_service_multiple_nodes_flow.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ async fn main() {
1515
integration_test_setup("restart_service_multiple_nodes").await;
1616
const INITIAL_BLOCK_TO_WAIT_FOR: usize = 20;
1717
const BLOCK_TO_WAIT_FOR_INCREMENT: usize = 5;
18-
const N_INVOKE_TXS: usize = 20;
18+
const N_INVOKE_TXS: usize = 10;
19+
const N_INVOKE_TXS_WITH_PROOF: usize = 10;
1920
const N_L1_HANDLER_TXS: usize = 1;
2021
/// The number of consolidated local sequencers that participate in the test.
2122
const N_CONSOLIDATED_SEQUENCERS: usize = 0;
@@ -72,7 +73,12 @@ async fn main() {
7273
nodes."
7374
);
7475
integration_test_manager
75-
.send_txs_and_verify(N_INVOKE_TXS, N_L1_HANDLER_TXS, block_to_wait_for)
76+
.send_txs_and_verify(
77+
N_INVOKE_TXS,
78+
N_INVOKE_TXS_WITH_PROOF,
79+
N_L1_HANDLER_TXS,
80+
block_to_wait_for,
81+
)
7682
.await;
7783
}
7884

crates/apollo_integration_tests/src/bin/sequencer_node_end_to_end_integration_tests/integration_test_revert_flow.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ async fn main() {
2020
assert!(REVERT_UP_TO_AND_INCLUDING < BLOCK_TO_REVERT_FROM);
2121
assert!(BLOCK_TO_REVERT_FROM < BLOCK_TO_WAIT_FOR_AFTER_REVERT);
2222

23-
const N_INVOKE_TXS: usize = 50;
23+
const N_INVOKE_TXS: usize = 25;
24+
const N_INVOKE_TXS_WITH_PROOF: usize = 25;
2425
const N_L1_HANDLER_TXS: usize = 5;
2526
/// The number of consolidated local sequencers that participate in the test.
2627
const N_CONSOLIDATED_SEQUENCERS: usize = 5;
@@ -58,7 +59,12 @@ async fn main() {
5859

5960
info!("Sending transactions and verifying state.");
6061
integration_test_manager
61-
.send_txs_and_verify(N_INVOKE_TXS, N_L1_HANDLER_TXS, BLOCK_TO_REVERT_FROM)
62+
.send_txs_and_verify(
63+
N_INVOKE_TXS,
64+
N_INVOKE_TXS_WITH_PROOF,
65+
N_L1_HANDLER_TXS,
66+
BLOCK_TO_REVERT_FROM,
67+
)
6268
.await;
6369

6470
info!("Shutting down nodes.");
@@ -113,7 +119,12 @@ async fn main() {
113119

114120
info!("Sending transactions and verifying state.");
115121
integration_test_manager
116-
.send_txs_and_verify(N_INVOKE_TXS, N_L1_HANDLER_TXS, BLOCK_TO_WAIT_FOR_AFTER_REVERT)
122+
.send_txs_and_verify(
123+
N_INVOKE_TXS,
124+
N_INVOKE_TXS_WITH_PROOF,
125+
N_L1_HANDLER_TXS,
126+
BLOCK_TO_WAIT_FOR_AFTER_REVERT,
127+
)
117128
.await;
118129

119130
integration_test_manager.shutdown_nodes(node_indices);

crates/apollo_integration_tests/src/integration_test_manager.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,15 +621,16 @@ impl IntegrationTestManager {
621621
pub async fn send_txs_and_verify(
622622
&mut self,
623623
n_invoke_txs: usize,
624+
n_invoke_txs_with_proof: usize,
624625
n_l1_handler_txs: usize,
625626
wait_for_block: BlockNumber,
626627
) {
627628
info!(
628-
"Sending {} invoke + {} l1handler txs and waiting for block {}.",
629-
n_invoke_txs, n_l1_handler_txs, wait_for_block
629+
"Sending {} invoke + {} invoke with proof + {} l1handler txs and waiting for block {}.",
630+
n_invoke_txs, n_invoke_txs_with_proof, n_l1_handler_txs, wait_for_block
630631
);
631632
self.test_and_verify(
632-
ConsensusTxs { n_invoke_txs, n_l1_handler_txs },
633+
ConsensusTxs { n_invoke_txs, n_invoke_txs_with_proof, n_l1_handler_txs },
633634
DEFAULT_SENDER_ACCOUNT,
634635
wait_for_block,
635636
)

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: 30 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,25 @@ 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_u64..)
543+
.take(n_txs)
544+
.map(|i| {
545+
tx_generator.account_with_id_mut(account_id).generate_trivial_rpc_invoke_tx_with_proof(
546+
1,
547+
// Use unique proof facts for each transaction to ensure proper proof
548+
// storage/retrieval.
549+
ProofFacts::snos_proof_facts_for_testing_with_index(i),
550+
Proof::proof_for_testing(),
551+
)
552+
})
553+
.collect()
554+
}
555+
530556
pub fn create_l1_to_l2_messages_args(
531557
tx_generator: &mut MultiAccountTransactionGenerator,
532558
n_txs: usize,
@@ -622,6 +648,7 @@ pub fn create_gateway_config(
622648
validate_resource_bounds: validate_non_zero_resource_bounds,
623649
max_calldata_length: 19,
624650
max_signature_length: 2,
651+
allow_client_side_proving: true,
625652
..Default::default()
626653
};
627654
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.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,12 @@ impl ProofFacts {
381381
///
382382
/// See [`crate::transaction::fields::ProofFacts`].
383383
pub fn snos_proof_facts_for_testing() -> Self {
384+
Self::snos_proof_facts_for_testing_with_index(0)
385+
}
386+
pub fn snos_proof_facts_for_testing_with_index(index: u64) -> Self {
384387
let block_hash_history_start = CURRENT_BLOCK_NUMBER - BLOCK_HASH_HISTORY_RANGE;
385388
let block_number = felt!(block_hash_history_start + 2);
386-
let block_hash = block_number * felt!(100_u64);
389+
let block_hash = block_number * felt!(100_u64) + felt!(index);
387390
assert!(
388391
block_number < felt!(CURRENT_BLOCK_NUMBER)
389392
&& block_number >= felt!(block_hash_history_start),

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)