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

baking rights with priority 0 #174

Open
sebeec opened this issue Dec 29, 2020 · 4 comments
Open

baking rights with priority 0 #174

sebeec opened this issue Dec 29, 2020 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@sebeec
Copy link

sebeec commented Dec 29, 2020

Can't get baking rights with 0 priority only:

if b.MaxPriority != 0 {

if "b.MaxPriority == 0" then the parameter "max_priority=0" should be appended to the request /../baking_rights?"

@DefinitelyNotAGoat
Copy link
Collaborator

This should be the case. I can write an integration test around this to verify/fix.

@DefinitelyNotAGoat DefinitelyNotAGoat added the bug Something isn't working label Jan 1, 2021
@DefinitelyNotAGoat DefinitelyNotAGoat self-assigned this Jan 1, 2021
@utdrmac
Copy link
Contributor

utdrmac commented Jan 15, 2021

@sebeec /baking_rights? rpc does not accept 'max_priority' as a parameter. You have to fetch all rights and filter manually.

@sebeec
Copy link
Author

sebeec commented Jan 30, 2021

The Tezos node rpc accepts a parameter "max_priority": https://tezos.gitlab.io/007/rpc.html#get-block-id-helpers-baking-rights.

When no parameter is provided then the max_priority is 64. If I only want to know priority 0 bakings, I will set this parameter to value '0'. When only querying 0 priority the RPC response is also much faster than querying all priorities up to 64.

However, the tezos go library allows to set a max_priority, but not priority 0 due to a mistake in the programming. If max_priority parameter in tezos go library is set to 0, then the Tezos rpc node is called without a "max_priority" parameter and thus defaults to 64.

@utdrmac
Copy link
Contributor

utdrmac commented Jan 30, 2021

@sebeec Interesting. A clear documentation issue as the CLI does not mention max_priority at all:

$ /opt/tezos_mainnet/tezos/tezos-client rpc list /chains/main/blocks/head/helpers/baking_rights
Available services:

  - GET /chains/main/blocks/head/helpers/baking_rights
      Retrieves the list of delegates allowed to bake a block.
By default, it
      gives the best baking priorities for bakers that have at least one
      opportunity below the 64th priority for the next block.
Parameters
      `level` and `cycle` can be used to specify the (valid) level(s) in the
      past or future at which the baking rights have to be returned.
      Parameter `delegate` can be used to restrict the results to the given
      delegates. If parameter `all` is set, all the baking opportunities for
      each baker at each level are returned, instead of just the first
      one.
Returns the list of baking slots. Also returns the minimal
      timestamps that correspond to these slots. The timestamps are omitted
      for levels in the past, and are only estimates for levels later that
      the next block, based on the hypothesis that all predecessor blocks
      were baked at the first priority.

But it certainly does work:

$ curl "http://127.0.0.1:18732/chains/main/blocks/head/helpers/baking_rights?delegate=tz1RMmSzPSWPSSaKU193Voh4PosWSZx1C7Hs&cycle=198&max_priority=0" | jq 'length'
31

$ curl "http://127.0.0.1:18732/chains/main/blocks/head/helpers/baking_rights?delegate=tz1RMmSzPSWPSSaKU193Voh4PosWSZx1C7Hs&cycle=198&max_priority=20" | jq 'length'
519

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants