Skip to content

Conversation

@tomaka
Copy link
Contributor

@tomaka tomaka commented Aug 22, 2021

Fix #910

PR is ready, but two questions remain to be solved before merging:

  • In a compact proofs, are the children of a node present in this node but with a length of 0? Or is the "children section" skipped altogether?
  • If the answer to the first question is that children are present, is it possible for some children to not have a length of 0? Or would the proof be invalid?

@tomaka
Copy link
Contributor Author

tomaka commented Aug 22, 2021

Oops, I must also verify that hashes match, otherwise it's completely unsecure.

@tomaka
Copy link
Contributor Author

tomaka commented Aug 23, 2021

We can still find inline nodes and hashes in the proof. Hashes can only be found for nodes that aren't interesting for what we want to prove.

Copy link
Contributor

@mergify mergify bot left a comment

Choose a reason for hiding this comment

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

Automatically approving tomaka's pull requests

Copy link
Contributor

@mergify mergify bot left a comment

Choose a reason for hiding this comment

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

Automatically approving tomaka's pull requests. This auto-approval will be removed once more maintainers are active.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2022

twiggy diff report

Difference in .wasm size before and after this pull request.


 Delta Bytes │ Item
─────────────┼───────────────────────────────────────────────────────────────────────────
       -1368 ┊ smoldot::trie::proof_verify::trie_node_info::h08654139cf6a6b24
       -1368 ┊ smoldot::trie::proof_verify::trie_node_info::h483b4aeac239e279
       -1368 ┊ smoldot::trie::proof_verify::trie_node_info::h70170abe979a7bbb
       -1368 ┊ smoldot::trie::proof_verify::trie_node_info::hc0faf47bbcefc70b
       -1354 ┊ smoldot::trie::proof_verify::trie_node_info::h660860731b9fcc1e
       -1345 ┊ smoldot::trie::proof_verify::trie_node_info::h3801826c1259be95
       -1345 ┊ smoldot::trie::proof_verify::trie_node_info::h393e1aeebbb73a9c
       -1345 ┊ smoldot::trie::proof_verify::trie_node_info::ha674d52446230276
       -1345 ┊ smoldot::trie::proof_verify::trie_node_info::ha961752544ea132c
       +1330 ┊ smoldot::trie::proof_verify::trie_node_info_non_compact::h16e8b4de1dac52e9
       +1330 ┊ smoldot::trie::proof_verify::trie_node_info_non_compact::hab47ed1ab461183a
       +1330 ┊ smoldot::trie::proof_verify::trie_node_info_non_compact::hf267706a0ae19eb4
       +1330 ┊ smoldot::trie::proof_verify::trie_node_info_non_compact::hf272aba75a28884c
       +1316 ┊ smoldot::trie::proof_verify::trie_node_info_non_compact::h65c0193fa6daea77
       +1307 ┊ smoldot::trie::proof_verify::trie_node_info_non_compact::h8c74cbc064165ad8
       +1307 ┊ smoldot::trie::proof_verify::trie_node_info_non_compact::h9a16db02635d1f94
       +1307 ┊ smoldot::trie::proof_verify::trie_node_info_non_compact::habc3b0535d4d353f
       +1307 ┊ smoldot::trie::proof_verify::trie_node_info_non_compact::hbf5af40517a290de
       -1234 ┊ smoldot::trie::proof_verify::trie_node_info::h209ccfd235f87414
       +1219 ┊ smoldot::trie::proof_verify::trie_node_info_non_compact::heca368c06142acb0
      +20774 ┊ ... and 246 more.
      +29254 ┊ Σ [266 Total Rows]

mergify bot pushed a commit that referenced this pull request Oct 4, 2022
Necessary in order to finish
#1166

Right now we can decode items from Merkle proofs. This PR implements
encoding back these items.

While implementing encoding, I've discovered several cases where the
decoding was too lenient and was accepting as valid things that
shouldn't really be valid. I've fixed this as part of this PR. See the
changes in `src/util.rs` and at the bottom of
`src/trie/proof_node_codec.rs`.

When I say "shouldn't really be valid" I mean that there were multiple
different sequences of bytes that could lead to the same decoded struct.
Since we're hashing things a lot here and there, it is important that
there is a bijection of decoded <-> encoded. The Substrate
implementation does the same. cc
paritytech/substrate#12417
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backport compact trie proofs

1 participant