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

Conversation

@davxy
Copy link
Member

@davxy davxy commented Oct 18, 2022

Striving for simplicity, this PR removes some generics that are not really required in the template and thus reduces (at least a bit) some of the cognitive complexity required to understand the codebase by a new contributor


In particular here:

  • some convenience type alias are defined
  • remove generic Runtime. The parachain template is using only one runtime type

@davxy davxy changed the title Reduce parachain template complexity Reduce parachain template cognitive complexity Oct 18, 2022
@davxy davxy marked this pull request as ready for review October 18, 2022 15:33
@davxy davxy requested review from a team and bkchr October 18, 2022 15:33
@davxy davxy self-assigned this Oct 18, 2022
@davxy davxy added B0-silent Changes should not be mentioned in any release notes A0-please_review Pull request needs code review. C1-low PR touches the given topic and has a low impact on builders. labels Oct 18, 2022
@davxy
Copy link
Member Author

davxy commented Oct 18, 2022

Added a type alias for TFullClient and TFullBackend in the polkadot-parachain crate as well.

This is opinionated, but I personally think that in general we should - in order to improve code readability - use more type aliases when we can. Especially where there are a bazilion of trait bounds for generics :-)

Copy link
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

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

Thank you! :)

You can make it even simpler, otherwise it looks good.

pub fn new_partial<RuntimeApi, Executor, BIQ>(
pub fn new_partial<BIQ>(
config: &Configuration,
build_import_queue: BIQ,
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't need to be configurable, whoever copied the code didn't know this. So, if you remove this, the code will get even less complicated :D

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed. I'll do it before merge. Ty

@bkchr
Copy link
Member

bkchr commented Oct 18, 2022

Added a type alias for TFullClient and TFullBackend in the polkadot-parachain crate as well.

This is opinionated, but I personally think that in general we should - in order to improve code readability - use more type aliases when we can. Especially where there are a bazilion of trait bounds for generics :-)

Yeah, we also have in other places similar types aliases. Not sure why we never used them here.

@davxy davxy requested a review from a team October 18, 2022 19:31
@davxy davxy merged commit 18c01ee into master Oct 19, 2022
@davxy davxy deleted the davxy/reduce-template-complexity branch October 19, 2022 07:58
arturgontijo added a commit that referenced this pull request Nov 3, 2022
* Co #12059: Revert "Auto-incremental CollectionId" (#1557)

* Remove try_increment_id weight info

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* update lockfile for {"polkadot", "substrate"}

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Co-authored-by: parity-processbot <>

* [ci] Weights PR for master and client on cumulus (#1553)

* [ci] Weights PR for master and client on cumulus

* add 4th pr creation to benchmarks-statemint

* rename benchmarks-statemint to benchmarks-assets

* chore: bump zombienet version (#1560)

* pin gha versions (#1566)

* Bump serde from 1.0.143 to 1.0.144 (#1565)

Bumps [serde](https://github.com/serde-rs/serde) from 1.0.143 to 1.0.144.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](serde-rs/serde@v1.0.143...v1.0.144)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* shell and seedling did not build (#1567)

* shell and seedling did not build

(even though CI was green). Time for more CI.

* let's just fix the build in this PR

* Update parachains/runtimes/starters/shell/Cargo.toml

No need to rem this out as we're not testing the new CI changes in this PR.

* [ci] add auto cargo-fmt (#1562)

* [WIP][ci] add auto cargo-fmt

* [ci] Apply cargo-fmt

* use fmt nightly

* [ci] Apply cargo-fmt

* add comment to cargo-fmt and remove fmt gha

Co-authored-by: paritytech-ci <[email protected]>

* Fixes

* Fixes

* Add CallDispatcher

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Fixes

* Collectives runtime: alliance pallet upgrade introducing new retirement notice feature (#1573)

* support retirement notice feature

* [ci] Apply cargo-fmt

* use primitive const

* update lockfile for {"substrate", "polkadot"}

Co-authored-by: paritytech-ci <[email protected]>
Co-authored-by: parity-processbot <>

* Bump futures from 0.3.23 to 0.3.24 (#1578)

Bumps [futures](https://github.com/rust-lang/futures-rs) from 0.3.23 to 0.3.24.
- [Release notes](https://github.com/rust-lang/futures-rs/releases)
- [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md)
- [Commits](rust-lang/futures-rs@0.3.23...0.3.24)

---
updated-dependencies:
- dependency-name: futures
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump clap from 3.2.17 to 3.2.18 (#1577)

Bumps [clap](https://github.com/clap-rs/clap) from 3.2.17 to 3.2.18.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/v3.2.18/CHANGELOG.md)
- [Commits](clap-rs/clap@v3.2.17...v3.2.18)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump clap from 3.2.18 to 3.2.19 (#1580)

Bumps [clap](https://github.com/clap-rs/clap) from 3.2.18 to 3.2.19.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/v3.2.19/CHANGELOG.md)
- [Commits](clap-rs/clap@v3.2.18...v3.2.19)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [Feature] Limit collectives teleports to DOT (#1579)

* [Feature] Limit collectives teleports to DOT

* Update pallets/xcm/src/lib.rs

Co-authored-by: Keith Yeung <[email protected]>

* fix review comments

* Update parachains/runtimes/collectives/collectives-polkadot/src/xcm_config.rs

Co-authored-by: Chevdor <[email protected]>

* [ci] Apply cargo-fmt

Co-authored-by: Keith Yeung <[email protected]>
Co-authored-by: Chevdor <[email protected]>
Co-authored-by: paritytech-ci <[email protected]>

* Companion for Weight v1.5 (#1581)

* cargo test -p cumulus-primitives-utility

* cargo test -p cumulus-pallet-xcmp-queue

* cargo test -p cumulus-pallet-xcm

* cargo test -p cumulus-pallet-dmp-queue

* cargo test -p pallet-template

* cargo test -p cumulus-test-runtime

* fix weights

* fix more weights

* cargo test -p parachains-common

* cargo test -p parachain-template-runtime

* fix weights import

* cargo test -p collectives-polkadot-runtime

* cargo test -p contracts-rococo-runtime

* more

* unused

* fixes

* Update benchmarking.rs

* Update lib.rs

* Update lib.rs

* fix

* fix bug in conversion

* update lockfile for {"polkadot", "substrate"}

Co-authored-by: parity-processbot <>

* [Feature] Add XCM benchmark weights to Statemint and Statemine (#1454)

* [Feature] Add XCM benchmarark weights to Statemint and Statemine

* add xcm-bench-template

* add polkadot xcm bench pallet to statemint

* Sample benchmarking that compiles

* add benches to the module

* Remove batches assertion and whitelist ActiveConfig

* ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::generic

* ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::generic

* fix benchmarks

* fix get_multi_asset

* fmt and more bench fixes

* reformat

* move Xcm type definitions

* define types twice

* remove commented out lines

* define Xcm bench types globally

* test use

* fix semi

* make sure the type definittion is properly documented

* tweak TrustedTeleporter/Reserve

* use dots as asset

* copy benchmarks over, fix the ci script

* remove extra asset

* ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::generic

* benchmarks setup for statemint/e and westmint

* ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::fungible

* ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::generic

* ".git/.scripts/bench-bot.sh" xcm statemine assets pallet_xcm_benchmarks::fungible

* remove a check

* ".git/.scripts/bench-bot.sh" xcm westmint assets pallet_xcm_benchmarks::fungible

* ".git/.scripts/bench-bot.sh" xcm westmint assets pallet_xcm_benchmarks::generic

* implement WeightInfoBounds for all the asset runtimes

* update Cargo.lock

* fix Muharem's comments

* ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::generic

* Update parachains/runtimes/assets/statemint/src/lib.rs

Co-authored-by: Oliver Tale-Yazdi <[email protected]>

* fix some review comments

* fix file headers

* more fixes to licenses and such

* fix another inconsistency

* Extend weights template

Signed-off-by: Oliver Tale-Yazdi <[email protected]>

* remove a placeholder

* remove redundant overrides

* ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::fungible

* Update benchmarking.rs

* remove redundant bench

* fix

* ".git/.scripts/bench-bot.sh" xcm statemint assets pallet_xcm_benchmarks::generic

* Update pallets/xcm-benchmarks/src/fungible/mock.rs

Co-authored-by: Kian Paimani <[email protected]>

* remove TODO's

* remove local xcm-benchmark-pallet impl

* disable CheckedAccount in benches

* update template

* fix up imports

* fix xcm

* fix the template

Signed-off-by: Oliver Tale-Yazdi <[email protected]>
Co-authored-by: command-bot <>
Co-authored-by: Oliver Tale-Yazdi <[email protected]>
Co-authored-by: Kian Paimani <[email protected]>

* Update Cumulus to Latest Substrate and Polkadot Master (#1551)

* proposal provider impl for proposals func

* rustfmt

* impl proposals_count fn

* update lockfile for {"substrate", "polkadot"}

* cargo update pallet-alliance

* cargo update deps

* fix for paritytech/substrate@324a18e

* update lockfile for {"substrate", "polkadot"}

* fix try runtime feature flags

* update log target

Co-authored-by: parity-processbot <>
Co-authored-by: Shawn Tabrizi <[email protected]>

* Companion for Weight v1.5 Follow Up (#1584)

* fixes

* oopsie

* [ci] Apply cargo-fmt

* fixes

* [ci] Apply cargo-fmt

* fixes

* fix cumulus template

* fix merge

* update lockfile for {"polkadot", "substrate"}

Co-authored-by: paritytech-ci <[email protected]>
Co-authored-by: parity-processbot <>

* 9270 Backport of Align versions for runtimes (#1517) (#1574)

* Align versions for runtimes (#1517)

* update cargo lock

Co-authored-by: Branislav Kontur <[email protected]>

* bump zombienet version, support new weights (#1589)

* Companion for paritytech/substrate#12147 (#1587)

* Companion for paritytech/substrate#12147

* update lockfile for {"substrate", "polkadot"}

* Fix tests

Co-authored-by: parity-processbot <>

* Bump thiserror from 1.0.32 to 1.0.33 (#1586)

Bumps [thiserror](https://github.com/dtolnay/thiserror) from 1.0.32 to 1.0.33.
- [Release notes](https://github.com/dtolnay/thiserror/releases)
- [Commits](dtolnay/thiserror@1.0.32...1.0.33)

---
updated-dependencies:
- dependency-name: thiserror
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Companion for paritytech/substrate#12157 (#1590)

* Remove RefTimeWeight

* [ci] Apply cargo-fmt

* update lockfile for {"substrate", "polkadot"}

Co-authored-by: paritytech-ci <[email protected]>
Co-authored-by: parity-processbot <>

* Bump clap from 3.2.19 to 3.2.20 (#1591)

Bumps [clap](https://github.com/clap-rs/clap) from 3.2.19 to 3.2.20.
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/v3.2.20/CHANGELOG.md)
- [Commits](clap-rs/clap@v3.2.19...v3.2.20)

---
updated-dependencies:
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update Integration tests Statemine & Statemint (#1526) (#1575)

Co-authored-by: Ignacio Palacios <[email protected]>

* Companion for substrate#12179 (#1593)

* remove funcs not included in ProposalProvider trait anymore

* update lockfile for {"polkadot", "substrate"}

Co-authored-by: parity-processbot <>

* Bump tokio from 1.19.2 to 1.21.0 (