Skip to content

Update Penalty (New) scenario to accepted TIP-004 (per-algorithm scope) - #2

Merged
m4r1m0 merged 2 commits into
mainfrom
sw-penalty-per-algo
Aug 19, 2026
Merged

Update Penalty (New) scenario to accepted TIP-004 (per-algorithm scope)#2
m4r1m0 merged 2 commits into
mainfrom
sw-penalty-per-algo

Conversation

@m4r1m0

@m4r1m0 m4r1m0 commented Aug 19, 2026

Copy link
Copy Markdown
Owner

Summary

Aligns the Penalty (New) scenario with the accepted TIP-RFC-MT-0004 (Last Modified 2026-08-19, Status: Accepted). The TIP no longer groups RxM/RxT into a shared RandomX penalty class — each of the four algorithms is now its own penalty scope.

Changes

  • js/config.js — removed PENALTY_CLASS_MAP; reworded the PENALTY_CAP comment (cap applies to per-algorithm runs).
  • js/simulation.jsrunCompetitionSW/computeAlgoRatesSW now track lastWinner/consecutiveCount per algorithm instead of per class. Only the algorithm that mined the previous block receives the min(2^n, 32) modifier; an RxT block following an RxM block now resets the run and pays no penalty (previously continued the RandomX run at 2x).
  • js/simulation.js (2nd commit) — fixed a pre-existing off-by-one in the New path's run tracking: the counter now holds the run length ending at the previous block, so a block extending a run at position r pays m = 2^(r-1) exactly per the TIP's cap table (previously the 2nd consecutive block paid 1x, the 3rd 2x, etc.).
  • js/lwma_sw.js — comment-only update (engine is scope-agnostic).
  • README.md — class wording replaced throughout; source date → 2026-08-19; config table documents per-algorithm scope; "Why no penalty" critique updated to the TIP's corrected figures (E[m]≈1.16, ~1.7% mean block-time inflation) instead of the old draft's class-based numbers.

Baseline, Penalty (Original), and WTEMA scenarios are untouched, preserving the comparison.

Verification

Test suite run headless on the VPS (Node v22.23.1, vm-context harness over the real block data, blocks 294400–296521):

  • T1: LwmaWindowSW with m=1 is numerically identical to LwmaWindow (499 targets, 0 mismatches).
  • T2: deterministic modifier checks — only the leading algorithm is penalized, 2^k for k preceding same-algo blocks, cap at 32 for k=6.
  • T3: end-to-end runCompetitionSW, 1522 simulated blocks: every block's recorded multiplier matches min(2^(r-1), 32) for its run position; 190 real-data RxM↔RxT switches all reset to multiplier 1 (the class-based behavior would have continued the run at 2x).
  • T4: Original and WTEMA paths unchanged (same result counts, no exceptions).
  • T5: scenario generation — 22 scenarios, lwma45pnew with penaltyMode: 'new' present.

All tests passed. Note: "Penalty (New)" results will shift relative to the previous class-based version (lower effective penalty, less block-time inflation) — expected, per the accepted TIP.

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