Skip to content

ltc: saturate emergency-decay target shift to prevent uint256 wrap - #561

Merged
frstrtr merged 1 commit into
masterfrom
ltc-doge/ltc-emergency-decay-overflow
Jun 27, 2026
Merged

ltc: saturate emergency-decay target shift to prevent uint256 wrap#561
frstrtr merged 1 commit into
masterfrom
ltc-doge/ltc-emergency-decay-overflow

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Replaces the bare prev << halvings in compute_share_target Step 3 with a saturating emergency_decay_shl() helper that clamps to max_target on 256-bit overflow. A large prev across a multi-window share gap could previously wrap to a tiny (harder) target and accelerate a death spiral; this makes the emergency-decay path easing-only.

Scope: src/impl/ltc/ only (single-coin, LTC lane). DOGE rides the same site; BTC carries its own copy of the helper separately in its lane (no cross-coin bundling).

Tests: new 5-case conformance KAT (easing-only invariant) green; full ltc share_test 11/11 green; clean rebuild.

Head: da75622. Held for integrator merge tap (consensus-bearing path).

Step 3 of compute_share_target used a bare prev<<halvings on the 256-bit
target. With a large prev and a multi-window share gap the shift overflows
256 bits and wraps to a tiny value (a HARDER target), accelerating the very
death spiral the emergency decay exists to arrest. The old halvings<256
guard bounded shift width only, never magnitude.

Add emergency_decay_shl() saturating helper (clamps to max_target on
overflow) and a 5-case conformance KAT enforcing the easing-only invariant
(emergency decay never decreases target).
@frstrtr
frstrtr merged commit d2ac860 into master Jun 27, 2026
21 checks passed
@frstrtr
frstrtr deleted the ltc-doge/ltc-emergency-decay-overflow branch June 27, 2026 15:11
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