/ crates / adnet-ipc / src / lib.rs
lib.rs
 1  // Copyright (c) 2025 ALPHA/DELTA Network
 2  // This file is part of the adnet-ipc crate.
 3  
 4  //! # ADNet IPC - Internal Cross-Chain Communication
 5  //!
 6  //! This crate provides the IPC (Inter-Process Communication) infrastructure
 7  //! for cross-chain attestation between ALPHA and DELTA runtimes within the
 8  //! unified `adnet` binary.
 9  //!
10  //! ## Key Design Points
11  //!
12  //! - **NOT an external bridge**: This is internal IPC using in-memory channels
13  //! - **Latency**: <1ms for cross-chain messages
14  //! - **Verification**: Merkle proofs only (no additional validator signatures)
15  //! - **Message types**: Lock/Unlock attestations, State roots, Governance outcomes
16  
17  pub mod channels;
18  pub mod messages;
19  pub mod attestation;
20  pub mod queue;
21  
22  pub use channels::*;
23  pub use messages::*;
24  pub use attestation::*;
25  
26  use thiserror::Error;
27  
28  /// Errors that can occur in IPC operations.
29  #[derive(Error, Debug)]
30  pub enum IpcError {
31      #[error("Channel send failed: {0}")]
32      SendFailed(String),
33  
34      #[error("Channel receive failed: {0}")]
35      ReceiveFailed(String),
36  
37      #[error("Invalid attestation: {0}")]
38      InvalidAttestation(String),
39  
40      #[error("Merkle proof verification failed")]
41      MerkleVerificationFailed,
42  
43      #[error("State root mismatch")]
44      StateRootMismatch,
45  
46      #[error("Attestation already processed: {0}")]
47      AlreadyProcessed(String),
48  
49      #[error("Finality not reached: need {required} blocks, have {current}")]
50      FinalityNotReached { required: u64, current: u64 },
51  }
52  
53  /// Result type for IPC operations.
54  pub type IpcResult<T> = Result<T, IpcError>;