Skip to main content

Module check

Module check 

Source
Expand description

Multi-tier validation system.

Hopper supports five validation levels:

  1. Account-local: owner, signer, writable, size, discriminator, layout_id
  2. Cross-account: vault.mint == mint.address(), authority matches
  3. State-transition: status enum transitions, balance bounds
  4. CPI composition: post-CPI invariants, no-CPI guards
  5. Post-mutation: balance conservation, solvency invariants (via PostMutationValidator)

Validation can be composed with named groups (ValidationGroup), instruction-specific rule packs (TransitionRulePack), and multi-group bundles (ValidationBundle).

Modules§

fast
Batched u32 header validation using a single-compare optimization.
graph
Composable Validation Pipeline.
guards
Security guard packs – safe-by-default exploit prevention.
modifier
Modifier-style composable account wrappers.
trust
Foreign-account trust profiles.

Structs§

InstructionAccountMeta
Account meta decoded from an Instructions sysvar entry.
InstructionsSysvar
Typed borrowed view over the Instructions sysvar account data.
IntrospectedInstruction
Typed borrowed view over one instruction inside the Instructions sysvar.

Functions§

check_account
Combined account check: owner + discriminator + minimum size.
check_accounts_unique
Check that two accounts are unique (different addresses).
check_accounts_unique_3
Check that three accounts are all unique.
check_address
Check an account’s address matches an expected value.
check_discriminator
Check that the discriminator byte matches.
check_executable
Check that an account is executable (a program).
check_has_one
Check has_one: a stored address in account data matches another account’s address.
check_instruction_data_min
Check instruction data meets minimum length.
check_keys_eq
Check that two account addresses are equal.
check_lamports_gte
Check that the account has at least min lamports.
check_no_subsequent_invocation
Ensure our program is not invoked after the current instruction.
check_not_closed
Check that an account has not been closed (no close sentinel).
check_owner
Check that an account is owned by the expected program.
check_owner_multi
Check that an account is owned by one of the given program IDs.
check_program
Check that an account is a specific program: its key matches expected_program_id and it is flagged executable.
check_rent_exempt
Check that an account is rent exempt.
check_signer
Check that an account is a signer.
check_size
Check minimum data size.
check_system_program
System program check.
check_uninitialized
Check uninitialized: account data is empty.
check_writable
Check that an account is writable.
current_instruction_index
Read the current instruction index from the Instructions sysvar.
detect_flash_loan_bracket
Detect flash-loan bracket: same program called before AND after current.
find_and_verify_pda
Find a PDA and verify it matches the account, returning the bump.
instruction_count
Read the number of instructions in the current transaction.
is_zero_address
Check if a 32-byte address is all zeros (the default/system address).
keys_eq_fast
Fast 32-byte key equality check using 4x u64 comparisons.
read_program_id_at
Read the program_id of instruction at the given index.
rent_exempt_min
Rent-exempt minimum lamports for a given data size.
require_top_level
Require that the current instruction is top-level (not a CPI).
verify_pda
Verify a PDA with bump, using the cheap create_program_address path.
verify_pda_cached
Verify a PDA by reading the bump from account data at a known offset.