Source: docs/lotus-v2/research/plans/lotus-v2-upgrade-mechanisms.md
Research — non-normative. This page records an investigation. It defines no rule; a research result enters the specification only through a decision recorded in decision history.

Lotus V2 upgrade mechanisms: soft-fork activation and the scalar vote

On this page

Status: research, third revision, after the second review (2026-11-19). This note changes no normative file and no code. Nothing was built. The draft normative text in sections 11 and 12 is a proposal only.

The owner's goal: "I want to not have to touch this again. Bitcoin died because of needing fixes that couldn't get done politically." Every future change must go through a mechanism agreed before launch. The owner also rejects caps and magic numbers.

Inputs:

Scripts: tools/lotus-v2-reference/research/upgrade/ (uncommitted; see Reproduce).

What changed in this revision. The second review's verdict was "sound with fixes". The coordinator set:

Decision Effect on the design
R1 Block polls A hold block is answered normally. Only a block whose signal moves something is held back. A stale or unpolled item counts as "no". Finality can no longer stop (section 5.4, simulated).
R2 Miner's half Dropped. The whole 50/25/25 split is staker policy (section 8).
R3 Snapshot A registry of once-finalized proofs; a proof counts only if it expires within the 66-epoch window, so never-expiring and lost-key stake ages out (section 5.2).
R4 A_0 A_0 = 0 and A ≥ 0: the vote only raises prices, the frozen-minimum principle. scalar_bounds.py now prices at 1,000 atoms/kB through the cu term.
R5, R6 Guarantee and floor The consensus guarantee is written down as what it is (section 4.5). The floor stays a share q of supply, because no chain-visible quantity can replace it; q is owner item D1. Lock-ins need the full q, not 3q/4.
R7 Supply Exactly defined, in u128, with expired unswept coins counted.
R8 Certificate size Bounded by C06's framing bound and charged in cu to the coinbase.
R9 Lock items One deployment ID per coin per boundary in consensus; policy polls at most one lock item from its own tally.
R10 Scope The note is now built around the genesis minimum. The certificate is signed by the stake coins' own keys, not built from Avalanche proofs. Everything else is a later policy release.

Decision summary

Decided (owner, 2026-11-18; coordinator under the owner's delegation, 2026-11-18 and 2026-11-19):

What goes into the genesis format (section 4). These four parts are all a later soft fork could not add:

  1. UpgradeState, a 72-byte element of the StateRoot preimage. It holds a running deployment root, a pending root, a count, and A active and pending. At genesis both roots are 0^32 and A = 0.
  2. The signal word, which is the coinbase input's sequence. ffffffff means hold. At a boundary (every 2,016 blocks) it can step A by ±1 and lock in one deployment ID. Every change takes effect one epoch after it is decided.
  3. The UpgradeCertificate, a new coinbase field.
  4. It is signed by the keys of the stake coins themselves: pubkey ‖ ballot ‖ signature ‖ outpoints.
  5. Consensus checks against the parent state that the coins are unspent, old enough and locked to the key. It also checks that their value clears a floor: more than q/2 of supply for a price step, at least q of supply for a lock-in.
  6. The certificate is empty when the signal holds.
  7. A miner without stake can therefore move nothing, and no single miner can activate anything.
  8. A on the cu term: L_tx·2^A and ByteFee·2^A, with 0 ≤ A ≤ 63.

The estimate is 14 commits, about 2,500–3,450 lines including tests, and 9–12 lane-days, or about 6–7 days elapsed with two lanes (section 13). That fits before the 2026-12-10 go/no-go.

The policy release (section 5). It can follow the launch:

Until it ships, nothing moves: nodes have no items, so every moving block counts as "no" and is parked (rule R1). That is the intended launch state.

What is actually guaranteed (section 4.5):

Capture, at 2 cents per XPI:

Still needs the owner:

# Decision Recommended Why it is the owner's
D1 q. Its exact meaning: the share of all coins (Supply, section 4.3) whose keys must sign at one boundary for consensus to accept a move made while Avalanche is not enforcing the tally. A step needs more than q/2, a lock-in at least q. q = 1/8. A step then needs more than 1/16 of all coins, and a lock-in 1/8. No on-chain fact fixes it: the stake that exists is off chain. A floor relative to the snapshot's W is impossible, because consensus cannot see W (section 4.5). Too high, and nothing can move. Too low, and a large holder plus one block moves alone when Avalanche is down.
D3 Write O11 into the spec as a norm: no deployment shortens an existing coin's lifespan, or strands coins without a rescue path specified first Yes, labelled as a norm. It binds by agreement, not by mechanism. It is the confiscation line, a statement of values.
D4 Schedule and fallback Build the genesis minimum now (section 13) and decide at the 2026-12-10 go/no-go. If that is at risk, the fallback drops the A fields and the price bits, and handles raises as deployments at 3/4 (saves 400–600 lines). The fallback must be chosen before genesis, because adding A later needs a StateRoot change. It is a launch-date call, and the fallback reverses part of the owner's scalar-vote decision.

D2 from the previous revision, coin-owner consent, is settled by construction: the certificate is signed by the coin keys.


1. What exists and what is missing

No rule gives the coinbase sequence a meaning.


2. Prior art

Activation:

Mechanism Who decides Used for What happened Lesson for V2
Flag day in code (BIP16, BIP30) Developers and node operators Early soft forks Worked while the community was small. BIP16 versus BIP17 was already a fight. Needs agreement on who ships code.
IsSuperMajority (BIP34, then BIP66 and BIP65) Miners, 750/950 of 1,000 blocks 2012–2015 At BIP66 (July 2015), miners that skipped validation built six invalid blocks. Signalling is not enforcement.
BIP9 Miners, 95% of a 2,016-block period, with a timeout CSV (2016), SegWit (2016–17) SegWit stalled at about 30% for months. A high threshold hands a small minority a veto.
BIP148, BIP91 Users threatening a split; miners at 80% Forcing SegWit, 2017 SegWit activated at block 481,824. BCH split off on 1 August 2017. SegWit2x was cancelled. A failed mechanism turns into brinkmanship.
BIP8 (LOT) Miners, or mandatory at the timeout Proposed for Taproot The 2021 fight was over the fallback itself. Fix the fallback before the first deployment. Here it is "withdraw".
Speedy Trial (Bitcoin Core 0.21.1: BIP9 at 90% with a minimum activation height) Miners Taproot, 2021 Locked in June 2021, active at block 709,632 Works when nobody objects.
BCH and eCash median-time upgrades Whoever writes the release Twice a year Splits in November 2018 (BSV) and November 2020 (ABC against BCHN) No measurable rule says whether the network agreed.
eCash Avalanche policies Stakers, by parking Finalization, staking rewards (2024) Binding for online nodes only Syncing nodes need a recorded result.
Decred Ticket holders: 75% of votes cast over 8,064 blocks, with a quorum Every rule change since 2017 No splits The closest precedent. Ticket votes are signed by the coins' keys and recorded on chain, as the certificate here is.
Tezos Bakers by stake, 80%, adaptive quorum Every upgrade Regular upgrades without forks A stake supermajority for code changes works.
XRPL amendments Validators, more than 80% for two weeks Features Works with a curated validator list A hold period gives notice.

Scalar votes:

Lessons:


3. The shape: a genesis minimum and a policy release

A soft fork cannot add:

Each of those changes what old nodes compute or accept. Everything else can be added later by a release that only narrows what it accepts.

Part Where Why there
UpgradeState in StateRoot, with the A fields Genesis Old nodes must compute the same root
The signal word and the transition (pending values, ±1 bounds, root hashing) Genesis Old nodes must accept a moving block
The certificate field, verified at genesis Genesis Without verification any miner moves and locks, and junk roots break predecessor targeting
A applied to L_tx and the byte fee Genesis (could be deferred) Small. With A ≥ 0, applying it later would be a tightening, but nothing is gained by waiting.
Ballot in the proof, snapshot registry, tally Policy release Avalanche policy only
Items, the R1 polling rule, UpgradePolicy Policy release Avalanche policy only
Certificate-group relay, templates, mempool, RPC, wallet Policy release Policy and tooling
Deployment-keyed script cache, deployment tables With the first deployment No deployment exists at genesis

Launch behaviour. The genesis release has no items. By rule R1 (section 5.4), a moving boundary block then counts as "no" on every node that runs Avalanche: it is parked, and a hold block replaces it. So nothing moves until the policy release ships, and the certificate keeps it so when Avalanche is not enforcing.


4. The genesis minimum (consensus)

4.1 UpgradeState

A fixed 72-byte element of the StateRoot preimage, little-endian:

Offset Field Type Meaning
0 deployment_root h32 Running hash of the activated deployment IDs; 0^32 at genesis
32 pending_root h32 Equals deployment_root, or H(deployment_root ‖ lock_id) while a lock-in awaits activation
64 deployment_count u32 Number of activated deployments
68 price_shift u16 A, active; 0 at genesis
70 pending_price_shift u16 A from the next boundary; 0 at genesis
StateRoot = H_state(00 || ChainID || height:u64 || UtxoRoot:h32 || Bytes(MonetaryState(h)) || UpgradeState)

4.2 Signal word and transition

Boundaries. With P = 2,016, a height b ≥ P with b mod P = 0 is a boundary.

Signal word. The coinbase input's sequence:

Bits Field Values
0–1 price step 11 hold, 01 +1, 10 −1, 00 invalid
2 lock 1 none, 0 lock in the certificate's lock_id
3–31 — must be 1

All-ones means hold. It is required at every non-boundary height.

Transition at a boundary b, from the parent state:

  1. Apply the pending values. If pending_root ≠ deployment_root, set deployment_root = pending_root and increment deployment_count. Set price_shift = pending_price_shift. Let v be the result.
  2. Check the signal and the certificate (section 4.3).
  3. Set pending_price_shift = v + step. Reject the block if the result leaves 0 … 63.
  4. If the signal locks, set pending_root = H_tag("lotus.v2.deployment_root", deployment_root ‖ lock_id). A lock is invalid while pending_root ≠ deployment_root after step 1. That cannot happen, because step 1 always clears it, so at most one lock-in is pending at a time.

At other heights UpgradeState is copied. A block is validated with its own active values, which come from its parent, so a coinbase never affects the validity of its own block.

Why 63. A shifts amounts. At A = 63, any nonzero indexed requirement is at least 2^63, twice MAX_MONEY = 2^62 and beyond what any one coin can hold, so the price is already prohibitive. 63 is the largest shift of a u64 amount, so it is the width of the amount type, not a policy choice.

4.3 The certificate

Grammar. A new final field of the coinbase input's authorization:

authorization(02 coinbase) = CoinbaseData || UpgradeCertificate
UpgradeCertificate = lock_id:h32 || Vec(CertGroup)          lock_id = 0^32 unless the lock bit is 0
CertGroup          = pubkey:x32 || ballot:33 || sig:64 || Vec(outpoint)
ballot             = price_target:u8 || deployment_id:h32
outpoint           = prev_txid:h32 || prev_index:u32
sig                = BIP340 by pubkey over
                     H_tag("lotus.v2.ballot_attest", ChainID || BlockID(b − P) || ballot)

Consensus checks, against the parent state only, so UtxoRoot stays independent of the coinbase:

  1. The signature verifies. It names BlockID(b − P), so a ballot attested at one boundary is valid only at b, on either side of a fork at b. Attestations from earlier epochs name a different block and fail.
  2. Each outpoint is a coin of the state at b − 1. Its native value is counted. The coin must also:
  3. be locked to the keyhash leaf of pubkey, the same lock AdmitProof requires of stakes;
  4. have creation height ≤ b − 2P, that is, at least P blocks old at the snapshot block b − P;
  5. have expiration_height = 0 or > b.
  6. No pubkey and no outpoint repeats. Each coin therefore supports at most one ballot, and so at most one deployment ID, per boundary (review R9).
  7. Every group supports at least one move in the signal. For +1, price_target ≠ 0xff and price_target > v. For −1, price_target < v. For a lock, deployment_id = lock_id.
  8. The supporting value clears the floor. Each move is checked separately over the groups that support it:
  9. +1: 2·Up_cert > q·Supply;
  10. −1: 2·Down_cert > q·Supply;
  11. lock: Lock_cert ≥ q·Supply. That is higher than the previous revision's 3q/4: lock-ins are rare and are the dangerous case (review R5).

The comparisons use checked u256 arithmetic, with q = 1/8 written as 8·Lock_cert ≥ Supply, and so on.

Supply (review R7). Supply(b − 1) is the sum of the native value of every coin in the state at b − 1 (C03), computed in u128. It counts:

It excludes burn outputs (never in the state) and token amounts (C04). Counting expired coins keeps Supply a pure function of the committed coin set, with no filter that depends on height. They can be at most one sweep behind, and counting them only raises the floor.

Supply fits u128 with a wide margin: each value is at most 2^62, and the state holds far fewer than 2^66 coins. lotusd's current SnapshotSupply is a u64 sum of the tree's total_value plus pending coinbase. It must become this u128 quantity. A node maintains it incrementally, adding created coins and subtracting spent ones, and a snapshot import recomputes it.

Size and cost (review R8).

Why coin keys and not Avalanche proofs (review R10):

4.4 A on the cu term (review R4)

L_tx(A)    = L_tx << A          (c)'s floor(X·√I_sub), shifted left
ByteFee(A) = ByteFee << A       (c)'s ceiling byte fee at the lagged index, shifted left

Effect, from scalar_bounds.py. The table shows the quiet-chain fee of a 1-in/2-out bare-key payment (251 bytes, 1,454 cu) at 1,000 atoms/kB; the standard keyhash payment (287 bytes, 1,537 cu) pays about 5.7% more, 12,309 atoms at I = 1, and every row scales the same way. The cu share, 11,633·√I + 12 atoms, sets that fee, and the byte fee (251·√I) never binds:

A Genesis work (√I = 19.9) I = 1 (2 cents) 200× ASIC step (√I = 0.071)
0 232,038 11,645 834
1 464,064 23,278 1,656
2 928,116 46,544 3,300
4 3,712,428 186,140 13,164
8 59,398,668 2,978,060 210,444

After a 200× step, 4 raises restore the I = 1 price (13,164 atoms against 11,645).

4.5 What consensus actually guarantees (review R5, R6)

Consensus checks a certificate's value against Supply, not against the stake that exists (W). It cannot do otherwise. W is the set of live Avalanche proofs, which is off chain by design. Making it chain-visible would need every staker's ballot on chain every epoch, which means censorable registrations, state growth and the proof format in consensus.

Two alternatives were checked:

So:

Situation A ±1 step needs A lock-in needs
Avalanche enforcing (the policy release, quorum present) More than half of the live snapshot stake W, and the consensus floor At least 3/4 of W, and the consensus floor
Avalanche not enforcing, for any reason More than q/2 of all coins signing, plus one boundary block At least q of all coins signing, plus one boundary block
Always One step per epoch; A ∈ 0 … 63; active one epoch after the decision One pending at a time; enforced one epoch after the decision

With q = 1/8, that means 6.25% of all coins for a step and 12.5% for a lock-in.

Why the no-Avalanche case is tolerable:

The previous revision claimed that a holder of the floor then held "more than half of all the stake there is". That is withdrawn: it holds only when the outage is W < q·Supply, not after a partition, a bug or too few nodes.


5. The policy release (Avalanche)

None of this is consensus. It can ship after launch, and different releases may differ in it.

5.1 Ballot

A new field of the V2 Avalanche proof, serialized after the treasury payouts and committed in the ProofId:

EpochBallot = price_target:u8 || deployment_id:h32          (the certificate's ballot)

Each stake's signature in the proof also covers H(EpochBallot). The tally then counts only what the coin owners signed, the same keys that sign the certificate. Staking software never fills deployment_id by default.

5.2 The snapshot registry (review R3)

lotusd forgets dangling proofs: cleanupDanglingProofs calls rejectProof(INVALIDATE), which drops hasFinalized, and dangling proofs are not offered in avaproofs. Nodes that started later would systematically miss offline stake. The registry fixes that:

5.3 Tally

With v the active A after the boundary update:

Up   = Σ weight : price_target ≠ 0xff and price_target > v
Down = Σ weight : price_target < v
up   = 2·Up > W   and 2·Up > q·Supply
down = 2·Down > W and 2·Down > q·Supply
lock(X) = 4·Lock_X ≥ 3·W and Lock_X ≥ q·Supply
          and X.predecessor = pending_root and start_X ≤ b < start_X + 66·P     (last two: for deployments the node knows)

5.4 Items and block polls (review R1)

Items. Every node polls up to three yes/no Avalanche items for each boundary b, keyed by the parent b − 1:

UpgradeItemId = BLAKE3_keyed("lotus.v2.ava.upgrade_item", H(b−1) || kind || payload)
kind 01 "price up?", 02 "price down?" (no payload), 03 "lock in X?" (payload id_X)
MSG_AVA_UPGRADE_ITEM = MSG_TYPE_AVALANCHE_INBOUND | 0x7 = 0x20000007   (unused in protocol.h)

A Sybil naming many IDs therefore adds nothing to poll (R9).

Block polls, the R1 rule:

Simulation. stale_items_sim.py uses the reviewer's Record model with lotusd's staleness rule and 60 nodes.

Part 1, the reviewer's table: items stall once most answers are inconclusive.

Inconclusive share Yes share among the conclusive answers Finalized / stale (of 200)
0.4 1.0 / 0.9 200 / 0 and 200 / 0
0.5 1.0 / 0.9 200 / 0 and 70 / 130
0.6 1.0 / 0.9 0 / 200 and 0 / 200

Part 2, block finality at a boundary under the R1 rule. A step is one poll per node; the table gives the worst of 4 runs.

Case Steps until every node finalized a block at the boundary Outcome
Launch, floor fails, hold block 134 hold
Launch, floor fails, moving block 269 replaced by hold
Genesis release (no items), moving block 269 replaced by hold
Items 60% inconclusive (all stale), moving block 4,231 replaced by hold
Items 50% inconclusive, 90% yes, moving block 8,154 replaced by hold
Items healthy, all yes, moving block 267 moved
Items healthy, hold block 134 hold

What the simulation shows:

binary_items_sim.py (the previous revision, unchanged) shows that the three items converge where one-contender-per-outcome rejects everything: 24/24 runs over three-way splits, and +1 in 19/20 and 20/20 runs at 60% agreement. Avalanche guarantees agreement, not that the majority wins a close split. Correctness comes from the registry making honest tallies nearly identical, and even a wrongly agreed move needs a real certificate.

The models use uniform stake, random pollees and no delay. They are not network simulations.

5.5 Certificate groups, relay and templates

5.6 UpgradePolicy


6. Soft-fork activation

6.1 Deployments, threshold and withdrawal

Upgraded share u P(rejection finalized) Median votes
0.55 0.005 more than 60,000
0.60 0.965 about 12,000
0.67 1.000 about 800
0.75 1.000 about 360
0.875 1.000 about 180

6.2 Timeline

release defines X (start, predecessor)
  → stakers set deployment_id = id_X in their proofs; the proofs re-register and finalize
  → the next boundary b − P snapshots those ballots; stakers relay CertGroups for b − P
  → at boundary b, the tally gives ≥ 3/4 of W and the floor q: "lock X" finalizes yes;
    the miner writes the lock bit and a certificate; pending_root = H(root ‖ id_X)
  → at b + P: deployment_root = pending_root and the rules are enforced
(no lock-in by start + 66·P → withdrawn)

6.3 Why not the alternatives

6.4 What stays hard-fork-only

The tally thresholds (1/2, 3/4) and the 66-epoch window are policy. Stakers could change them by running different releases, as they can change any parking rule.


7. The scalar vote in use

7.1 Capture (review U9, R4)

From scalar_bounds.py: a persistent majority starting at A = 0, I = 1, 2 cents per XPI. Each step is decided one epoch after its snapshot and takes effect one epoch after the decision.

Steps First active (days) Payment fee
1 5.6 0.023 XPI ($0.0005)
4 14 0.19 XPI ($0.004)
7 22 1.5 XPI ($0.03)
10 31 11.9 XPI ($0.24)
12 36 47.6 XPI ($0.95)
13 39 95.3 XPI ($1.91)

The power a majority gets:

What bounds it:

Other vectors:

Vector Assessment
Sybil splitting No effect: weight is by amount, and lock items come from the node's own tally
Reusing stake Each coin counts once per certificate; each key signs one ballot per boundary
Pooled staking The certificate needs the coin keys, and the policy ballot is signed by them too
Lost-key or dormant stake Never in a certificate; ages out of the tally within 66 epochs (section 5.2)
A miner's signal against the outcome Parked once the items end (section 5.6)
No Avalanche quorum Moves need the floor q (section 4.5)

7.2 Worked example: the ASIC case

A BLAKE3 ASIC arrives in year 3 of the tail era. √I falls about 14×, and the quiet-chain payment fee drops from 11,645 to 834 atoms. A is 0.

  1. Staking software suggests price_target = 4. Stakers holding 60% of W, and more than 1/16 of all coins, re-register their proofs during epoch e.
  2. The snapshot at the next boundary b1 holds those ballots, and the stakers relay their groups for b1.
  3. At b2 = b1 + P:
  4. every node's tally gives "up";
  5. the items finalize as (up yes, down no) before the boundary block arrives;
  6. the miner writes signal fffffffd and a certificate whose up-value clears q/2 of Supply;
  7. pending_price_shift = 1.
  8. At b3, A = 1 and fees double. Wallets saw it coming from b2.
  9. One step per epoch follows until A = 4 is active at b6, about 11 days after b2. A payment then costs 13,164 atoms.
  10. If the 60% falls to 45% along the way, Up no longer exceeds half of W and the steps stop. If (c)'s index later rises again, stakers vote A back down, one step per epoch.

8. The payout split (review U10, R2)

The whole 50/25/25 is staker policy. It is enforced only by StakingRewardsPolicy and TreasuryPolicy, which are the stakers' own parking.

The previous revision's rule 2·value(vout[0]) ≥ Σ value(vout) is dropped. Staker policy could simply require vout[0] to pay the treasury or the stakers, so the rule capped nothing. Its only effect was to forbid layouts such as pools paying several miners directly, or a burn commitment placed first.

Nothing in the vote touches the split.


9. Mapping the audit items to the mechanisms

Audit item Mechanism Class after
X5 E_min Not voted; (c) leaves it frozen; capacity is a later deployment 1
X6 S_linear, S_quad Not voted; L_tx is shifted by A on top of (c)'s √I 1, with A on L_tx
X7 MIN_FEE_PER_KB (c)'s √I (lagged), then << A 2 + 3
X8 DUST_LIMIT Not voted and not indexed: 54,600 for coinbase and ordinary outputs alike 1
X9 token burn "2" Not a vote matter: derive it (audit) 1
X10 CLEANING_CREW_REWARD Not voted: derive it from the erase cost (audit) 1 or 2
X14 UTXO_RENT Not voted 1
X22 payout ratios All staker policy, labelled as such (section 8) policy
X23 stake dust, quorum The quorum becomes q (D1), the certificate floor, folded into the tally. Stake dust stays policy. 3 / policy
X19 maturity raise Deployment 3
X12 minimum lifespan Frozen; D3 norm; also the source of the 66-epoch window 1
U1 activation Deployment IDs, certificate, 3/4 policy, withdrawal Specified
U2 PQ signatures Deployment. Audit U2b (multi-item operands) and U2c (a rescue path) are still needed. 3
U3 opcodes and profiles; U4 price raises Deployment 3
U5 scalar vote; U6 η A 3
X29 relay floors Derive them from consensus, including active and pending A —

10. Reorgs, IBD and C22a


11. Draft normative text for consensus.md (proposal only)

C02, after "An assignment may only narrow transaction/block validity":

An assignment takes effect only through a deployment activated under C29.

C14b, append:

The required fee is the byte fee of rule (c) shifted left by the block's active price shift A (C29).

C25, append:

The ordinary transactions' linear term of rule (c) is shifted left by A. K, the block's own linear term and Q are never shifted.

New rule in section 7:

C29 — Upgrade state, the epoch signal and the stake certificate.

State. StateRoot commits UpgradeState = deployment_root:h32 ‖ pending_root:h32 ‖ deployment_count:u32 ‖ price_shift:u16 ‖ pending_price_shift:u16 (72 bytes, little-endian) after Bytes(MonetaryState) (P02). At genesis every field is zero.

Boundaries. Let P = 2,016. A height b ≥ P with b mod P = 0 is a boundary.

Non-boundary heights. The coinbase input sequence MUST be ffffffff. The UpgradeCertificate MUST be 0^32 followed by an empty vector. UpgradeState is copied.

Boundaries: pending values. First apply the pending values. If pending_root ≠ deployment_root, set deployment_root = pending_root and add 1 to deployment_count. Set price_shift = pending_price_shift, and call it v.

Boundaries: signal. Then read sequence:

  • bits 0–1 are the price step: 11 hold, 01 +1, 10 −1, and 00 rejects;
  • bit 2 is the lock: 1 none, 0 lock;
  • bits 3–31 MUST be 1.

The certificate's group vector MUST be empty if and only if sequence = ffffffff. lock_id MUST be 0^32 unless the lock bit is 0.

Certificate groups. Each CertGroup = pubkey:x32 ‖ ballot ‖ sig:64 ‖ Vec(outpoint), with ballot = price_target:u8 ‖ deployment_id:h32, MUST satisfy:

  • sig is a valid BIP340 signature by pubkey over H_tag("lotus.v2.ballot_attest", ChainID ‖ BlockID(b − P) ‖ ballot);
  • every outpoint is a coin of the parent state locked to the keyhash leaf of pubkey, created at height ≤ b − 2P, with expiration_height = 0 or > b;
  • no pubkey and no outpoint appears twice in the certificate;
  • the group supports at least one move in the signal. It supports +1 if price_target ≠ 0xff and price_target > v; −1 if price_target < v; and the lock if deployment_id = lock_id.

Vectors are bounded as in C06. The certificate's bytes, signature checks and coin reads are charged to the coinbase's cost.

Floor. Let Supply be the u128 sum of the native values of all coins in the parent state, including immature and expired, unswept coins. Let V(m) be the sum of the native values of the coins of the groups that support move m. Then:

  • a +1 step needs 2·V(+1) > q·Supply;
  • a −1 step needs 2·V(−1) > q·Supply;
  • a lock needs V(lock) ≥ q·Supply;

with q = 1/8 (D1), computed exactly.

Update. Set pending_price_shift = v + step, and reject the block if that leaves 0 … 63. If the lock bit is 0, set pending_root = H_tag("lotus.v2.deployment_root", deployment_root ‖ lock_id).

Validation. A block is validated with its own active values, which depend only on its parent. A deployment's rules apply when its ID is chained into deployment_root. A deployment's specification MAY make its own lock-in invalid outside [start, start + 66·P) or under a different predecessor.

Guarantee. Consensus guarantees only the floor. A tally of the live stake is Avalanche policy (peering N06b).

Norm (D3). No deployment shortens an existing coin's expiration_height, or makes an existing spendable coin unspendable, unless a rescue path for it was specified before activation.

P01, coinbase paragraph:

Replace "sequence = ffffffff" with "sequence = ffffffff, or C29's signal word at a boundary". Append UpgradeCertificate to the coinbase authorization grammar. Explorers and PSBT tools must not decode it as a relative lock.

P02: add UpgradeState to the StateRoot preimage (202 bytes at genesis, 234 after) and define Supply. Snapshots carry the list of activated deployment IDs, checked against deployment_root and deployment_count.

C22a: add "or the activation of a deployment, which is known one epoch ahead" to the events that can change script validity.

C28 freeze list: P, the step, the range 0 … 63, q, and the signal and certificate formats.


12. Draft normative text for peering.md (proposal only)

§4 inventory table, add:

| MSG_AVA_UPGRADE_ITEM = 0x20000007 | UpgradeItemId = BLAKE3_keyed("lotus.v2.ava.upgrade_item", H(b−1) ‖ kind ‖ payload), kinds 1 (price up), 2 (price down), 3 (lock in id_X) | From the node's tally, and from the signal of any received boundary block |

(Aside: the table lists MSG_AVA_PROOF = 0x20000001 and MSG_AVA_STAKE_CONTENDER = 0x20000004, but protocol.h has 0x1f000001 and 0x1f000002. Fix the table separately.)

New subsection in §7, "Epoch vote (N06b)", policy:

Ballot. A V2 Avalanche proof carries EpochBallot = price_target:u8 ‖ deployment_id:h32 after the treasury payouts. The ProofId and each stake's signature commit to it.

Registry. A node keeps every proof it has seen finalized until a stake coin is spent, the proof expires, or a conflicting proof replaces it. Dangling does not remove a proof. The registry is persisted, and its proof IDs are served on request for a boundary snapshot block.

Snapshot. At boundary b, a proof counts if MTP(b−P) < expirationTime ≤ MTP(b−P) + 66·P·τ. Its weight is its stake whose coins are in the state at b − 1 and were created at height ≤ b − 2P.

Tally. Follow section 5.3 of the upgrade-mechanisms note. Every yes includes the C29 floor.

Items. On b − 1, a node polls "price up" and "price down", and "lock in X" only for an X its tally supports with 3/4 of W. On receiving a boundary block, it adds the items that block's signal implies. A stale or unpolled item counts as "no". Finalized items map to an outcome: up and not down is +1, down and not up is −1, and anything else holds.

Block polls. A boundary block with signal ffffffff is answered normally. A boundary block that moves anything, and its descendants, are answered inconclusively until the node's items for that boundary have ended. After that they are answered by the outcome.

Certificate groups. A staker's node relays avaballotattest(BlockID(b−P), CertGroup) when b − P connects, if its ballot wants anything. A node relays at most one group per key per epoch, and only groups whose signature and coins check.

Parking (UpgradePolicy).

  • Before the items end: park only a lock-in of a deployment the node knows is withdrawn or disqualified.
  • After they end: park a boundary block whose signal contradicts the outcome.
  • A block that holds an accepted move is parked only if the node holds groups sufficient for its certificate.

Templates. Write the outcome, with the certificate assembled from the groups held, largest first. Without ended items, hold.

Mempool. Admit against the larger of the active and pending fee, and evict at the boundary.


13. Implementation estimate (review R10)

The figures are lines including unit tests, and assume fee rule (c) itself is done by its own lane. Each commit builds and passes its own tests, following the project's commit-granularity rule. Paths are relative to lotusd's src/ unless noted.

13.1 Genesis minimum: commit list

# Commit Places Lines
1 reference: UpgradeState encoding and the StateRoot preimage; regenerate the vectors tools/lotus-v2-reference: new upgrade.py, monetary.py, block.py, dev_genesis.py 150–200
2 lotusd: UpgradeState type, encode and decode new lotus_v2/upgrade.{h,cpp} and unit tests 100–150
3 lotusd: StateRoot commits UpgradeState lotus_v2/sparse_state.{h,cpp}; the 23 non-test callers of StateRoot( (kernel/chainparams.cpp anchor, lotus_v2/{block,block_transition,dev_genesis,development_chain,disk_block,disk_body,disk_state,fast_sync,reorg_recovery}.cpp, fast_sync.h, net/v2_protocol_handler.cpp, node/miner.cpp, primitives/block.{h,cpp}, rpc/mining.cpp, validation.cpp, wallet/v2_{node_provider,payment}.cpp); dev-genesis roots and pinned vectors 450–550
4 lotusd: UpgradeState through undo, disk state and fast sync validation.cpp (BLOCKUNDO), disk_state.cpp, fast_sync.*, the fast-sync wire messages (protocol.h:390-396), reorg_recovery.cpp tests 200–300
5 reference: the signal word and the UpgradeCertificate grammar encoding.py, block_wire.py, vectors 100–150
6 lotusd: the coinbase grammar carries the certificate; sequence is free only at boundaries; templates write ffffffff and an empty certificate lotus_v2/transaction.{h,cpp} (parse, serialize, TxID/TxHash, :133-152), block_assembler.cpp, block_template.cpp, pool_coordinator.cpp 280–380
7 lotusd: PSBT and the explorer do not decode the signal as a lock; the functional framework's V2 codec psbt.cpp, chronik_explorer.cpp, test/functional/test_framework/messages.py 120–170
8 reference: Supply, the certificate check and the transition upgrade.py, vectors 150–200
9 lotusd: Supply as a specified u128 state quantity primitives/block.cpp (circulating_supply), sparse_state.* (SnapshotSupply), disk_state.cpp, tests 80–100
10 lotusd: certificate verification (signature, coin lookup against the parent, keyhash leaf, age, expiry, repeats, floor, cu charge) lotus_v2/upgrade.cpp, block_cost.cpp, block_transition.cpp 250–330
11 lotusd: the boundary transition (pending values, step and range, root hashing, the unknown-root warning) lotus_v2/upgrade.cpp, block_transition.cpp, validation.cpp 120–170
12 lotusd: A on L_tx and the byte fee lotus_v2/monetary.{h,cpp}, block_transition.cpp, network_profile.h (P, q), wallet/native.cpp, fee_hysteresis.*, mempool admission (active and pending) 250–350
13 functional: feature_upgrade_certificate.py forged and replayed signatures, an earlier epoch's group, repeated key and outpoint, a young or expired coin, below and at the floor, a miner with no stake, the range at 0 and 63 150–250
14 functional: feature_upgrade_state.py a regtest move and lock-in with short epochs, a snapshot import at nonzero A, a reorg across a boundary, IBD 100–150

Totals.

That is about 6–7 days elapsed with two lanes, plus independent review of the spec and the code.

Fallback (D4). Drop the A fields, the price bits and commit 12, and handle raises as deployments at 3/4. That saves about 400–600 lines, at the cost of the scalar protocol. It must be chosen before genesis.

13.2 Policy release

Work Places Lines
Ballot in the proof and in each stake signature avalanche/proof.{h,cpp} (computeProofId around :81-95), proofbuilder.*, lotus_v2/avalanche_proof.*, rpc/avalanche.cpp, test_framework/{messages.py,avatools.py}, hex-pinned proofs 500–800
Snapshot registry, liveness window and relay of registry proof IDs avalanche/peermanager.*, persistence 350–500
Certificate-group relay and template assembly net_processing.cpp, storage, block_assembler.cpp 350–500
Items and the R1 block-poll rule avalanche/processor.*, protocol.h (0x20000007), an item cache modelled on the treasury contender cache 600–800
UpgradePolicy new policy/block/upgradepolicy.* 200–300
RPC and wallet getupgradestate, getepochtally, fees against the pending value 200–300
Functional tests feature_epoch_vote.py, feature_deployment_activation.py (3/4 and not below, withdrawal, predecessor), multi-node finality under stale items 400–600

That is about 2,600–3,800 lines, or 10–14 lane-days, after launch. The deployment-keyed script cache (150–250 lines) ships with the first deployment.


14. Risks and what this note does not establish


Reproduce

All in tools/lotus-v2-reference/research/upgrade/ (uncommitted):

python3 -I voterecord_sim.py 2      # reviewer: threshold table (section 6.1); two-contender convergence
python3 -I multi_contender_sim.py   # reviewer: the old design's three-way splits reject everything
python3 -I binary_items_sim.py 11   # binary items under the same splits, plus near agreement (also seed 5)
python3 -I stale_items_sim.py       # reviewer part 1: stale items; part 2 (this revision): block finality under rule R1
python3 -I scalar_bounds.py         # A_0 = 0: the payment fee by A at 1,000 atoms/kB, the capture timeline

All five model avalanche::VoteRecord, or do plain arithmetic, and need only the Python standard library.

References