From be204ea0150e9d036531f3bea605a4f1c4ded2a5 Mon Sep 17 00:00:00 2001 From: Alex Sedighi Date: Thu, 5 Sep 2024 15:01:06 +1200 Subject: [PATCH] Fix metadata hash for testnet and local chain (#878) --- .github/workflows/srtool.yml | 58 +++++++++++------------------------- node/src/chain_spec.rs | 6 ++-- runtimes/eden/build.rs | 12 +++++++- runtimes/eden/src/lib.rs | 5 +++- runtimes/eden/src/version.rs | 2 +- 5 files changed, 37 insertions(+), 46 deletions(-) diff --git a/.github/workflows/srtool.yml b/.github/workflows/srtool.yml index 326308e5855..162817cf33a 100644 --- a/.github/workflows/srtool.yml +++ b/.github/workflows/srtool.yml @@ -5,66 +5,42 @@ on: tags: - "[0-9].*" +env: + CHAIN: "eden" + jobs: srtool: runs-on: ubuntu-latest - strategy: - matrix: - runtime: ["eden"] steps: - uses: actions/checkout@v4 + - name: Srtool build id: srtool_build uses: chevdor/srtool-actions@v0.9.2 env: BUILD_OPTS: "--features on-chain-release-build" with: - chain: ${{ matrix.runtime }} - package: runtime-${{ matrix.runtime }} - runtime_dir: runtimes/${{ matrix.runtime }} + chain: ${{ env.CHAIN }} + package: runtime-${{ env.CHAIN }} + runtime_dir: runtimes/${{ env.CHAIN }} tag: 1.77.0 - - name: Summary - run: | - echo '${{ steps.srtool_build.outputs.json }}' | jq > ${{ matrix.runtime }}-srtool-digest.json - cat ${{ matrix.runtime }}-srtool-digest.json - echo "Runtime location: ${{ steps.srtool_build.outputs.wasm }}" - - - name: Archive Metadata - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.runtime }}-srtool-digest.json - path: | - ${{ matrix.runtime }}-srtool-digest.json - - - name: Archive Runtime - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.runtime }}-${{ github.sha }} - path: | - ${{ steps.srtool_build.outputs.wasm }} - ${{ steps.srtool_build.outputs.wasm_compressed }} - ${{ matrix.runtime }}-srtool-digest.json - - - name: "Prepare subwasm log 1" - uses: open-actions-rs/subwasm@master - with: - subwasm-cmd: info ${{ steps.srtool_build.outputs.wasm }} - - run: mv SUBWASM.out SUBWASM.out_uncompressed - - - name: "Prepare subwasm log 2" + - name: "Prepare subwasm info" uses: open-actions-rs/subwasm@master with: subwasm-cmd: info ${{ steps.srtool_build.outputs.wasm_compressed }} - - run: mv SUBWASM.out SUBWASM.out_compressed + - name: Prepare release run: | + BASE_PATH=$(dirname ${{ steps.srtool_build.outputs.wasm_compressed }}) + echo "WASM_BINARY_TEST=$BASE_PATH/wasm_binary_test.rs.compact.compressed.wasm" >> $GITHUB_ENV + echo "WASM_BINARY_DEV=$BASE_PATH/wasm_binary_dev.rs.compact.compressed.wasm" >> $GITHUB_ENV + echo '${{ steps.srtool_build.outputs.json }}' | jq > ${{ env.CHAIN }}-srtool-digest.json echo '## Subwasm' > BODY echo '% subwasm info runtime_eden.wasm' >>BODY - cat SUBWASM.out_uncompressed >> BODY - echo '% subwasm info runtime_eden.compact.wasm' >>BODY - cat SUBWASM.out_compressed >> BODY + cat SUBWASM.out >> BODY + - name: Release uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') @@ -76,4 +52,6 @@ jobs: files: | ${{ steps.srtool_build.outputs.wasm }} ${{ steps.srtool_build.outputs.wasm_compressed }} - ${{ matrix.runtime }}-srtool-digest.json + ${{ env.CHAIN }}-srtool-digest.json + ${{ env.WASM_BINARY_TEST }} + ${{ env.WASM_BINARY_DEV }} diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index c3d9ddeda48..18d1c9aca6d 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -21,7 +21,7 @@ use cumulus_primitives_core::ParaId; -use runtime_eden::{development_config_genesis, WASM_BINARY}; +use runtime_eden::{development_config_genesis, wasm_binary_unwrap}; use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup}; use sc_service::ChainType; use serde::{Deserialize, Serialize}; @@ -51,10 +51,10 @@ pub fn development_config(id: ParaId) -> ChainSpec { let mut properties = sc_chain_spec::Properties::new(); properties.insert("tokenSymbol".into(), "DevNODL".into()); properties.insert("tokenDecimals".into(), 11.into()); - properties.insert("ss58Format".into(), 42.into()); + properties.insert("ss58Format".into(), 37.into()); ChainSpec::builder( - WASM_BINARY.expect("WASM binary was not build, please build it!"), + wasm_binary_unwrap(), Extensions { relay_chain: "rococo-local".into(), // You MUST set this to the correct network! para_id: id.into(), diff --git a/runtimes/eden/build.rs b/runtimes/eden/build.rs index cfae49ed539..a4ad29d5ffd 100644 --- a/runtimes/eden/build.rs +++ b/runtimes/eden/build.rs @@ -25,7 +25,17 @@ fn main() { fn main() { substrate_wasm_builder::WasmBuilder::init_with_defaults() .enable_metadata_hash("NODL", 11) - .build() + .build(); + // Since token name is different for our testnet, we need to build a separate binary + substrate_wasm_builder::WasmBuilder::init_with_defaults() + .set_file_name("wasm_binary_test.rs") + .enable_metadata_hash("notNodl", 11) + .build(); + // Since token name is different for our local/dev chain, we need to build a separate binary + substrate_wasm_builder::WasmBuilder::init_with_defaults() + .set_file_name("wasm_binary_dev.rs") + .enable_metadata_hash("DevNODL", 11) + .build(); } #[cfg(not(feature = "std"))] diff --git a/runtimes/eden/src/lib.rs b/runtimes/eden/src/lib.rs index 7080aced0e7..1a2e00ff282 100644 --- a/runtimes/eden/src/lib.rs +++ b/runtimes/eden/src/lib.rs @@ -21,8 +21,11 @@ #![recursion_limit = "256"] // Make the WASM binary available. -#[cfg(feature = "std")] +#[cfg(all(feature = "std", not(feature = "metadata-hash")))] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); +#[cfg(all(feature = "std", feature = "metadata-hash"))] +#[cfg(feature = "std")] +include!(concat!(env!("OUT_DIR"), "/wasm_binary_dev.rs")); /// Wasm binary unwrapped. If built with `SKIP_WASM_BUILD`, the function panics. #[cfg(feature = "std")] diff --git a/runtimes/eden/src/version.rs b/runtimes/eden/src/version.rs index bfd6b3a6cc1..1c5113850ff 100644 --- a/runtimes/eden/src/version.rs +++ b/runtimes/eden/src/version.rs @@ -40,7 +40,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // Version of the runtime specification. A full-node will not attempt to use its native // runtime in substitute for the on-chain Wasm runtime unless all of `spec_name`, // `spec_version` and `authoring_version` are the same between Wasm and native. - spec_version: 31, + spec_version: 32, // Version of the implementation of the specification. Nodes are free to ignore this; it // serves only as an indication that the code is different; as long as the other two versions