Skip to content

fix(pool): price admissions and reservations at the newest completed portfolio - #59

Merged
moscowchill merged 1 commit into
devfrom
codex/qp-stage-fix
Oct 20, 2026
Merged

moscowchill merged 1 commit into
devfrom
codex/qp-stage-fix

Conversation

@moscowchill

Copy link
Copy Markdown
Contributor

A correctness review of the withdrawal window on 2026-10-20 found one High issue in the native design. A superseded but still-fresh pricing stage kept admitting deposits and reserving withdrawals at its older economics after a newer portfolio was verified. That moved part of a proven loss or reward between holders. Reproduced on native bytecode with synthetic states: a withdrawer avoided 200 of a 520 QRL loss, and a newcomer captured 2,600 of income proven before its admission. The native pool holds no public funds.

Fix. Each admission or reservation batch first applies the newest completed portfolio. The stage keeps its cutoff, FIFO order, batch bounds and phase. Reserved claims, earned fees and pending refunds stay as they are. Repeated supersession cannot restart processing, and stale stages stay abortable.

Tests (native bytecode):

  • Both review scenarios: the withdrawer receives 19,800 QRL, and existing holders keep all income proven before the admission.
  • Freshness at ages 64 and 65, and newer snapshots that share an execution cutoff.
  • Renewal exactly at the recovery deadline, and irreversible recovery one slot later.
  • 65 admissions in bounded batches followed by FIFO withdrawals under repeated supersession.

Gas: ordinary batches cost 5,571 more. A batch that refreshes costs about 75k to 94k more. Pool runtime grows 278 bytes to 21,906. Batch limits stay at 32, and core ABIs are unchanged.

Gates: npm ci, npm test (43 model tests, 32 tooling tests, Go runner and proof tests, 66,455 native VM steps), test:model and test:tooling all exit 0. The frontend is untouched. Docs: architecture, IMPLEMENTATION, REVIEW (the staging-race regression now follows the new rule), proofs README and CHECKPOINT-EXECUTION, testing README, DECISIONS.

…portfolio

A superseded but still-fresh stage kept admitting deposits and reserving
withdrawals at its older economics after a newer portfolio was verified.
That moved part of a proven loss or reward between holders: in the
2026-10-20 review a withdrawer avoided 200 of a 520 QRL loss, and a
newcomer captured 2,600 of income proven before its admission.

Each admission or reservation batch now applies the newest completed
portfolio first. The stage keeps its cutoff, FIFO order, batch bounds
and phase; reserved claims, earned fees and pending refunds stay as they
are. Repeated supersession cannot restart processing, and stale stages
stay abortable.

Tests on native bytecode: both review scenarios (the withdrawer receives
19,800; existing holders keep all income proven before the admission),
freshness at ages 64 and 65, newer snapshots sharing an execution
cutoff, renewal at the recovery deadline and recovery one slot later,
and 65 admissions in bounded batches followed by FIFO withdrawals under
repeated supersession.

Gas: ordinary batches cost 5,571 more; a batch that refreshes costs
about 75k to 94k more; pool runtime grows 278 bytes to 21,906.
@moscowchill
moscowchill merged commit bade19f into dev Oct 20, 2026
2 checks passed
@moscowchill
moscowchill deleted the codex/qp-stage-fix branch October 20, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant