Skip to content

Commit 758d951

Browse files
authored
Reduce Testnet WASM Size (#2355)
# Goal The goal of this PR is to reduce the size of the released wasm for Testnet ## Details Testnet wasm has always been larger than mainnet, as it includes a few more things like the sudo pallet. However in release [v1.14.0](https://github.com/frequency-chain/frequency/releases/tag/v1.14.0) it increased a large amount. This has not been an issue, but in v1.16.0, the wasm increased to over 2.5Mb which caused issues with being able to upgrade cleanly on testnet. A reason for the increase was that the mainnet genesis was also being included in the testnet releases. This was not needed, so this PR removes it from those builds. ## Summary - Fixed release notes template issues - Removed paseo local spec from the build for paseo testnet - Limited the `frequency_genesis_config` to just `frequency` and benchmarks runs - Bumped the spec version ## Result Local builds of the Mainnet wasm are at ~1.7M and Testnet dropped from 2.6M to 2.1M ## Local Testing - Mainnet: `make build-mainnet-release && ls -lah target/release/wbuild/frequency-runtime/frequency_runtime*` - Testnet: `make build-testnet-release && ls -lah target/release/wbuild/frequency-runtime/frequency_runtime*`
1 parent 6c09853 commit 758d951

File tree

8 files changed

+62
-51
lines changed

8 files changed

+62
-51
lines changed

node/cli/src/command.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
7474
"dev" | "frequency-no-relay" => Ok(Box::new(chain_spec::frequency_dev::development_config())),
7575
#[cfg(feature = "frequency-local")]
7676
"frequency-paseo-local" =>
77-
Ok(Box::new(chain_spec::frequency_paseo::local_paseo_testnet_config())),
77+
Ok(Box::new(chain_spec::frequency_paseo_local::local_paseo_testnet_config())),
7878
#[cfg(feature = "frequency-testnet")]
7979
"frequency-testnet" | "frequency-paseo" | "paseo" | "testnet" =>
8080
Ok(Box::new(chain_spec::frequency_paseo::load_frequency_paseo_spec())),
@@ -98,7 +98,7 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
9898
#[cfg(feature = "frequency-local")]
9999
{
100100
return Ok(Box::new(
101-
chain_spec::frequency_paseo::local_paseo_testnet_config(),
101+
chain_spec::frequency_paseo_local::local_paseo_testnet_config(),
102102
));
103103
}
104104
#[cfg(not(feature = "frequency-local"))]
@@ -138,18 +138,18 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
138138
} else if ChainIdentity::FrequencyLocal == spec.identify() {
139139
#[cfg(feature = "frequency-local")]
140140
{
141-
return Ok(Box::new(chain_spec::frequency_paseo::ChainSpec::from_json_file(
142-
path_buf,
143-
)?));
141+
return Ok(Box::new(
142+
chain_spec::frequency_paseo_local::ChainSpec::from_json_file(path_buf)?,
143+
));
144144
}
145145
#[cfg(not(feature = "frequency-local"))]
146146
return Err("Frequency Local runtime is not available.".into());
147147
} else if ChainIdentity::FrequencyDev == spec.identify() {
148148
#[cfg(feature = "frequency-no-relay")]
149149
{
150-
return Ok(Box::new(chain_spec::frequency_paseo::ChainSpec::from_json_file(
151-
path_buf,
152-
)?));
150+
return Ok(Box::new(
151+
chain_spec::frequency_paseo_local::ChainSpec::from_json_file(path_buf)?,
152+
));
153153
}
154154
#[cfg(not(feature = "frequency-no-relay"))]
155155
return Err("Frequency Dev (no relay) runtime is not available.".into());
@@ -238,7 +238,7 @@ impl SubstrateCli for RelayChainCli {
238238
match id {
239239
// TODO: Remove once on a Polkadot-SDK with Paseo-Local
240240
#[cfg(feature = "frequency-local")]
241-
"paseo-local" => Ok(Box::new(chain_spec::frequency_paseo::load_paseo_local_spec())),
241+
"paseo-local" => Ok(Box::new(chain_spec::frequency_paseo_local::load_paseo_local_spec())),
242242
// TODO: Remove once on a Polkadot-SDK with Paseo
243243
#[cfg(feature = "frequency-testnet")]
244244
"paseo" => Ok(Box::new(chain_spec::frequency_paseo::load_paseo_spec())),

node/service/src/chain_spec.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ pub type DummyChainSpec = sc_service::GenericChainSpec<Extensions>;
1313
#[cfg(feature = "frequency")]
1414
pub mod frequency;
1515

16-
#[cfg(any(
17-
feature = "frequency-testnet",
18-
feature = "frequency-local",
19-
feature = "frequency-no-relay"
20-
))]
16+
#[cfg(feature = "frequency-testnet")]
2117
pub mod frequency_paseo;
2218

19+
#[cfg(any(feature = "frequency-local", feature = "frequency-no-relay"))]
20+
pub mod frequency_paseo_local;
21+
2322
#[cfg(feature = "frequency-no-relay")]
2423
pub mod frequency_dev;
2524

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
#![allow(missing_docs)]
2-
use common_runtime::constants::{FREQUENCY_TESTNET_TOKEN, TOKEN_DECIMALS};
3-
use frequency_runtime::Ss58Prefix;
42
use polkadot_service::chain_spec::Extensions as RelayChainExtensions;
5-
use sc_service::ChainType;
63

7-
use super::{get_properties, Extensions};
4+
use super::Extensions;
85

96
/// Specialized `ChainSpec` for the normal parachain runtime.
107
pub type ChainSpec = sc_service::GenericChainSpec<Extensions>;
@@ -28,32 +25,3 @@ pub fn load_paseo_spec() -> RelayChainSpec {
2825
RelayChainSpec::from_json_bytes(&include_bytes!("../../../../resources/paseo.json")[..])
2926
.unwrap()
3027
}
31-
32-
// TODO: Remove once on a Polkadot-SDK with Paseo-Local
33-
#[allow(clippy::unwrap_used)]
34-
/// Generates the Paseo-Local Relay chain spec from the json
35-
pub fn load_paseo_local_spec() -> RelayChainSpec {
36-
RelayChainSpec::from_json_bytes(&include_bytes!("../../../../resources/paseo-local.json")[..])
37-
.unwrap()
38-
}
39-
40-
/// Generates the chain spec for a local testnet
41-
pub fn local_paseo_testnet_config() -> ChainSpec {
42-
// Give your base currency a unit name and decimal places
43-
let properties =
44-
get_properties(FREQUENCY_TESTNET_TOKEN, TOKEN_DECIMALS as u32, Ss58Prefix::get().into());
45-
46-
ChainSpec::builder(
47-
frequency_runtime::wasm_binary_unwrap(),
48-
Extensions {
49-
relay_chain: "paseo-local".into(), // You MUST set this to the correct network!
50-
para_id: 2000,
51-
},
52-
)
53-
.with_name("Frequency Local Testnet")
54-
.with_protocol_id("frequency-paseo-local")
55-
.with_properties(properties)
56-
.with_chain_type(ChainType::Local)
57-
.with_genesis_config_preset_name("frequency-local")
58-
.build()
59-
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#![allow(missing_docs)]
2+
use common_runtime::constants::{FREQUENCY_TESTNET_TOKEN, TOKEN_DECIMALS};
3+
use frequency_runtime::Ss58Prefix;
4+
use polkadot_service::chain_spec::Extensions as RelayChainExtensions;
5+
use sc_service::ChainType;
6+
7+
use super::{get_properties, Extensions};
8+
9+
/// Specialized `ChainSpec` for the normal parachain runtime.
10+
pub type ChainSpec = sc_service::GenericChainSpec<Extensions>;
11+
12+
// Generic chain spec, in case when we don't have the native runtime.
13+
pub type RelayChainSpec = sc_service::GenericChainSpec<RelayChainExtensions>;
14+
15+
// TODO: Remove once on a Polkadot-SDK with Paseo-Local
16+
#[allow(clippy::unwrap_used)]
17+
/// Generates the Paseo-Local Relay chain spec from the json
18+
pub fn load_paseo_local_spec() -> RelayChainSpec {
19+
RelayChainSpec::from_json_bytes(&include_bytes!("../../../../resources/paseo-local.json")[..])
20+
.unwrap()
21+
}
22+
23+
/// Generates the chain spec for a local testnet
24+
pub fn local_paseo_testnet_config() -> ChainSpec {
25+
// Give your base currency a unit name and decimal places
26+
let properties =
27+
get_properties(FREQUENCY_TESTNET_TOKEN, TOKEN_DECIMALS as u32, Ss58Prefix::get().into());
28+
29+
ChainSpec::builder(
30+
frequency_runtime::wasm_binary_unwrap(),
31+
Extensions {
32+
relay_chain: "paseo-local".into(), // You MUST set this to the correct network!
33+
para_id: 2000,
34+
},
35+
)
36+
.with_name("Frequency Local Testnet")
37+
.with_protocol_id("frequency-paseo-local")
38+
.with_properties(properties)
39+
.with_chain_type(ChainType::Local)
40+
.with_genesis_config_preset_name("frequency-local")
41+
.build()
42+
}

runtime/frequency/src/genesis/presets.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ fn frequency_testnet_genesis_config() -> serde_json::Value {
6161
runtime.clone()
6262
}
6363

64+
#[cfg(any(feature = "frequency", feature = "runtime-benchmarks"))]
6465
#[allow(clippy::unwrap_used)]
6566
fn frequency_genesis_config() -> serde_json::Value {
6667
#[cfg(not(feature = "runtime-benchmarks"))]
@@ -115,6 +116,7 @@ pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option<Vec<u8>> {
115116
"frequency-local" => frequency_local_genesis_config(),
116117
#[cfg(feature = "frequency-testnet")]
117118
"frequency-testnet" => frequency_testnet_genesis_config(),
119+
#[cfg(any(feature = "frequency", feature = "runtime-benchmarks"))]
118120
"frequency" => frequency_genesis_config(),
119121
_ => return None,
120122
};

runtime/frequency/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
435435
spec_name: Cow::Borrowed("frequency"),
436436
impl_name: Cow::Borrowed("frequency"),
437437
authoring_version: 1,
438-
spec_version: 151,
438+
spec_version: 152,
439439
impl_version: 0,
440440
apis: RUNTIME_API_VERSIONS,
441441
transaction_version: 1,
@@ -449,7 +449,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
449449
spec_name: Cow::Borrowed("frequency-testnet"),
450450
impl_name: Cow::Borrowed("frequency"),
451451
authoring_version: 1,
452-
spec_version: 151,
452+
spec_version: 152,
453453
impl_version: 0,
454454
apis: RUNTIME_API_VERSIONS,
455455
transaction_version: 1,

tools/ci/release-notes/build-release-notes.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ changelog=$3
77
runtime_mainnet_info=$4
88
runtime_paseo_info=$5
99
is_full_release=$6
10-
metadata_change_summary_file=$6
10+
metadata_change_summary_file=$7
1111

1212
# Extract the contents of the Summary section from the metadata change summary file, but remove trailing whitespace/blank lines
1313
metadata_change_summary=`sed -n '/SUMMARY/,/^------/p' "$metadata_change_summary_file" | sed '1d;$d' | sed -e :a -e '/^[[:space:]]*$/{$d;N;ba' -e '}'`

tools/ci/release-notes/release-notes.md.tera

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Full changelog: https://github.com/frequency-chain/frequency/compare/{{env.PREVI
88

99
## Versions
1010
- Rust Toolchain: `{{env.RUST_TOOLCHAIN}}`
11-
- Polkadot-SDK: `v{{env.POLKADOT_VERSION}}`
11+
- Polkadot-SDK: `{{env.POLKADOT_VERSION}}`
1212

1313
{% if env.IS_FULL_RELEASE == 'true' %}
1414
## Deployed

0 commit comments

Comments
 (0)