rialo-types 0.2.0

Rialo Types
Documentation
// Copyright (c) Subzero Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//! This crate contains basic types used by Rialo network.
//! When a type is referenced by multiple crates, it is a
//! good idea to have it in crate for simpler dependency management.
//!
//! This crate now includes oracle-specific types with TEE attestation support.

/// Transaction validity window in milliseconds.
///
/// A transaction is valid from its `valid_from` timestamp until `valid_from + TRANSACTION_VALIDITY_WINDOW_SECS`.
/// This value is used by both the consensus layer (to filter invalid transactions before proposal)
/// and the execution layer (to reject transactions during processing).
///
/// The value of 120 seconds (2 minutes) provides a reasonable window for:
/// - Client clock drift tolerance
/// - Network propagation delays
/// - Transaction retry attempts
pub const TRANSACTION_VALIDITY_WINDOW_MS: u64 = 120 * 1000;

// Admin transaction types (only available in non-pdk builds)
#[cfg(feature = "non-pdk")]
pub mod admin;

// Consensus cryptographic types (only available in non-pdk builds)
#[cfg(feature = "non-pdk")]
pub mod consensus_crypto;

// Core cryptographic types
pub mod crypto;

pub mod headers;
pub mod http_filter;
#[cfg(test)]
mod http_filter_tests;
#[cfg(feature = "non-pdk")]
pub mod multiaddr;
pub mod nonce;
#[cfg(test)]
mod nonce_tests;
mod prelude;
pub mod shared_rpc_types;
pub mod transaction_execution_results;

// Oracle-specific modules
pub mod attestation;
pub mod duties;
pub mod duty_config;
pub mod error;
pub mod modified_entries;
pub mod oracle;
pub mod output;
pub mod tee_types;
#[cfg(test)]
mod tests;
pub mod websocket;

// Re-export oracle types
// Re-export admin types (only available in non-pdk builds)
#[cfg(feature = "non-pdk")]
pub use admin::{
    AdminTransaction, Blake3Hash, EpochChangeConfig, EpochConsensusConfig, EpochIdentifier,
    HandoverCertificate, ValidatorInfo, ValidatorReadyMessage, BLAKE3_HASH_SIZE,
    BLS12381_PUBLIC_KEY_SIZE, ED25519_PUBLIC_KEY_SIZE, READY_MESSAGE_SIGNING_SIZE,
};
// Re-export consensus crypto types (only available in non-pdk builds)
#[cfg(feature = "non-pdk")]
pub use attestation::{ed25519_keypair_to_pubkey_slice, ed25519_signature_to_slice};
pub use attestation::{
    AttestationReport, AttestationReportInner, VerificationError, VerifiedAttestation,
};
#[cfg(feature = "non-pdk")]
pub use consensus_crypto::{
    AuthorityPublicKey, NetworkKeyPair, NetworkPrivateKey, NetworkPublicKey, ProtocolKeyPair,
    ProtocolKeySignature, ProtocolPublicKey,
};
// Re-export crypto types
pub use crypto::{PublicKey, TeeUserData, TEE_USER_DATA_SIZE, X25519_KEY_SIZE};
pub use duties::{AuthorityKeyBytes, OracleDutiesMap, OracleDutiesMapKey, OracleDutiesMapValue};
pub use duty_config::*;
pub use error::*;
pub use modified_entries::*;
// Re-export multiaddr types
#[cfg(feature = "non-pdk")]
pub use multiaddr::{Multiaddr, Protocol};
pub use oracle::*;
pub use output::*;
/// Re-export for convenience
pub use prelude::*;
pub use tee_types::{
    parse_evidence, AttestationEvidence, AwsSevSnpEvidenceData, AzureSevSnpEvidenceData,
    SevSnpEvidenceData, TeeEvidenceError, TeeType,
};

/// A wrapper enum to distinguish different types of messages processed in consensus.
#[cfg(feature = "non-pdk")]
#[derive(serde::Deserialize, serde::Serialize)]
pub enum ConsensusMessage {
    OracleUpdateResult(Box<OracleUpdateResult>),
    VersionedTransaction(rialo_s_sdk::transaction::VersionedTransaction),
    /// Admin transactions for privileged operations like epoch changes.
    AdminTransaction(Box<AdminTransaction>),
}