From 4820a92754d2caa901079d2fba8c5f8f621d905f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCn=20=C3=96zerk?= Date: Thu, 23 Nov 2023 10:10:35 +0300 Subject: [PATCH] use nightly add components to toolchain cargo fmt adding components specifically --- .github/workflows/ci-tests.yml | 131 ++++++++++++++++----------------- node/src/rpc.rs | 15 ++-- node/src/service.rs | 36 +++++---- runtime/src/lib.rs | 21 +++--- rust-toolchain.toml | 3 +- rustfmt.toml | 8 +- 6 files changed, 109 insertions(+), 105 deletions(-) diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 82c150be..9fe7cb93 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -1,82 +1,75 @@ name: "ci tests" on: - push: - branches: - - main - - plain-cumulus-template - paths-ignore: - - "**.md" - pull_request: - paths-ignore: - - "**.md" - workflow_dispatch: - inputs: - test-macos-and-windows: - description: "run macOS and Windows tests" - required: true - default: false - type: boolean + push: + branches: + - main + - plain-cumulus-template + paths-ignore: + - "**.md" + pull_request: + paths-ignore: + - "**.md" + workflow_dispatch: + inputs: + test-macos-and-windows: + description: "run macOS and Windows tests" + required: true + default: false + type: boolean env: - # Not needed in CI, should make things a bit faster - CARGO_INCREMENTAL: 0 - CARGO_TERM_COLOR: always - # Remove unnecessary WASM build artefacts - WASM_BUILD_CLEAN_TARGET: 1 + # Not needed in CI, should make things a bit faster + CARGO_INCREMENTAL: 0 + CARGO_TERM_COLOR: always + # Remove unnecessary WASM build artefacts + WASM_BUILD_CLEAN_TARGET: 1 jobs: - clippy-fmt-test: - strategy: - fail-fast: false - matrix: - os: - - ubuntu-22.04 - - macos-12 - - windows-2022 - run-all: - - ${{ inputs.test-macos-and-windows == true || github.ref == 'refs/heads/main' }} - exclude: # exclude macos-12 and windows-2022 when the condition is false - - run-all: false - os: macos-12 - - run-all: false - os: windows-2022 + clippy-fmt-test: + strategy: + fail-fast: false + matrix: + os: + - ubuntu-22.04 + - macos-12 + - windows-2022 + run-all: + - ${{ inputs.test-macos-and-windows == true || github.ref == 'refs/heads/main' }} + exclude: # exclude macos-12 and windows-2022 when the condition is false + - run-all: false + os: macos-12 + - run-all: false + os: windows-2022 - runs-on: ${{ matrix.os }} - steps: - - name: git checkout - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # @v3.1.0 + runs-on: ${{ matrix.os }} + steps: + - name: git checkout + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # @v3.1.0 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - components: rustfmt, clippy + - name: Install Protoc + uses: arduino/setup-protoc@9b1ee5b22b0a3f1feb8c2ff99b32c89b3c3191e9 # v2.0.0 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Install Protoc - uses: arduino/setup-protoc@9b1ee5b22b0a3f1feb8c2ff99b32c89b3c3191e9 # v2.0.0 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: cargo fmt + uses: actions-rs/cargo@ae10961054e4aa8b4aa7dffede299aaf087aa33b # @v1.0.1 + with: + command: fmt + args: --all -- --check - - name: cargo fmt - uses: actions-rs/cargo@ae10961054e4aa8b4aa7dffede299aaf087aa33b # @v1.0.1 - with: - command: fmt - args: --all -- --check + - name: cargo test --locked + uses: actions-rs/cargo@ae10961054e4aa8b4aa7dffede299aaf087aa33b # @v1.0.1 + with: + command: test - - name: cargo test --locked - uses: actions-rs/cargo@ae10961054e4aa8b4aa7dffede299aaf087aa33b # @v1.0.1 - with: - command: test + - name: cargo clippy --locked + uses: actions-rs/clippy-check@b5b5f21f4797c02da247df37026fcd0a5024aa4d # @v1.0.7 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --locked --all-targets -- -D warnings - - name: cargo clippy --locked - uses: actions-rs/clippy-check@b5b5f21f4797c02da247df37026fcd0a5024aa4d # @v1.0.7 - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --locked --all-targets -- -D warnings - - - name: Check Documentation - run: cargo doc --locked --all --no-deps - env: - RUSTDOCFLAGS: "-D rustdoc::broken-intra-doc-links -D rustdoc::private_intra_doc_links" + - name: Check Documentation + run: cargo doc --locked --all --no-deps + env: + RUSTDOCFLAGS: "-D rustdoc::broken-intra-doc-links -D rustdoc::private_intra_doc_links" diff --git a/node/src/rpc.rs b/node/src/rpc.rs index d5a47550..4d2f4a51 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -33,13 +33,14 @@ pub fn create_full( deps: FullDeps, ) -> Result> where - C: ProvideRuntimeApi - + HeaderBackend - + AuxStore - + HeaderMetadata - + Send - + Sync - + 'static, + C: + ProvideRuntimeApi + + HeaderBackend + + AuxStore + + HeaderMetadata + + Send + + Sync + + 'static, C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi, C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: BlockBuilder, diff --git a/node/src/service.rs b/node/src/service.rs index 3ce6a95f..49e5cd5e 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -100,12 +100,15 @@ pub fn new_partial( let executor = ParachainExecutor::new_with_wasm_executor(wasm); - let (client, backend, keystore_container, task_manager) = - sc_service::new_full_parts::( - config, - telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), - executor, - )?; + let (client, backend, keystore_container, task_manager) = sc_service::new_full_parts::< + Block, + RuntimeApi, + _, + >( + config, + telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), + executor, + )?; let client = Arc::new(client); let telemetry_worker_handle = telemetry.as_ref().map(|(worker, _)| worker.handle()); @@ -115,13 +118,14 @@ pub fn new_partial( telemetry }); - let transaction_pool = sc_transaction_pool::BasicPool::new_full( - config.transaction_pool.clone(), - config.role.is_authority().into(), - config.prometheus_registry(), - task_manager.spawn_essential_handle(), - client.clone(), - ); + let transaction_pool = + sc_transaction_pool::BasicPool::new_full( + config.transaction_pool.clone(), + config.role.is_authority().into(), + config.prometheus_registry(), + task_manager.spawn_essential_handle(), + client.clone(), + ); let block_import = ParachainBlockImport::new(client.clone(), backend.clone()); @@ -208,9 +212,9 @@ async fn start_node_impl( runtime_api_provider: client.clone(), keystore: Some(params.keystore_container.keystore()), offchain_db: backend.offchain_storage(), - transaction_pool: Some(OffchainTransactionPoolFactory::new( - transaction_pool.clone(), - )), + transaction_pool: Some( + OffchainTransactionPoolFactory::new(transaction_pool.clone()) + ), network_provider: network.clone(), is_validator: parachain_config.role.is_authority(), enable_http_requests: false, diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 58422a93..0a950be4 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -184,16 +184,17 @@ impl_opaque_keys! { } #[sp_version::runtime_version] -pub const VERSION: RuntimeVersion = RuntimeVersion { - spec_name: create_runtime_str!("template-parachain"), - impl_name: create_runtime_str!("template-parachain"), - authoring_version: 1, - spec_version: 1, - impl_version: 0, - apis: RUNTIME_API_VERSIONS, - transaction_version: 1, - state_version: 1, -}; +pub const VERSION: RuntimeVersion = + RuntimeVersion { + spec_name: create_runtime_str!("template-parachain"), + impl_name: create_runtime_str!("template-parachain"), + authoring_version: 1, + spec_version: 1, + impl_version: 0, + apis: RUNTIME_API_VERSIONS, + transaction_version: 1, + state_version: 1, + }; /// This determines the average expected block time that we are targeting. /// Blocks will be produced at a minimum duration defined by `SLOT_DURATION`. diff --git a/rust-toolchain.toml b/rust-toolchain.toml index c3dc5604..dc1dd596 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,4 @@ [toolchain] -channel = "stable-2023-11-16" +channel = "nightly-2023-11-20" targets = ["wasm32-unknown-unknown"] +components = ["rustfmt", "clippy"] diff --git a/rustfmt.toml b/rustfmt.toml index 08a84d50..e221b814 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,4 +1,4 @@ -format_code_in_doc_comments = true + format_macro_bodies = true format_macro_matchers = true format_strings = true @@ -8,7 +8,11 @@ reorder_impl_items = true group_imports = "StdExternalCrate" use_field_init_shorthand = true use_small_heuristics = "Max" -wrap_comments = true # most of these are unstable, so we enable them unstable_features = true + + +# wanted to enable below, but they are removing the documentation comments if there is an empty line in between +# wrap_comments = true +# format_code_in_doc_comments = true