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

Support long polling in the getblocktemplate RPC (excluding mempool changes) #5720

Closed
12 of 14 tasks
Tracked by #5235
teor2345 opened this issue Nov 25, 2022 · 5 comments · Fixed by #5862
Closed
12 of 14 tasks
Tracked by #5235

Support long polling in the getblocktemplate RPC (excluding mempool changes) #5720

teor2345 opened this issue Nov 25, 2022 · 5 comments · Fixed by #5862
Assignees
Labels
A-rpc Area: Remote Procedure Call interfaces C-enhancement Category: This is an improvement

Comments

@teor2345
Copy link
Contributor

teor2345 commented Nov 25, 2022

Motivation

Some mining pools need long polling support, where the RPC response is delayed until the block template changes.

Specifications

https://en.bitcoin.it/wiki/BIP_0022#Optional:_Long_Polling

Designs

RPC fields:

  • Declare longpoll support in the getblocktemplate RPC capabilities
  • Provide a longpollid field in the RPC response, which represents the contents of the tip and mempool used to create the response.
  • Accept a longpollid parameter to the RPC request,
    • which activates long polling until the ID changes.

When long polling is requested by the client using a longpollid parameter, delay the RPC response until:

  • the tip block changes:
    • add a submitold: false field, because the old template is invalid, and
    • use a ChainTipChange watch channel that is updated by the state;
  • any transactions in the mempool change:
    • add a submitold: true field, because the old template can still be a valid block, and
    • use a watch channel that is updated by the mempool, like ChainTipChange;
  • or the max_time is reached (or close?):
    • add a submitold: false field, because the old template is invalid.

RPC server:

  • Increase the default number of RPC threads when the getblocktemplate-rpcs feature is on, because every long polling client could use one thread.
    • Test the jsonrpc_core implementation to see what happens when a RPC request future is held open. (We assume it will do whatever the underlying tokio executor does.)

Testing

I have tested long polling with zcashd, and it works with this command:

 zcash-cli getblocktemplate '{ "longpollid": "0000000000ab159b36911c7860f637a8e5c2d99d17c2a922029ff0905655a30080497" }'
@teor2345 teor2345 added C-enhancement Category: This is an improvement S-needs-triage Status: A bug report needs triage P-Medium ⚡ A-rpc Area: Remote Procedure Call interfaces labels Nov 25, 2022
@mpguerra
Copy link
Contributor

We probably want to do this, however, this seems like a nice and should wait until we have the basic MVP functionality done (Scope section in #5234)

@teor2345
Copy link
Contributor Author

We probably want to do this, however, this seems like a nice and should wait until we have the basic MVP functionality done (Scope section in #5234)

How will we know our MVP implementation actually works, if we don't implement enough functionality for a mining pool to run it?

@mpguerra
Copy link
Contributor

mpguerra commented Dec 2, 2022

@teor2345
Copy link
Contributor Author

teor2345 commented Dec 4, 2022

This is potentially a very large ticket, and it's in this sprint, so I'm going to split the mempool part into another ticket.

@teor2345 teor2345 changed the title Support long polling in the getblocktemplate RPC Support long polling in the getblocktemplate RPC (excluding mempool changes) Dec 4, 2022
@teor2345 teor2345 self-assigned this Dec 5, 2022
@teor2345
Copy link
Contributor Author

This is potentially a very large ticket, and it's in this sprint, so I'm going to split the mempool part into another ticket.

The specific split I planned didn't end up working out, so I closed that ticket, and I did it in multiple PRs instead.

@mergify mergify bot closed this as completed in #5862 Dec 15, 2022
@mpguerra mpguerra moved this to 🆕 New in Zebra Jan 24, 2023
@mpguerra mpguerra added this to Zebra Jan 24, 2023
@mpguerra mpguerra moved this from 🆕 New to ✅ Done in Zebra Jan 24, 2023
@mpguerra mpguerra removed the S-needs-triage Status: A bug report needs triage label Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rpc Area: Remote Procedure Call interfaces C-enhancement Category: This is an improvement
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants