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

Multiple pools support in query stake snapshot #4279

Merged
merged 5 commits into from
Jan 17, 2023

Conversation

newhoggy
Copy link
Contributor

@newhoggy newhoggy commented Aug 5, 2022

Add support for querying of multiple pools. Note, this changes the JSON structure:

Query for no pools:

$ time CARDANO_NODE_SOCKET_PATH=example/main.sock cardano-cli query stake-snapshot --testnet-magic 42
{
    "pools": {}
    "total": {
        "stakeGo": 1800000000000,
        "stakeMark": 1800000000000,
        "stakeSet": 1800000000000
    }
}
CARDANO_NODE_SOCKET_PATH=example/main.sock  query stake-snapshot  42  0.01s user 0.00s system 42% cpu 0.029 total

Query for two pools:

$ time CARDANO_NODE_SOCKET_PATH=example/main.sock cardano-cli query stake-snapshot --testnet-magic 42 --stake-pool-id 0436087e6f0a3d828d4dadaf0fcbccff3a3d5a2fa8f76a015d991613 --stake-pool-id 67086804da63179eb7972e2be856a6fbbd9e3673e50fecc6efbd12f3
{
    "pools": {
        "0436087e6f0a3d828d4dadaf0fcbccff3a3d5a2fa8f76a015d991613": {
            "stakeGo": 300000000000,
            "stakeMark": 300000000000,
            "stakeSet": 300000000000
        },
        "67086804da63179eb7972e2be856a6fbbd9e3673e50fecc6efbd12f3": {
            "stakeGo": 1200000000000,
            "stakeMark": 1200000000000,
            "stakeSet": 1200000000000
        }
    },
    "total": {
        "stakeGo": 1800000000000,
        "stakeMark": 1800000000000,
        "stakeSet": 1800000000000
    }
}
CARDANO_NODE_SOCKET_PATH=example/main.sock  query stake-snapshot  42      0.01s user 0.01s system 45% cpu 0.028 total

Query for all pools:

$ time CARDANO_NODE_SOCKET_PATH=example/main.sock cardano-cli query stake-snapshot --testnet-magic 42 --all-stake-pools
{
    "pools": {
        "0436087e6f0a3d828d4dadaf0fcbccff3a3d5a2fa8f76a015d991613": {
            "stakeGo": 300000000000,
            "stakeMark": 300000000000,
            "stakeSet": 300000000000
        },
        "2b8126681160daab09f013163df264274aaa77d4a972e4067e2554b2": {
            "stakeGo": 300000000000,
            "stakeMark": 300000000000,
            "stakeSet": 300000000000
        },
        "67086804da63179eb7972e2be856a6fbbd9e3673e50fecc6efbd12f3": {
            "stakeGo": 1200000000000,
            "stakeMark": 1200000000000,
            "stakeSet": 1200000000000
        }
    },
    "total": {
        "stakeGo": 1800000000000,
        "stakeMark": 1800000000000,
        "stakeSet": 1800000000000
    }
}
CARDANO_NODE_SOCKET_PATH=example/main.sock  query stake-snapshot  42   0.01s user 0.01s system 43% cpu 0.029 total

Usage:

Usage: cardano-cli query stake-snapshot
            [ --shelley-mode
            | --byron-mode [--epoch-slots NATURAL]
            | --cardano-mode [--epoch-slots NATURAL]
            ]
            (--mainnet | --testnet-magic NATURAL)
            [--all-pools | [--stake-pool-id STAKE_POOL_ID]]

  Obtain the three stake snapshots for a pool, plus the total active stake
  (advanced command)

Available options:
  --shelley-mode           For talking to a node running in Shelley-only mode.
  --byron-mode             For talking to a node running in Byron-only mode.
  --epoch-slots NATURAL    The number of slots per epoch for the Byron era.
                           (default: 21600)
  --cardano-mode           For talking to a node running in full Cardano mode
                           (default).
  --epoch-slots NATURAL    The number of slots per epoch for the Byron era.
                           (default: 21600)
  --mainnet                Use the mainnet magic id.
  --testnet-magic NATURAL  Specify a testnet magic id.
  --all-pools              Query for all pools
  --stake-pool-id STAKE_POOL_ID
                           Stake pool ID/verification key hash (either
                           Bech32-encoded or hex-encoded). Zero or more
                           occurences of this option is allowed.
  -h,--help                Show this help text

Implements #4570

Depends on:

@newhoggy newhoggy force-pushed the newhoggy/query-stake-snapshot-multiple-pools branch from 3f2f2e4 to dc105a5 Compare August 7, 2022 11:07
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, can you ask QA to look at it

@newhoggy
Copy link
Contributor Author

newhoggy commented Sep 3, 2022

This PR is blocked on #4250

@newhoggy newhoggy force-pushed the newhoggy/query-stake-snapshot-multiple-pools branch from 73314b1 to 76a3d9f Compare December 22, 2022 06:08
@newhoggy newhoggy force-pushed the newhoggy/query-stake-snapshot-multiple-pools branch 2 times, most recently from be6bbe5 to 2d64efb Compare January 10, 2023 23:29
cardano-api/src/Cardano/Api/Orphans.hs Outdated Show resolved Hide resolved
@newhoggy newhoggy force-pushed the newhoggy/query-stake-snapshot-multiple-pools branch 6 times, most recently from 20728b7 to 14a3449 Compare January 13, 2023 03:43
@newhoggy newhoggy requested a review from a team as a code owner January 13, 2023 03:48
@newhoggy newhoggy mentioned this pull request Jan 13, 2023
22 tasks
@newhoggy newhoggy force-pushed the newhoggy/query-stake-snapshot-multiple-pools branch from fd9aa0d to 110d74c Compare January 13, 2023 04:09
@newhoggy newhoggy force-pushed the newhoggy/query-stake-snapshot-multiple-pools branch 2 times, most recently from efee15a to 13a7159 Compare January 17, 2023 01:28
@newhoggy newhoggy force-pushed the newhoggy/query-stake-snapshot-multiple-pools branch from 13a7159 to 61e2f28 Compare January 17, 2023 22:52
@newhoggy newhoggy merged commit ce3daec into master Jan 17, 2023
@iohk-bors iohk-bors bot deleted the newhoggy/query-stake-snapshot-multiple-pools branch January 17, 2023 23:35
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.

3 participants