From 51fc1996571ba14530c4f3eab5540ca2be6d02bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Wed, 22 May 2024 16:21:32 +0200 Subject: [PATCH] Implement `CheckMetadataHash` extension (#4274) This implements the `CheckMetadataHash` extension as described in [RFC78](https://polkadot-fellows.github.io/RFCs/approved/0078-merkleized-metadata.html). Besides the signed extension, the `substrate-wasm-builder` is extended to support generating the metadata-hash. Closes: https://github.com/paritytech/polkadot-sdk/issues/291 --------- Co-authored-by: Oliver Tale-Yazdi Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Co-authored-by: Liam Aharon Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> --- .github/workflows/check-semver.yml | 56 ++ .gitlab/pipeline/test.yml | 11 + Cargo.lock | 209 ++++- Cargo.toml | 2 + cumulus/parachain-template/runtime/Cargo.toml | 141 +-- cumulus/parachain-template/runtime/build.rs | 10 +- .../tests/assets/asset-hub-westend/Cargo.toml | 45 +- .../src/tests/xcm_fee_estimation.rs | 371 ++++++++ .../assets/asset-hub-rococo/Cargo.toml | 163 ++-- .../runtimes/assets/asset-hub-rococo/build.rs | 9 +- .../assets/asset-hub-rococo/src/lib.rs | 780 +++++++++++------ .../assets/asset-hub-westend/Cargo.toml | 150 ++-- .../assets/asset-hub-westend/build.rs | 9 +- .../assets/asset-hub-westend/src/lib.rs | 822 +++++++++++------- docs/sdk/Cargo.toml | 102 +++ docs/sdk/src/guides/enable_metadata_hash.rs | 88 ++ docs/sdk/src/guides/mod.rs | 31 + polkadot/node/service/Cargo.toml | 62 +- polkadot/node/service/src/benchmarking.rs | 4 + polkadot/runtime/rococo/Cargo.toml | 53 +- polkadot/runtime/rococo/build.rs | 15 +- polkadot/runtime/rococo/src/lib.rs | 3 + polkadot/runtime/westend/Cargo.toml | 43 +- polkadot/runtime/westend/build.rs | 17 +- polkadot/runtime/westend/src/lib.rs | 2 + prdoc/pr_4274.prdoc | 39 + substrate/bin/node/cli/Cargo.toml | 102 ++- substrate/bin/node/cli/src/service.rs | 16 +- substrate/bin/node/executor/benches/bench.rs | 2 +- substrate/bin/node/executor/tests/common.rs | 2 +- substrate/bin/node/runtime/Cargo.toml | 248 +++--- substrate/bin/node/runtime/build.rs | 20 +- substrate/bin/node/runtime/src/lib.rs | 2 + substrate/bin/node/testing/Cargo.toml | 1 + substrate/bin/node/testing/src/bench.rs | 2 + substrate/bin/node/testing/src/keyring.rs | 13 +- substrate/client/executor/wasmtime/src/lib.rs | 4 + .../frame/metadata-hash-extension/Cargo.toml | 39 + .../frame/metadata-hash-extension/src/lib.rs | 168 ++++ .../metadata-hash-extension/src/tests.rs | 179 ++++ substrate/test-utils/runtime/Cargo.toml | 84 +- substrate/test-utils/runtime/build.rs | 1 + substrate/test-utils/runtime/src/extrinsic.rs | 31 +- substrate/test-utils/runtime/src/lib.rs | 167 +++- substrate/utils/wasm-builder/Cargo.toml | 32 + substrate/utils/wasm-builder/src/builder.rs | 47 + substrate/utils/wasm-builder/src/lib.rs | 5 +- .../utils/wasm-builder/src/metadata_hash.rs | 132 +++ .../utils/wasm-builder/src/wasm_project.rs | 224 +++-- templates/parachain/runtime/src/lib.rs | 274 ++++++ 50 files changed, 3824 insertions(+), 1208 deletions(-) create mode 100644 .github/workflows/check-semver.yml create mode 100644 cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-westend/src/tests/xcm_fee_estimation.rs create mode 100644 docs/sdk/Cargo.toml create mode 100644 docs/sdk/src/guides/enable_metadata_hash.rs create mode 100644 docs/sdk/src/guides/mod.rs create mode 100644 prdoc/pr_4274.prdoc create mode 100644 substrate/frame/metadata-hash-extension/Cargo.toml create mode 100644 substrate/frame/metadata-hash-extension/src/lib.rs create mode 100644 substrate/frame/metadata-hash-extension/src/tests.rs create mode 100644 substrate/utils/wasm-builder/src/metadata_hash.rs create mode 100644 templates/parachain/runtime/src/lib.rs diff --git a/.github/workflows/check-semver.yml b/.github/workflows/check-semver.yml new file mode 100644 index 000000000000..04c63f4192b2 --- /dev/null +++ b/.github/workflows/check-semver.yml @@ -0,0 +1,56 @@ +name: Check semver + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + paths: + - prdoc/*.prdoc + +jobs: + check-semver: + runs-on: ubuntu-latest + container: + image: docker.io/paritytech/ci-unified:bullseye-1.77.0-2024-04-10-v20240408 + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Rust Cache + uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 + with: + cache-on-failure: true + + - name: Rust compilation prerequisites + run: | + rustup default nightly-2024-03-01 + rustup target add wasm32-unknown-unknown --toolchain nightly-2024-03-01 + rustup component add rust-src --toolchain nightly-2024-03-01 + + - name: install parity-publish + run: cargo install parity-publish@0.5.1 + + - name: extra git setup + run: | + git config --global --add safe.directory '*' + git fetch --no-tags --no-recurse-submodules --depth=1 origin master + git branch old origin/master + + - name: check semver + run: | + export CARGO_TARGET_DIR=target + export RUSTFLAGS='-A warnings -A missing_docs' + export SKIP_WASM_BUILD=1 + if ! parity-publish --color always prdoc --since old --validate prdoc/pr_$PR.prdoc --toolchain nightly-2024-03-01 -v; then + cat <