freshet 0.1.0

Resumable, permissionless, sharded MapReduce over Solana accounts (framework-agnostic core)
Documentation
  • Coverage
  • 41.33%
    31 out of 75 items documented1 out of 31 items with examples
  • Size
  • Source code size: 46.47 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 816.17 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 5s Average build duration of successful builds.
  • all releases: 5s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • JuanMarchetto/freshet
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • JuanMarchetto

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 the std feature) that the property tests model-check.
  • monoid — the Monoid trait for the REDUCE accumulator, with Sum and MaxWinner.

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

[dependencies]
freshet = { version = "0.1", default-features = false } # no_std, for on-chain programs
use freshet::partition::{partition_len, partition_start};
use freshet::monoid::{Monoid, Sum};

assert_eq!(partition_len(10, 3, 0), 4); // 10 members over 3 shards → 4 + 3 + 3
assert_eq!(partition_start(10, 3, 1), 4);
assert_eq!(Sum(3).combine(Sum(4)).combine(Sum(0)), Sum(7));

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.