Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convenience flag to query stake distribution with drep-state query #557

Merged
merged 1 commit into from
Feb 13, 2024

Conversation

carlhammann
Copy link
Contributor

Changelog

- description: |
    Add `--include-stake` flag to obtain the stake in the `drep-state` query
# 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
  # - improvement    # QoL changes e.g. refactoring
  # - 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

This PR closes #551.

I introduce an overlap between the drep-state and drep-stake-distribution queries. With the --include-stake flag, the former now subsumes the latter. AFAICT, the queries are exposed separately because drep-stake-distribution is expensive. This makes obtaining all information associated with a DRep credential a two-command process. With the new flag, the expensive query is still guarded, but the CLI gets more user-friendly.

How to trust this PR

Highlight important bits of the PR that will make the review faster. If there are commands the reviewer can run to observe the new behavior, describe them.

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

Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

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

LGTM but one comment

cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs Outdated Show resolved Hide resolved
@gitmachtl
Copy link
Contributor

gitmachtl commented Jan 16, 2024

looks like the current command defaults to --include-stake, i guess that should be false per default?

also, the generated output does not contain the keyhash anymore. looks like:

[
    {
        "anchor": {
            "dataHash": "1111111111111111111111111111111111111111111111111111111111111111",
            "url": "https://bit.ly/3zCH2HL"
        },
        "deposit": 2000000,
        "expiry": 188,
        "stake": null
    },
    {
        "anchor": null,
        "deposit": 2000000,
        "expiry": 230,
        "stake": null
    },
    {
        "anchor": null,
        "deposit": 2000000,
        "expiry": 216,
        "stake": null
    },
    {
        "anchor": {
            "dataHash": "f8f21b94aef91b0d5e7ff330889d60f665529897b5c1ae4a1aa608b6249e20e6",
            "url": "https://github.com/Mborongoma/SANCH-GOV-TESTES/blob/main/bio.txt"
        },
        "deposit": 2000000,
        "expiry": 227,
        "stake": null
    },
    {
        "anchor": {
            "dataHash": "fd1b4e7fd844a8e2805bfda173f6461fd59812fcad4ce8a69b5ab427f7226cf7",
            "url": "https://my-ip.at/test/hwdrep.json"
        },
        "deposit": 2000000,
        "expiry": 232,
        "stake": null
    }
]

@carlhammann
Copy link
Contributor Author

carlhammann commented Jan 17, 2024

looks like the current command defaults to --include-stake, i guess that should be false per default?

Well spotted, @gitmachtl! The flag is actually off by default, in the sense that the query isn't performed, but the output includes the "stake" field always. That's confusing, so I changed that behaviour in f11dd55: Now the field should only be present when --include-stake is used.

@gitmachtl
Copy link
Contributor

gitmachtl commented Jan 17, 2024

looks like the current command defaults to --include-stake, i guess that should be false per default?

Well spotted, @gitmachtl! The flag is actually off by default, in the sense that the query isn't performed, but the output includes the "stake" field always. That's confusing, so I changed that behaviour in f11dd55: Now the field should only be present when --include-stake is used.

thx! and the keyHash is missing in the output too for some reason.

@carlhammann carlhammann force-pushed the ch/query-drep-stake-convenience branch from dcb4d68 to f11dd55 Compare January 17, 2024 15:38
@carlhammann
Copy link
Contributor Author

thx! and the keyHash is missing in the output too for some reason.

Fixed in 9bd912b. Thanks for the reminder 🙇

@carlhammann carlhammann force-pushed the ch/query-drep-stake-convenience branch from 9bd912b to a9656ef Compare January 19, 2024 12:53
@gitmachtl
Copy link
Contributor

hi, any plans to merge this into main soon? thx.

@smelc smelc self-assigned this Feb 12, 2024
@smelc smelc force-pushed the ch/query-drep-stake-convenience branch from a9656ef to 6b49db7 Compare February 12, 2024 09:03
, "anchor" .= (ds ^. Ledger.drepAnchorL)
, "deposit" .= (ds ^. Ledger.drepDepositL)
]
drepStateToJson stakeDistr (cred, ds) = (cred,) . A.object $
Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine for now but we should convert this into a ToJSON instance.

Copy link
Contributor

Choose a reason for hiding this comment

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

Follow-up issue created: #606

@smelc smelc force-pushed the ch/query-drep-stake-convenience branch from 5df595d to 3f44c29 Compare February 13, 2024 10:10
@smelc smelc enabled auto-merge February 13, 2024 10:12
@smelc smelc added this pull request to the merge queue Feb 13, 2024
Merged via the queue into main with commit 61cf8da Feb 13, 2024
16 checks passed
@smelc smelc deleted the ch/query-drep-stake-convenience branch February 13, 2024 10:41
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.

[FR] - include the stake-distribution within the drep-state query
4 participants