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

Fix prefix_proof misbehavior #2947

Merged
merged 2 commits into from
Oct 31, 2022
Merged

Conversation

tomaka
Copy link
Contributor

@tomaka tomaka commented Oct 29, 2022

Fix #2946

The behavior of prefix_proof is currently buggy. When a node isn't found in the proof that the remote sent us, we simply discard it instead of adding it to the list of keys to query at the next iteration.
The consequence is that state_getKeysPaged was wrong most the time.

In order to fix this, I had to reorganize the entire function.

There's still an issue because we're asking for too much data, which leads the remote to shutdown the connection, so queries still occasionally fail. But this other issue is not the fault of the prefix_proof module, and this PR is only about fixing prefix_proof.

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 29, 2022

twiggy diff report

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


 Delta Bytes │ Item
─────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
        +247 ┊ alloc::vec::Vec<T,A>::extend_desugared::hbaeb7f0c5e25a059
        +202 ┊ smoldot::trie::proof_verify::Children::unfold_append_to_key::h1f7a1fcba0cd8176
        +148 ┊ <either::Either<L,R> as core::iter::traits::iterator::Iterator>::next::h9b6915deff098083
        +125 ┊ <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold::h7b6972ecc80fef6e
        -125 ┊ <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold::hd5db437a6e9ea09a
        -122 ┊ <either::Either<L,R> as core::iter::traits::iterator::Iterator>::next::h10547ac7a0b12bb9
        -100 ┊ smoldot::trie::proof_verify::Children::next_nibbles::h307490ac770c6230
         +95 ┊ <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,I>>::spec_extend::h93f182feb68db6c2
         +91 ┊ alloc::vec::Vec<T,A>::push::hd0340debd00be006
         +90 ┊ <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,alloc::vec::into_iter::IntoIter<T>>>::spec_extend::h08ca0219a99450fa
         +86 ┊ <either::Either<L,R> as core::iter::traits::iterator::Iterator>::size_hint::h85c767ac457ee02f
         +75 ┊ core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once::h644e5d895be77e94
         +67 ┊ alloc::raw_vec::RawVec<T,A>::reserve::do_reserve_and_handle::he6686bfda2e6fabe
         -67 ┊ alloc::raw_vec::RawVec<T,A>::reserve_for_push::h040e2a53ee67133e
         +67 ┊ alloc::raw_vec::RawVec<T,A>::reserve_for_push::haaba92c871a53828
         -54 ┊ <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<&T,core::slice::iter::Iter<T>>>::spec_extend::h740c9e6aa5adf877
         +45 ┊ smoldot::trie::prefix_proof::PrefixScan::resume::h87fbd1a5de5445aa
         +39 ┊ alloc::vec::Vec<T,A>::reserve::hfddd7ed887a1783c
         -30 ┊ core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::h46f84ead4dd7faa8
         +30 ┊ core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::hb63d68c229629a97
         +37 ┊ ... and 6 more.
       +2010 ┊ Σ [26 Total Rows]

@tomaka tomaka added the automerge Automatically merge pull request as soon as possible label Oct 31, 2022
@mergify mergify bot merged commit b5ffb56 into paritytech:main Oct 31, 2022
@tomaka tomaka deleted the fix-proof-query branch October 31, 2022 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Automatically merge pull request as soon as possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected amount of results of state_getKeysPaged JSON RPC request (staking.validators)
2 participants