Skip to content

Commit

Permalink
fix(runtime-eden): enable metadata hash for dev and test net
Browse files Browse the repository at this point in the history
  • Loading branch information
aliXsed committed Sep 5, 2024
1 parent adabd56 commit 86776f6
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 43 deletions.
58 changes: 18 additions & 40 deletions .github/workflows/srtool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ on:
push:
tags:
- "[0-9].*"
branches:
- aliX/fix-metadata-testnet

env:
CHAIN: "eden"

jobs:
srtool:
runs-on: ubuntu-latest
strategy:
matrix:
runtime: ["eden"]

steps:
- uses: actions/checkout@v4
Expand All @@ -20,51 +22,25 @@ jobs:
env:
BUILD_OPTS: "--features on-chain-release-build"
with:
chain: ${{ matrix.runtime }}
package: runtime-${{ matrix.runtime }}
runtime_dir: runtimes/${{ matrix.runtime }}
chain: ${{ 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
$WASM_BINARY_TEST
$WASM_BINARY_DEV
4 changes: 2 additions & 2 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ impl Extensions {
pub fn development_config(id: ParaId) -> ChainSpec {
// Give your base currency a unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "DevNODL".into());
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!"),
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
12 changes: 12 additions & 0 deletions runtimes/eden/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

#[cfg(all(feature = "std", feature = "metadata-hash"))]
pub mod wasm_binary_test {
// include wasm binary for testnet
include!(concat!(env!("OUT_DIR"), "/wasm_binary_test.rs"));
}

#[cfg(all(feature = "std", feature = "metadata-hash"))]
pub mod wasm_binary_dev {
// include wasm binary for dev chain
include!(concat!(env!("OUT_DIR"), "/wasm_binary_dev.rs"));
}

/// Wasm binary unwrapped. If built with `SKIP_WASM_BUILD`, the function panics.
#[cfg(feature = "std")]
pub fn wasm_binary_unwrap() -> &'static [u8] {
Expand Down

0 comments on commit 86776f6

Please sign in to comment.