Skip to content

feat(discipline): commitment bond slashing curves with integer-cents validation - #815

Closed
jay23606 wants to merge 1 commit into
TheVicky1:mainfrom
jay23606:pr-go/802-discipline-add-commitment-bond-forfeitur
Closed

jay23606 wants to merge 1 commit into
TheVicky1:mainfrom
jay23606:pr-go/802-discipline-add-commitment-bond-forfeitur

Conversation

@jay23606

Copy link
Copy Markdown
Contributor

Bug

calculateBondSlashing must not accept a fractional stakedBondCents. A non-integer such as 100.7 would be truncated to 100 for the slash calculation, while refundAmountCents = stakedBondCents - slashedAmountCents would still use the raw value, so the refund would come back fractional. The module is documented as integer-cents only.

Change

  • stakedBondCents must be an integer; anything else throws RangeError.
  • Uses BigInt(...) calls instead of BigInt literals (0n, 100n). The project's TypeScript target is below ES2020, so tsc rejects the literals.
  • Added a regression test that a fractional bond (100.7) throws RangeError.

Testing

  • node node_modules/typescript/bin/tsc --noEmit: 0 errors.
  • npm test -- discipline-bond-slashing (run inside WSL): passed.
  • npm test -- discipline-bond-slashing (run without WSL): 12/12 tests pass.
  • Base commit: npm test -- discipline-bond-slashing failed with Cannot find module '../src/lib/discipline/bond-slashing'. The base has no src/lib/discipline/bond-slashing.ts, so that import failure is expected.

Regression test: on base, the test file fails at import (Cannot find module), so it never exercises the fractional-bond check. On the fix, it passes twice (npm test -- discipline-bond-slashing).

Refs #802

@vercel

vercel Bot commented Nov 23, 2026

Copy link
Copy Markdown

@jay23606 is attempting to deploy a commit to the Vicky's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@jay23606 jay23606 closed this Nov 23, 2026
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