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

Introduce auxiliary block requests #9171

Closed

Conversation

jonasschnelli
Copy link
Contributor

@jonasschnelli jonasschnelli commented Nov 16, 2016

This PR will allow auxiliary block requests. This will be required to run SPV wallets as well as this solves some other interesting use cases.

CAuxiliaryBlockRequest

  • A new "lock-free" class that handles the auxiliary blocks-download/processing
  • Contains a single global CAuxiliaryBlockRequest pointer (switching to a queue would be trivial).

SyncTransaction signal

  • A new parameter will be added that defines if the transactions are coming from a validated or non-validated block

New RPC call "requestblocks"

Allows to request blocks, if available on disk, they will be optionally passed tough the SyncTransaction signal (Wallet/ZMQ). If some or all of the blocks are not available, they will be downloaded (prioritized over "normal" IBD downloads).
The blocks will be downloaded in parallel using the current block download mechanisms.
CAuxiliaryBlockRequest will ensure that the blocks get processes in the correct order (as requested).

If someone has a good testplan for this, please stand up.

@jonasschnelli jonasschnelli changed the title Introduce out-of-band block requests Introduce auxiliary block requests Nov 16, 2016
@jonasschnelli
Copy link
Contributor Author

Renamed "Out-of-band Block Requests" to "Auxiliary Block Request" to avoid confusion.

@jonasschnelli jonasschnelli force-pushed the 2016/11/spv_step_1 branch 2 times, most recently from dbcc0eb to 963c6c9 Compare December 16, 2016 15:05
@jonasschnelli
Copy link
Contributor Author

Did the non-trivial post main.cpp split rebase.
Travis issue is related to #9364.

Short explanation how this works.

  • This PR allows someone to request blocks during IBD (or catch-up). These requested blocks can be newer the the current chaintip (validated blocks tip).

    • Example:
      requestblocks start '["0000000000000000000a394efd567b68581485fa91bbec42b24a4268fda73a42"]'
  • If one requests blocks with a auxiliary block request (RPC requestblocks), bitcoin-core checks if the blocks are already available on disk and eventually download the missing ones from other peers.

  • Downloads of auxiliary block requests are prioritized over "normal IBD block downloads".

  • Optionally, requestblocks will stuff the requested blocks through the SyncTransaction signal (example. ZMQ).

  • CAuxiliaryBlockRequest ensures that the blocks get passed in the right sequence through the signal (download can be asynchronous, but signal passing is in order [example: download can be D-F-E-G-B-C-A, but signal passing is always A-B-C-D-E-F-G])

  • You can check the status of the auxiliary request (if all blocks has been downloaded) by requestblock status
    ** During download, it can look like:

{
  "request_present": 1,
  "created": 1481888029,
  "is_cancled": false,
  "requested_blocks": 80,
  "loaded_blocks": 65,
  "processed_blocks": 11
}
  • Once the download/processing has been completed, you can get details from the block with things like getblock 0000000000000000000a394efd567b68581485fa91bbec42b24a4268fda73a4.

Use cases

  • This could serve as the core infrastructure for the fullblock hybrid SPV mode.
  • One could process (only header/PoW checked) blocks with this PR (attach an SPV wallet over ZMQ as example)

@jonasschnelli
Copy link
Contributor Author

I forgot to mention that this could – in general – be useful for pruned nodes.

@jonasschnelli jonasschnelli force-pushed the 2016/11/spv_step_1 branch 4 times, most recently from 220282d to 95d2838 Compare December 19, 2016 13:06
@jonasschnelli
Copy link
Contributor Author

Added a hidden RPC command (setautorequestblocks) as well as a debug startup configuration (-autorequestblocks) to stop requesting blocks (IBD / catch-up).

This allows regression-tests of the auxiliary block requests.

Added a simple RPC test.

@rebroad
Copy link
Contributor

rebroad commented Dec 30, 2016

I'm not really understanding why this PR is needed or what new functionality (that was needed) it does... sorry.

@jonasschnelli
Copy link
Contributor Author

Force push fixed a rebase error.

@jtimon
Copy link
Contributor

jtimon commented Jan 3, 2017

Concept ACK

@jtimon
Copy link
Contributor

jtimon commented Apr 18, 2017

Needs rebase

@ryanofsky
Copy link
Contributor

Maybe this PR should be closed? #9483 is newer and includes these changes. Also I posted a big batch of review comments there in February.

@jonasschnelli
Copy link
Contributor Author

Closing in favour of #10794

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants