Skip to main content

Crate hopper_core

Crate hopper_core 

Source
Expand description

§Hopper Core

Core engine for Hopper, a zero-copy state framework for Solana.

Typed account architecture, phased execution, composable validation, zero-copy collections, layout evolution with deterministic fingerprints, policy-aware capabilities, state receipts, and cross-program interfaces. no_std, no_alloc, no proc macros required.

§Architecture

  • Account memory: Fixed, overlay, segmented, and arena layout styles
  • Execution: Frame-based borrowed-state execution with phases
  • Validation: Named rule groups, instruction-specific rule packs, post-mutation invariant checks, composable pipelines
  • Policy: Declare instruction capabilities, auto-resolve validation requirements via InstructionPolicy
  • Receipts: Structured mutation summaries combining snapshots, diffs, field masks, invariant results, and CPI tracking
  • Collections: Zero-copy FixedVec, RingBuffer, SlotMap, BitSet, Journal, Slab, PackedMap
  • Segments: Typed segment roles (Core, Extension, Journal, Index, Cache, Audit, Shard) for semantic classification
  • Fingerprints: Deterministic layout_id from SHA-256, compile-time compatibility assertions, schema diffing
  • Evolution: Append-only versioned layouts with migration helpers
  • Interfaces: Cross-program read-only views with ABI proof

Built on hopper-native. Compatible with jiminy account layouts.

§Feature flags

hopper-core ships one hot-path core plus opt-in advanced subsystems. The default feature set is programs, hopper-native-backend, cpi, collections, and the advanced umbrella (frame, receipt, policy, graph, migrate, virtual-state, diff, explain). Programs that only touch raw fields and segments can disable every optional surface:

hopper-core = { version = "0.1", default-features = false,
                features = ["programs", "hopper-native-backend", "cpi"] }

That lean configuration drops frame, receipt, policy, graph, migrate, virtual-state, diff, explain, and collections from the compile surface and leaves only the hot-path access model, validation primitives, ABI, layout metadata, and CPI. Re-enable features individually as the program grows.

Re-exports§

pub use field_map::*;

Modules§

abi
Alignment-1 little-endian ABI wire types.
account
Account memory architecture.
accounts
Hopper Account DSL – typed account ergonomics for zero-copy programs.
check
Multi-tier validation system.
collections
Zero-copy collections for on-chain account data.
cpi
Const-generic CPI builder – stack-only, zero-allocation CPI calls.
diff
State Diff Engine: field-level change tracking.
dispatch
Instruction dispatch – tag-based routing with zero allocation.
event
Zero-allocation event emission via sol_log_data.
field_map
Runtime-owned field map metadata re-exported through Hopper Core.
frame
Borrowed-state execution context.
invariant
Invariant engine – post-execution correctness verification.
math
Checked arithmetic operations.
migrate
Migration helpers – safe version upgrades for on-chain accounts.
policy
Policy-Aware Capabilities – tie instruction behavior to validation requirements.
prelude
Prelude re-exports for ergonomic usage.
prelude_advanced
Advanced subsystem prelude: everything outside the core identity.
prelude_core
Narrow, hot-path-only prelude.
receipt
State Receipts – structured mutation summaries.
segment_map
Compile-time segment mapping for zero-copy account layouts.
state
State machine validation.
sysvar
Sysvar readers – zero-copy Clock and Rent parsing.
time
Time-based validation: deadlines, cooldowns, staleness.
virtual_state
Account Virtualization.

Macros§

hopper_dispatch
Macro for instruction dispatch.
hopper_dispatch_8
8-byte discriminator dispatch (Anchor/Quasar compatible).
hopper_dispatch_lazy
Lazy dispatch – routes on instruction data before parsing any accounts.

Functions§

anchor_account_discriminator
Compute an Anchor-compatible 8-byte account discriminator at compile time.
anchor_discriminator
Compute an Anchor-compatible 8-byte discriminator at compile time.