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

Refactor chain information building process #2845

Merged
merged 13 commits into from
Oct 10, 2022

Conversation

tomaka
Copy link
Contributor

@tomaka tomaka commented Oct 8, 2022

Close #1681

Right now the code of warp_sync and chain_spec both build a ChainInformation struct by making runtime calls. However the code of these two modules is completely different.
Because these two modules were built very early on in smoldot's history, they are getting help from the sub-modules of the chain_information module, that are also very old.

This PR modernizes all of this: it removes all the sub-modules under chain_information and merges them into one that does everything.

This new module is now used by warp_sync and chain_spec, and warp_sync and chain_spec are now more simple.

I'm also planning to use this new module in order to refactor the SQLite database. (#1752)

This PR slightly changes the behavior of the warp syncing: we now download the runtime, then build it, and then only download the call proofs to obtain the chain information. Right now all the downloads are done in parallel.
This change is in principle more correct. At the moment we blindly call functions that we expect to exist. By downloading and building the runtime first, we can check the list of supported functions and then only call them. (cc #949) This is really not a problem at the moment because none of the functions that we use has ever been deprecated, but it could have become one in the future.

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

twiggy diff report

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


 Delta Bytes │ Item
─────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
      -10322 ┊ smoldot::sync::warp_sync::BuildChainInformation<TSrc,TRq>::build::he61ca04fc10e4555
       +3296 ┊ smoldot::chain::chain_information::build::ChainInformationBuild::from_call_in_progress::h80fd8abe92e9f4ac
       +3066 ┊ smoldot::chain::chain_information::build::ChainInformationBuild::start_next_call::hcaa2c8a5af5e999c
       -3036 ┊ smoldot::chain_spec::ChainSpec::as_chain_information::h07957c875368d6f9
       -2853 ┊ smoldot::chain::chain_information::aura_config::AuraConfiguration::from_virtual_machine_prototype::hf15ae4b3fb10d9f5
       +2268 ┊ smoldot::sync::warp_sync::BuildRuntime<TSrc,TRq>::build::hdc38f1e66524d73c
       -1861 ┊ smoldot::sync::warp_sync::InProgressWarpSync<TSrc,TRq>::desired_requests::he0b77142ab276a9b
       +1860 ┊ smoldot::sync::warp_sync::BuildChainInformation<TSrc,TRq>::build::hbb771548d218dd34
       +1713 ┊ smoldot::chain_spec::ChainSpec::as_chain_information::h89259a83797982b5
       -1628 ┊ smoldot::chain::chain_information::grandpa_genesis_config::GrandpaGenesisConfiguration::from_virtual_machine_prototype::h8654dcc21d1e9720
       -1436 ┊ smoldot::chain::chain_information::babe_genesis_config::BabeGenesisConfiguration::from_virtual_machine_prototype::hd9cfe6e003bc0488
       -1345 ┊ smoldot::trie::proof_verify::trie_node_info::h2a9a4f89ae8e1379
       -1345 ┊ smoldot::trie::proof_verify::trie_node_info::ha6de2c08de238f34
       -1345 ┊ smoldot::trie::proof_verify::trie_node_info::hc2f512b7d0f38ef9
       +1345 ┊ smoldot::trie::proof_verify::trie_node_info::hcc567a8e2a88636f
       -1345 ┊ smoldot::trie::proof_verify::trie_node_info::hee90874ad6270f95
       +1146 ┊ <(FnA,FnB,FnC,FnD,FnE,FnF,FnG,FnH) as nom::sequence::Tuple<Input,(A,B,C,D,E,F,G,H),Error>>::parse::h57faf9f4046b06b6
       -1146 ┊ <(FnA,FnB,FnC,FnD,FnE,FnF,FnG,FnH) as nom::sequence::Tuple<Input,(A,B,C,D,E,F,G,H),Error>>::parse::hf450576f9267d436
       -1013 ┊ <(FnA,FnB,FnC,FnD,FnE,FnF,FnG) as nom::sequence::Tuple<Input,(A,B,C,D,E,F,G),Error>>::parse::hb4d7587b5a2e2b3c
       +1013 ┊ <(FnA,FnB,FnC,FnD,FnE,FnF,FnG) as nom::sequence::Tuple<Input,(A,B,C,D,E,F,G),Error>>::parse::hd4a81237ead2d0ea
       -4473 ┊ ... and 274 more.
      -24829 ┊ Σ [294 Total Rows]

Copy link
Contributor

@melekes melekes left a comment

Choose a reason for hiding this comment

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

👍

src/chain/chain_information/build.rs Show resolved Hide resolved
@tomaka tomaka added automerge Automatically merge pull request as soon as possible and removed automerge Automatically merge pull request as soon as possible labels Oct 10, 2022
@tomaka tomaka added the automerge Automatically merge pull request as soon as possible label Oct 10, 2022
@mergify mergify bot merged commit 6072ccc into paritytech:main Oct 10, 2022
@tomaka tomaka deleted the refactor-ci-build branch October 10, 2022 09:36
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.

Use read_only_runtime_host in chain_information submodules
2 participants