Skip to main content

Module verify

Module verify 

Source
Expand description

Verified CPI – pre/post state assertions around cross-program invocations.

Every Solana framework fires CPI and blindly trusts the result. If the called program has a bug, state corruption propagates silently. Hopper is the first framework to provide substrate-level CPI verification.

The pattern: snapshot relevant state before CPI, invoke, then assert post-conditions. If the assertion fails, the instruction aborts before the corrupted state can be read by downstream logic.

§Usage

use hopper_native::verify::{LamportSnapshot, verify_transfer};

// Before CPI transfer:
let snap = LamportSnapshot::capture(source, destination);

// Do the CPI:
system_transfer(&source, &destination, amount)?;

// Verify the transfer actually happened correctly:
snap.verify_transfer(source, destination, amount)?;

This catches:

  • Called program transferring wrong amount
  • Called program not deducting from source
  • Called program crediting wrong destination
  • Integer overflow in lamport accounting

Structs§

BalanceSnapshot
Snapshot of a single account’s lamports for simple balance assertions.
DataFingerprint
Fast integrity check for account data using FNV-1a hash.
LamportSnapshot
Snapshot of lamport balances for two accounts before a CPI.