Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Logic for checking Substrate proofs from within runtime module. #3783

Merged
merged 1 commit into from
Oct 10, 2019

Conversation

jimpo
Copy link
Contributor

@jimpo jimpo commented Oct 8, 2019

See PR title.

@jimpo jimpo requested a review from HCastano October 8, 2019 15:33
@@ -0,0 +1,25 @@
// Copyright 2017-2019 Parity Technologies (UK) Ltd.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Copyright 2017-2019 Parity Technologies (UK) Ltd.
// Copyright 2019 Parity Technologies (UK) Ltd.

@@ -0,0 +1,103 @@
// Copyright 2017-2019 Parity Technologies (UK) Ltd.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Copyright 2017-2019 Parity Technologies (UK) Ltd.
// Copyright 2019 Parity Technologies (UK) Ltd.

@@ -242,7 +246,7 @@ mod tests {
MockBridge::tracked_bridges(1),
Some(BridgeInfo {
last_finalized_block_number: 42,
last_finalized_block_hash: test_header.hash(), // FIXME: This is broken
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know the details but is this now unbroken?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is now fixed in this PR. Was a compilation issue.

Copy link
Contributor

@HCastano HCastano Oct 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testing::Header doesn't have a hash() method available, which is why it was broken. But yeah, it's fixed now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comment was due to the fact that only looking at the local scope of the code, I only identified that test_header.hash(); now has a variable and no logic has changed and I was like hmm.. how does that solve the problem? 😬

/// Constructs a new storage proof checker.
///
/// This returns an error if the given proof is invalid with respect to the given root.
pub fn new(root: H::Out, proof: Vec<Vec<u8>>) -> Result<Self, Error> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API does look a bit strange to me that you build a new instance of checked and via the constructor you also give it the task that it has to do (i.e. proof to check). If it woks for you then it's okay but I was expecting new to actually return a new instance of something that can check and a .check to actually check.

Copy link
Contributor

@kianenigma kianenigma Oct 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though looking at the test I see it more clear of how you intend to use it. Just a thought. It seems like this struct is StateProofCheckerAndReader?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... I'm also not thrilled about this API, but it's kind of a direct consequence of the proof format. See #3782.

StateProofCheckerAndReader is somewhat more accurate of a description, but in substrate-state-machine, it's just called check_read_proof usually so ¯_(ツ)_/¯.

@HCastano HCastano merged commit 48dde61 into paritytech:hc-jp-bridge-module Oct 10, 2019
@jimpo jimpo deleted the bridge-module branch October 10, 2019 10:47
HCastano pushed a commit to HCastano/substrate that referenced this pull request Oct 22, 2019
HCastano pushed a commit to HCastano/substrate that referenced this pull request Nov 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants