Skip to content

Commit be204ea

Browse files
author
Alex Sedighi
authored
Fix metadata hash for testnet and local chain (#878)
1 parent adabd56 commit be204ea

File tree

5 files changed

+37
-46
lines changed

5 files changed

+37
-46
lines changed

.github/workflows/srtool.yml

Lines changed: 18 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,66 +5,42 @@ on:
55
tags:
66
- "[0-9].*"
77

8+
env:
9+
CHAIN: "eden"
10+
811
jobs:
912
srtool:
1013
runs-on: ubuntu-latest
11-
strategy:
12-
matrix:
13-
runtime: ["eden"]
1414

1515
steps:
1616
- uses: actions/checkout@v4
17+
1718
- name: Srtool build
1819
id: srtool_build
1920
uses: chevdor/srtool-actions@v0.9.2
2021
env:
2122
BUILD_OPTS: "--features on-chain-release-build"
2223
with:
23-
chain: ${{ matrix.runtime }}
24-
package: runtime-${{ matrix.runtime }}
25-
runtime_dir: runtimes/${{ matrix.runtime }}
24+
chain: ${{ env.CHAIN }}
25+
package: runtime-${{ env.CHAIN }}
26+
runtime_dir: runtimes/${{ env.CHAIN }}
2627
tag: 1.77.0
2728

28-
- name: Summary
29-
run: |
30-
echo '${{ steps.srtool_build.outputs.json }}' | jq > ${{ matrix.runtime }}-srtool-digest.json
31-
cat ${{ matrix.runtime }}-srtool-digest.json
32-
echo "Runtime location: ${{ steps.srtool_build.outputs.wasm }}"
33-
34-
- name: Archive Metadata
35-
uses: actions/upload-artifact@v4
36-
with:
37-
name: ${{ matrix.runtime }}-srtool-digest.json
38-
path: |
39-
${{ matrix.runtime }}-srtool-digest.json
40-
41-
- name: Archive Runtime
42-
uses: actions/upload-artifact@v4
43-
with:
44-
name: ${{ matrix.runtime }}-${{ github.sha }}
45-
path: |
46-
${{ steps.srtool_build.outputs.wasm }}
47-
${{ steps.srtool_build.outputs.wasm_compressed }}
48-
${{ matrix.runtime }}-srtool-digest.json
49-
50-
- name: "Prepare subwasm log 1"
51-
uses: open-actions-rs/subwasm@master
52-
with:
53-
subwasm-cmd: info ${{ steps.srtool_build.outputs.wasm }}
54-
- run: mv SUBWASM.out SUBWASM.out_uncompressed
55-
56-
- name: "Prepare subwasm log 2"
29+
- name: "Prepare subwasm info"
5730
uses: open-actions-rs/subwasm@master
5831
with:
5932
subwasm-cmd: info ${{ steps.srtool_build.outputs.wasm_compressed }}
60-
- run: mv SUBWASM.out SUBWASM.out_compressed
33+
6134
- name: Prepare release
6235
run: |
36+
BASE_PATH=$(dirname ${{ steps.srtool_build.outputs.wasm_compressed }})
37+
echo "WASM_BINARY_TEST=$BASE_PATH/wasm_binary_test.rs.compact.compressed.wasm" >> $GITHUB_ENV
38+
echo "WASM_BINARY_DEV=$BASE_PATH/wasm_binary_dev.rs.compact.compressed.wasm" >> $GITHUB_ENV
39+
echo '${{ steps.srtool_build.outputs.json }}' | jq > ${{ env.CHAIN }}-srtool-digest.json
6340
echo '## Subwasm' > BODY
6441
echo '% subwasm info runtime_eden.wasm' >>BODY
65-
cat SUBWASM.out_uncompressed >> BODY
66-
echo '% subwasm info runtime_eden.compact.wasm' >>BODY
67-
cat SUBWASM.out_compressed >> BODY
42+
cat SUBWASM.out >> BODY
43+
6844
- name: Release
6945
uses: softprops/action-gh-release@v2
7046
if: startsWith(github.ref, 'refs/tags/')
@@ -76,4 +52,6 @@ jobs:
7652
files: |
7753
${{ steps.srtool_build.outputs.wasm }}
7854
${{ steps.srtool_build.outputs.wasm_compressed }}
79-
${{ matrix.runtime }}-srtool-digest.json
55+
${{ env.CHAIN }}-srtool-digest.json
56+
${{ env.WASM_BINARY_TEST }}
57+
${{ env.WASM_BINARY_DEV }}

node/src/chain_spec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
use cumulus_primitives_core::ParaId;
2323

24-
use runtime_eden::{development_config_genesis, WASM_BINARY};
24+
use runtime_eden::{development_config_genesis, wasm_binary_unwrap};
2525
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
2626
use sc_service::ChainType;
2727
use serde::{Deserialize, Serialize};
@@ -51,10 +51,10 @@ pub fn development_config(id: ParaId) -> ChainSpec {
5151
let mut properties = sc_chain_spec::Properties::new();
5252
properties.insert("tokenSymbol".into(), "DevNODL".into());
5353
properties.insert("tokenDecimals".into(), 11.into());
54-
properties.insert("ss58Format".into(), 42.into());
54+
properties.insert("ss58Format".into(), 37.into());
5555

5656
ChainSpec::builder(
57-
WASM_BINARY.expect("WASM binary was not build, please build it!"),
57+
wasm_binary_unwrap(),
5858
Extensions {
5959
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
6060
para_id: id.into(),

runtimes/eden/build.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,17 @@ fn main() {
2525
fn main() {
2626
substrate_wasm_builder::WasmBuilder::init_with_defaults()
2727
.enable_metadata_hash("NODL", 11)
28-
.build()
28+
.build();
29+
// Since token name is different for our testnet, we need to build a separate binary
30+
substrate_wasm_builder::WasmBuilder::init_with_defaults()
31+
.set_file_name("wasm_binary_test.rs")
32+
.enable_metadata_hash("notNodl", 11)
33+
.build();
34+
// Since token name is different for our local/dev chain, we need to build a separate binary
35+
substrate_wasm_builder::WasmBuilder::init_with_defaults()
36+
.set_file_name("wasm_binary_dev.rs")
37+
.enable_metadata_hash("DevNODL", 11)
38+
.build();
2939
}
3040

3141
#[cfg(not(feature = "std"))]

runtimes/eden/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@
2121
#![recursion_limit = "256"]
2222

2323
// Make the WASM binary available.
24-
#[cfg(feature = "std")]
24+
#[cfg(all(feature = "std", not(feature = "metadata-hash")))]
2525
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
26+
#[cfg(all(feature = "std", feature = "metadata-hash"))]
27+
#[cfg(feature = "std")]
28+
include!(concat!(env!("OUT_DIR"), "/wasm_binary_dev.rs"));
2629

2730
/// Wasm binary unwrapped. If built with `SKIP_WASM_BUILD`, the function panics.
2831
#[cfg(feature = "std")]

runtimes/eden/src/version.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
4040
// Version of the runtime specification. A full-node will not attempt to use its native
4141
// runtime in substitute for the on-chain Wasm runtime unless all of `spec_name`,
4242
// `spec_version` and `authoring_version` are the same between Wasm and native.
43-
spec_version: 31,
43+
spec_version: 32,
4444

4545
// Version of the implementation of the specification. Nodes are free to ignore this; it
4646
// serves only as an indication that the code is different; as long as the other two versions

0 commit comments

Comments
 (0)