Skip to content

Commit 207e94e

Browse files
apollo_gateway: create proof archive writer trait
1 parent 78b4f58 commit 207e94e

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

crates/apollo_gateway/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ blockifier_test_utils = { workspace = true, optional = true }
3939
cairo-lang-starknet-classes.workspace = true
4040
clap.workspace = true
4141
mempool_test_utils.workspace = true
42+
mockall.workspace = true
4243
num-rational.workspace = true
4344
reqwest.workspace = true
4445
serde.workspace = true

crates/apollo_gateway/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pub mod errors;
33
pub mod gateway;
44
pub mod gateway_fixed_block_state_reader;
55
pub mod metrics;
6+
pub mod proof_archive_writer;
67
pub mod rpc_objects;
78
pub mod rpc_state_reader;
89
#[cfg(test)]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
use async_trait::async_trait;
2+
#[cfg(any(feature = "testing", test))]
3+
use mockall::automock;
4+
use starknet_api::transaction::fields::{Proof, ProofFacts};
5+
use thiserror::Error;
6+
/// Trait for writing proof facts and proofs to large storage systems.
7+
/// Implementations should be thread-safe (Send + Sync).
8+
#[cfg_attr(any(feature = "testing", test), automock)]
9+
#[async_trait]
10+
pub trait ProofArchiveWriterTrait: Send + Sync {
11+
async fn set_proof(
12+
&self,
13+
proof_facts: ProofFacts,
14+
proof: Proof,
15+
) -> Result<(), ProofArchiveError>;
16+
}
17+
18+
#[derive(Debug, Error)]
19+
pub enum ProofArchiveError {
20+
#[error("Proof archive write error: {0}")]
21+
WriteError(String),
22+
}
23+
24+
#[derive(Clone, Default)]
25+
// TODO(Einat): Add GCS related fields.
26+
pub struct GcsProofArchiveWriter;
27+
28+
impl GcsProofArchiveWriter {
29+
pub fn new() -> Self {
30+
// TODO(Einat): connect to GCS client.
31+
Self
32+
}
33+
}
34+
35+
#[async_trait]
36+
impl ProofArchiveWriterTrait for GcsProofArchiveWriter {
37+
async fn set_proof(
38+
&self,
39+
_proof_facts: ProofFacts,
40+
_proof: Proof,
41+
) -> Result<(), ProofArchiveError> {
42+
// TODO(Einat): Write proof to GCS.
43+
Ok(())
44+
}
45+
}

0 commit comments

Comments
 (0)