On this page
  1. §0 The area in one paragraph
  2. 1. The survival field and the header survival
  3. 2. The longevity record, the interval, the period and the free window
  4. 3. FundLongevity (52)
  5. 4. CancelLongevity (53)
  6. 5. CloseLongevity (309)
  7. 6. Longevity rent
  8. 7. The longevity pool payout (per block, through the lottery)
  9. 8. The pruning horizon and what is pruned
  10. 9. Account rent and account pruning
  11. 10. Token persistence and expiry
  12. 11. Ledger rows and the consensus/local split

13 — Survival: account rent, paid longevity, token persistence and the pruning horizon

Edition 0.6.1 · verified against the reference implementation, version 0.6.1

Out of scope the fee floor and refund (04); dataset and stored-file rent and the DFS file refunds (10 §11–§12, 11 §4); the escrow rent (12 §3); token bodies and operations beyond persistence (14); account groups and the group record's weight (18); the reward distribution a survival payment and the longevity pool join (21); the snapshot document and fast sync (26); the block-level order of every step (22); survival MODE, the freeze of governance while too few distinct blocksmiths make blocks (19, 36), which is a different mechanism from the survival deposit of this chapter (only its retention floor in the prune is here, §8)

§0 The area in one paragraph

Nothing on this chain is kept for free beyond a fixed window. An account that holds a balance pays a fixed rent per snapshot cycle (out of its prepaid storage first, then its balance) or is tombstoned, and what it held goes to the longevity pool ZBCLONGV (ZBC is never burned); the genesis allocation counts as a first credit, so every funded genesis account is on the rent clock from block 0. A transaction is pruned from every node's database once it falls below the snapshot before the latest one, unless a longevity record attached to its id holds a deposit: anyone funds it with a FundLongevity, or the transaction opens its own record with the survival field of a version-2 or version-3 envelope; every payment is recorded in order, and rent per period is drawn from the deposit (the oldest money first) at the size and price captured when the record was opened, into the pool. The pool pays the nodes a slice every block through the coinbase lottery (longevity_continuous, 21). A record lives while anyone pays: the payers whose money is not yet used up each vote with a CloseLongevity, and the record closes, its remainder to the pool, when every one of them has voted, or when rent uses up the money of the last payer who had not. The type CancelLongevity is retired (refused). A token lives until its persist_height: a free period at issue plus whatever its explicit survival payments buy; past it the token is invisible to every reader, and the next block pays its remaining backing to the accounts that held its units; a token with no expiry (every genesis coin) can never be given one. The pruning horizon and the free windows derive from the chain's snapshot interval, so the two can never drift apart; the horizon is a pure function of the height (escrow_horizon_pure, §8), transaction rows are kept at least 25 hours, and the prune deletes nothing a snapshot of that height would carry. Every record, clock and balance here is consensus state; what each node physically deletes is local but bounded by the same horizon.

1. The survival field and the header survival

Purpose. A version-2 transaction's own longevity deposit.

Inputs. The envelope's version and survival (8 bytes after the fee, 03 §1).

Output and effect. Version 1 carries no field and must report survival 0. Version 2, and version 3 (which adds the stated expiry of 03 §4 under tx_expiry_field), are accepted from survival_field; survival ≥ 0 and, when > 0, ≥ 10,000,000 (LONGEVITY_MIN_DEPOSIT, 0.1 ZBC). The amount is reserved at admission with the fee and spent after the type's fee settlement (08 §1 step 11): sender −survival (an unaffordable debit does nothing and the transaction stands); then the record for tx.id is opened: sponsor = owner = the canonical account that holds the sender's balance, deposit = funded_total = survival, payload_bytes = |body| + |message| (at least 1), cost_per_mib_locked = dataset_storage_cost_per_mib now (default 100,000,000), free_until_height = this height + 2 × interval (§2), paid_through_height = the same; a funder row for the account; a deposit row (§2) for the account with the amount the record received (all of it, unless the deposit would overflow i64); a ledger row event 37 for −survival. A record that already exists for the id (impossible for a fresh id) is topped up by the rules of §3. A failed insert returns the money.

How to compute it. As stated.

Rule activation. survival_field (height 0).

Rejections and errors. "A version-1 transaction carries no survival; use transaction version 2", "Survival must not be negative", "Survival below the minimum deposit of 10000000 units (0 means none)", "Invalid transaction version"; for version 3 also 03 §4's expiry refusals; a carrier transaction signed by a foreign key (Ethereum, Solana or Bitcoin, 02) with survival ≠ 0: "A foreign-signed carrier transaction cannot carry survival (the foreign signature does not cover it); fund it with FundLongevity instead". All are refused at admission and make a block invalid.

Vector. computed (TestNet prices: dataset_storage_cost_per_mib 5,000,000, interval 172,800).

  • Input: a version-2 CreateApp (type 24) of the sender 00000000B6675786BEDF28B3E7DCD8BAC9BF99758B3A64604570BFFD12FD10CBF20B39EA, body 12 0000000000000000 00CA9A3B00000000 01 0300 010001 00 (24 bytes), message empty, survival 10,000,000, mined at height 11,877, its id 5,331,875,765,163,016,418 (the LE i64 of the first 8 bytes of its hash, E2400E49C2A0FE49…).
  • Expected output: the sender −10,000,000 after its fee settlement, ledger row event 37 −10,000,000; longevity row for target 5,331,875,765,163,016,418: deposit = funded_total = 10,000,000, payload_bytes 24, cost_per_mib_locked 5,000,000, free_until_height = paid_through_height = 11,877 + 2 × 172,800 = 357,477, sponsor = owner = the sender; longevity_funder row (target, sender) total 10,000,000; longevity_deposit row (target, seq 0) payer = the sender, amount 10,000,000.
  • Invalid input: the same transaction with survival 9,999,999 → refused at admission and makes a block invalid: "Survival below the minimum deposit of 10000000 units (0 means none)"; as a version-1 transaction with survival 10,000,000 → "A version-1 transaction carries no survival; use transaction version 2".
  • computed (the view): on a chain with no live record GET /api/v1/longevity at height 12,467 answers {"chain_height":12467,"billing_period_blocks":172800,"count":0,"longevity":[]}.

Test cases · §1

6 cases · 2 valid · 4 invalid · 1 reference

A version-2 CreateApp with a survival of 0.1 ZBC opens a longevity record13-1-recordvalid

Loading the test widget…

A survival of 9,999,999 is below the minimum deposit13-1-below-minimuminvalid

Loading the test widget…

A version-1 transaction cannot carry a survival13-1-version-1invalid

Loading the test widget…

A negative survival is refused13-1-negativeinvalid

Loading the test widget…

Version 4 is not a transaction version13-1-bad-versioninvalid

Loading the test widget…

The longevity view of a chain with no live record, at height 12,46713-1-view-emptyvalidreference

A stated value: there is nothing to compute. A compatible node shows the same value.

value
{"chain_height":12467,"billing_period_blocks":172800,"count":0,"longevity":[]}

Defects to match. A version-2 transaction whose survival is unaffordable at execution is still mined and pays nothing for survival.

2. The longevity record, the interval, the period and the free window

Purpose. The state object and the three clocks every mechanism here shares.

Inputs. main_snapshot_interval, longevity_billing_period_blocks, dataset_storage_cost_per_mib (consensus parameters); the genesis flag is_test_chain.

Output and effect. longevity(target_tx_id, sponsor_address, deposit, paid_through_height, payload_bytes, cost_per_mib_locked, free_until_height, block_height, latest, owner_address, funded_total), key target_tx_id, versioned (07 §2); longevity_funder(target_tx_id, funder_address, total, block_height, latest), key (target, funder). Addresses are stored canonical; owner_address is recorded but decides nothing (closing is the payers' vote, §5). A record is live while deposit > 0. Types: target_tx_id signed 64-bit (the target's id); addresses are typed account bytes (01); deposit, funded_total, total, amount, cost_per_mib_locked signed 64-bit; payload_bytes signed 64-bit; every height unsigned 32-bit; latest 0/1. Versioning (07 §2): a change writes a new row at the block's height with latest 1 and sets latest 0 on the key's previous row; "the record" is the row of the key with latest 1; a rollback to height H deletes every row above H and marks the newest remaining row of each key latest 1. The rent step selects live records by (free_until_height, paid_through_height) and processes them in ascending target_tx_id.

Two more versioned tables:

  • longevity_deposit(target_tx_id, seq, payer_address, amount, block_height, latest), key (target, seq): one row per payment into the record (header survival, FundLongevity), seq from 0 per record (MAX(seq) + 1), payer_address = the canonical account that holds the paying address's balance (its group for a member), amount = what the record received. A row is written once and never changed.
  • longevity_vote(target_tx_id, voter_address, voted, block_height, latest), key (target, voter): a payer's standing vote to close, voted 1 when cast, 0 when a top-up withdraws it (each change a new version).

Each payer's unused money (first in, first out). Over the deposit rows in seq order and left = the record's deposit: consumed = max(0, Σ amount − max(left, 0)) (sums in 128-bit, saturating at 2⁶³−1); walk the rows, each row consumes min(amount, consumed) and lowers consumed by it; per payer (in the order of its first row) paid = Σ its amounts, unconsumed = Σ (amount − used). When left exceeds everything paid in, nothing counts as used and the excess has no payer (no record reaches that state: every payment into a record writes its row). A payer voted when its newest longevity_vote row has voted = 1. The longevity_funder totals are kept beside the rows (the same money, counted twice in state).

All four tables are in the snapshot set (26 §2: longevity, longevity_funder, longevity_deposit, longevity_vote) and are rolled back with a popped block.

Clock Definition TestNet DevNet
interval main_snapshot_interval when > 0, else the compiled 1,440 (is_test_chain) or 172,800 172,800 240
period longevity_billing_period_blocks when > 0 (no live genesis sets it), else the interval, else 5,760 172,800 240
free window from + 2 × interval (u32-capped), from = the target's height, or the block of a header survival 345,600 blocks 480 blocks
first-funding window target_height < h and h − target_height < interval — —

How to compute it. As stated; FirstFundingLastHeight = target_height + interval − 1.

Mainnet's columns are TestNet's.

Rule activation. None.

Rejections and errors. None.

Vector. computed (the first-in-first-out shares, amounts in units of 10,000,000).

  • Input: deposit rows seq 0 creator 10, seq 1 B 5, seq 2 C 5, seq 3 creator 5 (Σ 25); the record's deposit (left) = 10.
  • Expected output: consumed = 25 − 10 = 15, taken from seq 0 (10) and seq 1 (5); payers in order of first row: creator paid 15, unconsumed 5; B paid 5, unconsumed 0; C paid 5, unconsumed 5.

computed (TestNet parameters; GET /api/v1/longevity/quote?target=E2400E49C2A0FE4930D7DD1B457C87AFB1EF7D427D3FB999302BCC75CED14603 asked at height 12,468):

  • Input: the target hash above (the CreateApp of §1: mined at 11,877 with a 24-byte body and no message, no record).
  • Expected output: target_tx_id "5331875765163016418", target_height 11,877, payload_bytes 24, price_now 5,000,000, billing_period_blocks 172,800, first_funding_last_height 184,676 (= 11,877 + 172,800 − 1), existing.funded false, existing.free_until_height 357,477 (= 11,877 + 2 × 172,800); for the default amount 10,000,000: after.rent_per_period 115, after.periods_remaining 86,957.
  • Invalid input: GET /api/v1/longevity/quote without target → HTTP 400, {"success":false,"error":"target is required: a transaction id or its 64-hex hash","code":400}.

Test cases · §2

3 cases · 2 valid · 1 invalid · 1 reference

Four payments, ten units left: who still has money on the record13-2-fifovalid

Loading the test widget…

The quote for funding a 24-byte CreateApp mined at 11,877 with 0.1 ZBC13-2-quotevalid

Loading the test widget…

A quote without a target is refused with HTTP 40013-2-quote-no-targetinvalidreference

A stated value: there is nothing to compute. The statement is a refusal: what a compatible node does with this input.

value
{"success":false,"error":"target is required: a transaction id or its 64-hex hash","code":400}

Defects to match. None.

3. FundLongevity (52)

Purpose. Open or top up a record for any transaction.

Inputs. Body, exactly 28 bytes:

Offset Length Field Encoding
0 8 target_tx_id i64 LE
8 8 amount i64 LE, ≥ 10,000,000
16 4 target_height u32 LE, the block the target is in
20 8 target_bytes i64 LE ≥ 1, the target's |body| + |message|

Output and effect. Sender −(amount + fee); rows event 37 for −amount and event 1 for −fee; then 04 §5. The record:

  • first funding (no live record with payload_bytes > 0): the stated height and size must pass the window of §2 and equal the target's row (block_height, |body| + |message|), else a paid no-op; the record gets sponsor = sender, deposit = amount, payload_bytes = target_bytes, price = dataset_storage_cost_per_mib now, free_until = target_height + 2 × interval, paid_through = free_until; the owner = the canonical holder of the target's sender and funded_total = amount;
  • top-up: target_bytes must equal the record's payload_bytes (else a paid no-op); sponsor, owner, size and window unchanged; deposit += amount (an overflow leaves it unchanged); paid_through unchanged; price = floor((deposit × old_price + amount × now_price) / (deposit + amount)) in 128-bit, at least 1; funded_total += amount (saturating).
  • Either way the sender's funder row total += amount, and a deposit row (§2) is added for the sender's canonical balance holder with added = new deposit − old deposit (the whole amount, 0 on an overflow, then no row). When that payer has a standing vote on the record, the row withdraws it (a new longevity_vote version with voted 0): a payer who tops up wants the record kept. A payer new to the record has no vote and must vote too for the record to close.

How to compute it. Stateless: the size ("FundLongevity body must be exactly 28 bytes (target id, amount, target height, target bytes)"), amount ≥ 10,000,000 ("FundLongevity deposit is below the minimum"), target_bytes ≥ 1. Admission mirrors: the same window and match tests judged at the next height ("FundLongevity: stated target size S does not match the funded record (R)", "FundLongevity: …" with the problem text below), and amount + fee affordable. Execution: the stated checks first (a failure keeps only the fee); the debit (unaffordable → paid no-op, rule state_answer_noop); the record write.

Problem texts: "stated target size must be at least 1 byte", "stated target height H is not below this block (B)", "the target is not younger than one snapshot interval (I blocks); a first funding must come before height H+I", "the target transaction does not exist on this chain", "stated target height H but the target is at X", "stated target size S bytes but the target is N".

Rule activation. longevity_stated_target, survival_field, uniform_fee_refund, state_answer_noop (height 0).

Rejections and errors. As listed; "deposit + fee overflow" (block invalid).

Vector. computed (TestNet; the target of §2's quote).

  • Input: FundLongevity (type 52) at height 12,500 by any account P with spendable ≥ 10,000,000 + fee, body (28 bytes) E2400E49C2A0FE49 8096980000000000 652E0000 1800000000000000 = target 5,331,875,765,163,016,418 (its LE bytes are the first 8 bytes of the target's hash), amount 10,000,000, target_height 11,877, target_bytes 24; no record exists for the target.
  • Expected output: P −(10,000,000 + fee), rows event 37 −10,000,000 and event 1 −fee; longevity row: sponsor P, owner = the CreateApp's sender, deposit = funded_total = 10,000,000, payload_bytes 24, cost_per_mib_locked 5,000,000, free_until_height = paid_through_height = 357,477; longevity_funder (target, P) total 10,000,000; longevity_deposit (target, 0) payer P, amount 10,000,000. Its rent will be ceil(24 × 5,000,000 / 1,048,576) = 115 per period.
  • Invalid input: the same body with target_bytes 23 (…1700000000000000) → refused at admission: "FundLongevity: stated target size 23 bytes but the target is 24"; mined, a paid no-op. The same body at height 184,677 → "FundLongevity: the target is not younger than one snapshot interval (172800 blocks); a first funding must come before height 184677". Amount 9,999,999 → "FundLongevity deposit is below the minimum" (stateless: makes a block invalid). A 16-byte body → "FundLongevity body must be exactly 28 bytes (target id, amount, target height, target bytes)".

Test cases · §3

5 cases · 1 valid · 4 invalid

A first FundLongevity of 0.1 ZBC for the CreateApp of 11,87713-3-firstvalid

Loading the test widget…

A stated size of 23 bytes does not match the 24-byte target13-3-wrong-sizeinvalid

Loading the test widget…

A first funding one snapshot interval after the target is too late13-3-too-lateinvalid

Loading the test widget…

An amount of 9,999,999 is below the minimum deposit13-3-below-minimuminvalid

Loading the test widget…

A 16-byte FundLongevity body is refused13-3-short-bodyinvalid

Loading the test widget…

Defects to match. The target's sender is read from the local transaction table at first funding; the window guarantees every node still holds it.

4. CancelLongevity (53)

Purpose. The retired sponsor cancellation.

Inputs. Body: target_tx_id (8, i64 LE).

Output and effect. The type is retired: admission refuses it and a block carrying it is invalid (the retired-type check runs before any body check), and the executor, if ever reached, keeps only the fee. No CancelLongevity is valid on any chain. Nothing paid into a record is ever returned to a payer.

How to compute it. The retired-type check (03 §2): the type maps to the retiring rule survival_field; from that rule's height the type is refused.

Rule activation. survival_field (height 0) retires it.

Rejections and errors. "Transaction type 53 is retired from height 0" (the retirement refusal of 03 §2): refused at admission, makes a block invalid.

Vector. computed.

  • Input: any CancelLongevity (type 53), body E2400E49C2A0FE49.
  • Expected output: refused at admission and makes a block invalid: "Transaction type 53 is retired from height 0".

Test cases · §4

1 case · 1 invalid

CancelLongevity is retired13-4-retiredinvalid

Loading the test widget…

Defects to match. None.

5. CloseLongevity (309)

Purpose. One payer's vote to close a record; the record closes when every payer with money left on it has voted.

Inputs. Body, exactly 8 bytes: target_tx_id (i64 LE). The record, its deposit rows and its votes (§2).

Output and effect. Fee first (charged as in 04 §5; a sender who cannot cover it writes nothing and the generic path books the fee as not collected). Then, with me = the canonical balance holder of the sender (its group when it is a member), the sender's slots are the payers of the record with unconsumed > 0 and a non-empty payer whose own canonical balance holder is me (the payer itself, or an address that paid alone and has since joined me's group):

  1. no live record (deposit ≤ 0 or none) → paid no-op;
  2. no slot without a standing vote → paid no-op (nothing written beyond the fee);
  3. a vote row (voted 1, new version) for every such slot, so one transaction votes for every payer the sender's account speaks for;
  4. the record closes when it still holds money, every payer with unconsumed > 0 has a non-empty payer and a standing vote, at least one such payer exists, and the payers' unconsumed parts sum to exactly the deposit (money the record holds beyond its rows has no voter, so such a record never closes by vote and runs out instead; no record has any, §2). Then: deposit = 0 (new version, the transaction rejoins ordinary pruning) and the whole remainder is credited to the pool (a plain credit to ZBCLONGV, row event 50 on the pool, transaction_id = this transaction). Nobody is paid back. Otherwise the vote stands and the record lives.

A payer whose money is used up has no vote; a payer who lost its key keeps the record alive until rent uses up its money (then §6 closes it, when everyone else has voted). The record's sender or owner has no say unless it paid. Then 04 §5.

How to compute it. Stateless: the size ("CloseLongevity body must be exactly 8 bytes"). Admission (the executor's three answers, refused up front): a live record ("CloseLongevity: nothing is funded for that transaction"), at least one slot ("CloseLongevity: only an account whose money on the record is not used up yet votes to close it"), at least one slot without a standing vote ("CloseLongevity: your vote to close this record is already counted").

Rule activation. The type exists from survival_field (height 0). The vote has no rule of its own.

Rejections and errors. As listed; every one is a paid no-op when mined.

Vector. computed (the record of §2's first vector, left = 10 units of 10,000,000; body = the target id, 8 bytes LE, e.g. E2400E49C2A0FE49 for the record of §3).

  • Input 1: B's CloseLongevity. Expected: refused at admission "CloseLongevity: only an account whose money on the record is not used up yet votes to close it"; mined, a paid no-op.
  • Input 2: the creator's CloseLongevity. Expected: fee charged, longevity_vote (target, creator) voted 1; the record stays live (C has not voted).
  • Input 3: the creator's second CloseLongevity. Expected: refused at admission "CloseLongevity: your vote to close this record is already counted".
  • Input 4: C's CloseLongevity. Expected: longevity_vote (target, C) voted 1; unconsumed 5 + 5 = 10 = deposit, so the record closes: deposit 0 (new version), the pool +100,000,000 with row event 50, transaction_id = C's transaction.
  • Input 5: a CloseLongevity for a target with no live record. Expected: "CloseLongevity: nothing is funded for that transaction"; a 9-byte body → "CloseLongevity body must be exactly 8 bytes" (makes a block invalid).

Test cases · §5

6 cases · 2 valid · 4 invalid

B's money is used up, so B has no vote13-5-b-no-moneyinvalid

Loading the test widget…

The creator votes; C has not voted, so the record lives13-5-creator-votesvalid

Loading the test widget…

The creator's second vote is already counted13-5-creator-againinvalid

Loading the test widget…

C's vote is the last one: the record closes and the pool receives the rest13-5-c-closesvalid

Loading the test widget…

A CloseLongevity for a record with no deposit13-5-nothing-fundedinvalid

Loading the test widget…

A 9-byte CloseLongevity body is refused13-5-body-9invalid

Loading the test widget…

Defects to match. Nothing paid into a record ever returns to a payer. A group member cannot vote or be refunded apart from its group (the payer is the balance holder).

6. Longevity rent

Purpose. What a live record pays per period, and when.

Inputs. The live records; the period of §2; the block.

Output and effect. Every block (after the stored-file rent, before the payout of §7): the records with deposit > 0, free_until_height < height and paid_through_height ≤ height − period, in ascending target_tx_id: rent = 1 when payload_bytes ≤ 0 or the locked price ≤ 0, else ceil(payload_bytes × price / 1,048,576) (a product that overflows i64 saturates; never below 1); take = min(rent, deposit); deposit −= take; paid_through_height = this height. Then when the record still holds money and the close test of §5 step 4 now passes (rent used up the money of the last payer that had not voted), the record closes: the rest of its deposit is credited to the pool with a row event 50 (transaction_id 0, the block's timestamp) and deposit = 0. A new version either way; a record at 0 is released (its transaction is prunable again). The sum taken as rent this block is credited to the pool 00000000 ‖ "ZBCLONGV" ‖ 24 × 0x00 by a plain credit with one row event 38 (transaction_id 0, the block's timestamp), after every record is written.

How to compute it. As stated; the rounding of the HTTP quote (/api/v1/longevity/quote, extended floating point) yields the same integer for realistic sizes.

Rent writes nothing to the deposit rows: which payer it used is arithmetic over the rows and the new deposit (§2).

Rule activation. None.

Rejections and errors. None.

Vector. computed.

  • Input: DevNet (price 100,000,000, interval = period 240); a record of 43 payload bytes opened at height 432 with deposit 100,000,000, free_until_height = paid_through_height = 912.
  • Expected output: rent = ceil(43 × 10⁸ / 1,048,576) = ceil(4,100.8) = 4,101; billed at 1,152 (the first h with 912 < h and 912 ≤ h − 240), then 1,392, 1,632, …; at each billing deposit −4,101, paid_through_height = h, the pool +4,101 (event 38); after 185 billings deposit = 100,000,000 − 185 × 4,101 = 99,241,315.
  • Input (the close at billing): rent 4,101; deposit rows A 4,101 (seq 0), B 4,101 (seq 1); deposit 8,202; B has voted, A has not. Expected: the billing takes 4,101 (deposit 4,101), consumed uses up A's row; the only payer with money is B, who voted, so the record closes in the same block: the pool +4,101 event 38 and +4,101 event 50 (transaction_id 0), deposit 0. With A voted and B not: only the rent is taken; the record lives.
  • computed (the quote of §2): rent_per_period 115 = ceil(24 × 5,000,000 / 1,048,576), periods_remaining 86,957 = ceil(10,000,000 / 115).

Test cases · §6

4 cases · 4 valid

A 43-byte record on DevNet after 185 billings13-6-devnet-185valid

Loading the test widget…

The billing uses up A's money; B has voted, so the record closes13-6-close-at-billingvalid

Loading the test widget…

The billing uses up A's money; A voted but B has not, so the record lives13-6-live-at-billingvalid

Loading the test widget…

The TestNet quote's rent and periods13-6-quotevalid

Loading the test widget…

Defects to match. (1) The size and price are frozen at first funding: a later vote on dataset_storage_cost_per_mib changes new records only. (2) A record whose deposit is smaller than one rent still buys a whole period.

7. The longevity pool payout (per block, through the lottery)

Purpose. Paying the nodes that keep the funded data: the pool pays a slice every block through the coinbase lottery (longevity_continuous, 21); the per-period payout step does nothing.

Inputs. The pool's spendable balance; the active registry with scores; the period of §2; who earns (the income view as of the block, 09 §12: not missing, not suspended, mature).

Output and effect. Under rule longevity_continuous (height 0) the per-period payout step does nothing, and the pool is drawn down a slice per block by the coinbase lottery (21 §2): every block above 1 takes slice = floor(pool balance / (period − (height mod period))) (integer division; nothing when the pool is smaller than the blocks left) into the lottery's distributable amount, with one row event 39 (−slice) on the pool; the winners' side is the lottery's own reward row (21). The pool has two more outflows: the archive reward of each storage epoch (snapshot_reward_share_ppm 100,000 = 10 % of the pool, event 77, 11/26) and nothing else.

How to compute it. As stated.

Rule activation. longevity_continuous (height 0).

Rejections and errors. None.

Vector. computed (TestNet, period 172,800).

  • Input: the pool ZBCLONGV holds 1,000,000 at the start of block 12,467.
  • Expected output: slice = floor(1,000,000 / (172,800 − 12,467 mod 172,800)) = floor(1,000,000 / 160,333) = 6; the pool −6 (row event 39); the lottery distributes 6 more.
  • Input: the pool holds 100,000 at height 12,467. Expected: floor(100,000 / 160,333) = 0, nothing moves; a pool that has received nothing since block 0 (the pool's address is 000000005A42434C4F4E4756000000000000000000000000000000000000000000000000) shows balance 0 and an empty /movements.

Test cases · §7

3 cases · 3 valid · 1 reference

A pool of 1,000,000 at block 12,467 pays a slice of 613-7-slicevalid

Loading the test widget…

A pool of 100,000 at block 12,467 pays nothing13-7-too-smallvalid

Loading the test widget…

A pool that has received nothing since block 0 shows balance 0 and no movements13-7-pool-emptyvalidreference

A stated value: there is nothing to compute. A compatible node shows the same value.

address
000000005A42434C4F4E4756000000000000000000000000000000000000000000000000
balance
0
movements
[]

Defects to match. None.

8. The pruning horizon and what is pruned

Purpose. Which history every node is allowed to delete, and the one exception money buys.

Inputs. The stored spine manifests (25 §4), main_snapshot_interval, main_snapshot_min_height (the snapshot depth: TestNet 760; DevNet 80), batch_receipt_lookback_height (40), receipt_lifecycle (TestNet 518,400; DevNet 1,440), max_rollback_height (TestNet 720; DevNet 60; compiled 720), min_block_interval (15), the registered nodes, the live longevity records; the stored survival flags (19: one row per height, the flag the block at that height was judged by) and the unresolved oracle events with their attestations (17 §4, §6; 34). Mainnet's values are TestNet's.

Output and effect. After every block's other steps, unless the node keeps all history (a local switch). The horizons (one definition, which the prune and the snapshot share, so the snapshot of height S leaves out exactly what the prune at S deletes, 26 §2). The age of a row at h is h − its height − the survival heights in (its height, h] (the heights whose stored survival flag is on do not count: a frozen chain does not spend a window); the idle age of an event is the age of its newest current attestation:

Name Value
lifecycle max(max(100, 2 × registered nodes) + 1, receipt_lifecycle); registered = rows with status 0, latest
receipt h − lifecycle, 0 when h ≤ lifecycle (then sections 3 and 4 below do not run, and none of the rows below is deleted)
floor (versioned, skipped) min(receipt, h − max_rollback_height)
fee_vote min(receipt, h − (cycle + max_rollback_height)), cycle = the snapshot cycle (17)
governance the vote-window start of h over cycle + max_rollback_height
release_keep RELEASE_VOTE_WINDOW_BLOCKS 172,800 + max_rollback_height (TestNet 173,520; DevNet 172,860)
release h − release_keep, 0 when not positive
survival_from h − (max_rollback_height + 120) + 1, 1 when not positive: the survival rows a rollback inside the depth and the flag of the next block (its 120-block window, 19) can still need
survival_pending the lowest of: for every unresolved event that is neither a parameter vote (ZBCGOV1:) nor a release vote (ZBCREL1:) and whose idle age ≤ 720 (BRIDGE_EVENT_IDLE_WINDOW), the height of its newest current attestation; for the unresolved release votes whose age ≤ release_keep, the lowest vote height; none → no bound
  • horizon = the older of the two most recent distinct manifest reference heights (main chain), or the only one minus the interval; 0 (nothing pruned) without a manifest. The manifest rows are never deleted (a node deletes only its local copies of old snapshots, the record of each snapshot stays; 26 §9), so after two snapshots both heights are always present. Under escrow_horizon_pure (height 0) it is clamped never to exceed the pure PruneHorizon(h) = (h div interval) × interval − interval (0 when either multiple is below main_snapshot_min_height or not positive), the number the escrow release of 12 §5 uses.
  • bound (blocks) = min(horizon, tip − max(2 × lookback + 20, 1,440), ref − 1,440) (1,440 = MIN_ROLLBACK_BLOCKS = SIGNAL_WINDOW_MAX_BLOCKS), when horizon > 0, with ref = the newest snapshot's reference height (below; the last clamp only when ref > 0): the readiness tally reads at most the 1,440 headers below a height and the snapshot of ref carries them (29, 26), so the block headers that snapshot reads are kept until it is built.
  • tx_bound (transactions) = min(bound, tip − R, W) where R = the replay window = ceil(90,000 / max(1, min_block_interval − 2)) = 6,924 blocks at 15 s (a transaction stays valid in a block for 25 h, TRANSACTION_EXPIRY_CAP 86,400 + TRANSACTION_FUTURE_TOLERANCE 3,600, counted at the fastest legal pace), and W = the first block of the newest snapshot's RecentTransactions window: with ref = NewestSnapshotHeight(h) − depth (the newest snapshot's reference, 0 when none), W = ref − max(R, interval + depth), at least 1 (26 §2).
  • At most 500 rows (PRUNING_CHUNKED_SIZE) per statement per block: blocks with 0 < height < bound are deleted except a block carrying a transaction with a live record or one funded as of ref (below); transactions with block_height < tx_bound are deleted except those with a live record or funded as of ref (rule snapshot_funded_transactions: the newest version at or below ref has deposit > 0), so the snapshot being built still finds them; ledger rows below the horizon are deleted. Block 0 is never deleted.
  • Receipts: published receipts below min(receipt, the highest stored spine reference height); node receipts and merkle trees below receipt.
  • Superseded versions (latest 0) of participation_score, node_registry, account_balance, node_liveness and queue_state (no chunk limit): a version goes only when it is below floor and a newer version of its key sits at or below floor, so no rollback inside max_rollback_height ever finds a key without a row. score_unit_clock rows below receipt; queue_attendance rows below receipt two windows below the last evaluated window (09 §9).
  • skipped_blocksmith below floor (chunked); spine skipped rows, the score ledger and the registry ledger below receipt; fee-vote commitments and reveals below fee_vote; executed MultiSignature envelopes whose execution is below floor go whole (one statement), superseded envelope versions by the floor rule above, and signatures of an envelope whose newest version at or below floor is not pending (12 §10).
  • Oracle attestations (every version of a row, 17 §10), in three statements: the rows of events that are neither parameter nor release votes, below receipt, except every row of an unresolved event whose idle age ≤ 720 (its resolution is frozen while the chain is in survival mode, and it stays resolvable for 720 unfrozen blocks after its last attestation, 17 §4, 34); parameter-vote rows (ZBCGOV1:) below governance; release-vote rows (ZBCREL1:) of a resolved event below release, and of an unresolved event once the row's age exceeds release_keep (a vote counts for 172,800 unfrozen blocks and a reorg may recount it, 17 §6).
  • Survival flags (survival_state, chunked): rows below survival_from and below survival_pending, so the flags that any kept pending event's age or idle age is computed over are kept with it (the same rows the snapshot carries, 26 §2).

How to compute it. As stated; each condition is a predicate over the table's own columns.

Rule activation. escrow_horizon_pure, snapshot_funded_transactions, attendance_tail, readiness_registry_schedule (the ref − 1,440 clamp), survival_mode (the ages, the survival rows and the two exceptions above), all active from height 0 on every chain.

Rejections and errors. None; a failed delete is logged.

Vector. computed.

  • Input: TestNet (interval 172,800, depth 760, rollback 720, lifecycle 518,400, min_block_interval 15), manifests stored at the reference heights 172,040 and 344,840, h = 360,000.
  • Expected output: horizon 172,040 (the pure 345,600 − 172,800 = 172,800 does not bind); ref = 345,600 − 760 = 344,840; bound = min(172,040, 360,000 − 1,440, 344,840 − 1,440) = 172,040; R = ceil(90,000 / 13) = 6,924; W = 344,840 − max(6,924, 173,560) = 171,280; tx_bound = min(172,040, 353,076, 171,280) = 171,280; receipt = 0 (h ≤ 518,400): no versioned row, attestation or survival flag is pruned.
  • Input: DevNet (interval 240, depth 80, rollback 60, lifecycle 1,440), manifests at 1,600 and 1,840, h = 2,000, no unresolved oracle event.
  • Expected output: horizon 1,600; ref = 1,920 − 80 = 1,840; bound = min(1,600, 2,000 − 1,440, 1,840 − 1,440) = 400; h − 6,924 < 0, so tx_bound = 0 (no transaction row goes until height 6,925); receipt = 2,000 − 1,440 = 560; floor = min(560, 1,940) = 560; release_keep 172,860, release 0; survival_from = 2,000 − 180 + 1 = 1,821, no survival_pending bound: the survival flags of heights 1 … 1,820 are deleted (500 per block), those from 1,821 stay.
  • Input: the same DevNet chain in survival mode from height 600 to 1,900 (1,301 heights with the flag on) with an unresolved generic event whose newest attestation is at 500. Expected: its idle age at 2,000 = 2,000 − 500 − 1,301 = 199 ≤ 720, so its attestation rows stay although 500 < 560 (receipt), and survival_pending = 500 keeps the flags from 500 on (not only from 1,821). A release vote cast at 500 on that chain has age 199 at 2,000 and still counts (17 §6). Without the survival heights the same event would be 1,500 blocks idle and its rows would go.

Test cases · §8

4 cases · 4 valid

TestNet at height 360,000 with manifests at 172,040 and 344,84013-8-testnetvalid

Loading the test widget…

DevNet at height 2,000 with manifests at 1,600 and 1,84013-8-devnetvalid

Loading the test widget…

DevNet in survival mode from 600 to 1,900: an event last attested at 500 is 199 blocks idle and stays13-8-survivalvalid

Loading the test widget…

Without the survival heights the same event is 1,500 blocks idle and its rows go13-8-survival-nonevalid

Loading the test widget…

Defects to match. (1) The escrow release of 12 §5 runs before this step, so no pending escrow is ever stranded by it. (2) A node that keeps all history is still bound by the same rules for consensus; the difference is only what it can serve. (3) Below tx_bound and above bound nothing is deleted from the transaction table, but the block headers below bound are: a node can hold transactions whose block it no longer holds (I think harmless, as the transaction row carries its height).

9. Account rent and account pruning

Purpose. The fixed rent every funded account pays to the pool, and the tombstone for one that cannot.

Inputs. account_rent_period_cost (TestNet 1,000,000; DevNet 100,000,000; compiled 100,000,000; governable from 1 atomic unit to the 10 ZBC per-period ceiling of governance_window, 17); the period = the snapshot cycle, main_snapshot_interval when > 0, else 172,800, at least 2 (TestNet 172,800; DevNet 240; there is no account_rent_period_blocks, and the genesis builder refuses one that differs from the interval); the account rows' rent_due_height, balance and prepaid_storage_balance; the genesis account rows.

Output and effect. The rent-exempt set is the three system pools ZBCLONGV, ZBCSTORE, ZBCCARRY, the apps pool ZBCAPPS and every address of account type 10 (ZBS_ deposit addresses); nothing in it is ever armed, billed or pruned. The clock of any other account arms, setting rent_due_height = height + period, at whichever comes first:

  1. the genesis allocation (rule genesis_rent_clock): after every account row of the genesis is written, the genesis builder reads every current account_balance row with rent_due_height 0 and balance > 0, in ascending account_address order (bytewise), and skips an address in the rent-exempt set and a group member whose balance holder is another account; every other row gets rent_due_height = 0 + period and block_height 0. So at height 0 every funded genesis account (the treasury, the release authority, node owners, test accounts) is due at height period (TestNet 172,800; DevNet 240), and a genesis account with balance 0 stays unarmed;
  2. the first credit of a positive balance to a row whose rent_due_height is 0 (07 §3);
  3. the account's first spend (nonce 0 → 1) when it is not a group member.

Every block (after the token expiry of §10, before the triggers of 08): the current rows with 0 < rent_due_height ≤ height, ordered by (rent_due_height, address), at most 2,000 per block (ACCOUNT_RENT_MAX_PER_BLOCK), excluding the rent-exempt set and group members (a selected row that is either is skipped, and it still counts toward the 2,000 read); for each: cost = the period cost, plus, for a group account, CalculateStorageFee(group record weight, cost_per_mib, ppm) (10 §12, 18). The account pays when prepaid ≥ cost or balance ≥ cost − prepaid (prepaid floored at 0): from_prepaid = min(prepaid, cost), from_balance = cost − from_prepaid; prepaid −from_prepaid, balance −from_balance, spendable −from_balance clamped at 0; rent_due_height advanced by whole periods until it exceeds this height; rows on the account event 83 for +from_prepaid (only when > 0) and event 24 for −cost (so its rows sum to its balance's movement); cost credited to the pool (a plain credit, row event 19 on ZBCLONGV). Else the account is pruned: a tombstone version with balance, spendable, prepaid storage, pop revenue, nonce and rent clock all 0, its split policy cleared and, for a group account, the group dissolved (18); rows on the account event 83 for +prepaid (only when > 0: the prepaid storage moves out of it) and event 25 for −(balance + prepaid) (everything that left the account; the rows sum to its balance's movement); balance + prepaid credited to the pool (row event 50, transaction_id 0, equal to the event-25 amount). ZBC is never burned: the dust and the prepaid storage go to the pool.

How to compute it. As stated; the due list is read first, then each row is re-read for its prepaid storage.

Rule activation. genesis_rent_clock (height 0): the genesis arming of step 1. The rule's table default is 0, so a genesis that omits the key is armed by the builder too. A genesis that lists it at a height H > 0 leaves the genesis rows unarmed, and the block at height H arms them once, with the same selection, due H + period, before that block's sweep; no live chain does this.

Rejections and errors. None.

Vector. computed (TestNet, cost 1,000,000, period 172,800).

  • Input: an account due at 172,800 with balance 600,000 and prepaid storage 500,000.
  • Expected output: it pays: from_prepaid 500,000, from_balance 500,000; rows event 83 +500,000 and event 24 −1,000,000 on the account; the pool +1,000,000 (event 19); balance 100,000, prepaid 0, rent_due_height 345,600.
  • Input: the same account at 345,600 (balance 100,000, prepaid 0). Expected: tombstoned (balance, spendable, prepaid, pop revenue, nonce, rent_due_height all 0); row event 25 −100,000; the pool +100,000 (event 50).
  • Input: balance 100,000 and prepaid 300,000 at a due height. Expected: tombstoned; rows event 83 +300,000 and event 25 −400,000; the pool +400,000 (event 50).
  • Input: the TestNet genesis, which funds the treasury ZBC_CIHOJSU5_EWGXKZLJ_AHWEQNZX_HYDXMM3J_VV263DLD_7IY4PYFX_5ADSND7R with 100,000,000,000,000. Expected: at height 0 its row carries rent_due_height 172,800 and block_height 0; at block 172,800 it pays 1,000,000 (event 24; the pool +1,000,000, event 19) and is next due at 345,600. The pool ZBCLONGV (exempt) and any genesis account with balance 0 keep rent_due_height 0.

Test cases · §9

5 cases · 5 valid · 1 reference

Prepaid storage pays first, the balance the rest13-9-paysvalid

Loading the test widget…

An account that cannot pay is tombstoned and its dust goes to the pool13-9-prunedvalid

Loading the test widget…

A pruned account's prepaid storage goes to the pool too13-9-pruned-prepaidvalid

Loading the test widget…

The TestNet treasury pays its first rent at block 172,80013-9-treasuryvalid

Loading the test widget…

The genesis arms every funded account's rent clock one period out13-9-genesis-armedvalidreference

A stated value: there is nothing to compute. A compatible node shows the same value.

treasury_rent_due_height
172800
treasury_block_height
0
pool_rent_due_height
0
unfunded_genesis_rent_due_height
0

Defects to match. (1) A tombstoned account that is credited again starts a fresh clock and a fresh nonce. (2) The rent is compared with balance, not with the spendable balance, so an account whose funds are all held still pays and its spendable balance is clamped at 0.

10. Token persistence and expiry

Purpose. How long a token exists, what extends it, and what happens when it ends.

Inputs. token_free_persist_blocks (TestNet 172,800; DevNet 240; else one snapshot cycle), token_persist_period_cost (TestNet 10,000,000; DevNet 100,000,000; compiled 100,000,000; governable from 1 atomic unit to the 10 ZBC per-period ceiling of governance_window, like the account rent of §9); the period a payment buys = the snapshot cycle (§9; dataset_billing_period_blocks is not read); the explicit survival payment of a token body (14: after the name of an IssueToken, bytes 17…24 of TransferToken / MintToken / BurnToken, bytes 8…15 of FinanceToken; a body without the field pays nothing; a value with the top bit set is refused as negative).

Output and effect. Blocks bought by a payment p: (p div cost) × period + ((p mod cost) × period) div cost, 0 when p ≤ 0, saturating at 2³²−1. The payment leaves the sender as its own amount (row event 45; an unaffordable one buys nothing and moves nothing) and the same amount is credited to the longevity pool (row event 50 on the pool, transaction_id = the transaction), not to the block's reward distribution (21); the fee buys nothing. The token row's persist_height: at IssueToken = height + free blocks + bought (saturating at 2³²−1; at least height + 1); TransferToken, MintToken and BurnToken on a token with persist_height > 0: max(persist_height, height) + bought; FinanceToken: fee > 0, a positive payment, token known and not expired (expired → paid no-op), a token with persist_height 0 → paid no-op (a never-expiring token, every genesis coin, stays never-expiring), fee charged, then max(persist_height, height) + bought, with no extension when nothing was taken. persist_height 0 = never expires, and nothing can give it an expiry. A token with 0 < persist_height < h is invisible at height h to every reader (a token lookup at h reports it unknown), so every operation on it fails as on an unknown token.

Settlement, every block (before the account rent): tokens with 0 < persist_height < height and backing_amount > 0, in ascending token id: the holdings at the block's timestamp — balances; open sell orders' remaining base and open buy orders' quote (remaining × price div 10⁸, 15); open swap offers' give side; pending token escrows' amounts (to their senders); pre-locked schedules' locked remainder (to their owners); pending token streams split into the ceil-vested part (recipient) and the rest (sender); the stakes of multiplayer apps (seats ≥ 2) still open or in play with pot > 0 (pot div n to each player, n = the seats taken, read as 16 §1 reads them, the odd units to the first player; a solo app's stake already sits in the apps pool's balance) — summed per canonical holder, ordered by holder bytes; the backing is split pro rata in 128-bit (floor(total × units / all)) with the leftover units handed one each to the largest remainders (ties by holder bytes ascending); each share is a plain credit with a row event 21 (transaction_id = the token id, the block's timestamp); with no holder at all the issuer gets the whole backing (event 21). A share whose credit is refused for a reason every node computes (the holder's balance would overflow, or the holder's address fails the typed-address check of 01) is credited to the longevity pool instead, with a row event 50 on the pool (transaction_id = the token id, the block's timestamp): nothing is destroyed (rule failed_credit_to_pool); a storage fault in a credit fails the block on that node. Then backing_amount = 0 (a token version) and a row event 20 with change 0 on the issuer. This step runs after the block's transactions (22), so in the first block above persist_height a transaction of the token is already judged expired (14 §9) while the backing is still whole.

How to compute it. As stated.

Rule activation. uniform_fee_refund, survival_field, token_expiry_to_holders, failed_credit_to_pool (active from height 0 on every chain). The never-expiring refusal has no rule (unconditional).

Rejections and errors. "FinanceToken needs a fee to fund persistence", "FinanceToken amount must be positive" (execution; 14 states the admission side), "Unknown token"; admission refuses a never-expiring token with "Token <id> never expires: FinanceToken has nothing to fund" (14 §8).

Vector. computed (TestNet: cost 10,000,000, period 172,800, free 172,800).

  • Input → expected blocks bought: 10,000,000 → 172,800; 25,000,000 → 2 × 172,800 + (5,000,000 × 172,800) div 10,000,000 = 432,000; 1 → (1 × 172,800) div 10,000,000 = 0; 0 → 0.
  • Input: IssueToken at height h with no survival payment. Expected: persist_height = h + 172,800.
  • Input: FinanceToken on ZUSD (id 1, persist_height 0), payment 10,000,000. Expected: refused at admission "Token 1 never expires: FinanceToken has nothing to fund"; mined, a paid no-op.
  • DevNet (cost 100,000,000, period 240): 100,000,000 → 240.
  • Input: an expiring token with backing 1,000 held 600 : 400 by two holders H1 and H2, where H1's credit is refused (its balance would overflow). Expected: H2 +400 (event 21); the pool ZBCLONGV +600 (event 50, transaction_id = the token id); the token's backing 0; nothing destroyed.
  • computed (from both genesis files, 06 §3): the token set at block 0 is the 14 genesis coins 1–14 (ZUSD … ZUSDT), every one with persist_height 0 and backing_amount 0; /api/v1/tokens lists exactly them until an IssueToken is mined.

Test cases · §10

9 cases · 8 valid · 1 invalid · 1 reference

0.1 ZBC buys one period13-10-one-periodvalid

Loading the test widget…

0.25 ZBC buys two and a half periods13-10-two-and-halfvalid

Loading the test widget…

One unit buys nothing13-10-one-unitvalid

Loading the test widget…

Nothing buys nothing13-10-zerovalid

Loading the test widget…

On DevNet 1 ZBC buys one 240-block period13-10-devnetvalid

Loading the test widget…

A token issued at height 12,500 with no survival payment lives for the free period13-10-issuevalid

Loading the test widget…

FinanceToken on ZUSD, which never expires, is refused13-10-finance-genesisinvalid

Loading the test widget…

An expired token's backing of 1,000 held 600 : 400, where the first holder's credit would overflow13-10-expiry-refusedvalid

Loading the test widget…

The token set at block 0 is the 14 genesis coins, none of which expires13-10-genesis-tokensvalidreference

A stated value: there is nothing to compute. A compatible node shows the same value.

tokens
1-14 (ZUSD ... ZUSDT)
persist_height
0
backing_amount
0

Defects to match. (1) A token with no backing is never settled or marked; it is only hidden. (2) The holdings snapshot counts a pending token escrow for its sender and a pre-locked schedule for its owner, not for the eventual recipient.

11. Ledger rows and the consensus/local split

Event Row Written by
37 sender −deposit FundLongevity, header survival
1 sender −fee FundLongevity, CloseLongevity (the fee charge)
38 pool +rent longevity rent (§6)
39 pool −slice the per-block slice into the lottery (§7, 21)
50 pool +remainder a closed record (§5, transaction_id = the vote; §6, transaction_id 0); a pruned account's dust and prepaid storage (§9); a refused holder share at a token expiry (§10, transaction_id = the token id); the sweeps of 10, 11, 12 and every other credit failed_credit_to_pool redirects (a fired trigger, a pruned gateway's stake, a schedule remainder: 08, 17 §7)
19 pool +rent account rent (§9); dataset rent (10 §12)
24 / 25 account −cost / −(balance + prepaid) account rent / prune
83 account +from_prepaid the part of a rent its prepaid storage paid (§9; 10 §12); at a prune, +prepaid
45 sender −payment token survival payment, escrow rent; each paired with event 50 +payment on the pool
20 / 21 issuer 0 / holder +share token expiry
22, 47 per 04 §5 the generic settlement

Consensus: the longevity, funder, deposit and vote rows, persist_height and backing_amount of a token, the rent_due_height and tombstones of account rows, the pool balance, every clock and formula above, and the set of transactions a node must still hold (a live record). Local: the ledger rows, how much history beyond the horizon a node keeps, the API views (/longevity, /longevity/quote, /accounts/<a>/survival, /accounts/<a>/objects, /objects/<id>).

A question about this chapter, or a statement that does not match the network? Discuss on zoobc.pro.