Skip to main content

Crate hopper_runtime

Crate hopper_runtime 

Source
Expand description

Hopper Runtime – canonical semantic runtime surface.

Hopper Runtime owns the public rules, validation, typed loading, CPI semantics, and execution context that authored Hopper code targets. Hopper Native owns the raw execution boundary.

Re-exports§

pub use account::AccountView;
pub use account_wrappers::Account;
pub use account_wrappers::InitAccount;
pub use account_wrappers::Interface;
pub use account_wrappers::InterfaceAccount;
pub use account_wrappers::InterfaceAccountLayout;
pub use account_wrappers::InterfaceAccountResolve;
pub use account_wrappers::InterfaceSpec;
pub use account_wrappers::Program;
pub use account_wrappers::ProgramId;
pub use account_wrappers::Signer as HopperSigner;
pub use account_wrappers::SystemAccount;
pub use account_wrappers::SystemId;
pub use account_wrappers::UncheckedAccount;
pub use address::Address;
pub use audit::AccountAudit;
pub use audit::DuplicateAccount;
pub use behavior::BehaviorChecked;
pub use behavior::BehaviorWrite;
pub use behavior::HopperBehavior;
pub use borrow::Ref;
pub use borrow::RefMut;
pub use compact::CompactDynamicLayout;
pub use compact::CompactLayout;
pub use compact::COMPACT_BODY_OFFSET;
pub use compute::check_compute_units;
pub use compute::remaining_compute_units;
pub use compute::require_compute_units;
pub use context::Context;
pub use context::ScopedContext;
pub use cpi::invoke;
pub use cpi::invoke_checked;
pub use cpi::invoke_signed;
pub use cpi::invoke_signed_checked;
pub use crypto::blake3;
pub use crypto::blake3_single;
pub use crypto::keccak256;
pub use crypto::keccak256_single;
pub use crypto::recover_ethereum_address;
pub use crypto::secp256k1_recover;
pub use crypto::sha256;
pub use crypto::sha256_single;
pub use error::ProgramError;
pub use field_map::FieldInfo;
pub use field_map::FieldMap;
pub use foreign::ExplainExternal;
pub use foreign::ExternalAccount;
pub use foreign::ExternalBytes;
pub use foreign::ExternalChecked;
pub use foreign::ExternalExplainSink;
pub use foreign::ExternalLens;
pub use foreign::ExternalLensValue;
pub use foreign::ExternalProof;
pub use foreign::ExternalResolve;
pub use foreign::ExternalZeroCopy;
pub use foreign::ForeignLens;
pub use foreign::ForeignManifest;
pub use interop::TransparentAddress;
pub use lamports::transfer_lamports;
pub use lazy::LazyContext;
pub use migrate::apply_pending_migrations;
pub use migrate::ensure_fits_with_rent;
pub use migrate::migrate_layout;
pub use migrate::migrate_layout_resizing;
pub use migrate::validate_header_for_epoch_migration;
pub use migrate::LayoutMigration;
pub use migrate::MigrationEdge;
pub use policy::HopperInstructionPolicy;
pub use policy::HopperProgramPolicy;
pub use policy::HopperProgramProfile;
pub use proof::AccountProof;
pub use proof::ExecutableChecked;
pub use proof::HasOneChecked;
pub use proof::LayoutChecked;
pub use proof::OwnerChecked;
pub use proof::SeedsChecked;
pub use proof::SignerChecked;
pub use proof::TokenExtensionsChecked;
pub use proof::Unchecked;
pub use proof::WritableChecked;
pub use ref_only::HopperRefOnly;
pub use remaining::RemainingAccountViews;
pub use remaining::RemainingAccounts;
pub use remaining::RemainingError;
pub use remaining::RemainingExternalAccounts;
pub use remaining::RemainingGroup;
pub use remaining::RemainingLazy;
pub use remaining::RemainingLazySlot;
pub use remaining::RemainingMode;
pub use remaining::RemainingSigners;
pub use remaining::RemainingTyped;
pub use remaining::MAX_REMAINING_ACCOUNTS;
pub use return_data::get_return_data;
pub use return_data::set_return_data;
pub use return_data::try_set_return_data;
pub use return_data::ReturnData;
pub use tail::borrow_address_slice;
pub use tail::borrow_bounded_str;
pub use tail::read_tail;
pub use tail::read_tail_len;
pub use tail::seq_capacity_for;
pub use tail::seq_region_bytes_for;
pub use tail::tail_capacity;
pub use tail::tail_payload;
pub use tail::write_tail;
pub use tail::write_tail_payload;
pub use tail::BoundedString;
pub use tail::BoundedVec;
pub use tail::HopperString;
pub use tail::HopperVec;
pub use tail::SeqElement;
pub use tail::SeqTailRead;
pub use tail::SeqTailWrite;
pub use tail::TailBytes;
pub use tail::TailCodec;
pub use tail::TailElement;
pub use tail::TailSeq;
pub use tail::TailSeqIter;
pub use tail::TailSeqMut;
pub use tail::TailStr;
pub use tail::SEQ_LEN_PREFIX;
pub use instruction::CpiAccount;
pub use instruction::InstructionAccount;
pub use instruction::InstructionView;
pub use instruction::Seed;
pub use instruction::Signer;
pub use instruction::StoredAccountMeta;
pub use instruction::StoredInstruction;
pub use layout::HopperHeader;
pub use layout::LayoutContract;
pub use layout::LayoutInfo;
pub use result::ProgramResult;
pub use segment::FieldCapability;
pub use segment::Segment;
pub use segment::TypedSegment;
pub use segment::FIELD_POLICY_AUTHORITY_GATED;
pub use segment::FIELD_POLICY_CHECKED_MATH;
pub use segment::FIELD_POLICY_IMMUTABLE_AFTER_INIT;
pub use segment::FIELD_ROLE_AUTHORITY;
pub use segment::FIELD_ROLE_BALANCE;
pub use segment::FIELD_ROLE_DATA;
pub use segment::FIELD_ROLE_VERSION;
pub use segment_borrow::AccessKind;
pub use segment_borrow::SegmentBorrow;
pub use segment_borrow::SegmentBorrowGuard;
pub use segment_borrow::SegmentBorrowRegistry;
pub use segment_lease::SegRef;
pub use segment_lease::SegRefMut;
pub use segment_lease::SegmentLease;
pub use segment_lease::SegmentsMut;
pub use write_policy::ParametricWriteRange;
pub use write_policy::WritePolicy;
pub use write_policy::WriteRange;
pub use write_policy::WRITE_POLICY_VIOLATION_PAGE;
pub use zerocopy::AccountLayout;
pub use zerocopy::WireLayout;
pub use zerocopy::ZeroCopy;

Modules§

account
Hopper-owned account view for Solana programs.
account_wrappers
Typed account wrappers for #[derive(Accounts)] and Hopper context lowering.
address
Hopper-owned address type for Solana programs.
audit
behavior
Reusable, parameterized account lifecycle behaviors.
borrow
Hopper-owned borrow guards for account data.
compact
Tier 1 of the three-tier metadata model: compact account access.
compute
Compute-budget introspection helpers.
context
Execution context for Hopper programs.
cpi
Cross-program invocation for Hopper programs.
cpi_event
Self-CPI event emission: the wire format, the verification primitives, and the runtime half of the one-line macro surface.
crank
Crank marker type emitted by the #[hopper::crank] attribute.
crypto
Runtime cryptography helpers built on Solana syscalls and precompiles.
dyn_cpi
Stack-allocated variable-length CPI builder.
error
Hopper-owned program error type for Solana on-chain programs.
field_map
Field-level layout descriptors for inspectable state contracts.
foreign
Manifest-backed foreign-account lenses.
instruction
Hopper-owned CPI instruction types.
interop
Type interop for Hopper-owned address values.
lamports
Gate-aware lamport movement.
layout
Layout contracts as runtime truth.
lazy
Runtime-typed lazy account parsing.
log
Hopper logging helpers.
memory
Hopper-owned memory helpers backed by Solana memory syscalls.
migrate
Schema-epoch in-place migration runtime.
option_byte
Zero-copy, tag-validated optional values for instruction args.
pda
Hopper-owned PDA ergonomics on top of the native runtime boundary.
pod
Pod, the canonical runtime-layer “safe to interpret from raw bytes” marker.
policy
Program-level safety policy.
proof
Proof-carrying account markers.
ref_only
Compile-proven borrow-guard constraint.
remaining
Remaining-accounts accessor with strict and passthrough modes.
rent
Rent-exemption helpers.
result
Canonical result type for Hopper programs.
return_data
CPI return-data helpers.
segment
Runtime-local segment primitive.
segment_borrow
Segment-level borrow registry for fine-grained access control.
segment_lease
RAII-leased typed segment guards.
sha256
Const SHA-256 implementation used for Hopper-owned discriminators.
syscall
Small Hopper-owned wrappers for individual runtime syscalls used directly by framework crates.
syscalls
Minimal syscall shims exposed through Hopper Runtime.
system
Hopper-native System Program CPI builders.
tail
Hybrid serialization tail for #[hopper::state(dynamic_tail = T)].
token
Hopper-native SPL Token CPI builders.
token_2022_ext
Zero-copy Token-2022 extension TLV readers.
token_mint
Allocation and initialization of legacy SPL and Token-2022 mints.
utils
Small utilities for Hopper program authors.
write_policy
Declared write sets enforced at borrow acquisition.
zerocopy
Unified zero-copy trait family.

Macros§

address
Compile-time base58 address literal.
const_pda
A program-derived address evaluated at compile time: const_pda!(PROGRAM_ID, [seed, ...], bump) is pda::const_program_address with the seed list spelled inline (each seed anything that casts to &[u8]: a byte-string literal, an Address::as_array(), a &[u8; N]). See that function for the bump contract and the soundness note.
declare_id
Declare a program’s on-chain id, mirroring the declare_id! convention every other Solana framework ships (Anchor, Pinocchio, Quasar).
default_allocator
Install the default bump allocator over the SVM heap region. Opt-in counterpart to no_allocator! for programs that need alloc on a cold path. See hopper_native::BumpAllocator.
err
Return an error immediately. Parallel to Anchor’s err!.
error
Alias for err!. Anchor-style spelling for ported code. Functionally identical.
fast_entrypoint
Backward-compatible alias for the fast Hopper entrypoint macro.
hopper_emit_cpi
Emit a Hopper event via self-CPI for reliable indexing, the manual-wiring form.
hopper_entrypoint
Declare the explicit Hopper runtime entrypoint bridge.
hopper_exact_entrypoint
Declare the count-exact program entrypoint.
hopper_fast_entrypoint
Without the simd-0321 feature the “fast” entrypoint is an alias for the standard scanning entrypoint. The SIMD-0321 gate is live on every public cluster (mainnet-beta 2026-04-01), so the two-argument form is sound to build; it stays opt-in because the r2 path measured CU-neutral against the fused scanning walk for ~368 bytes of extra .text (see the simd-0321 feature note in the workspace Cargo.toml). Build with --features simd-0321 to select the r2 entrypoint.
hopper_lazy_entrypoint
Declare the Hopper lazy entrypoint, RUNTIME-typed, matching the eager hopper_fast_entrypoint!’s layering.
hopper_log
Cheap structured logging for hot handlers.
hopper_unsafe_region
Auditable raw-pointer boundary.
layout_migrations
Compose a layout’s LayoutMigration::MIGRATIONS chain from a list of #[hopper::migrate]-emitted edge constants.
lazy_entrypoint
Backward-compatible alias for the lazy Hopper entrypoint macro.
migrate_chain
Typed multi-hop layout migration: probe-and-migrate each declared hop in declaration order, so ONE call heals an account from ANY declared starting version to the newest, the chain Quasar’s pairwise Migration<From, To> cannot express in one instruction.
msg
Backend-neutral logging macro.
no_allocator
nostd_panic_handler
program_entrypoint
Declare the canonical Hopper program entrypoint.
require
Early-return with an error if the condition is false.
require_eq
Assert two values are equal, returning an error on mismatch.
require_gt
Assert left > right strictly.
require_gte
Assert left >= right, returning the supplied error on underrun. Useful for lamport / balance checks.
require_keys_eq
Assert two public keys (or any byte slices convertible via [AsRef<[u8; 32]>]) are equal. Narrower than require_eq! but matches the ergonomic spelling ecosystem migrators coming from Anchor / Jiminy are familiar with.
require_keys_neq
Assert two public keys are not equal. Used for pinning distinct accounts (authority != user, source != destination). Same coercion and error semantics as require_keys_eq!.
require_lt
Assert left < right strictly. Anchor-parity sibling of require_gt!. Default error is ProgramError::InvalidArgument because a failed ordering check most often flags a bad user input.
require_lte
Assert left <= right. Anchor-parity sibling of require_gte!.
require_neq
Assert two values are not equal. Early-returns with the supplied error on match (or ProgramError::InvalidArgument in the short form). Symmetric with require_eq!.
seeds
Convenience macro for building an array of Seed from expressions.

Constants§

MAX_TX_ACCOUNTS
SUCCESS

Traits§

Pod
Marker for types that can be safely overlaid as &T / &mut T on raw account bytes at any offset.
ValuePod
Marker for Copy + Sized scalars/arrays that may be read by value from raw bytes with read_unaligned_value (alignment-independent).
Zeroable
Marker for Copy + Sized values that are valid for every bit pattern.

Functions§

read_unaligned_value
Read a ValuePod scalar/array out of bytes at offset by value, tolerating any alignment (uses core::ptr::read_unaligned).