Skip to content

[hotfix]: Fix PSE division by zero in distributeToDelegator#101

Merged
ysv merged 4 commits into
release-v6from
john/fix-pse-division-by-zero-v6
Mar 5, 2026
Merged

[hotfix]: Fix PSE division by zero in distributeToDelegator#101
ysv merged 4 commits into
release-v6from
john/fix-pse-division-by-zero-v6

Conversation

@metalarm10

@metalarm10 metalarm10 commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

Description

Guard against division by zero when a delegator has score but zero delegation token balance (e.g., after validator slashing). Adds distribution test reproducing the exact testnet crash.

Reviewers checklist:

  • Try to write more meaningful comments with clear actions to be taken.
  • Nit-picking should be unblocking. Focus on core issues.

Authors checklist

  • Provide a concise and meaningful description
  • Review the code yourself first, before making the PR.
  • Annotate your PR in places that require explanation.
  • Think and try to split the PR to smaller PR if it is big.

This change is Reviewable

@metalarm10 metalarm10 requested a review from a team as a code owner March 5, 2026 14:55
@metalarm10 metalarm10 requested review from TxCorpi0x, masihyeganeh, miladz68 and ysv and removed request for a team March 5, 2026 14:55

@TxCorpi0x TxCorpi0x left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TxCorpi0x made 1 comment.
Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on masihyeganeh, metalarm10, miladz68, and ysv).


x/pse/keeper/distribute_test.go line 22 at r1 (raw file):

)

func TestKeeper_Distribute_DelegationWithZeroBalanceAfterSlash(t *testing.T) {

Test is good, but can't we add a new test case to the existing TestKeeper_Distribute and define a slashAction similar to distributAction, this help more scenarios to be added for slashing, at this point we don't have extensive slashing scenarios.

Note: lint also failing

@TxCorpi0x TxCorpi0x left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@TxCorpi0x made 1 comment.
Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on masihyeganeh, metalarm10, miladz68, and ysv).

@ysv ysv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ysv reviewed 3 files and all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on masihyeganeh, metalarm10, and miladz68).

@ysv ysv merged commit 9e0b94b into release-v6 Mar 5, 2026
7 of 8 checks passed
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.

3 participants