BatchClaim

Struct BatchClaim 

Source
#[repr(C)]
pub struct BatchClaim { pub start_epoch: [u8; 8], pub end_epoch: [u8; 8], pub participant_type: u8, pub claim_type: u8, pub epoch_count: u8, pub max_batch_size: u8, pub _padding: [u8; 4], }
Expand description

BatchClaim instruction data for Dual Merkle Tree system.

This instruction allows users to claim rewards for multiple epochs in a single transaction using the Dual Merkle Tree verification system. Each epoch requires both payment and seal merkle proofs for complete security verification.

§Dual Merkle Verification for Batch Claims

For each epoch in the batch:

  1. Payment Proof: Verifies user’s activity within the epoch
  2. Seal Proof: Verifies the payment merkle root is authentic (from oracle)
  3. Dual Verification: Both proofs must pass for each epoch

§Data Structure

The instruction uses a hybrid approach supporting different claim types:

// Fixed-size struct (25 bytes)
struct BatchClaim {
    start_epoch: [u8; 8],     // 8 bytes - Start epoch for range claims
    end_epoch: [u8; 8],       // 8 bytes - End epoch for range claims
    participant_type: u8,     // 1 byte - 0 for customer, 1 for merchant
    claim_type: u8,           // 1 byte - 0=range, 1=vector, 2=date_range
    epoch_count: u8,          // 1 byte - Number of epochs for vector claims
    max_batch_size: u8,       // 1 byte - Maximum epochs to process
    _padding: [u8; 4],        // 4 bytes - Padding for alignment
}

// Variable-size additional data (appended after fixed struct)
// For vector claims: Vec<u64> of epochs
// For each epoch: payment_proof + payment_indices + payment_root + seal_proof + seal_indices + epoch_data
// Social flags array: 1 byte per epoch (0=no social, 1=has social)
// Social data array: SocialClaimData for epochs with social claims

§Claim Types

  • Range Claims (0): Claim all epochs from start_epoch to end_epoch (inclusive)
  • Vector Claims (1): Claim specific epochs listed in variable data
  • Date Range Claims (2): Convert date range to epoch range automatically

§Benefits

  • Gas Efficiency: Single transaction for multiple epochs
  • User Experience: Natural date-based interface
  • Flexibility: Support for both contiguous and non-contiguous epochs
  • Security: Each epoch validated independently with dual merkle proofs
  • Unified: Supports both payment and social rewards in single batch
  • Payment-First: All social claims require payment activity
  • Unlimited History: No storage limits for historical claims

§Historical Claims Support

For historical epoch claims, each epoch includes epoch-specific data:

  • Current Epochs: Use on-chain snapshot data for reward calculation
  • Historical Epochs: Use epoch-specific data embedded in the instruction
  • No On-Chain Storage: Historical data comes with the batch claim instruction
  • Accurate Rewards: Users get correct rewards for historical activity across all epochs

This enables the Dual Merkle Tree’s promise of unlimited claim history without requiring expensive on-chain storage of historical snapshots.

§Error Handling

  • No Activity: Skip epochs with no user activity
  • Invalid Proofs: Fail on security-critical errors (payment or seal)
  • Batch Limits: Respect max_batch_size to prevent gas limit issues
  • Pool Limits: Validate against both payment and social pool limits

Fields§

§start_epoch: [u8; 8]

Start epoch for range claims (inclusive)

§end_epoch: [u8; 8]

End epoch for range claims (inclusive)

§participant_type: u8

Participant type: 0 for customer, 1 for merchant

§claim_type: u8

Claim type: 0=range, 1=vector, 2=date_range

§epoch_count: u8

Number of epochs for vector claims

§max_batch_size: u8

Maximum epochs to process (gas limit protection)

§_padding: [u8; 4]

Padding to ensure proper alignment (4 bytes)

Implementations§

Trait Implementations§

Source§

impl Clone for BatchClaim

Source§

fn clone(&self) -> BatchClaim

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BatchClaim

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Discriminator for BatchClaim

Source§

impl Zeroable for BatchClaim

Source§

fn zeroed() -> Self

Source§

impl Copy for BatchClaim

Source§

impl Pod for BatchClaim

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> AccountDeserialize for T
where T: Discriminator + Pod,

Source§

impl<T> AccountHeaderDeserialize for T
where T: Discriminator + Pod,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<T> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
Source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> AnyBitPattern for T
where T: Pod,

Source§

impl<T> NoUninit for T
where T: Pod,