-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Add simple light-client mode (RPC only) #10794
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
Conversation
|
Contains overhauled parts from #9483 |
|
I'd like to help out here, and I've spent literally days reviewing previous iterations of this change (#9076 #9483 #9171), but I can't figure out if this is going anywhere and if providing more review now is a good use of time. As I've mentioned previously, I don't think the auxiliary block download class design is great, because it duplicates functionality from the networking layer in a wholly different part of the code, and gives the wallet too much control & responsibility over low level p2p details in the case where it's used to let the wallet code prioritize which blocks to download. I've tried to describe what I think would be better alternatives in my previous review comments, like #9483 (comment). @jonasschnelli, assuming you don't want to take my previous suggestions, and do want to stick with the current design, I think it would be helpful if you could reach out to some other reviewers and get some concept acks for your current approach. It might help to put together some kind of design document, or at least a detailed comment to the top of |
|
@ryanofsky:
|
7b8973f to
b2364c6
Compare
|
Followed yesterdays discussion we had in #bitcoin-core-dev. Removed the This PR now also adds a new signal The scope of this PR is not to make the block download interface flexible for multiple "users" (like the validation and eventually the light-client wallet). |
cd6f21b to
7a7be30
Compare
7a7be30 to
dfc3bc8
Compare
|
fixed @ryanofsky points. |
ryanofsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change seems pretty straightforward. Main thing missing is a test for the new RPC call.
It would be useful to get concept ACKs from @gmaxwell and @sipa to make sure concerns from the earlier design discussion (https://botbot.me/freenode/bitcoin-core-dev/msg/88437543/) are addressed now.
I don't have a very clear idea of how this functionality is going to be used, and what future plans for it are, so I personally wouldn't mind seeing a list of what the next steps & future prs might look like, or knowing some applications that could use the new option & RPC. But probably these things are clearer to others.
|
Thanks @ryanofsky. Agree about required conceptual ACKs from other devs. |
dfc3bc8 to
1794a11
Compare
ryanofsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 1794a11037150b0d2c6ba2eb9f06e310f51f7c1c. Change looks great: code & test are straightforward and commit history is well thought out.
I still can't figure out if new RPC is actually supposed to be useful for something other than debugging/testing. Seems fine if it isn't, though, because it's a simple wrapper around the functions for downloading blocks of order, which obviously are useful for SPV.
src/net_processing.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "Add priority block request queue"
Should update comment for new return value
src/net_processing.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "Add priority block request queue"
Could be const auto
src/rpc/blockchain.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "Add requestblocks - a simple way to priorize block downloads"
Maybe drop part of comment in parentheses, seems to imply value will be true for priority block requests.
src/rpc/blockchain.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "[RPC] Add requestblocks - a simple way to priorize block downloads"
Copy is redundant, get_array just returns reference to *this.
src/rpc/blockchain.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "[RPC] Add requestblocks - a simple way to priorize block downloads"
Can never happen, get_array call above would have thrown if the hash_Uarray / params[1] value was not an array
src/rpc/blockchain.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "[RPC] Add requestblocks - a simple way to priorize block downloads"
Probably should write mi->second
1794a11 to
9723672
Compare
|
Overhauled and fixed @ryanofsky points (mostly nits), also removed the new (unused) signal. |
ryanofsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 9723672ced8b48eeee4847e6c0e0ed39833c7eaf. Changes since last review were dropping a commit that added a BlockProcessed signal, changing order of other commits, changing brace styles, and making various suggested tweaks.
src/rpc/blockchain.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "[RPC] Add requestblocks - a simple way to priorize block downloads"
Don't really need this check, because the get_array call below will trigger it's own error about the value not being an array. But if you prefer this error, you should change the check to request.params[1].isNull() to avoid making a distinction between a null and a missing value (#10281, #10783).
9723672 to
5544da6
Compare
|
Overhauled first commit to make sure we request blocks in order: |
5544da6 to
c42ebeb
Compare
This is now tested on my SPV branch and could be the first reviewable step towards light clients / wallet process separation. |
c42ebeb to
02e14b0
Compare
…e (pure light-client mode)
47a25e2 to
d18dce1
Compare
|
Rebased |
d18dce1 to
0cc99c1
Compare
0cc99c1 to
77561f7
Compare
|
I rebased it here: https://github.com/Sjors/bitcoin/commits/2018/08/spv-rpc (I may have broken the functional test) @ryanofsky said:
The bigger picture for me is #9483, the ability for users to get started while IBD happens in the background. However, a use case I have in mind for
Being able to fetch blocks by height range (or up to a certain height) instead of hashes would be nice, but that's something that can be built on top of this. I noticed there's no log entry when you Can you explain when Did some light testing and couldn't find problems, but more people should try :-) |
| assert_equal(block['validated'], False) | ||
|
|
||
| #prevblock must not be available | ||
| assert_raises_rpc_error(-1, "Block not found on disk", self.nodes[1].getblock, block['previousblockhash']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe do a prune here and then refetch the old block?
| return NullUniValue; | ||
| } | ||
| else { | ||
| throw JSONRPCError(RPC_INVALID_PARAMETER, "Unkown action"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo found by codespell: Unkown
| There hasn't been much activity lately and the patch still needs rebase, so I am closing this for now. Please let me know when you want to continue working on this, so the pull request can be re-opened. |
This adds a simple light client mode (RPC only, no wallet support).
With this PR, It is possible to disable auto-request-blocks by passing in
-autorequestblocks=0.In that mode, one can request out-of-band blocks by calling
requestblock add ["<blockhash>", ...].Those blocks will then be requested/downloaded and can be loaded via
getblock(and they will also be passed through ZMQ).This allows a very simple light-client mode ideally when you already have a validated peer in your trusted network.
This is also a reviewable step towards light client mode for the wallet (which will ultimately allow process separation o the wallet).