Skip to content

Commit 8ba62ff

Browse files
committed
apollo_committer_types: add patricia proofs request and response types
1 parent 8f39705 commit 8ba62ff

3 files changed

Lines changed: 43 additions & 0 deletions

File tree

crates/apollo_committer_types/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ license.workspace = true
77
description = "Type definitions and interfaces for the Apollo committer component."
88

99
[features]
10+
os_input = ["starknet_committer/os_input"]
1011
testing = ["mockall", "tokio"]
1112

1213
[dependencies]
@@ -17,6 +18,7 @@ mockall = { workspace = true, optional = true }
1718
serde.workspace = true
1819
starknet_api.workspace = true
1920
starknet_committer.workspace = true
21+
starknet-types-core = { workspace = true, features = ["serde"] }
2022
strum = { workspace = true, features = ["derive"] }
2123
thiserror.workspace = true
2224
tokio = { workspace = true, optional = true }

crates/apollo_committer_types/src/committer_types.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1+
#[cfg(feature = "os_input")]
2+
use std::collections::HashMap;
3+
14
use serde::{Deserialize, Serialize};
25
use starknet_api::block::BlockNumber;
6+
#[cfg(feature = "os_input")]
7+
use starknet_api::core::{ClassHash, ContractAddress};
38
use starknet_api::core::{GlobalRoot, StateDiffCommitment};
49
use starknet_api::state::ThinStateDiff;
10+
#[cfg(feature = "os_input")]
11+
use starknet_committer::block_committer::input::StarknetStorageKey;
12+
#[cfg(feature = "os_input")]
13+
use starknet_committer::patricia_merkle_tree::types::StarknetForestProofs;
514

615
#[derive(Clone, Debug, Serialize, Deserialize)]
716
pub struct CommitBlockRequest {
@@ -32,3 +41,21 @@ pub enum RevertBlockResponse {
3241
// Nothing to revert. A future block that has not been committed.
3342
Uncommitted,
3443
}
44+
45+
/// Commit a block and return merged Patricia witness proofs for OS input (pre- and post-commit
46+
/// paths).
47+
#[cfg(feature = "os_input")]
48+
#[derive(Clone, Debug, Serialize, Deserialize)]
49+
pub struct ReadPathsAndCommitBlockRequest {
50+
pub commit: CommitBlockRequest,
51+
pub class_hashes: Vec<ClassHash>,
52+
pub contract_addresses: Vec<ContractAddress>,
53+
pub contract_storage_keys: HashMap<ContractAddress, Vec<StarknetStorageKey>>,
54+
}
55+
56+
#[cfg(feature = "os_input")]
57+
#[derive(Clone, Serialize, Deserialize)]
58+
pub struct ReadPathsAndCommitBlockResponse {
59+
pub global_root: GlobalRoot,
60+
pub patricia_proofs: StarknetForestProofs,
61+
}

crates/apollo_committer_types/src/errors.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ pub enum CommitterError {
4848
calculated_commitment: StateDiffCommitment,
4949
height: BlockNumber,
5050
},
51+
/// Patricia trie path collection for OS input failed.
52+
#[cfg(feature = "os_input")]
53+
#[error("Failed Patricia paths collection at block {height}: {message}")]
54+
PatriciaPathsCollectionFailed { height: BlockNumber, message: String },
55+
/// Stored accessed-keys digest does not match the request (or no digest was stored).
56+
#[cfg(feature = "os_input")]
57+
#[error(
58+
"Accessed-keys digest mismatch at block {height}: expected {expected:?}, stored {stored:?}"
59+
)]
60+
AccessedKeysDigestMismatch { height: BlockNumber, stored: Option<[u8; 32]>, expected: [u8; 32] },
61+
/// Merged Patricia witness paths are missing for replay.
62+
#[cfg(feature = "os_input")]
63+
#[error("Missing Patricia paths for block {height}")]
64+
MissingPatriciaPaths { height: BlockNumber },
5165
}
5266

5367
pub type CommitterResult<T> = Result<T, CommitterError>;

0 commit comments

Comments
 (0)