Skip to content

Commit 4abd5b2

Browse files
apollo_gateway: set the proof when adding a transaction (#11638)
1 parent 3082c9c commit 4abd5b2

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

crates/apollo_gateway/src/gateway.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ use starknet_api::rpc_transaction::{
3232
InternalRpcTransaction,
3333
InternalRpcTransactionWithoutTxHash,
3434
RpcDeclareTransaction,
35+
RpcInvokeTransaction,
3536
RpcTransaction,
3637
};
3738
use starknet_api::transaction::fields::TransactionSignature;
38-
use tracing::{debug, warn};
39+
use tracing::{debug, error, warn};
3940

4041
use crate::errors::{
4142
mempool_client_result_to_deprecated_gw_result,
@@ -130,6 +131,18 @@ 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 = match tx {
136+
RpcTransaction::Invoke(RpcInvokeTransaction::V3(ref tx)) => {
137+
if !tx.proof_facts.is_empty() {
138+
Some((tx.proof_facts.clone(), tx.proof.clone()))
139+
} else {
140+
None
141+
}
142+
}
143+
_ => None,
144+
};
145+
133146
if let RpcTransaction::Declare(ref declare_tx) = tx {
134147
if let Err(e) = self.check_declare_permissions(declare_tx) {
135148
metric_counters.record_add_tx_failure(&e);
@@ -155,6 +168,14 @@ impl Gateway {
155168
.await
156169
.inspect_err(|e| metric_counters.record_add_tx_failure(e))?;
157170

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

160181
let add_tx_args = AddTransactionArgsWrapper {

0 commit comments

Comments
 (0)