Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

v0 source pure

Package hlroute is the state a bridge route realm keeps (bridge/PLAN.md §5.2–§5.5, §5.9), shared by r/hlgnot and r/hl...

Overview

Package hlroute is the state a bridge route realm keeps (bridge/PLAN.md §5.2–§5.5, §5.9), shared by r/hlgnot and r/hlbubble: the lock's counters and the supply identity, the claims in per-recipient queues, the two meters that rate-limit what is paid, the sweep queue, the send records a successor refunds by id, and GovDAO's decisions on the route's settings. It holds no coins and makes no call: the realm that owns a State moves the asset through the Env callbacks and asks hlmailbox what only the realm can ask. Every clock here is unix time, passed in.

Constants 3

const Day, MaxClaims, MaxIDs, PageLines, PullPage, MaxRangeClaims, guardianSeats, maxGuardianSeats, Open, Withheld, Forged, Done, BySigners, ByVote, KindCapFloor, KindMaximum, KindFee, KindFeeFloor, KindRouter, KindVoid, KindRestore, KindCredit, KindSweep, KindRefund, KindApplyRefund, KindWriteOff, KindMigrate, KindCancel, one, maxInt64, maxHeight

 1const (
 2	Day = decisions.Day
 3	// MaxClaims is the most claims one Claim call pays (§5.4: n ≤ 20).
 4	MaxClaims = 20
 5	// MaxIDs is the most message ids one void, restore, credit or refund names.
 6	MaxIDs = 256
 7	// PageLines is how many waiting claims, and how many sweep entries, the route's page lists; the rest are
 8	// counted there and read by hundreds at claims/<from> and sweeps/<from>, so a flood of dust can never make
 9	// the page a member reads exceed a query's gas.
10	PageLines = 100
11	// PullPage is how many records one Pull hands to a successor (R13): the migration moves the claims, the sweep
12	// entries and the sends a page at a time, so no page outgrows a block however long the route ran.
13	PullPage = 500
14	// MaxRangeClaims is the most credits (claims and sweep entries, voidable or not, R23) a range void's scan may
15	// visit when it is made (R14): at ≈0.4M gas a credit on chain a thousand is ≈0.4B, inside a block with room;
16	// GovDAO splits a bigger range by heights, from the last height a decision's note says it voided. The range is
17	// closed at the height the proposal is made, so what it covers never grows after.
18	MaxRangeClaims = 1000
19	// guardianSeats are seats 1–4 (hlmailbox's numbering); a void's unpause option vacates at most maxGuardianSeats
20	// of them (§5.3: two guardians at most per proposal).
21	guardianSeats    = 4
22	maxGuardianSeats = 2
23
24	// Claim states.
25	Open     = "open"     // credited, unpaid or paying
26	Withheld = "withheld" // voided as withheld: the remainder stays booked, restorable at once
27	Forged   = "forged"   // voided as forged: the remainder dropped, the paid part lost; restorable after 7 days
28	Done     = "done"     // paid in full
29
30	// Who credited a claim.
31	BySigners = "signers" // the verifier (the signers until Proposal 2)
32	ByVote    = "vote"    // GovDAO's credit by id
33
34	// Decision kinds.
35	KindCapFloor = "set cap floor"
36	KindMaximum  = "set maximum"
37	KindFee      = "set fee and minimum"
38	KindFeeFloor = "set fee floor"
39	KindRouter   = "set router"
40	KindVoid     = "void"
41	KindRestore  = "restore"
42	KindCredit   = "credit"
43	KindSweep    = "sweep"
44	KindRefund   = "refund"
45	// KindApplyRefund is GovDAO's own at-once apply of a queued refund decision (AT2): a refund is never Execute's.
46	KindApplyRefund = "apply refund"
47	KindWriteOff    = "write off"
48	KindMigrate     = "migrate"
49	KindCancel      = "cancel"
50
51	one = int64(1_000_000) // 6 decimals on both sides
52
53	maxInt64  = int64(1<<63 - 1)
54	maxHeight = int64(9_999_999_999_999_999) // the height index's keys are 16 digits
55)
source

const EnrolmentWait

1const EnrolmentWait = 2 * decisions.Delay
source

EnrolmentWait is how long a refund waits after r/hlgov's dispatch of the kind 6 enrolling this route (R37, F27): two of the 7-day delays — a week for the delivery to Solana and a week for Solana's own clock, since the admin program executes a kind 6 7 days after it is recorded there, so a week from the dispatch always ended before the enrolment could take effect. A hold defers Solana further, which the realm cannot see: hlwatch and the relayer read the token's enrolled router there.

Functions 6

func CleanID

1func CleanID(id string) (string, error)
source

CleanID is a message id as the state keys it: lowercase hex, no 0x; it errors on anything but 32 bytes.

func ParseFns

1func ParseFns(fns string) []string
source

ParseFns reads a comma-separated list of the three functions, "" for none; no repeats.

func ParseIDs

1func ParseIDs(list string) []string
source

ParseIDs reads a comma-separated list of message ids, refusing an empty list, a bad id and a repeat.

func ParseSeats

1func ParseSeats(seats string) []int
source

ParseSeats reads a comma-separated list of seat numbers (1–6), "" for none; no repeats, and two guardian seats (1–4) at most — §5.3's cap on guardian changes per proposal, the same as hlmailbox's rotate seats, so no void vacates the four guardians in one stroke.

func ParseRange

1func ParseRange(s string) (r Range, ok bool)
source

ParseRange reads a range; ok is false when s is not one (a list of ids, then). A malformed range panics.

func New

1func New(l Launch) *State
source

New is a route's state with its launch values, the meters empty as of l.Now.

Types 14

type Claim

struct
 1type Claim struct {
 2	ID     string // the message id, lowercase hex
 3	To     address
 4	Amount int64
 5	Paid   int64 // fee included
 6	At     int64 // credited at (unix time)
 7	Height int64 // credited at (block height): what a range names
 8	By     string
 9	State  string
10	Seq    int64 // its place in the recipient's queue
11	// QueueNext is set in a migration page only (R20): the predecessor's final counter for the recipient's queue, so
12	// the successor's own credits land above every place a later page can claim. It is 0 on a stored claim.
13	QueueNext int64
14}
source

Claim is one IOU the route owes a recipient (§5.4).

Methods on Claim

func Remaining

method on Claim
1func (c *Claim) Remaining() int64
source

Remaining is what the claim still owes.

type Draft

struct
1type Draft struct {
2	Kind   string
3	Text   string
4	Params any
5}
source

Draft is a builder's checked parameters: what a proposal carries, decided and applied when it executes.

type Env

struct
 1type Env struct {
 2	Flagged      func(id string, height int64, verifier bool) bool // a guardian's standing payouts flag on this route names the claim: by id, or by a range covering the height it was credited at (and whether the verifier credited it)
 3	ClearFlags   func(fn string) bool                              // clears every key's flag for fn on this route (the void's unpause option)
 4	RemoveSeat   func(seat int, holder address) bool               // vacates a guardian or watch-key seat if holder still has it (the void's unpause option); false, nothing done, if the occupant changed (R17)
 5	Delivered    func(id string) bool                              // hlmailbox marked the id done
 6	MarkDone     func(id string)                                   // marks an id done in hlmailbox (credit by vote)
 7	Epoch        func() int64                                      // hlmailbox's payouts epoch for this route now (a queue made by a decision starts there)
 8	Height       func() int64                                      // the block height now (a claim credited by a decision is credited at it; a range void closes at it)
 9	Pay          func(to address, amount int64)
10	PayFee       func(amount int64)
11	AddRoute     func(path string)         // registers a successor route with hlmailbox
12	AnnouncedFor func(path string) string  // the route ("GNOT" or "BUBBLE") a realm at this pkgpath announced itself to hlmailbox as a successor of (R25, AQ5), "" if it never did: a migrate names only a path announced for this route
13	Predecessor  func() string             // the route whose migrate registered this realm with hlmailbox (hlmailbox.Predecessor of this realm's own path), "" for a launch route or a realm not registered yet (R31): a successor migrates on only once its own import has ended
14	IsRoute      func(path string) bool    // whether hlmailbox registers a route at this pkgpath (R31): a migrate never names one
15	Enrolled     func() (height, at int64) // the block height and time r/hlgov last dispatched a kind 6 enrolling this realm as the token's router on Solana, as it noted with hlmailbox (hlmailbox.Enrolled of this realm's own path); 0, 0 if never, or cleared by r/hlgov's cancel (AR1, R37): a refund waits 14 days after it, and a successor sends nothing before it (AT7)
16}
source

Env is what the realm does for the state: the calls only a realm can make. Every field is set.

type Launch

struct
 1type Launch struct {
 2	Symbol   string // "GNOT" or "BUBBLE"
 3	Fee      int64  // the flat fee on every send and the first installment of every claim
 4	Minimum  int64  // the least a send may carry
 5	FeeFloor int64  // the fee and the minimum never go below it
 6	CapFloor int64  // the day cap is max(CapFloor, 10% of the lock)
 7	Maximum  int64  // the most a send may carry
 8	Domain   uint32 // the destination's domain
 9	Router   [32]byte
10	Now      int64 // deploy time: the meters start empty here
11}
source

Launch are a route's compiled launch values.

type Meter

struct
1type Meter struct {
2	Level int64
3	At    int64 // last refill
4	Epoch int64 // the payouts epoch it last saw
5	Frac  int64
6}
source

Meter is §5.4's bucket: a level that refills at a rate per day up to a ceiling, emptied at every payouts epoch. Frac carries the refill's remainder (in base units × seconds, below a day), so refills in any pieces sum to exactly rate a day.

type Queue

struct
1type Queue struct {
2	items    avl.Tree // seqKey(seq) → claim id: the open claims only (a voided or paid claim leaves the queue, R12)
3	meter    Meter
4	next     int64
5	base     int64 // an import places a predecessor's claim at base + its old seq, so the pages keep the queue's order
6	imported bool
7}
source

Queue is one recipient's claims, oldest first, and that recipient's own meter (a quarter of the bridge's).

type Range

struct
1type Range struct {
2	From, To int64
3	Since    bool
4}
source

Range names claims by when they were credited rather than by id: every claim credited at a block height from From to To inclusive, or — Since — every claim the verifier credited at a height at or above From, open above while a flag stands (the verifier's later credits are covered too) and closed by a void at the height it executes (claims credited after the vote were not decided on). Written "heights:<from>-<to>" or "since:<from>"; a guardian's payouts flag and the void builder take one in place of a list of ids, so one flag and one closure cover a flood larger than a list.

Methods on Range

func Covers

method on Range
1func (r Range) Covers(height int64, verifier bool) bool
source

Covers is whether a claim credited at height — by the verifier, or not — is in the range.

func String

method on Range
1func (r Range) String() string
source

String says the range in words.

type Send

struct
1type Send struct {
2	From       address
3	Amount     int64
4	At         int64
5	Refunded   int64 // when it was refunded, 0 if not
6	WrittenOff int64 // when it was written off as delivered on Solana after its refund (AR1), 0 if not
7	Imported   bool  // brought by a predecessor's page (AQ2): the only sends a refund may name
8}
source

Send is one outgoing transfer's record, kept so a successor can refund it by id if it was never delivered.

type SendItem

struct
1type SendItem struct {
2	ID         string
3	From       address
4	Amount     int64
5	At         int64
6	Refunded   int64 // when it was refunded, 0 if not (R33): the mark goes with the record, so some realm always answers it
7	WrittenOff int64 // when it was written off (AR1), 0 if not: the same
8}
source

type Snapshot

struct
1type Snapshot struct {
2	Page                                                  int
3	More                                                  bool // records remain for the next page
4	Lock, SentTotal, PaidTotal, Owed, Voided, Lost, Sweep int64
5	Claims                                                []Claim
6	Sweeps                                                []SweepItem
7	Sends                                                 []SendItem
8}
source

Snapshot is one page of what a successor takes over: plain values it copies into its own state. Page 0 carries the counters; every page up to the page size of records.

type State

struct
 1type State struct {
 2	Symbol string
 3	Domain uint32
 4
 5	Fee, Minimum, FeeFloor, CapFloor, Maximum int64
 6	LaunchMinimum, LaunchCapFloor             int64 // the compiled floors no builder goes below
 7
 8	Router    [32]byte
 9	OldRouter [32]byte
10	OldUntil  int64 // the old router's messages are accepted until this time (7 days after a swap)
11
12	// The identity (§5.9): Lock = SentTotal − PaidTotal = supply + Owed + Voided − Lost, up to in-flight messages.
13	SentTotal int64 // locked by sends (fees excluded)
14	PaidTotal int64 // paid out of claims, fees included, and sweep payments
15	Owed      int64 // credited, unpaid; the sweep queue included
16	Voided    int64 // the unpaid remainder of claims voided as withheld
17	Lost      int64 // the paid part of claims voided as forged, and the sends delivered on Solana after their refund, written off (AR1)
18	Lock      int64
19	Sweep     int64 // the sweep queue's balance, part of Owed
20
21	claims          avl.Tree // id → *Claim, every claim ever credited
22	credits         avl.Tree // heightKey(height, id) → id: the claims and the sweep entries by the height they were credited at, what a range walks
23	queues          avl.Tree // recipient → *Queue
24	waiting         avl.Tree // recipient → true while its queue holds an open claim — exact (set at a credit or a restore, dropped with the last open claim, R12): the cursor's ring and the page's walk
25	cursor          string   // the last recipient served
26	meter           Meter    // the bridge's meter
27	sweeps          avl.Tree // id → *SweepEntry
28	sends           avl.Tree // id → *Send
29	refunds         avl.Tree // id → true: the sends refunded here, what refunds/<from> pages (AQ2)
30	nRefunded       int64    // sends refunded here (the records held here: a refunded send goes with its page, R33)
31	refundedTotal   int64    // what they summed to
32	nWrittenOff     int64    // sends written off as delivered on Solana after their refund (AR1), held here
33	writtenOffTotal int64    // what they summed to
34	nClaims         int64    // claims ever credited
35	nOpen           int64    // claims open now
36	exported        int      // pages handed to the successor by Export (R13)
37	imported        int      // pages taken from a predecessor by Import, in order (R20)
38	importing       bool     // between a predecessor's first page and its last (AP4): Credit refuses, so no credit of this route's own can collide with a place a page still to come claims
39
40	Ledger     decisions.Ledger
41	MigratedTo string // the successor realm, once a migrate decision applied; every function then refuses
42	MigratedAt int64
43	LaunchSeen int64 // the launch time the meters were last emptied for
44}
source

State is a route's whole state but the asset itself.

Methods on State

func Amount

method on State
1func (s *State) Amount(n int64) string
source

Amount writes base units as whole tokens with the symbol: 12,000,000 → "12 GNOT".

func Cap

method on State
1func (s *State) Cap() int64
source

Cap is the day cap: max(the floor, a tenth of the lock).

func CheckSend

method on State
1func (s *State) CheckSend(amount int64)
source

CheckSend is what a send must satisfy: a positive amount between the minimum and the maximum.

func Claim

method on State
1func (s *State) Claim(now int64, n int, epoch, epochAt int64, env Env) int
source

Claim pays up to n claims (n ≤ 20) taking recipients in turns: the oldest open claim of each recipient with something waiting, as much of it as both meters allow, the fee as its first installment, skipping a recipient whose meter is dry. epoch and epochAt are hlmailbox's payouts epoch for this route. It returns how many claims it paid something on; the payments went through env.PayFee and env.Pay.

func ClaimJSON

method on State
1func (s *State) ClaimJSON(id string) string
source

ClaimJSON is one claim by id, or the sweep entry under that id, or "null".

func ClaimOf

method on State
1func (s *State) ClaimOf(id string) *Claim
source

ClaimOf is a claim by id, or nil.

func ClaimsPage

method on State
1func (s *State) ClaimsPage(from int) string
source

ClaimsPage is up to PageLines waiting claims from the from-th on (from 0), in the page's order, as a JSON array of ClaimJSON's objects; "[]" past the end.

func Credit

method on State
1func (s *State) Credit(now, height, epoch int64, id string, to address, amount int64, by string, sweep bool) bool
source

Credit books an incoming transfer: a claim in the recipient's queue, or — for a burn below the fee, one to a realm address (sweep), or one above the lock — the sweep queue. height is the block height now (what a range names the claim by); epoch is hlmailbox's payouts epoch for the route now (a fresh queue's meter starts there). It returns whether it was swept.

A burn above the lock cannot be honest (a mint needs a lock and a burn needs supply, so the supply is never above the lock): it is swept, owed and paying nobody until GovDAO directs it, which also bounds every claim by the lock. An amount that would overflow what is owed is refused outright (the message stays undelivered), and so is every credit while a predecessor's pages are still arriving (AP4): the relayer brings the message again once the last page is in.

func Decide

method on State
1func (s *State) Decide(made, now int64, d Draft, env Env) *decisions.Decision
source

Decide is what a builder's closure does when its proposal executes: it records the decision and settles the at-once test against the live state — a lowering, a cancel, a restore of a withheld claim and the void of ids a guardian's standing payouts flag names apply now; everything else waits 7 days for Execute. A migrate is checked again here (R31, AR2: the state may have moved since the proposal was made) and a cancel, or a migrate that re-points a migration nothing was pulled from, is taken on a migrated route.

func DraftApplyRefund

method on State
1func (s *State) DraftApplyRefund(id, now int64, env Env) Draft
source

DraftApplyRefund: GovDAO's own at-once apply of a queued refund decision whose 7 days have passed (AT2). A refund is the one decision whose gate the realm cannot read — Solana's: the token's router there must be this realm and the kind 6 executed, which hlwatch reads and alarms NOT ENROLLED ON SOLANA while it is not — and anyone's Execute on the note alone let a refunded sender, his id in the proposal's description, apply his refund the day it matured while a kind 6 deferred by one flag left the predecessor the router, then deliver his send there with the published tool: minted twice, the lock short for good. So Execute refuses the kind, and a refund is applied by this builder alone — at once, like an unpause — the member having read hlwatch's gate before the vote. The apply is the delay's own (apply's refund branch: mustBeEnrolled's 14-day note asked again, the sum at most the lock, a send refunded since skipped), and the realm asks its payouts flag of it as of a sweep payment. Refused — when the proposal is made and again when it executes, the proposal surviving for a retry — for a decision that is no refund, one not pending (applied, cancelled), one whose delay has not passed, and until the note is 14 days old. The description names the refund decision and carries its text, the ids included.

func DraftCancel

method on State
1func (s *State) DraftCancel(id int64) Draft
source

DraftCancel: cancel a pending decision of this route.

func DraftCapFloor

method on State
1func (s *State) DraftCapFloor(n int64) Draft
source

DraftCapFloor: the day cap's floor; never below the compiled launch floor, and its quarter never below the fee (a recipient's meter holds a quarter of the cap at most and the fee is a claim's first installment, whole: a quarter under the fee would stall every new recipient's first payment, with no flag and no alarm).

func DraftCredit

method on State
1func (s *State) DraftCredit(id string, to address, amount int64, delivered bool) Draft
source

DraftCredit: credit a claim by id, by hand (§5.3): refused for an id already done unless its claim stands voided, or the id is a sweep entry's (R11) — the credit then replaces the entry with the claim it names, the cure for a burn to a realm or non-gno recipient, or a diverted credit. The amount is at most the lock (R26, R7's rule for the verifier's credits: a credit above the lock cannot be honest, and a claim above it would ask Claim for coins the lock does not hold); the closure asks again.

func DraftFee

method on State
1func (s *State) DraftFee(fee, minimum int64) Draft
source

DraftFee: the fee and the minimum together; the fee not below the fee floor and not above a quarter of the cap floor (the most a recipient's meter can hold, and the fee is the first installment, whole), the minimum positive and not above the maximum.

func DraftFeeFloor

method on State
1func (s *State) DraftFeeFloor(n int64) Draft
source

DraftFeeFloor: the fee floor; not above the fee, not negative.

func DraftMaximum

method on State
1func (s *State) DraftMaximum(n int64) Draft
source

DraftMaximum: the per-message maximum; never below the minimum. The description reminds GovDAO of the order a raise takes (R15): the pausable ISM's per-message maximum on Solana (r/hlgov's kind 12) is raised first, since a send above it leaves gno.land and is refused at delivery for good — stranded until a refund by id.

func DraftMigrate

method on State
1func (s *State) DraftMigrate(to, self string, env Env) Draft
source

DraftMigrate: the lock, the claims and the send records go to a successor realm at pkgpath — a deployed realm's, never a sub-identity's (`host#subpath`; the mailbox refuses such a route too), never a route the mailbox registers already (R31: the mailbox would refuse it when the migration applies, a week on, the vote wasted), and one that announced itself to the mailbox from its own code for this route (Env.AnnouncedFor: the symbol it named, "" if it never announced itself, R25 and AQ5), so the lock never goes to a path with no realm behind it — a typo, or an undeployed path whose namespace owner could deploy anything there and pull it — nor to the other token's successor by a slip. A route that succeeds another migrates on only once its own import has ended (R28, R31): before page 0 nothing has moved, and its MigratedTo would make its Import refuse, the predecessor's Pull revert for ever and the lock sit on the first predecessor, which refuses everything, with no decision that reaches it. The same checks are made again when the migration applies (mustMigrate).

func DraftRefund

method on State
1func (s *State) DraftRefund(ids string, now int64, env Env) Draft
source

DraftRefund: refund sends by id to their senders — a successor's duty, over the sends it imported from its predecessor (AQ2, §5.3): a refunded send stays deliverable on Solana, so only a send addressed to a router the token no longer enrolls is ever refunded, after kind 6 enrolled this realm — which the realm cannot see, so it reads the note r/hlgov leaves with the mailbox when it dispatches a kind 6 for this route (Env.Enrolled) and refuses until the note is 14 days old (AR1, R37, mustBeEnrolled; asked again when the refund applies): a refund that lands before kind 6 lets one stranger's Reemit and delivery of the refunded send mint it twice, with no realm able to refuse the message. Necessary, not sufficient: the member checks hlwatch first, which reads the token's enrolled router on Solana and the kind 6's state there, alarms a refund proposal whose successor the token has not enrolled and prints DELIVERED beside any id Solana processed — and the apply, after the 7 days, is GovDAO's own at-once decision (DraftApplyRefund, AT2), never anyone's Execute, so that check stands between the delay and the coins. A live route's own send, stranded or not, is never refunded: it waits for a kind 12 (§5.4). The sum is at most the lock (R30, the sweep payment's bound: a forgery paid before its void can leave the lock short of the sends it imported), checked again when it applies.

func DraftRestore

method on State
1func (s *State) DraftRestore(ids string) Draft
source

DraftRestore: restore voided claims, voided sweep entries, or written-off sends, by id — a write-off's inverse (R38): a mistaken write-off (a record two providers showed differently read as delivered, a neighbouring id in a list) books lost for the deployment's life, the watch's "mistaken void" alarm stands as long, and a later forged credit up to that amount moves the alarm's figure and trips nothing; the restore clears the mark and takes the amount back out of lost, after 7 days like a forged claim's restore, since it re-opens the identity.

func DraftRouter

method on State
1func (s *State) DraftRouter(router [32]byte, text string) Draft
source

DraftRouter: the remote router; the old one's messages stay accepted 7 days after the swap applies.

func DraftSweep

method on State
1func (s *State) DraftSweep(ids string, to address) Draft
source

DraftSweep: pay sweep entries, named by id (comma separated, up to MaxIDs), to an address — their sum, at most the lock (R11: a forged entry above the lock is voided, never paid out of coins the lock does not hold). The queue is settled by id (R19): a paid entry is dropped with its index, so it never stands to be credited by id or voided a second time, and the counters never go negative. A voided entry is restored first; a claim's id is no entry's; an entry voided or gone by the time the payment applies is skipped and the note says so.

func DraftVoid

method on State
1func (s *State) DraftVoid(ids string, forged bool, unpauseFns, removeSeats string, height int64, seatOf func(seat int) address) Draft
source

DraftVoid: void credits by id — a list of up to MaxIDs ids, claims or sweep entries (an entry as forged only), or a Range ("heights:<from>-<to>", every credit at those heights; "since:<from>", every credit the verifier made at or after it), closed at height — the block height the proposal is made at (R14), so what it covers never grows before it executes — and covering at most MaxRangeClaims credits, voidable or not (R23: the walk at execution visits them all), else GovDAO splits it by heights — as withheld or forged, with the unpause option — the functions whose flags to clear (comma separated, "" for none) and the seats to vacate (comma separated, "" for none; seatOf gives each seat's holder now, recorded so a seat whose occupant changes before the proposal executes is skipped, R17), applied in the same closure as the void so the void and the reopening never execute in the wrong order (§5.3). A range must cover a credit the void can take when the proposal is made; one in it the void cannot take as it stands (forged already; withheld, paid or a sweep entry, for a void as withheld) is skipped, not refused.

func DraftWriteOff

method on State
1func (s *State) DraftWriteOff(ids string) Draft
source

DraftWriteOff: book refunded sends, by id (comma separated, up to MaxIDs), as lost (AR1) — a refunded send delivered on Solana after all, by a stranger's Reemit before kind 6 replaced the predecessor's router or in the day a hold's lift leaves, minted a second time against nothing, and no builder but this one closes the identity: lock = sentTotal − paidTotal = supply + owed + voided − lost, the amount lost. Only a refunded send, once; the realm cannot see Solana, so the member reads hlwatch's DELIVERED line for each id first and the description says so. After 7 days; an id written off by another decision since is skipped and counted.

func Execute

method on State
1func (s *State) Execute(now, id int64, env Env) *decisions.Decision
source

Execute applies a queued decision whose delay has passed; on a migrated route only a migrate that re-points a migration nothing was pulled from (AR2: apply asks). Never a refund (AT2): its apply is GovDAO's own at-once decision (DraftApplyRefund), made after hlwatch's check that the token's router on Solana is this realm — a check the realm cannot make and anyone's Execute would skip.

func Export

method on State
1func (s *State) Export(page, size int) *Snapshot
source

Export hands the state to the successor a page at a time (R13): page 0 carries the counters (the realm pays the lock with it) and every page up to size records — the claims first, every claim ever credited (open, voided and paid, so a void or a restore reaches them on the successor, R12), then the sweep entries, then the sends, a refunded one with its mark (R33: the monitors drop a refunded send from what is in flight by the realm that answers send/<id> for it, so the record is never dropped; the refund counters follow it) — each leaving this state as it goes, so a page outgrows no block however long the route ran. The pages go in order; a page handed over already exports nothing (and the realm pays nothing). Only after a migrate decision applied.

func Exported

method on State
1func (s *State) Exported() int
source

Exported is how many pages went to the successor so far: the next Pull takes that page number.

func Figures

method on State
1func (s *State) Figures(now int64, epoch, epochAt, launchedAt int64, paused string) string
source

Figures is the realm's page body: the settings, the identity and the queues. launchedAt is hlmailbox's launch time (the meter is shown as the launch reset leaves it until the first Claim applies the reset).

func Import

method on State
1func (s *State) Import(now, epoch, launchedAt int64, snap *Snapshot)
source

Import takes a page of a predecessor's snapshot into this state: the counters add (page 0 carries them), the claims keep their ids, states and order — a recipient's queue places every imported claim at a base plus its old seq, and its counter is raised to the predecessor's final one on first seeing the recipient (R20), so this route's own credits land above every place a later page can claim — the open ones queued, the voided and paid ones kept as records, the sweep entries and the sends as they were, a refunded send with its mark, in the refunds index and counted (R33). The pages go in order, each once; from the first to the one that says no more follows, Credit refuses (AP4). epoch is this route's payouts epoch now: the queues it makes start there. Page 0 empties the bridge meter and every quarter as of now and takes launchedAt — hlmailbox's launch time — as the launch the meters were last emptied for (R34): a successor starts with empty meters, as a launch route does at Launch and every route after an unpause, and its first Claim applies no launch reset, which rewound every meter to the launch, months back, and filled them all at once — a third cap in the 24 hours the predecessor closed. The queues a later page makes start empty at their first claim, as every queue does.

func Imported

method on State
1func (s *State) Imported() int
source

Imported is how many of a predecessor's pages this route took in: 0 for a route that succeeded none.

func Importing

method on State
1func (s *State) Importing() bool
source

Importing is whether a predecessor's pages are still arriving: from page 0's import until the page that says no more follows (AP4). A successor's adopt loop reads it to know when it is done.

func JSON

method on State
1func (s *State) JSON(now int64, epoch, epochAt, launchedAt int64) string
source

JSON is the figures for the agents; launchedAt as Figures takes it.

func MeterLevels

method on State
1func (s *State) MeterLevels(now int64, to address, epoch, epochAt int64) (bridge, recipient int64)
source

MeterLevels is the bridge meter's level now and a recipient's, after refilling under the given epoch.

func Migrated

method on State
1func (s *State) Migrated() bool
source

Migrated is whether the lock went to a successor; every function refuses then.

func MustHaveImported

method on State
1func (s *State) MustHaveImported()
source

MustHaveImported is the gate on a message the router addressed to this route's predecessor (AQ1): hlmailbox lets a successor take such a message — the burns name the predecessor until kind 6 enrolls the successor — and this route credits it only once the predecessor's last page is in: before page 0 the lock is not here (the credit would be swept as one above the lock), and between pages Credit refuses anyway. The message waits undelivered meanwhile and the relayer brings it again; after the last page it is an ordinary credit, done once in the shared mailbox. A route that succeeded none refuses such a message for good.

func MustSend

method on State
1func (s *State) MustSend(predecessor string, env Env)
source

MustSend is the gate on a send, asked by the realm's TransferRemote before anything moves (R35, F28; AT7): a route that succeeds another takes no send before its predecessor's last page is in — the mirror of MustTake — nor before r/hlgov has dispatched the kind 6 enrolling it as the token's router on Solana (Env.Enrolled: the note the kind-6 closure leaves with the mailbox, cleared by a cancel). Before page 0 nothing has moved, so the migration may still be re-pointed (AR2) and this realm dropped: a send through it would lock the sender's coins in a realm Solana never enrols (kind 6 waits for page 0), which cannot refund them (its own send, never a refund's) and cannot migrate (a route no more) — stranded for good. Between pages the lock is only partly here and Credit refuses anyway; a send waits for the last page as a credit does. After the last page and before the kind 6, the token program refuses a sender that is not its enrolled router, so every send would park on Solana until a kind 6 lands — weeks under a hold, never if GovDAO cancels it — unrefundable as the route's own (§5.3: a live route's stranded send waits for a kind 12, since a refund voids nothing on Solana); with the note in, a send parks a week at most (the kind 6's own clock there; a hold defers it, the guardians' sends flag the brake). A launch route sends as it always did: the setup step enrolled it, and no kind 6 ever notes it.

func MustTake

method on State
1func (s *State) MustTake(toSelf bool, predecessor string)
source

MustTake is the gate on every incoming message, asked by the realm's Process before the mailbox is: toSelf is whether the message names this realm as its recipient, predecessor the route whose migrate registered this one (hlmailbox.Predecessor of the realm's own path, "" for a launch route). A route that succeeds another credits nothing before its predecessor's last page is in — a message addressed to itself included (R32, AR3): before page 0 the lock is not here, so an honest burn to the successor, which kind 6 may enroll the day the migrate applies, would be swept as one above the lock, owed and paying nobody until a sweep payment by vote — so every message waits undelivered meanwhile and the relayer brings it again. A message addressed to another realm is a predecessor's (MustHaveImported): taken once the last page is in, refused for good by a route that succeeded none. A launch route takes its own as it always did.

func RefundsPage

method on State
1func (s *State) RefundsPage(from int) string
source

RefundsPage is up to PageLines sends refunded here from the from-th on (from 0), by id, as a JSON array of SendJSON's objects: what the monitors read to drop a refunded send from what is in flight (AQ2); "[]" past the end.

func ResetMeters

method on State
1func (s *State) ResetMeters(now int64)
source

ResetMeters empties both meters as of now (the launch).

func RouterAccepts

method on State
1func (s *State) RouterAccepts(now int64, sender [32]byte) bool
source

RouterAccepts is whether a message from this sender is from the route's router: the current one, or the old one within the 7 days after a swap.

func Send

method on State
1func (s *State) Send(now int64, id string, from address, amount int64)
source

Send records an outgoing transfer that locked amount.

func SendJSON

method on State
1func (s *State) SendJSON(id string) string
source

SendJSON is one send by id — {"id","from","amount","at","imported","refunded","writtenOff"}: "refunded" the unix time it was, 0 if not, "writtenOff" the unix time it was written off as delivered on Solana after its refund (AR1), 0 if not, and "imported" whether a predecessor's page brought it (the only sends a refund may name, AQ2) — or "null".

func SendOf

method on State
1func (s *State) SendOf(id string) *Send
source

SendOf is the record of a send by id, or nil.

func Sends

method on State
1func (s *State) Sends() int
source

Sends is how many sends are recorded.

func SweepOf

method on State
1func (s *State) SweepOf(id string) *SweepEntry
source

SweepOf is a sweep entry by id, or nil.

func SweepsPage

method on State
1func (s *State) SweepsPage(from int) string
source

SweepsPage is up to PageLines sweep entries from the from-th on (from 0), by id, as a JSON array of {"id","swept"}; "[]" past the end.

func SweptOf

method on State
1func (s *State) SweptOf(id string) int64
source

SweptOf is the amount swept under an id (0 if none), voided or not.

type SweepEntry

struct
1type SweepEntry struct {
2	ID     string
3	Amount int64
4	Height int64
5	By     string
6	Voided bool
7}
source

SweepEntry is one entry of the sweep queue (§5.4): a credit that pays nobody until GovDAO directs it — a burn below the fee, to a realm or non-gno recipient, or above the lock — kept by id with the height it was credited at and who credited it, so a void names it by id or by range like a claim (R11): a forged entry is voided as forged (Voided: its amount leaves the sweep queue's balance and what is owed, so the identity closes) and restored after 7 days; a credit by id to its owner replaces it with a claim.

type SweepItem

struct
1type SweepItem struct {
2	ID     string
3	Amount int64
4	Height int64
5	By     string
6	Voided bool
7}
source

type VoidParams

struct
1type VoidParams struct {
2	IDs         []string
3	Ranged      bool
4	Range       Range
5	Forged      bool
6	UnpauseFns  []string
7	RemoveSeats []int
8	RemoveAddrs []address // the seats' holders when the proposal was made: a seat whose occupant changed is skipped (R17)
9}
source

VoidParams are a void's: the ids left to void (the at-once ones are gone from the list once applied) or, Ranged, the range of credits to void (closed at the height the proposal executed), and the unpause option's parameters — the functions whose flags to clear and the seats to vacate — applied in the executing transaction.

Dependencies

Source Files 2