Skip to content

Conversation

@CarlosLopezDeLara
Copy link
Contributor

cardano-cli latest query spo-stake-distribution --all-spos was buggy when reporting SPO's rewards address vote delegation in cases where the rewards address is not delegated to the pool that registered it as the reward account. i.e. delegated to a different pool, and potentially in other cases. This PR fixes it.

Fixes #1264

Changelog

- description: |
    Fixes a bug where the cardano-cli query spo-stake-distribution --all-spos what missrepresenting some cases as delegating to `null` (no delegation), when in reality thery were delegating to always abstain. This is a bug on the CLI only and not on the node side. 
    
# uncomment types applicable to the change:
  type:
  # - feature        # introduces a new feature
  # - breaking       # the API has changed in a breaking way
  # - compatible     # the API has changed but is non-breaking
  # - optimisation   # measurable performance improvements
  # - refactoring    # QoL changes
   - bugfix         # fixes a defect
  # - test           # fixes/modifies tests
  # - maintenance    # not directly related to the code
  # - release        # related to a new release preparation
  # - documentation  # change in code docs, haddocks...

Context

#1264

How to trust this PR

cardano-cli latest query spo-stake-distribution --all-spos --mainnet | jq '.[] | select(.[0] == "0019cb5ac91c786a809f4d87622a29d2c7f57f4697f8c8e8457f4de4")'
[
  "0019cb5ac91c786a809f4d87622a29d2c7f57f4697f8c8e8457f4de4",
  24645887862198,
  "drep-alwaysAbstain"
]

cardano-cli conway query spo-stake-distribution --spo-key-hash 0019cb5ac91c786a809f4d87622a29d2c7f57f4697f8c8e8457f4de4
[
    [
        "0019cb5ac91c786a809f4d87622a29d2c7f57f4697f8c8e8457f4de4",
        24645887862198,
        "drep-alwaysAbstain"
    ]
]

More over, in the attached file I show the diff of the same command with cardano-cli 10.8.0.0 and the CLI from this PR.
diff-previous-vs-current.txt

This PR also comes with an optimization:

 time cardano-cli latest query spo-stake-distribution --all-spos --mainnet --out-file previous.json

real    0m37.582s
user    0m6.566s
sys     0m1.243s

󰕈 carlos  ~/Desktop   17:15  
 time cardano-cli latest query spo-stake-distribution --all-spos --mainnet --out-file current.json

real    0m0.386s
user    0m0.086s
sys     0m0.019s

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff

cardano-cli latest query spo-stake-distribution --all-spos is buggy for reporting SPO's rewards address vote delegation in cases where the rewards address is not delegated to the pool that registered it as the reward account. i.e. delegated to a different pool.  This PR fixes it.

Fixes https://github.com/IntersectMBO/cardano-ledger/issues/5213
@carbolymer
Copy link
Contributor

Nice work! That's cool that we don't have node query in a loop anymore.

@CarlosLopezDeLara CarlosLopezDeLara added this pull request to the merge queue Aug 19, 2025
Merged via the queue into master with commit c082196 Aug 19, 2025
25 checks passed
@CarlosLopezDeLara CarlosLopezDeLara deleted the clr/spo-vote-deleg branch August 19, 2025 11:44
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.

Incorrect handling of always abstain for stake pools.

3 participants