Skip to main content

Crate hopper_native

Crate hopper_native 

Source
Expand description

Hopper Native – sovereign raw backend for Solana.

Direct syscall-native runtime layer purpose-built for zero-copy state frameworks. A sovereign substrate with genuinely novel features no other framework provides:

  • Alignment-safe wire types: LeU64, LeU32, LeBool etc. – alignment-1 types with checked arithmetic by default, explicit endianness, const constructors. The foundation for safe zero-copy structs. (wire)
  • Verified CPI: LamportSnapshot, DataFingerprint – snapshot state before CPI, verify post-conditions after. First framework to provide substrate-level CPI result verification. (verify)
  • Cross-program lenses: read_address(), read_le_u64() – read specific fields from foreign program accounts by byte offset without importing their types at compile time. (lens)
  • Instruction introspection: is_cpi(), require_top_level(), require_ed25519_instruction() – CPI guard and precompile signature verification patterns. (introspect)
  • SVM-optimized memory: memcpy, memset, memcmp – dispatch to the VM’s JIT-compiled intrinsics instead of Rust’s libc. (mem)
  • Lazy account parsing: LazyContext – dispatch on instruction data before touching any accounts, parse only what you need. (lazy)
  • Compile-time capability types: SignerView, WritableView, MutableView, OwnedView – prove account roles in the type system with zero runtime cost after boundary validation. (capability)
  • Zero-copy struct projection: project::<T>() with bounds, alignment, and discriminator checks in one operation. (project)
  • CU budget tracking: CuBudget snapshots and cu_trace! macro for structured profiling. (budget)
  • Hash syscall wrappers: sha256, keccak256 – zero-alloc multi-part hashing via direct syscalls. (hash)
  • Typed CPI return data: invoke_and_read::<T>() – CPI + deserialization in one step. (return_data)
  • Chainable validation: account.check_signer()?.check_writable()? – Steel-inspired fluent validation, improved and built in. (account_view)
  • Packed flags: account.flags(), account.expect_flags(SIGNER|WRITABLE) – check multiple account properties in a single comparison. (account_view)
  • Full sysvar access: Clock, Rent, EpochSchedule with computed helpers. (sysvar)
  • Batch operations: close_and_transfer, realloc_checked, require_account_type with proper atomicity. (batch)

no_std, no_alloc, zero external runtime dependencies.

Re-exports§

pub use account_view::AccountView;
pub use address::Address;
pub use borrow::Ref;
pub use borrow::RefMut;
pub use error::ProgramError;
pub use pod::Pod;
pub use raw_account::RuntimeAccount;
pub use budget::CuBudget;
pub use capability::ExecutableView;
pub use capability::MutableView;
pub use capability::OwnedView;
pub use capability::ReadonlyView;
pub use capability::SignerView;
pub use capability::WritableView;
pub use lazy::LazyContext;
pub use pda::verify_pda_strict;
pub use pda::find_bump_for_address;
pub use pda::read_bump_from_account;
pub use pda::verify_pda_from_stored_bump;
pub use return_data::ReturnData;
pub use verify::BalanceSnapshot;
pub use verify::DataFingerprint;
pub use verify::LamportSnapshot;
pub use wire::LeBool;
pub use wire::LeI16;
pub use wire::LeI32;
pub use wire::LeI64;
pub use wire::LeU128;
pub use wire::LeU16;
pub use wire::LeU32;
pub use wire::LeU64;
pub use instruction::CpiAccount;
pub use instruction::InstructionAccount;
pub use instruction::InstructionView;
pub use instruction::Seed;
pub use instruction::Signer;

Modules§

account_view
RuntimeAccount memory layout and AccountView zero-copy wrapper.
address
Solana address type – 32-byte public key.
batch
Batch account operations.
borrow
Deterministic borrow guards for account data.
budget
Compute-unit budget tracking and instrumentation.
capability
Compile-time account capability types.
cpi
Cross-program invocation via sol_invoke_signed_c.
entrypoint
Program entrypoint ownership for Hopper Native.
error
Program error type for Solana on-chain programs.
expert
Expert optimized path for Hopper Native.
hash
Cryptographic hash functions via Solana syscalls.
instruction
CPI instruction types: InstructionView, InstructionAccount, Seed, Signer.
introspect
Instruction introspection – stack height and sibling instruction access.
lazy
Lazy account parser – on-demand account deserialization.
lens
Cross-program account lenses – read foreign fields by offset.
log
Zero-allocation logging via Solana syscalls.
mem
SVM-optimized memory operations.
pda
PDA (Program Derived Address) helpers.
pod
Substrate-level Pod marker.
raw
Raw escape hatch for Hopper Native.
raw_account
Raw account header for the Solana loader input buffer.
raw_input
Raw loader input parsing for Hopper Native.
return_data
CPI return data retrieval and typed deserialization.
safe
Safe default path for Hopper Native.
syscalls
Raw Solana syscall declarations.
system
System program CPI instructions.
sysvar
Sysvar access via direct syscalls.
token
SPL Token program CPI instructions.
verify
Verified CPI – pre/post state assertions around cross-program invocations.
wire
Alignment-safe wire types for zero-copy account data.

Macros§

address
Compile-time base58 address literal.
cu_measure
Run a closure and log the CU consumed by it (feature-gated).
cu_trace
Structured CU tracing macro for profiling.
fast_entrypoint
Backward-compatible alias for hopper_fast_entrypoint!.
hopper_fast_entrypoint
Declare a fast two-argument Hopper Native program entrypoint.
hopper_lazy_entrypoint
Declare the canonical lazy program entrypoint that defers account parsing.
hopper_program_entrypoint
Declare the canonical Hopper Native program entrypoint.
lazy_entrypoint
Backward-compatible alias for hopper_lazy_entrypoint!.
msg
Convenience macro for logging. Equivalent to hopper_native::log::log(msg).
no_allocator
Set up a no-op global allocator that aborts on allocation.
nostd_panic_handler
Default no_std panic handler that aborts immediately.
program_entrypoint
Backward-compatible alias for hopper_program_entrypoint!.
seeds
Convenience macro for building an array of Seed from expressions.

Constants§

MAX_PERMITTED_DATA_INCREASE
Maximum permitted data increase during realloc (10 KiB).
MAX_TX_ACCOUNTS
Maximum number of accounts in a single transaction.
NOT_BORROWED
Borrow state value indicating the account is not currently borrowed.
SUCCESS
Success return code for the BPF entrypoint.

Traits§

Projectable
Marker trait for types that can be safely projected from raw account data.

Type Aliases§

ProgramResult
Result type for Solana program instructions.