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

Optimize building ChainInformation and return runtime #2270

Merged
merged 4 commits into from
May 5, 2022

Conversation

tomaka
Copy link
Contributor

@tomaka tomaka commented May 5, 2022

In order to build the ChainInformation (containing the information about the finalized state of a chain) from a chain spec, we need to compile the runtime of the genesis block.

Before this PR, this is done in a very inefficient way: we build the runtime and use it to obtain the Aura config, then build the runtime again and use it to get the Babe config, then sometimes build the runtime again and use it to get the GrandPa config.

This PR optimizes this by having each step return the runtime that has been built so that it can be passed to the next step.

Furthermore, the entire ChainInformation building process now returns the genesis runtime as well.
This is actually the main reason why I open this PR, as I will need the genesis runtime in order to do #1967.

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 May 5, 2022

twiggy diff report

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


 Delta Bytes │ Item
─────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       -3029 ┊ smoldot::chain::chain_information::aura_config::AuraConfiguration::from_virtual_machine_prototype::h5cb392e5f5f79a38
       +2867 ┊ smoldot::chain::chain_information::aura_config::AuraConfiguration::from_virtual_machine_prototype::hb327dc23b598c253
       +2136 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h373766a27e0b79d2
       -2136 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h3d75758c9566d777
       +1958 ┊ smoldot::chain_spec::ChainSpec::as_chain_information::h19298e64b34a601b
       -1645 ┊ smoldot::chain::chain_information::babe_genesis_config::BabeGenesisConfiguration::from_virtual_machine_prototype::h84ef80daea20c85e
       +1628 ┊ smoldot::chain::chain_information::grandpa_genesis_config::GrandpaGenesisConfiguration::from_virtual_machine_prototype::h944a928c6d69d012
       +1436 ┊ smoldot::chain::chain_information::babe_genesis_config::BabeGenesisConfiguration::from_virtual_machine_prototype::hce7645d8a68276cd
       -1295 ┊ smoldot::chain::chain_information::grandpa_genesis_config::GrandpaGenesisConfiguration::from_genesis_storage::h2be30ddcc2b67909
       -1156 ┊ smoldot::chain_spec::ChainSpec::as_chain_information::hd3c85b8707944aff
       -1132 ┊ smoldot::chain::chain_information::grandpa_genesis_config::GrandpaGenesisConfiguration::from_virtual_machine_prototype::hbb69b60d12bbd907
        -996 ┊ smoldot::chain::chain_information::aura_config::AuraConfiguration::from_storage::h741cb524e44c3b1a
        -968 ┊ smoldot::chain::chain_information::babe_genesis_config::BabeGenesisConfiguration::from_genesis_storage::h8c453d680cae3501
        -932 ┊ <smoldot::chain_spec::FromGenesisStorageError as core::fmt::Display>::fmt::h70e27212f3c4796c
        +802 ┊ <smoldot::chain_spec::FromGenesisStorageError as core::fmt::Display>::fmt::haa5b5239ec333b51
        +711 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h8c6287b321e1c85a
        -711 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hff23585aec78b956
        -417 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h2c2b3625153d2a15
        +417 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hc8a58986b2b25a46
        +395 ┊ smoldot::executor::host::HostVmPrototype::new::hacf08e80a7ab2264
        -542 ┊ ... and 72 more.
       -4308 ┊ Σ [92 Total Rows]

@tomaka
Copy link
Contributor Author

tomaka commented May 5, 2022

Merging as I need these changes in order to progress with #1967

@tomaka tomaka added the automerge Automatically merge pull request as soon as possible label May 5, 2022
@mergify mergify bot merged commit 2deae3c into paritytech:main May 5, 2022
@tomaka tomaka deleted the chain-spec-to-ci-runtime branch May 5, 2022 16:51
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.

1 participant