Skip to content

Conversation

drew-u410
Copy link

@drew-u410 drew-u410 commented Jun 24, 2025

Describe your changes

  • Additional tests to show reward history wipe after unbond + claim.
$ cargo test test_protocol_bug_fully_unbonded_rewards_history_lost -q -- --nocapture
...
🐛 TESTING PROTOCOL BUG: Fully unbonded accounts lose reward history
========================================================================
✅ STEP 1: Delegator bonded 500.000000 tokens to validator
✅ STEP 2: Accumulated rewards: 4.500000 tokens
✅ STEP 3: Fully unbonded all tokens (remaining bonds: 0.000000)
✅ STEP 4: Rewards after unbond: 4.500000 tokens (preserved in counter)
   📊 Rewards counter before claim: 4.500000 tokens
✅ STEP 5: Claimed rewards: 4.500000 tokens
❌ BUG REVEALED: Rewards counter after claim: 0.000000 tokens
❌ BUG REVEALED: Available rewards after claim: 0.000000 tokens
❌ BUG CONFIRMED: Rewards next epoch: 0.000000 tokens
❌ BUG CONFIRMED: Rewards counter next epoch: 0.000000 tokens

🔍 ANALYSIS:
   Before claiming: 4.500000 tokens available
   After claiming:  4.500000 tokens claimed
   Counter deleted: 0.000000 tokens remain
   Next query:     0.000000 tokens available

🚨 PROTOCOL BUG IDENTIFIED:
   When a fully unbonded account claims rewards, the rewards counter
   is PERMANENTLY DELETED from storage. This means:
   1. The network forgets this account ever earned rewards
   2. Historical reward data is irretrievably lost
   3. Future queries will always return 0
   4. This creates unfair incentives against full unbonding

💡 EXPECTED BEHAVIOR:
   The rewards counter should either:
   1. Be preserved (set to 0) but not deleted, OR
   2. Have separate functions for querying vs claiming
   This would maintain reward history for accounting purposes.

🔄 COMPARISON: Partially unbonded account behavior
   📊 Partial unbond - rewards before claim: 0.000000
   📊 Partial unbond - rewards claimed: 0.000000
   📊 Partial unbond - rewards after claim: 0.000000
   ✅ Partially unbonded accounts can continue earning rewards

========================================================================
🐛 PROTOCOL BUG TEST COMPLETED - Issue clearly demonstrated

Checklist before merging

  • If this PR has some consensus breaking changes, I added the corresponding breaking:: labels
    • This will require 2 reviewers to approve the changes
  • If this PR requires changes to the docs or specs, a corresponding PR is opened in the namada-docs repo
    • Relevant PR if applies:
  • If this PR affects services such as namada-indexer or namada-masp-indexer, a corresponding PR is opened in that repo
    • Relevant PR if applies:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants