Source: docs/lotus-v2/research/plans/lotus-v2-upgrade-mechanisms-review.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.

Review: Lotus V2 upgrade mechanisms (soft-fork activation and the epoch vote)

On this page

Status: independent adversarial review (2026-11-18) of lotus-v2-upgrade-mechanisms.md, called "the note" below. Research only: no normative file, no code and no commit changed. Code was read at lotusd fd10cf77a7 (the note cites 38cfb7d273; same subject line, rebased) with git show. Two small simulations of avalanche::VoteRecord are in the session scratchpad (see Reproduce).

Verdict

Sound with fixes. Do not adopt it as written. The fixes are serious, and two of them change the genesis format.

What holds up:

What does not hold up:

  1. The agreement layer can halt the chain at a boundary (U1). Lotusd's Avalanche polls each contender as an independent yes/no item. It is not a multi-value Snowball. When local tallies split three ways, every contender finalizes as rejected (simulated). "Park unless the signal matches my own preference" then parks every boundary block on most nodes, and Avalanche block polling invalidates them.
  2. Deployment levels are numbers that carry no content (U2). A ballot of level_target ≥ n never says which rules it supports. It persists, and the note reuses numbers. So consent carries over to different code, and two releases that both define "deployment 5" split the chain at activation.
  3. Without a quorum, a single miner can activate any deployment whose start_n has passed (U3). The 7/8 staker threshold exists only in policy, so a stake-free activation path exists.
  4. "All eligible stake" is not all stake (U4). W sums only the proofs bound to connected peers whose local registration time is old enough. Offline stake drops out of W; it is not counted for the status quo. Quorum is latched, so after a mass staker loss the survivors keep tallying and parking. The note's claims about bribery cost and "no quorum constant" rest on the opposite.
  5. The 7/8 lock-in is not Avalanche's threshold (U5). With 67% of upgraded stake rejecting a breaking block, rejection finalizes in about 780 votes. The 7-of-8 window does not translate into a 7/8 stake requirement. As chosen, 7/8 hands 12.5% of online stake a permanent veto with no timeout, and because levels are sequential that veto also blocks every later deployment. That is the SegWit pattern at a lower threshold.
  6. G does almost nothing, because the unvoted backstop C²>>32 it leaves in place prices capacity (U8). A's bounds and A_0 rest on a stale MIN_FEE_PER_KB (U7).

The smaller design is one voted scalar (A), binary agreement items, a deterministic tally input, and deployment IDs in place of bare numbers (section 4).

Findings at a glance

# Severity Finding
U1 High (chain-halt class) With independent per-item contender polling, a three-way split of local preferences finalizes no outcome. Combined with "park unless the signal equals my own preference", every boundary block is parked by most nodes and then invalidated by block polling, and nothing re-polls. A fresh node also never polls the signal in a block it receives, because contenders come only from its own tally.
U2 High level_target is a bare number. Persistent ballots plus number reuse carry consent over to different rules. Competing releases that define the same level split the chain at activation. "Who numbers deployments" becomes the political choke point.
U3 High Without a quorum (cold start, or any node whose Avalanche has not started), consensus accepts a lock-in written by any miner. After start_n that activates deployment n with no staker support. Before start_n it splits upgraded nodes from the rest. Pre-quorum scalar moves also drift one way, since honest miners write "hold" rather than reversing them.
U4 High W covers only connected peers whose local registration_time is more than an hour old (peermanager.cpp:1237-1262). Offline or knocked-off stake leaves W instead of counting as the status quo, so DoS against status-quo stakers before a boundary shifts the vote. The quorum is latched (processor.cpp:998-1058) and set by local -avaminquorum* arguments. The note's §4.8 and its bribery row describe neither.
U5 Medium The 7/8 threshold is presented as derived from Avalanche's 7-of-8 window, but it is not. Rejection finalizes reliably from about 2/3 of stake. 7/8 is a free choice that grants a 12.5% veto, and with sequential levels the veto is head-of-line blocking.
U6 Medium lock = 1 if 8·Σ ≥ 7·W locks in when W = 0, for example on a node whose proofs all re-registered within the last hour. It must also require W > 0.
U7 Medium A_0 = 9 is justified as "1000 >> 9 = 1 atom per kB" and by covering the review's 400× launch overpricing. The approved byte fee is 100,000 atoms per kB, and under the revised √I rule launch overpricing is 20×. The upper bound 62 confuses A with A − A_0. The headroom A_0 is a magic number.
U8 Medium G cannot do its job. The unvoted C²>>32 backstop it deliberately leaves alone already makes a 2× design block cost about 2 subsidies at bootstrap and hundreds in the tail. Raising G cuts only the terms the backstop dominates. Either G is inert, or moving S_quad would make it an unguarded lever.
U9 Medium Capture is limited in rate, not in level. A simple majority, which is less than the roughly 2/3 that parking-halts need, can price out every ordinary payment in about 10 to 15 epochs. Because the result is consensus state, undoing it takes as long, even after the community acts. "Adds little to what capture already buys" is not accurate.
U10 Medium O9 freezes 50/25/25 "as permanent policy". The split is enforced only by the stakers' own parking (TreasuryPolicy, StakingRewardsPolicy), so stakers can change it whenever they like, and freezing it binds nobody. Either make it consensus or say plainly that it is staker policy.
U11 Medium Format collisions and stale sizes. MSG_AVA_UPGRADE_CONTENDER = 0x20000006 is already MSG_AVA_MEMPOOL_BATCH (protocol.h:716, peering.md §4). The revised fee floor adds ema_miner_fees:u64 to the same record, giving 76/108 bytes, not 68/100. The field order and alignment are unspecified.
U12 Medium The estimate is low. The 56-byte record is pinned in about 25 places: the fast-sync wire messages, BLOCKUNDO, the compiled-in snapshot anchor, the disk format, the reference and the tests. There are about 100 non-test call sites for the scaled quantities, plus a second proof adapter (src/lotus_v2/avalanche_proof.*), script-cache flags for level-dependent rules, and the functional test framework's proof codec. A realistic figure is 4,000 to 5,500 lines and 15 to 20 days.
U13 Low–Medium The ballot belongs to the proof's master key. Stake signatures commit only to (expirationTime, master) (proof.cpp:30-37), so pooled-staking operators vote their pool's coins without the coin owners' consent. That is a custody concentration beyond exchanges.
U14 Low Accuracy:<br>• TreasuryPolicy does not just "accept while not ready". It parks against its local tally winner before finalization, which is the same as the epoch vote's rule.<br>• BIP34 is listed as a flag day. It was the first IsSuperMajority deployment.<br>• The gas-limit history stops at 45M (it reached 60M in late 2025).<br>• Monero's long-term median is its defence against ratcheting, not a source of it.<br>• The size is given as about 3,000 lines in the summary and 2,550 in §10.<br>• The ASIC example still uses the full-I 200× rather than √I's 14×.
U15 Low Spec text owed:<br>• C22a's "a script's result depends only on the transaction, its coins and ChainID" now also depends on level_active. That is monotone, but it must be stated.<br>• The contender id needs a domain tag, as the treasury id has (BLAKE3_keyed("lotus.v2.ava.treasury_contender", …)).<br>• The coupling of the epoch to the stake-confirmation default (-avastakeutxoconfirmations, a local argument) is nominal.

1. Safety and liveness of activation

1.1 Contender agreement (U1)

The note says that "Avalanche converges even from a near-tie, which is what Snowball is for". Lotusd does not run multi-value Snowball. VoteRecord::registerVote (voterecord.cpp:14-58) is a binary record per item. TreasuryContenderCache (treasury.cpp:474-591) gives each node a yes vote only for its own tally's winner, and nothing links contenders of the same prevblockhash as a conflict set. The treasury tolerates this because its policy accepts any slate in a winner set (TreasuryPolicy, treasury.cpp:653-721). The note's UpgradePolicy instead demands the finalized outcome, and in its absence the node's own preference.

The simulation (multi_contender_sim.py) uses 60 nodes, each initially accepting only its preferred outcome and answering polls from its current state:

Local preferences Result (4 runs each)
50% / 50% Always converges on one outcome (the two items are complements)
40% / 35% / 25% Every contender finalized rejected on every node, in all 4 runs
50% / 30% / 20% Rejected everywhere in 3 runs; outcome 0 in 1 run
34% / 33% / 33% Rejected everywhere

Three or more distinct preferences arise when two dimensions are close at once: a price share near 50% and a level share near 7/8. They also arise when nodes' W differ (U4), which is exactly when the vote is contested. The chain then fails like this:

  1. Nodes whose preference differs from the block's signal park it.
  2. They vote "parked" (net_processing.cpp:6794, error code 2, a no vote).
  3. Block polling finalizes it as Invalid, so it is parked and BlockInvalidated is signalled everywhere (net_processing.cpp:9306-9328).
  4. The next boundary block meets the same fate.
  5. Nothing re-tallies, because hasTally latches per prevblockhash.

Separately, contenders are "derived locally … no announcement". A node whose tally yields only "hold", for example one with W ≈ 0 after a restart, never polls the signal carried by the block it has just received. It can never finalize that outcome, so it never unparks.

Fix, all of it policy except the last item:

1.2 Lock-in, one epoch later, and no timeout (U2, U3, U5)

Upgraded share u P(rejection finalized) Median votes needed
0.55 about 0.02 within 60k votes more than 60k
0.60 0.98 about 13,000
0.67 1.00 about 780
0.80 1.00 about 264
0.875 1.00 about 182

Safety against breaking blocks needs about 2/3, not 7/8. The threshold is a free choice. A lower one, such as 3/4 or 2/3, gives a smaller veto. Alternatively, keep 7/8 with a bounded signalling window after which the deployment is withdrawn, never forced. Withdrawal frees its level without reusing its ID, which removes the head-of-line block without BIP8's LOT fight, because the fallback is fixed in advance as "withdraw".

1.3 Offline stake, partitions and no quorum (U3, U4)

1.4 Reorgs, IBD and parking


2. The scalar rule under manipulation

Vector Assessment
Re-registering a proof It drops the staker from W for an hour. Under the current rule that helps the side the staker opposes (U4). With the deterministic ballot set, it simply defers the new ballot by one epoch.
Stake churn before a boundary A proof is eligible an hour after registration. Stakes need 2,016 confirmations at registration, measured from the coin's height, not aligned to the epoch. Old coins can therefore be staked and counted within about an hour, and custodians and lenders hold old coins. The note's claim that a coin "cannot be counted until the next epoch" holds only for freshly moved coins.
Stake reused across proofs Handled. Conflicting proofs go to the conflicting pool, and only finalized proofs count.
Sybil splitting Weight is by amount, so splitting has no effect on the sums. It can help satisfy the 8-node quorum gate.
Miner signal against the Avalanche outcome Parked with a quorum and accepted without one (U3). Under the current policy, a miner who races the poll causes U1-type parking churn rather than a wrong outcome.
O10, miners steering with no quorum One direction only, at about the miner's hash share in steps per epoch, and lock-ins cannot be undone (U3).
Pooled staking The ballot is the proof master's, and stake signatures do not commit to it (U13). Either accept this and document it, or add H(ballot) to the StakeCommitment. The second option costs a re-sign by the coin owners to change the ballot, which is defensible for a rarely changed ballot.
How bounded is capture One factor of 2 per epoch, with one epoch's notice. The payment fee is 25,100 atoms at launch prices. +10 steps make it 25.7 XPI (about $0.51 at 2 cents), and +15 make it about 822 XPI. A majority prices out payments in 4 to 6 weeks. A majority is cheaper than the roughly 2/3 that a parking halt needs (part 1 of the simulation: 55% yields no finalization). The result is consensus state, so after the coalition loses, undoing it takes the same 10 to 15 epochs. The lower direction is a DoS lever: at A = 0 byte and cu prices are 512× cheaper for state bloat, and the per-block backstop does not bind below E_min (U9).

3. Format and consensus


4. Owner-goal fit, and the smaller design

Does the mechanism create politics?

A and G against the fee floor.

Raising G lowers only the linear and F1 terms, which this backstop dominates once a block passes E_min. Capacity politics lives in S_quad, which is unvoted. Drop G. The fee-floor note's usage-relative knee, or a later deployment, can address capacity.

Smallest sound design.

"None" (no voted scalar) is viable only under (c), accepting the unanchored ASIC drift of about 14×. The re-review's reasons for keeping A stand.

O9 is not enforceable as stated (U10). The 25/25 split is enforced by StakingRewardsPolicy and TreasuryPolicy, which are the stakers' own parking. Stakers can raise their share by running different policy, and nothing in consensus stops them. Freezing the split protects against the self-dealing O9 worries about only if consensus enforces it: a coinbase rule with treasury and staker outputs whose script choice is policy and whose amounts are consensus. Otherwise O9 should say "the stakers' policy, not voted", and accept that it is staker-controlled.


5. Prior art accuracy

Most of it is correct, checked against the cited sources and the record:

Corrections:


6. Implementation estimate

The note gives about 1,050 lines of code plus 1,500 of tests, in 8 to 10 days. For comparison, the treasury split commit fcb7aeb8c4 touched 105 files (+2,295/−828), and the epoch vote is a treasury-sized policy plus a genesis-format consensus change. A realistic figure is 4,000 to 5,500 lines including tests and the reference, and 15 to 20 days, plus review, more if U1 and U3 are fixed as proposed.

The riskiest parts, in order:

  1. Contender agreement and parking interplay (U1). It is new semantics, it has no simulation, and its failure halts the chain.
  2. The MonetaryState layout change, coordinated with the fee-floor field, across the fast-sync wire format, undo, disk, the snapshot anchor, dev genesis and every pinned root.
  3. Threading A (and G) through about 100 non-test call sites. The policy shadows (fee_hysteresis.h, X29), wallet fee estimation, mempool admission against max(active, pending) with eviction at boundaries, and Chronik/RPC are all included.
  4. Level-dependent script rules. The script execution cache must key on the active level's flags, the classic source of soft-fork cache bugs.
  5. The second proof codec, in src/lotus_v2/avalanche_proof.* and the Python test framework, and the hex proof fixtures.
  6. Functional tests. They need short regtest epochs, mocktime for the one-hour registration delay, and multi-node quorum setups, as the existing treasury tests do.

Suggested owner questions

  1. Binary agreement items with a deterministic ballot set (U1, U4): yes?
  2. Deployment IDs in the ballot and in UpgradeState (U2), which is a genesis-format change: yes?
  3. A lock-in certificate (U3), or accept and document a stake-free activation path when there is no quorum?
  4. The lock-in threshold: 7/8 with a predeclared withdrawal window, or a lower threshold such as 3/4 (U5)?
  5. Drop G (U8): yes?
  6. May A go below its launch value at all? This trades launch correction against a DoS lever (U7, U9).
  7. O9: enforce the split in consensus, or label it staker policy (U10)?

Reproduce

Scripts in tools/lotus-v2-reference/research/upgrade/ (uncommitted), run from that directory:

python3 -I voterecord_sim.py 2      # threshold table (part 1); two-contender convergence (part 2)
python3 -I multi_contender_sim.py   # three-way splits: all contenders finalize rejected
python3 -I stale_items_sim.py       # addendum: items under inconclusive answers, with lotusd's staleness rule

Both scripts model avalanche::VoteRecord as in voterecord.cpp at fd10cf77a7: 8-vote window, more than 6 to agree, finalization at 128. They use uniform stake per node and random pollees. They are qualitative models, not network simulations.


Addendum: re-review of the revised note (2026-11-18)

This addendum re-reviews the revised upgrade-mechanisms note (712 lines, findings mapped U1–U15). Code was re-read at lotusd fd10cf77a7. The new check script is stale_items_sim.py, and the scripts moved to tools/lotus-v2-reference/research/upgrade/ (see Reproduce).

Verdict on the revision

Sound with fixes. The revision answers U1–U6, U8, U11 and U13 in substance:

Four problems remain, and one is new and serious:

  1. The new "inconclusive until the items finalize" block-poll rule can stop Avalanche finality for good (R1). An item that never finalizes goes stale under lotusd's rule. The boundary block, and every block after it, is then never finalized. The most likely trigger is launch itself: the gate W ≥ q·Supply fails, nobody polls the items, and no rule says what follows.
  2. The miner's-half rule does not protect miners (R2). Consensus cannot tell whose script vout[0] pays, so stakers' policy can simply require vout[0] to be a staker or treasury payout.
  3. The snapshot is less deterministic than claimed (R3). Dangling proofs are invalidated and not relayed in lotusd, so new and old nodes systematically disagree about offline stake. Proofs with expirationTime = 0 never expire, so dormant stake becomes permanent veto weight against lock-ins.
  4. A_0 = 4 is justified by a byte fee that is not the owner's (R4). The derivation happens to survive at 1,000 atoms/kB, but what it buys is a permanent 16× downward lever sized by a launch transient. A_0 = 0, tightening only, is the non-magic choice, and launch is exactly when the certificate floor will fail anyway.

On size (R10): the minimum genesis format is smaller than the note's phase 1. It needs UpgradeState, the signal word, a certificate signed by the coin keys rather than built from proofs, deployment-root hashing, and A ≥ 0. That is about 2,300–3,200 lines in 8–11 lane-days, which fits before the 2026-12-10 go/no-go with two lanes. Everything else, including the ballot in the proof, can ship in a later policy release.

Findings at a glance

# Severity Finding
R1 High (finality-halt class) "Until its items finalize, a node answers block polls for the boundary block and its descendants inconclusively." Items whose pollees are at least about 50% inconclusive go stale and never finalize (simulated with lotusd's staleness rule: at 60% inconclusive, 200 of 200 records went stale). Under the gate W ≥ q·Supply, which will likely fail at launch, no node polls the items at all. Every block from the first boundary on is then never finalized, and no rule maps "stale" or "not polled" to "hold".
R2 Medium 2·value(vout[0]) ≥ Σ value(vout) constrains only that some single output holds half. Staker policy can require vout[0] to pay the treasury or the stakers, so the rule does not cap staker self-dealing. It also breaks pools that pay several miners directly from the coinbase, and a burn-commitment output placed first.
R3 Medium–High The snapshot is "proofs seen finalized" with dangling proofs included. In lotusd a dangling proof is rejectProof(INVALIDATE)d into the dangling pool, losing hasFinalized, and is not shared by avaproofs. A node that joined after a staker went offline never learns that proof. Never-expiring proofs (expirationTime = 0, proof.cpp:253) of lost-key stakers count as "no" on every lock-in forever.
R4 Medium A_0 = ⌊log2 √(S_0/T_g)⌋ = 4 does not depend on MIN_FEE_PER_KB at all: A scales the cu term, which sets the fee at 1,000. The note's label ("down to the approved 100,000 atoms per kB") is wrong, and scalar_bounds.py hard-codes 100,000 and treats the byte fee as the payment fee, so its fee and capture tables are 2.16× high. The figure is derived, but its effect is a permanent 16× downward lever after the launch transient has gone.
R5 Medium Consensus checks only q/2·Supply (1/16 of coins) behind a scalar move and 3q/4·Supply (3/32) behind a lock-in. It does not check the tally's "more than half of W" or "3/4 of W". When Avalanche is not parking for any reason (fewer than 8 nodes, a partition, IBD, a bug, a miner the network cannot see), 6.25% of coins plus one boundary block can move A, and 9.4% can lock in a deployment. The holder exception ("more than half of all stake") holds only when the cause is W < q·Supply.
R6 Medium q = 1/8 (D1) is a magic number, as the note admits. It also gates the vote at exactly the time A_0's headroom was meant for: at launch the staked share is likely below 1/8 of supply.
R7 Low–Medium Supply is under-specified. The code (SnapshotSupply) is the UTXO tree's total_value plus pending coinbase, in u64. The note says "spendable coins". With no supply cap, u64 overflows within about a decade at Bitcoin-scale work. Whether expired, unswept coins count is not stated.
R8 Low–Medium The certificate has no size bound. A proof may hold 1,000 stakes (about 145 KB each). A move needing 1/16 of supply in small pooled stakes can run to MBs, which conflicts with the transaction-size limits (X2) unless the coinbase is exempt.
R9 Low "Lock X" is polled for every ID with nonzero snapshot support, so a Sybil naming many IDs from minimum-stake proofs inflates the item set. Poll only IDs at or above 3/4 of the local tally, plus the ID in the received block.
R10 — Size against benefit: see below.

R1: inconclusive block answers and stale items

The revision's agreement layer is right: binary items converge, and "every combination of finalized items is a valid outcome". But it assumes the items finalize. Lotusd has a third ending. VoteRecord::isStale (voterecord.h:103-107) drops an item once successfulVotes > 4096 and successfulVotes > confidence × 64, and inconclusive answers count as votes. stale_items_sim.py adds that rule to the reviewer's Record model:

Inconclusive share of pollees Yes share among conclusive answers Finalized Stale
0.4 1.0 / 0.9 200 / 200 0 / 0
0.5 1.0 / 0.9 200 / 70 0 / 130
0.6 1.0 / 0.9 0 / 0 200 / 200

Inconclusive answers come from nodes with no snapshot and from nodes whose gate fails. The gate is the main case: at launch, staked coins below 1/8 of supply means no node polls the items at all (section 4.7: "Nodes do not vote on the items"). Yet section 4.5 still answers block polls for the boundary block and its descendants inconclusively "until its items finalize". As written, Avalanche finality stops at height 2,016 if the gate fails then, and stays stopped. That in turn takes down staking rewards, treasury cleanup (both keyed on block finalization, net_processing.cpp:9337-9340) and the preconsensus code that tracks the finalized tip.

Fix, all policy:

R2: the miner's half

Section 5 concedes that "consensus cannot tell a staker-reward output from a treasury output". It cannot tell the miner's output from either. 2·value(vout[0]) ≥ Σ vout holds just as well when vout[0] is the treasury slate, and TreasuryPolicy and StakingRewardsPolicy are exactly where stakers would make that demand. The rule therefore caps nothing against stakers. Its only effect is to forbid coinbase layouts: pools that pay several participants directly from the coinbase (P2Pool style), or a burn-commitment output placed first.

Fix: drop it, and label the whole 50/25/25 split as staker policy, as U10's second option said. Its cost, 80–120 lines, buys nothing.

R3: the snapshot's determinism

The intended rule, finalized and non-conflicting proofs with dangling ones counted, is sound. Lotusd's state does not support it:

Fix:

R4: what A_0 should be

Under fee rule (c) at the owner's MIN_FEE_PER_KB = 1,000 (fee-floor note §9.1), the byte fee is 251·√I for a payment and never binds. A payment pays its cu share: 11,633·√I + 12 atoms on a quiet chain, 11,645 at I = 1, for the bare-key payment (the standard keyhash payment: about 12,296·√I + 13, 12,309 at I = 1).

R5 and R6: what consensus actually guarantees

A lock-in made that way can activate rules that well under 2/3 of the online stake enforces, which is the split condition of §1.2. The note's "the holder then has more than half of all the stake there is" is true only when the outage is W < q·Supply on the honest nodes, and other outages (a partition, too few nodes, a bug) do not imply it.

The other new pieces

Size against benefit, and the minimum genesis format

What must be in the genesis format is what a later soft fork cannot add. A soft fork cannot add a StateRoot element, a coinbase grammar field, or a new meaning for a signal bit that old nodes reject. Each of those changes what old nodes compute or accept. So:

Must be in genesis Why Lines
UpgradeState in the StateRoot preimage, including the A fields Old nodes must compute the same root 900–1,200 (note item 1)
The signal word with the price and lock bits, and the transition (apply pending, ±1 bounds, root hashing) Old nodes must accept moves part of the next row
The UpgradeCertificate field in the coinbase grammar, verified at genesis Without verification any miner moves and locks, and junk roots break predecessor targeting 500–700 grammar plus 600–800 verification
A applied to L_tx and the byte fee, with A_0 = 0, A ≥ 0 (R4 (i)) Small. It could even be deferred, because with A ≥ 0 enabling it is a tightening 250–350

A smaller certificate.

Not needed at genesis:

Until phase 2 ships, no attestations are relayed, so nothing moves and the certificate keeps it that way. That matches the note's D4.

Minimum: about 2,300–3,200 lines and 8–11 lane-days, against the note's phase 1 of 3,300–4,700 lines and 9–12 days, plus independent review. It fits before the 2026-12-10 go/no-go with two lanes, with little slack.

The even smaller option, which conflicts with the owner's decision: