Skip to content

Conversation

@rrruko
Copy link
Contributor

@rrruko rrruko commented Jul 17, 2025

Description

This adds a ledger state query to obtain the delegators (and deposit) for each DRep, including DRepAlwaysAbstain and DRepAlwaysNoConfidence, which cannot be queried via the existing queryDRepState. Since there is no sensible expiry or anchor for those DReps, a new type is introduced that is like DRepState but with those fields omitted. The result is computed by folding over the UMap.

This would be useful for amaru; see for example this comment.

Checklist

  • Commits in meaningful sequence and with useful messages.
  • Tests added or updated when needed.
  • CHANGELOG.md files updated for packages with externally visible changes.
    NOTE: New section is never added with the code changes. (See RELEASING.md).
  • Versions updated in .cabal and CHANGELOG.md files when necessary, according to the
    versioning process.
  • Version bounds in .cabal files updated when necessary.
    NOTE: If bounds change in a cabal file, that package itself must have a version increase. (See RELEASING.md).
  • Code formatted (use scripts/fourmolize.sh).
  • Cabal files formatted (use scripts/cabal-format.sh).
  • CDDL files are up to date (use scripts/gen-cddl.sh)
  • hie.yaml updated (use scripts/gen-hie.sh).
  • Self-reviewed the diff.

@rrruko rrruko requested a review from a team as a code owner July 17, 2025 23:02
Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

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

First of all, let me say thank you for a very nice contribution.
I can certainly see how this query can be useful, but there are some surprising things that I have some questions about.
Also, unfortunately, it is a bad timing to add such a query, because we are on a verge of replacing UMap in favor of a more accurate and simpler representation in #5128
It doesn't mean we can't add this query. It's just I would recommend addressing all other comments in this PR first and then we can change the implementation in the query itself once the above PR is merged.

@rrruko rrruko force-pushed the rrruko/add-query-drep-delegation-state branch from 8ba689c to 72c566c Compare August 5, 2025 16:04
@rrruko rrruko requested a review from lehins August 6, 2025 13:23
KtorZ added a commit to pragma-org/amaru that referenced this pull request Aug 6, 2025
  The generated snapshots are 'null' because we failed to fetch the right status when building the initial data. This should be hopefully resolved by:

  IntersectMBO/cardano-ledger#5176

Signed-off-by: KtorZ <[email protected]>
Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

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

This query is exactly what we had discussed. Hopefully it was simpler to work with new AccountState abstraction, rather than the older UMap representation.
Most of my suggestions should lead to a slightly simpler implementation, but the end result should be the same.

Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

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

Beautiful! Thank you for your hard work!
Could I ask you one last thing. Could you please create couple of tickets on:

  1. https://github.com/IntersectMBO/ouroboros-consensus
  2. and https://github.com/IntersectMBO/cardano-api

that mentions the need to integrate this query all the way to cardano-cli

Copy link
Collaborator

@lehins lehins left a comment

Choose a reason for hiding this comment

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

@rrruko
Copy link
Contributor Author

rrruko commented Aug 13, 2025

Beautiful! Thank you for your hard work! Could I ask you one last thing. Could you please create couple of tickets on:

1. https://github.com/IntersectMBO/ouroboros-consensus

2. and https://github.com/IntersectMBO/cardano-api

that mentions the need to integrate this query all the way to cardano-cli

Should we create a ticket in cardano-cli too?

@lehins lehins force-pushed the rrruko/add-query-drep-delegation-state branch from 1260fee to 0590262 Compare August 14, 2025 18:53
@lehins lehins enabled auto-merge August 14, 2025 18:54
@lehins
Copy link
Collaborator

lehins commented Aug 14, 2025

Should we create a ticket in cardano-cli too?

Yes, it would be good too! Although, I think if cardano-api adds a query, I believe compiler will force cardano-cli to account for it as well.

@lehins lehins changed the title add queryDRepDelegationState state query add queryDRepDelegations ledger state query Aug 14, 2025
Also export `credToDRep` and `dRepToCred`
@lehins lehins force-pushed the rrruko/add-query-drep-delegation-state branch from 0590262 to e262c58 Compare August 14, 2025 19:10
@lehins lehins merged commit 693218d into IntersectMBO:master Aug 14, 2025
123 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.

2 participants