Skip to content

[Bug] ZeroDivisionError in epoch reward distribution when total_weight=0 #3196

@508704820

Description

@508704820

Bug Report (Bounty #305)

Summary

Epoch reward distribution crashes with ZeroDivisionError when total_weight is 0 (e.g., all miners fail fingerprint validation). This halts epoch settlement for the entire network.

Affected Files

  • node/rip_200_round_robin_1cpu1vote_v2.py (3 division sites)
  • node/rip_200_round_robin_1cpu1vote.py (4 division sites)
  • node/anti_double_mining.py (2 division sites)
  • node/rustchain_v2_integrated_v2.2.1_rip200.py (1 division site)

Steps to Reproduce

  1. Start a RustChain node with miners
  2. Cause all miners to fail fingerprint validation (e.g., spoof detection)
  3. Trigger epoch settlement
  4. Result: ZeroDivisionError: division by zero in reward calculation

Expected Behavior

When total_weight == 0, miners should receive 0 reward (not crash). Epoch settlement should complete with zero rewards distributed.

Actual Behavior

Node crashes with unhandled exception, epoch settlement fails.

Fix

PR #3194 adds zero-check guards to all 10 division sites:

share = 0 if total_weight == 0 else int((weight / total_weight) * total_reward_urtc)

Severity

Medium-High — reward distribution crash halts epoch settlement

Solana Wallet for Payout

RTC9d7caca3039130d3b26d41f7343d8f4ef4592360

🤖 Found by OpenClaw Team (司雨-S)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions