Skip to content

Commit 65c175d

Browse files
apollo_gateway: set the proof when adding a transaction
1 parent b2b4448 commit 65c175d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

crates/apollo_gateway/src/gateway.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use starknet_api::rpc_transaction::{
3232
InternalRpcTransaction,
3333
InternalRpcTransactionWithoutTxHash,
3434
RpcDeclareTransaction,
35+
RpcInvokeTransaction,
3536
RpcTransaction,
3637
};
3738
use starknet_api::transaction::fields::TransactionSignature;
@@ -130,6 +131,17 @@ impl Gateway {
130131
let mut metric_counters = GatewayMetricHandle::new(&tx, &p2p_message_metadata);
131132
metric_counters.count_transaction_received();
132133

134+
// Extract proof data early for potential archiving later.
135+
let proof_data = if let RpcTransaction::Invoke(RpcInvokeTransaction::V3(ref tx)) = tx {
136+
if !tx.proof_facts.is_empty() {
137+
Some((tx.proof_facts.clone(), tx.proof.clone()))
138+
} else {
139+
None
140+
}
141+
} else {
142+
None
143+
};
144+
133145
if let RpcTransaction::Declare(ref declare_tx) = tx {
134146
if let Err(e) = self.check_declare_permissions(declare_tx) {
135147
metric_counters.record_add_tx_failure(&e);
@@ -155,6 +167,14 @@ impl Gateway {
155167
.await
156168
.inspect_err(|e| metric_counters.record_add_tx_failure(e))?;
157169

170+
if let Some((proof_facts, proof)) = proof_data {
171+
let proof_archive_writer = self.proof_archive_writer.clone();
172+
tokio::spawn(async move {
173+
if let Err(e) = proof_archive_writer.set_proof(proof_facts, proof).await {
174+
warn!("Failed to archive proof to GCS: {}", e);
175+
}
176+
});
177+
}
158178
let gateway_output = create_gateway_output(&internal_tx);
159179

160180
let add_tx_args = AddTransactionArgsWrapper {

0 commit comments

Comments
 (0)