freshet
Resumable, permissionless, sharded MapReduce over Solana accounts — the framework-agnostic core.
A Solana transaction can only lock ~128 accounts and spend 1.4M CU, so one event cannot
atomically modify an unbounded set of accounts. freshet is the on-chain pattern that
lifts that ceiling: a single logical effect is partitioned into permissionless,
resumable, idempotent crank batches, optionally in two phases:
- REDUCE — scan N members into a commutative-monoid accumulator (tally, winner, …);
- MAP — apply the result to every member, including members whose owner never shows up (push-mode) — which a pull-based "claim it yourself" design cannot express.
Exactly-once is guaranteed by a monotonic cursor within an epoch plus a per-member epoch stamp across re-runs; liveness by a keeper bounty. See the SPEC for the full contract.
What this crate is
The pure, no_std, alloc-free logic with no Solana dependency:
partition— the deterministic member→shard partition (computed, never stored).state— the verified state-machine guards (advance_step, …) that drive every phase transition, plus a host-only executable model (Machine, behind thestdfeature) that the property tests model-check.monoid— theMonoidtrait for the REDUCE accumulator, withSumandMaxWinner.
freshet is a library linked into the consumer program (only the owning program may
write an account). The consumer owns its account layout and delegates control-flow to these
guards, so its handlers run the verified logic. Reference settlers in Pinocchio, Anchor,
and Quasar — with a cross-framework CU benchmark — live in the
repository.
Usage
[]
= { = "0.1", = false } # no_std, for on-chain programs
use ;
use ;
assert_eq!; // 10 members over 3 shards → 4 + 3 + 3
assert_eq!;
assert_eq!;
The default std feature enables the host-only Machine model used by the tests; on-chain
programs link with default-features = false.
Status
Unaudited; the reference on-chain programs use a placeholder program ID — do not deploy
as-is. Licensed under MIT.