#[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:
- Payment Proof: Verifies user’s activity within the epoch
- Seal Proof: Verifies the payment merkle root is authentic (from oracle)
- 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§
Source§impl BatchClaim
impl BatchClaim
pub fn try_from_bytes(data: &[u8]) -> Result<&Self, ProgramError>
Trait Implementations§
Source§impl Clone for BatchClaim
impl Clone for BatchClaim
Source§fn clone(&self) -> BatchClaim
fn clone(&self) -> BatchClaim
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for BatchClaim
impl Debug for BatchClaim
Source§impl Discriminator for BatchClaim
impl Discriminator for BatchClaim
fn discriminator() -> u8
impl Copy for BatchClaim
impl Pod for BatchClaim
Auto Trait Implementations§
impl Freeze for BatchClaim
impl RefUnwindSafe for BatchClaim
impl Send for BatchClaim
impl Sync for BatchClaim
impl Unpin for BatchClaim
impl UnwindSafe for BatchClaim
Blanket Implementations§
Source§impl<T> AccountDeserialize for Twhere
T: Discriminator + Pod,
impl<T> AccountDeserialize for Twhere
T: Discriminator + Pod,
fn try_from_bytes(data: &[u8]) -> Result<&T, ProgramError>
fn try_from_bytes_mut(data: &mut [u8]) -> Result<&mut T, ProgramError>
Source§impl<T> AccountHeaderDeserialize for Twhere
T: Discriminator + Pod,
impl<T> AccountHeaderDeserialize for Twhere
T: Discriminator + Pod,
fn try_header_from_bytes(data: &[u8]) -> Result<(&T, &[u8]), ProgramError>
fn try_header_from_bytes_mut( data: &mut [u8], ) -> Result<(&mut T, &mut [u8]), ProgramError>
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<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
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
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self
.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