#[repr(C)]pub struct SealMerkleTree {
pub root: [u8; 32],
/* private fields */
}
Expand description
Seal Merkle Tree for incremental construction of historical payment roots.
This tree grows incrementally, adding each new payment merkle root as a leaf. It enables unlimited claim history while maintaining perfect security.
§Growth Pattern
The seal tree grows incrementally:
- Epoch 0: [Payment Root 0]
- Epoch 1: [Payment Root 0] + [Payment Root 1] -> Seal Root 1
- Epoch 2: [Payment Root 0] + [Payment Root 1] + [Payment Root 2] -> Seal Root 2
- …
- Epoch N: [Payment Root 0] + … + [Payment Root N] -> Seal Root N
§Security
- Each payment root is embedded in the seal tree
- Seal proofs demonstrate payment root authenticity
- Dual verification prevents all attack vectors
§🚨 CRITICAL: Chronological Ordering Requirement
PAYMENT ROOTS MUST BE PROVIDED IN CHRONOLOGICAL ORDER (EPOCH 0, 1, 2, 3…)
This is essential for:
- Deterministic seal merkle root generation
- Consistent verification between Oracle and on-chain program
- Preventing
0x10
(InvalidPaymentProof) errors
The Oracle team MUST ensure:
- Database queries return epochs in chronological order
- Payment roots are collected in epoch sequence
SealMerkleTree::from_payment_roots()
receives ordered data
Failure to maintain chronological ordering will result in:
- Different seal merkle roots between Oracle and on-chain
- Proof verification failures
- Inability to process claims
Fields§
§root: [u8; 32]
Current seal merkle root (32 bytes)
Implementations§
Source§impl SealMerkleTree
impl SealMerkleTree
Sourcepub fn from_payment_roots(payment_roots: Vec<[u8; 32]>) -> Self
pub fn from_payment_roots(payment_roots: Vec<[u8; 32]>) -> Self
Create a seal merkle tree from existing payment roots.
§Parameters
payment_roots
: Vector of historical payment merkle roots
§Returns
- Seal merkle tree with all payment roots included
§Important: Chronological Ordering
The payment roots MUST be provided in chronological order (epoch 0, 1, 2, 3…) to ensure deterministic and verifiable seal merkle roots across all systems. This ordering rule is enforced to maintain consistency between Oracle and on-chain verification.
Sourcepub fn add_payment_root(&mut self, payment_root: [u8; 32])
pub fn add_payment_root(&mut self, payment_root: [u8; 32])
Add a new payment root to the seal merkle tree.
This function incrementally grows the seal tree by adding the new payment root and rebuilding the tree structure.
§Parameters
payment_root
: New payment merkle root to add
§Returns
- Updated seal merkle tree with new payment root included
§Important: Chronological Ordering
Payment roots MUST be added in chronological order (epoch 0, 1, 2, 3…) to maintain deterministic tree structure. This method assumes the new payment root is for the next sequential epoch.
Sourcepub fn payment_root_count(&self) -> usize
pub fn payment_root_count(&self) -> usize
Sourcepub fn payment_roots(&self) -> &[[u8; 32]]
pub fn payment_roots(&self) -> &[[u8; 32]]
Sourcepub fn validate_chronological_order(&self) -> bool
pub fn validate_chronological_order(&self) -> bool
Validate that payment roots are in chronological order.
This method helps ensure the Oracle team is providing payment roots in the correct epoch sequence for deterministic tree construction.
§Returns
true
if payment roots appear to be in chronological orderfalse
if there are potential ordering issues
§Note
This is a best-effort validation since we can’t directly determine epoch numbers from payment root hashes. The Oracle team must ensure chronological ordering when calling this method.
Sourcepub fn generate_seal_proof(&self, payment_root: [u8; 32]) -> Option<SealProof>
pub fn generate_seal_proof(&self, payment_root: [u8; 32]) -> Option<SealProof>
Generate a seal proof for a specific payment root.
This function creates a proof that demonstrates a payment root is included in the current seal merkle tree.
§Parameters
payment_root
: Payment root to generate proof for
§Returns
Some(SealProof)
if payment root is foundNone
if payment root is not in the tree
Sourcepub fn generate_seal_proof_for_epoch(
&self,
epoch_index: usize,
) -> Option<SealProof>
pub fn generate_seal_proof_for_epoch( &self, epoch_index: usize, ) -> Option<SealProof>
Find and generate a seal proof for a payment root by epoch.
This is a convenience function that finds a payment root by its epoch index and generates a seal proof for it.
§Parameters
epoch_index
: Index of the epoch (0-based)
§Returns
Some(SealProof)
if epoch existsNone
if epoch index is out of bounds
Trait Implementations§
Source§impl Clone for SealMerkleTree
impl Clone for SealMerkleTree
Source§fn clone(&self) -> SealMerkleTree
fn clone(&self) -> SealMerkleTree
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SealMerkleTree
impl Debug for SealMerkleTree
Source§impl<'de> Deserialize<'de> for SealMerkleTree
impl<'de> Deserialize<'de> for SealMerkleTree
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for SealMerkleTree
impl RefUnwindSafe for SealMerkleTree
impl Send for SealMerkleTree
impl Sync for SealMerkleTree
impl Unpin for SealMerkleTree
impl UnwindSafe for SealMerkleTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more