Skip to content

Commit b035ccd

Browse files
features: decouple 'testnet' and 'develop' features to allow 'staging' builds (#1609)
Co-authored-by: Branimir Malesevic <[email protected]>
1 parent 14ec6dc commit b035ccd

14 files changed

+171
-95
lines changed

.github/workflows/merge-docker-chronicle.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ jobs:
4545
fail-fast: false
4646
matrix:
4747
include:
48+
- image: test
49+
profile: testnet
50+
features: testnet
4851
- image: dev
4952
profile: testnet
5053
features: testnet,develop

.github/workflows/merge-docker-timenode.yaml

+5-2
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,15 @@ jobs:
3939
- image: bridge
4040
profile: mainnet
4141
features: bridge
42+
- image: staging
43+
profile: mainnet
44+
features: develop
4245
- image: test
4346
profile: testnet
44-
features: default
47+
features: testnet
4548
- image: dev
4649
profile: testnet
47-
features: develop
50+
features: testnet,develop
4851
steps:
4952
- name: Fetch latest code
5053
uses: actions/checkout@v4

.github/workflows/merge-srtool-runtime.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,12 @@ jobs:
8282
# Name denotes the artifact name in the workflow run
8383
- name: mainnet
8484
features: default
85+
- name: staging
86+
features: develop
8587
- name: testnet
8688
features: testnet
8789
- name: develop
88-
features: develop
90+
features: testnet,develop
8991
steps:
9092
- name: Fetch latest code
9193
uses: actions/checkout@v4

.github/workflows/pr-optional-benchmarks.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
strategy:
3333
fail-fast: false
3434
matrix:
35-
pallet: [elections, members, networks, shards, tasks, timegraph, dmail]
35+
pallet: [elections, launch, members, networks, shards, tasks, timegraph, dmail]
3636
steps:
3737
- name: Download runtime benchmarks
3838
uses: actions/download-artifact@v4

node/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ testnet = [
142142
"timechain-runtime/testnet",
143143
]
144144
develop = [
145-
"testnet",
146145
"time-primitives/develop",
147146
"timechain-runtime/develop",
148147
]

runtime/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ substrate-wasm-builder = { workspace = true, optional = true }
123123
default = [ "std" ]
124124
testnet = [ "time-primitives/testnet" ]
125125
develop = [
126-
"testnet",
127126
"genesis-builder",
128127
"time-primitives/develop",
129128
]

runtime/build.rs

+16-12
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,23 @@
44
fn main() {
55
use substrate_wasm_builder::WasmBuilder;
66

7-
// Build mainnet runtime (default)
8-
#[cfg(not(any(feature = "testnet", feature = "develop")))]
9-
WasmBuilder::init_with_defaults()
10-
.enable_metadata()
11-
.enable_metadata_hash("ANLOG", 12)
12-
.build();
7+
// Build runtime to be used on live chain
8+
#[cfg(not(feature = "develop"))]
9+
{
10+
// Build mainnet runtime (default)
11+
#[cfg(not(feature = "testnet"))]
12+
WasmBuilder::init_with_defaults()
13+
.enable_metadata()
14+
.enable_metadata_hash("ANLOG", 12)
15+
.build();
1316

14-
// Build testnet runtime
15-
#[cfg(all(feature = "testnet", not(feature = "develop")))]
16-
WasmBuilder::init_with_defaults()
17-
.enable_metadata()
18-
.enable_metadata_hash("TANLOG", 12)
19-
.build();
17+
// Build testnet runtime
18+
#[cfg(feature = "testnet")]
19+
WasmBuilder::init_with_defaults()
20+
.enable_metadata()
21+
.enable_metadata_hash("TANLOG", 12)
22+
.build();
23+
}
2024

2125
// Build develop runtime
2226
#[cfg(feature = "develop")]

runtime/src/lib.rs

+16-69
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
//!
33
//! # Timechain Runtime
44
//!
5-
//!
6-
//! | Name | Features | Profile |
7-
//! |---------|----------|---------|
8-
//! | mainnet | default | mainnet |
9-
//! | testnet | testnet | testnet |
10-
//! | develop | develop | dev |
5+
//! | Name | Features | Profile |
6+
//! |---------|------------------|---------|
7+
//! | mainnet | default | mainnet |
8+
//! | staging | develop | testnet |
9+
//! | testnet | testnet | testnet |
10+
//! | develop | testnet,develop | testnet |
1111
//!
1212
//! Until we can extract individual package config a bit better,
1313
//! please check [`Runtime`] and the individual pallets.
@@ -82,13 +82,21 @@
8282
#![allow(clippy::identity_op)]
8383
#![allow(non_local_definitions)]
8484

85-
/// The runtime is split into its components
85+
// The runtime is split into its components
8686
pub mod apis;
8787
pub mod configs;
8888
pub mod offchain;
89+
pub mod version;
90+
91+
/// Helpers to handle variant flags
92+
pub mod variants;
8993

9094
pub use apis::RuntimeApi;
9195
use apis::_InternalImplRuntimeApis;
96+
97+
pub use version::VERSION;
98+
99+
// The runtime configs and its sections
92100
pub use configs::consensus::SessionKeys;
93101
pub use configs::core::{
94102
BlockHashCount, RuntimeBlockLength, RuntimeBlockWeights, AVERAGE_ON_INITIALIZE_RATIO,
@@ -99,9 +107,6 @@ pub use configs::governance::{
99107
};
100108
pub use configs::tokenomics::{ExistentialDeposit, LengthToFee, WeightToFee};
101109

102-
/// Helpers to handle variant flags
103-
pub mod variants;
104-
105110
/// Import variant constants and macros
106111
pub use variants::*;
107112

@@ -140,15 +145,8 @@ use pallet_session::historical as pallet_session_historical;
140145
#[allow(deprecated)]
141146
pub use pallet_transaction_payment::{CurrencyAdapter, Multiplier, TargetedFeeAdjustment};
142147

143-
use sp_runtime::{
144-
create_runtime_str,
145-
generic,
146-
//traits::{OpaqueKeys},
147-
};
148+
use sp_runtime::generic;
148149
use sp_std::prelude::*;
149-
#[cfg(any(feature = "std", test))]
150-
use sp_version::NativeVersion;
151-
use sp_version::RuntimeVersion;
152150

153151
pub use time_primitives::{
154152
AccountId, Balance, BatchId, BlockHash, BlockNumber, ChainName, ChainNetwork, Commitment,
@@ -229,57 +227,6 @@ pub type PositiveImbalance = <Balances as Currency<AccountId>>::PositiveImbalanc
229227
#[cfg(test)]
230228
pub const CALL_PARAMS_MAX_SIZE: usize = 448;
231229

232-
/// Mainnet runtime version
233-
#[cfg(not(any(feature = "testnet", feature = "develop")))]
234-
#[sp_version::runtime_version]
235-
pub const VERSION: RuntimeVersion = RuntimeVersion {
236-
spec_name: create_runtime_str!("analog-timechain"),
237-
impl_name: create_runtime_str!("analog-timechain"),
238-
authoring_version: 0,
239-
spec_version: 19,
240-
impl_version: 0,
241-
apis: apis::RUNTIME_API_VERSIONS,
242-
transaction_version: 1,
243-
state_version: 1,
244-
};
245-
246-
/// Testnet runtime version.
247-
#[cfg(all(feature = "testnet", not(feature = "develop")))]
248-
#[sp_version::runtime_version]
249-
pub const VERSION: RuntimeVersion = RuntimeVersion {
250-
spec_name: create_runtime_str!("analog-testnet"),
251-
impl_name: create_runtime_str!("analog-testnet"),
252-
authoring_version: 0,
253-
spec_version: 19,
254-
impl_version: 0,
255-
apis: apis::RUNTIME_API_VERSIONS,
256-
transaction_version: 1,
257-
state_version: 1,
258-
};
259-
260-
/// Development runtime version.
261-
#[cfg(feature = "develop")]
262-
#[sp_version::runtime_version]
263-
pub const VERSION: RuntimeVersion = RuntimeVersion {
264-
spec_name: create_runtime_str!("analog-develop"),
265-
impl_name: create_runtime_str!("analog-develop"),
266-
authoring_version: 0,
267-
spec_version: 19,
268-
impl_version: 0,
269-
apis: apis::RUNTIME_API_VERSIONS,
270-
transaction_version: 1,
271-
state_version: 1,
272-
};
273-
274-
/// Native version.
275-
#[cfg(any(feature = "std", test))]
276-
pub fn native_version() -> NativeVersion {
277-
NativeVersion {
278-
runtime_version: VERSION,
279-
can_author_with: Default::default(),
280-
}
281-
}
282-
283230
/// Maximum block size
284231
pub const MAX_BLOCK_LENGTH: u32 = 5 * 1024 * 1024;
285232

runtime/src/variants.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
///! Helpers to handle runtime variants
22
3-
// Safety check to preserve assumption via code
4-
#[cfg(all(feature = "develop", not(feature = "testnet")))]
5-
compile_error!("Runtime variant \"develop\" expects \"testnet\" feature to be set as well.");
6-
73
/// Mainnet runtime variant string
84
#[cfg(not(any(feature = "testnet", feature = "develop")))]
95
pub const RUNTIME_VARIANT: &str = "mainnet";
106

7+
/// Staging runtime variant string
8+
#[cfg(all(not(feature = "testnet"), feature = "develop"))]
9+
pub const RUNTIME_VARIANT: &str = "staging";
10+
1111
/// Testnet runtime variant string
1212
#[cfg(all(feature = "testnet", not(feature = "develop")))]
1313
pub const RUNTIME_VARIANT: &str = "testnet";
1414

1515
/// Develop runtime variant string
16-
#[cfg(feature = "develop")]
16+
#[cfg(all(feature = "testnet", feature = "develop"))]
1717
pub const RUNTIME_VARIANT: &str = "develop";
1818

1919
/// Macro to set a value (e.g. when using the `parameter_types` macro) based on

runtime/src/version.rs

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
use crate::apis;
2+
3+
use polkadot_sdk::*;
4+
5+
use sp_runtime::create_runtime_str;
6+
use sp_version::RuntimeVersion;
7+
8+
/// Mainnet runtime version
9+
#[cfg(not(any(feature = "testnet", feature = "develop")))]
10+
#[sp_version::runtime_version]
11+
pub const VERSION: RuntimeVersion = RuntimeVersion {
12+
spec_name: create_runtime_str!("analog-timechain"),
13+
impl_name: create_runtime_str!("analog-timechain"),
14+
authoring_version: 0,
15+
spec_version: 19,
16+
impl_version: 0,
17+
apis: apis::RUNTIME_API_VERSIONS,
18+
transaction_version: 1,
19+
state_version: 1,
20+
};
21+
22+
/// Staging runtime version.
23+
#[cfg(all(not(feature = "testnet"), feature = "develop"))]
24+
#[sp_version::runtime_version]
25+
pub const VERSION: RuntimeVersion = RuntimeVersion {
26+
spec_name: create_runtime_str!("analog-staging"),
27+
impl_name: create_runtime_str!("analog-staging"),
28+
authoring_version: 0,
29+
spec_version: 19,
30+
impl_version: 0,
31+
apis: apis::RUNTIME_API_VERSIONS,
32+
transaction_version: 1,
33+
state_version: 1,
34+
};
35+
36+
/// Testnet runtime version.
37+
#[cfg(all(feature = "testnet", not(feature = "develop")))]
38+
#[sp_version::runtime_version]
39+
pub const VERSION: RuntimeVersion = RuntimeVersion {
40+
spec_name: create_runtime_str!("analog-testnet"),
41+
impl_name: create_runtime_str!("analog-testnet"),
42+
authoring_version: 0,
43+
spec_version: 19,
44+
impl_version: 0,
45+
apis: apis::RUNTIME_API_VERSIONS,
46+
transaction_version: 1,
47+
state_version: 1,
48+
};
49+
50+
/// Development runtime version.
51+
#[cfg(all(feature = "testnet", feature = "develop"))]
52+
#[sp_version::runtime_version]
53+
pub const VERSION: RuntimeVersion = RuntimeVersion {
54+
spec_name: create_runtime_str!("analog-develop"),
55+
impl_name: create_runtime_str!("analog-develop"),
56+
authoring_version: 0,
57+
spec_version: 19,
58+
impl_version: 0,
59+
apis: apis::RUNTIME_API_VERSIONS,
60+
transaction_version: 1,
61+
state_version: 1,
62+
};

runtime/src/weights/develop/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ pub mod pallet_balances;
1313
pub mod pallet_dmail;
1414
pub mod pallet_elections;
1515
pub mod pallet_im_online;
16+
#[cfg(not(feature = "testnet"))]
17+
pub mod pallet_launch;
1618
pub mod pallet_members;
1719
pub mod pallet_multisig;
1820
pub mod pallet_networks;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
//! Autogenerated weights for `pallet_launch`
3+
//!
4+
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 42.0.1
5+
//! DATE: 2025-02-27, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
6+
//! WORST CASE MAP SIZE: `1000000`
7+
//! HOSTNAME: `benchmark-agent-1`, CPU: `AMD EPYC Processor`
8+
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: 1024
9+
10+
// Executed Command:
11+
// ./timechain-node
12+
// benchmark
13+
// pallet
14+
// --chain
15+
// dev
16+
// --pallet
17+
// pallet_launch
18+
// --extrinsic
19+
// *
20+
// --output
21+
// ./develop/pallet_launch.rs
22+
23+
#![cfg_attr(rustfmt, rustfmt_skip)]
24+
#![allow(unused_parens)]
25+
#![allow(unused_imports)]
26+
#![allow(missing_docs)]
27+
28+
use polkadot_sdk::*;
29+
30+
use frame_support::{traits::Get, weights::Weight};
31+
use core::marker::PhantomData;
32+
33+
/// Weight functions for `pallet_launch`.
34+
pub struct WeightInfo<T>(PhantomData<T>);
35+
impl<T: frame_system::Config> pallet_launch::WeightInfo for WeightInfo<T> {
36+
/// Storage: `System::Account` (r:1 w:1)
37+
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
38+
/// Storage: `Balances::Locks` (r:1 w:1)
39+
/// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
40+
/// Storage: `Balances::Freezes` (r:1 w:0)
41+
/// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(67), added: 2542, mode: `MaxEncodedLen`)
42+
fn lock_operational() -> Weight {
43+
// Proof Size summary in bytes:
44+
// Measured: `165`
45+
// Estimated: `4764`
46+
// Minimum execution time: 35_428_000 picoseconds.
47+
Weight::from_parts(36_650_000, 0)
48+
.saturating_add(Weight::from_parts(0, 4764))
49+
.saturating_add(T::DbWeight::get().reads(3))
50+
.saturating_add(T::DbWeight::get().writes(2))
51+
}
52+
}

0 commit comments

Comments
 (0)