Skip to main content

rialo_types/
lib.rs

1// Copyright (c) Subzero Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4//! This crate contains basic types used by Rialo network.
5//! When a type is referenced by multiple crates, it is a
6//! good idea to have it in crate for simpler dependency management.
7//!
8//! This crate now includes oracle-specific types with TEE attestation support.
9
10/// Transaction validity window in milliseconds.
11///
12/// A transaction is valid from its `valid_from` timestamp until `valid_from + TRANSACTION_VALIDITY_WINDOW_SECS`.
13/// This value is used by both the consensus layer (to filter invalid transactions before proposal)
14/// and the execution layer (to reject transactions during processing).
15///
16/// The value of 120 seconds (2 minutes) provides a reasonable window for:
17/// - Client clock drift tolerance
18/// - Network propagation delays
19/// - Transaction retry attempts
20pub const TRANSACTION_VALIDITY_WINDOW_MS: u64 = 120 * 1000;
21
22// Admin transaction types (only available in non-pdk builds)
23#[cfg(feature = "non-pdk")]
24pub mod admin;
25
26// Consensus cryptographic types (only available in non-pdk builds)
27#[cfg(feature = "non-pdk")]
28pub mod consensus_crypto;
29
30// Core cryptographic types
31pub mod crypto;
32
33pub mod headers;
34pub mod http_filter;
35#[cfg(test)]
36mod http_filter_tests;
37#[cfg(feature = "non-pdk")]
38pub mod multiaddr;
39pub mod nonce;
40#[cfg(test)]
41mod nonce_tests;
42mod prelude;
43pub mod shared_rpc_types;
44pub mod transaction_execution_results;
45
46// Oracle-specific modules
47pub mod attestation;
48pub mod duties;
49pub mod duty_config;
50pub mod error;
51pub mod modified_entries;
52pub mod oracle;
53pub mod output;
54pub mod tee_types;
55#[cfg(test)]
56mod tests;
57pub mod websocket;
58
59// Re-export oracle types
60// Re-export admin types (only available in non-pdk builds)
61#[cfg(feature = "non-pdk")]
62pub use admin::{
63    AdminTransaction, Blake3Hash, EpochChangeConfig, EpochConsensusConfig, EpochIdentifier,
64    HandoverCertificate, ValidatorInfo, ValidatorReadyMessage, BLAKE3_HASH_SIZE,
65    BLS12381_PUBLIC_KEY_SIZE, ED25519_PUBLIC_KEY_SIZE, READY_MESSAGE_SIGNING_SIZE,
66};
67// Re-export consensus crypto types (only available in non-pdk builds)
68#[cfg(feature = "non-pdk")]
69pub use attestation::{ed25519_keypair_to_pubkey_slice, ed25519_signature_to_slice};
70pub use attestation::{
71    AttestationReport, AttestationReportInner, VerificationError, VerifiedAttestation,
72};
73#[cfg(feature = "non-pdk")]
74pub use consensus_crypto::{
75    AuthorityPublicKey, NetworkKeyPair, NetworkPrivateKey, NetworkPublicKey, ProtocolKeyPair,
76    ProtocolKeySignature, ProtocolPublicKey,
77};
78// Re-export crypto types
79pub use crypto::{PublicKey, TeeUserData, TEE_USER_DATA_SIZE, X25519_KEY_SIZE};
80pub use duties::{AuthorityKeyBytes, OracleDutiesMap, OracleDutiesMapKey, OracleDutiesMapValue};
81pub use duty_config::*;
82pub use error::*;
83pub use modified_entries::*;
84// Re-export multiaddr types
85#[cfg(feature = "non-pdk")]
86pub use multiaddr::{Multiaddr, Protocol};
87pub use oracle::*;
88pub use output::*;
89/// Re-export for convenience
90pub use prelude::*;
91pub use tee_types::{
92    parse_evidence, AttestationEvidence, AwsSevSnpEvidenceData, AzureSevSnpEvidenceData,
93    SevSnpEvidenceData, TeeEvidenceError, TeeType,
94};
95
96/// A wrapper enum to distinguish different types of messages processed in consensus.
97#[cfg(feature = "non-pdk")]
98#[derive(serde::Deserialize, serde::Serialize)]
99pub enum ConsensusMessage {
100    OracleUpdateResult(Box<OracleUpdateResult>),
101    VersionedTransaction(rialo_s_sdk::transaction::VersionedTransaction),
102    /// Admin transactions for privileged operations like epoch changes.
103    AdminTransaction(Box<AdminTransaction>),
104}