Expand description
Batched u32 header validation using a single-compare optimization.
The SVM RuntimeAccount header packs borrow_state, is_signer,
is_writable, and executable into a 4-byte prefix. We read this as
a single u32 and compare against precomputed constants, collapsing
3-4 branch instructions into ONE comparison.
This saves ~4-8 CU per account validation on the hot path.
§Wire Layout (RuntimeAccount header, little-endian u32)
byte 0 = borrow_state (0xFF for non-duplicate)
byte 1 = is_signer (0 or 1)
byte 2 = is_writable (0 or 1)
byte 3 = executable (0 or 1)§Safety Model
The read_account_header function relies on hopper-native’s AccountView
being #[repr(C)] with its first field being a *mut u8 pointing to
the start of the RuntimeAccount in the SVM input buffer. This is
verified by hopper-native’s own compile-time assertions. If hopper-native changes
its layout, the compile-time size assertion below will fail.
This optimization is gated to target_os = "solana" only. Off-chain
code uses the safe fallback via AccountView::is_signer() etc.
Constants§
- HEADER_
AUTHORITY - Non-duplicate + writable + signer (same as SIGNER_WRITABLE, alias).
- HEADER_
EXECUTABLE - Non-duplicate + executable.
- HEADER_
NODUP - Non-duplicate, no flags.
- HEADER_
SIGNER - Non-duplicate + signer.
- HEADER_
SIGNER_ WRITABLE - Non-duplicate + signer + writable.
- HEADER_
WRITABLE - Non-duplicate + writable.
Functions§
- check_
account_ fast - Fast single-compare account validation.
- check_
authority_ fast - Validate a signer + writable account (authority) with single u32 compare.
- check_
executable_ fast - Validate an executable (program) account with single u32 compare.
- check_
signer_ fast - Validate a signer account with single u32 compare.
- check_
writable_ fast - Validate a writable account with single u32 compare.