Accounts #
The Solana account model. An on-chain account carries five fields: its lamport balance (u64), the program that owns it, an opaque data blob, an executable flag (true for programs, false for data accounts), and the rent epoch at which rent next comes due.
Account.lamports is a Lamports (= UInt64), so credit and debit
carry explicit no-overflow / no-underflow preconditions in their type
signatures. The compiler will reject any call site that hasn't proved the
relevant bound — modelling the Solana convention of checked_add /
checked_sub returning Err on overflow, but at the type level.
Main definitions #
Solanalib.Account— the five-field on-chain account record.Solanalib.Account.credit— credit lamports, requireslhs + rhs < 2^64.Solanalib.Account.debit— debit lamports, requiresamount ≤ balance.
Main statements #
Projection @[simp] lemmas for every field of every operation, so simp
can chain through .field accesses uniformly. The credit_lamports_toNat
and debit_lamports_toNat variants drop the result into Nat for
conservation-style reasoning where omega does the heavy lifting.
A Solana account: lamport balance, owning program, data blob, executable flag, and rent epoch.
- lamports : Lamports
The number of lamports held by this account (u64 on chain).
- owner : Pubkey
The program that owns this account and is authorised to mutate it.
- data : ByteArray
The opaque data the account holds. Interpretation is owner-specific.
- executable : Bool
True if this account is a program (BPF binary), false for data.
- rentEpoch : Lamports
Slot at which rent next becomes due.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- Solanalib.instReprAccount = { reprPrec := Solanalib.instReprAccount.repr }
Equations
- One or more equations did not get rendered due to their size.
Instances For
Credit amount lamports to an account.
Requires a proof h that the resulting balance fits in u64, so the
underlying UInt64 addition can never silently wrap. This mirrors what
production Solana code does with checked_add, but lifted to a
compile-time obligation.
Equations
Instances For
Debit amount lamports from an account.
Requires a proof h that the account holds at least amount lamports,
so the underlying UInt64 subtraction can never underflow / wrap.
Equations
Instances For
Projection @[simp] lemmas. The _toNat variants drop the equation
into Nat, which is what omega needs for conservation arithmetic.
Bridging to Nat. Conservation-style theorems use these to translate
Lamports (UInt64) operations into UncheckedLamports (Nat) where omega
can close the arithmetic.