-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat(light client): fetch block body from remote #2527
Conversation
It looks like this contributor signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
1 similar comment
It looks like this contributor signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
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 order to avoid creating new network messages, when we receive a BlockResponse
we check whether the request is for on_demand
(i.e. there's a pending request there for that id), and otherwise fall through and pass the request to sync
.
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.
This patch needs a minor amount of refactoring.
header, | ||
retry_count: None, | ||
}) | ||
.into_future().wait() |
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.
We should really return a Future
instead of blocking.
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.
Yeah I agree, but this is a part of the trait Backend
impl which doesn't support futures. I guess this relies on http timeouts
instead?!
However, this is out-of-scope of this PR and could probably refactored to be async instead.
4f25cef
to
ef6569f
Compare
ef6569f
to
13e4957
Compare
self.update_peer_info(&who); | ||
return outcome | ||
// Note, this is safe because only `ordinary bodies` and `remote bodies` are received in this matter. | ||
if self.is_on_demand_response(&who, r.id) { |
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.
Perform this check first because otherwise the peer might be disconnected/punished.
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.
/cc @andresilva something like you had in mind?
It is kind of ugly to introduce is_on_demand_response
but because of encapsulation/trait object
I don't see any other options!
13e4957
to
eef6baa
Compare
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.
Looks good. Probably add couple of tests (positive, when response is accepted and negative, when that's extrinsic root mismatch) to client/src/light/fetcher.rs
(could be done in follow up PR)?
0085eef
to
d65b5a2
Compare
Yeah, I will take care of that in this PR |
As long as we can't compute `ordered_trie_root(body)` just compare that request.header.hash() == response.header.hash()
d65b5a2
to
d1aa286
Compare
@@ -191,6 +205,12 @@ pub trait FetchChecker<Block: BlockT>: Send + Sync { | |||
request: &RemoteChangesRequest<Block::Header>, | |||
proof: ChangesProof<Block::Header> | |||
) -> ClientResult<Vec<(NumberFor<Block>, u32)>>; | |||
/// Check remote body proof. | |||
fn check_body_proof( |
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.
moved the extrinsic_root
verification here to test it!
* feat(on_demand): block body request * fix(light block req): no justific + one block * fix(bad rebase) * feat(protocol): add messages for `remote_body` * fix(on demand body): remove needless `take()` * fix(network): remove messages for `on_demand_body` * fix(grumbles): use `hash` in `remote_body_requests` As long as we can't compute `ordered_trie_root(body)` just compare that request.header.hash() == response.header.hash() * fix(grumbles): `hdr.ext_root == trie_root(body)` * fix(grumbles): propogate `Err` in `fn body()` * fix(grumbles): Vec<Block::Extrinsic> * fix(grumbles): util_fn for `not_impl` in tests * fix(on remote body): tests `fetch` and `on_demand` * docs(resolve todos)
Attempt to close #1445