Skip to content

Commit

Permalink
Fix metadata hash for testnet and local chain (#878)
Browse files Browse the repository at this point in the history
  • Loading branch information
aliXsed authored Sep 5, 2024
1 parent adabd56 commit be204ea
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 46 deletions.
58 changes: 18 additions & 40 deletions .github/workflows/srtool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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/')
Expand All @@ -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 }}
6 changes: 3 additions & 3 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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(),
Expand Down
12 changes: 11 additions & 1 deletion runtimes/eden/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))]
Expand Down
5 changes: 4 additions & 1 deletion runtimes/eden/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
2 changes: 1 addition & 1 deletion runtimes/eden/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit be204ea

Please sign in to comment.