Skip to main content

Module layout

Module layout 

Source
Expand description

Kani proofs and golden-vector tests for the shipped SPL Token and System-program CPI instruction-data encoders.

§What is proven, and where the bytes come from

The SPL Token builders and the System-program builders in hopper_runtime::token / hopper_runtime::system now construct every instruction-data buffer by calling a small, pure, #[inline(always)] encoder in hopper_runtime::{token,system}::encoders. Those encoders return the bytes that leave the program on a CPI. Because a builder’s invoke_signed* path delegates to one of them (instead of building the buffer inline and dropping it straight into the syscall), the shipped bytes are directly callable and model-checkable.

The #[cfg(kani)] proofs below call the shipped hopper_runtime::{token,system}::encoders::* functions directly and pin, over symbolic inputs, each field’s discriminator, byte offset, endianness, and total encoded length. The proofs therefore exercise the encoder functions called by the CPI builders.

§The reference encoders are now a differential oracle

The spl_token and system modules in this file retain an independent, second implementation of the same wire formats. They are no longer the proof target. They serve as a differential oracle. The *_matches_reference proofs assert, byte-for-byte over symbolic inputs, that the shipped encoder equals this independent reference, so the shipped bytes are pinned from two directions at once: a direct wire-format proof and N-version agreement with a separately-authored encoder. A divergence in either implementation fails a proof.

§CBMC tractability

Scalars are compared as one word (u64::from_le_bytes(..)), never a slice ==, and a 32-byte pubkey region is proven with a single symbolic index i in 0..32 and one assertion, universal over all offsets, with no 32-iteration memcmp loop that would blow up the SAT formula. The differential proofs use the same discipline (field-wise / symbolic-index equality between the two fixed-size buffers), which avoids large comparison loops in the harnesses.

§Provenance of the shipped encoders (runtime source)

SPL Token: crates/hopper-runtime/src/token.rs, pub mod encoders: Transfer 3, Approve 4, MintTo 7, Burn 8, TransferChecked 12, ApproveChecked 13, MintToChecked 14, BurnChecked 15, Revoke 5, CloseAccount 9, FreezeAccount 10, ThawAccount 11, SyncNative 17, InitializeAccount 1, InitializeAccount2 16 / InitializeAccount3 18 (encode_initialize_account_with_owner), SetAuthority 6 (encode_set_authority).

System: crates/hopper-runtime/src/system.rs, pub mod encoders: CreateAccount 0, Transfer 2, Assign 1, Allocate 8, CreateAccountAllowPrefund 13. System discriminators are 4-byte u32 LE (only the low byte is nonzero for these tags).

Modules§

spl_token
SPL Token instruction discriminators (TokenInstruction tags), plus an independent reference encoder per instruction used as a differential oracle for the shipped hopper_runtime::token::encoders.
system
System program instruction reference encoders, used as a differential oracle for the shipped hopper_runtime::system::encoders.