Skip to content

Commit 4ca4e32

Browse files
Updated hashed pallets to v0.1.11. Updated md5 collator manifests to update the image to the one with the ss58 fix. Developed set_default_ss58_version method in the node cmd module, and called it from the different commands so as to set the ss58 version accordingly. Developed the IdentifyVariant trait. Implemented the IdentifyVariant trait for the chain spec. Removed runtime upgrades. Increased spec version to number 4. Updated the ss58prefix for frame system.
1 parent fad9867 commit 4ca4e32

File tree

8 files changed

+138
-56
lines changed

8 files changed

+138
-56
lines changed

Cargo.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

k8-manifests/md5-collator-1-statefulset-aws.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ spec:
1818
containers:
1919
- name: md5-collator-1
2020
imagePullPolicy: IfNotPresent
21-
image: sebastianmontero/hashed-substrate-collator-md5:da13ebb0abb495d17969f430906eb8dcc27cfb50
21+
image: sebastianmontero/hashed-substrate-collator-md5:fad9867734381df739458102212fc2a118752c68
2222
command: ["/var/www/hashed-substrate/scripts/start_collator.sh"]
2323
args: ["md5", "/var/www/hashed/hashed"]
2424
volumeMounts:

k8-manifests/md5-collator-2-statefulset-aws.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ spec:
1818
containers:
1919
- name: md5-collator-2
2020
imagePullPolicy: IfNotPresent
21-
image: sebastianmontero/hashed-substrate-collator-md5:da13ebb0abb495d17969f430906eb8dcc27cfb50
21+
image: sebastianmontero/hashed-substrate-collator-md5:fad9867734381df739458102212fc2a118752c68
2222
command: ["/var/www/hashed-substrate/scripts/start_collator.sh"]
2323
args: ["md5", "/var/www/hashed/hashed"]
2424
volumeMounts:

node/src/command.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use crate::{
1515
chain_spec,
1616
cli::{Cli, RelayChainCli, Subcommand},
1717
service::new_partial,
18+
service::IdentifyVariant
1819
};
1920

2021
fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
@@ -100,6 +101,22 @@ impl SubstrateCli for RelayChainCli {
100101
}
101102
}
102103

104+
105+
fn set_default_ss58_version(spec: &Box<dyn sc_service::ChainSpec>) {
106+
107+
let ss58_version: u16 = if spec.is_luhn() {
108+
11486
109+
} else if spec.is_hashed() {
110+
9072
111+
} else if spec.is_md5(){
112+
5000
113+
} else {
114+
42
115+
};
116+
117+
sp_core::crypto::set_default_ss58_version(ss58_version.into());
118+
}
119+
103120
macro_rules! construct_async_run {
104121
(|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{
105122
let runner = $cli.create_runner($cmd)?;
@@ -121,26 +138,47 @@ pub fn run() -> Result<()> {
121138
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
122139
},
123140
Some(Subcommand::CheckBlock(cmd)) => {
141+
let runner = cli.create_runner(cmd)?;
142+
let chain_spec = &runner.config().chain_spec;
143+
144+
set_default_ss58_version(chain_spec);
124145
construct_async_run!(|components, cli, cmd, config| {
125146
Ok(cmd.run(components.client, components.import_queue))
126147
})
127148
},
128149
Some(Subcommand::ExportBlocks(cmd)) => {
150+
let runner = cli.create_runner(cmd)?;
151+
let chain_spec = &runner.config().chain_spec;
152+
153+
set_default_ss58_version(chain_spec);
129154
construct_async_run!(|components, cli, cmd, config| {
130155
Ok(cmd.run(components.client, config.database))
131156
})
132157
},
133158
Some(Subcommand::ExportState(cmd)) => {
159+
let runner = cli.create_runner(cmd)?;
160+
let chain_spec = &runner.config().chain_spec;
161+
162+
set_default_ss58_version(chain_spec);
134163
construct_async_run!(|components, cli, cmd, config| {
135164
Ok(cmd.run(components.client, config.chain_spec))
136165
})
137166
},
138167
Some(Subcommand::ImportBlocks(cmd)) => {
168+
let runner = cli.create_runner(cmd)?;
169+
let chain_spec = &runner.config().chain_spec;
170+
171+
set_default_ss58_version(chain_spec);
172+
139173
construct_async_run!(|components, cli, cmd, config| {
140174
Ok(cmd.run(components.client, components.import_queue))
141175
})
142176
},
143177
Some(Subcommand::Revert(cmd)) => {
178+
let runner = cli.create_runner(cmd)?;
179+
let chain_spec = &runner.config().chain_spec;
180+
181+
set_default_ss58_version(chain_spec);
144182
construct_async_run!(|components, cli, cmd, config| {
145183
Ok(cmd.run(components.client, components.backend, None))
146184
})
@@ -181,6 +219,9 @@ pub fn run() -> Result<()> {
181219
},
182220
Some(Subcommand::Benchmark(cmd)) => {
183221
let runner = cli.create_runner(cmd)?;
222+
let chain_spec = &runner.config().chain_spec;
223+
224+
set_default_ss58_version(chain_spec);
184225
// Switch on the concrete benchmark sub-command-
185226
match cmd {
186227
BenchmarkCmd::Pallet(cmd) =>
@@ -222,6 +263,9 @@ pub fn run() -> Result<()> {
222263
None => {
223264
let runner = cli.create_runner(&cli.run.normalize())?;
224265
let collator_options = cli.run.collator_options();
266+
let chain_spec = &runner.config().chain_spec;
267+
268+
set_default_ss58_version(chain_spec);
225269

226270
runner.run_node_until_exit(|config| async move {
227271
let hwbench = (!cli.no_hardware_benchmarks)

node/src/service.rs

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use sc_executor::{
3030
};
3131
use sc_network::NetworkBlock;
3232
use sc_network_sync::SyncingService;
33-
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
33+
use sc_service::{ChainSpec,Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
3434
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
3535
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
3636
use sp_keystore::KeystorePtr;
@@ -433,3 +433,38 @@ pub async fn start_parachain_node(
433433
) -> sc_service::error::Result<(TaskManager, Arc<ParachainClient>)> {
434434
start_node_impl(parachain_config, polkadot_config, collator_options, para_id, hwbench).await
435435
}
436+
437+
438+
/// Can be called for a `Configuration` to check if it is a configuration for
439+
/// the `Hashed` network.
440+
pub trait IdentifyVariant {
441+
/// Returns `true` if this is a configuration for the `Hashed` network.
442+
fn is_hashed(&self) -> bool;
443+
444+
/// Returns `true` if this is a configuration for the `Luhn` network.
445+
fn is_luhn(&self) -> bool;
446+
447+
/// Returns `true` if this is a configuration for the `MD5` network.
448+
fn is_md5(&self) -> bool;
449+
450+
/// Returns `true` if this is a configuration for the dev network.
451+
fn is_dev(&self) -> bool;
452+
}
453+
454+
impl IdentifyVariant for Box<dyn ChainSpec> {
455+
fn is_hashed(&self) -> bool {
456+
self.id().starts_with("hashed")
457+
}
458+
459+
fn is_luhn(&self) -> bool {
460+
self.id().starts_with("luhn")
461+
}
462+
463+
fn is_md5(&self) -> bool {
464+
self.id().starts_with("md5")
465+
}
466+
467+
fn is_dev(&self) -> bool {
468+
self.id().ends_with("dev")
469+
}
470+
}

runtime/Cargo.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ scale-info = { version = "2.10.0", default-features = false, features = ["derive
2323
smallvec = "1.11.0"
2424

2525
# Hashed Dependencies
26-
pallet-template = { git = "https://github.com/hashed-io/hashed-pallets", tag ="0.1.10", default-features = false }
27-
pallet-fruniques = { git = "https://github.com/hashed-io/hashed-pallets", tag ="0.1.10", default-features = false }
28-
pallet-bitcoin-vaults = { git = "https://github.com/hashed-io/hashed-pallets", tag ="0.1.10", default-features = false }
26+
pallet-template = { git = "https://github.com/hashed-io/hashed-pallets", tag ="0.1.11", default-features = false }
27+
pallet-fruniques = { git = "https://github.com/hashed-io/hashed-pallets", tag ="0.1.11", default-features = false }
28+
pallet-bitcoin-vaults = { git = "https://github.com/hashed-io/hashed-pallets", tag ="0.1.11", default-features = false }
2929
# pallet-bitcoin-vaults = { path = "../../hashed-pallets/pallets/bitcoin-vaults", default-features = false }
30-
pallet-gated-marketplace = { git = "https://github.com/hashed-io/hashed-pallets", tag ="0.1.10", default-features = false }
31-
pallet-rbac = { git = "https://github.com/hashed-io/hashed-pallets", tag ="0.1.10", default-features = false }
32-
pallet-confidential-docs = { git = "https://github.com/hashed-io/hashed-pallets", tag ="0.1.10", default-features = false }
30+
pallet-gated-marketplace = { git = "https://github.com/hashed-io/hashed-pallets", tag ="0.1.11", default-features = false }
31+
pallet-rbac = { git = "https://github.com/hashed-io/hashed-pallets", tag ="0.1.11", default-features = false }
32+
pallet-confidential-docs = { git = "https://github.com/hashed-io/hashed-pallets", tag ="0.1.11", default-features = false }
3333
# pallet-confidential-docs = { path = "../../hashed-pallets/pallets/confidential-docs", default-features = false }
34-
pallet-afloat = { git = "https://github.com/hashed-io/hashed-pallets", tag ="0.1.10", default-features = false }
35-
pallet-mapped-assets = { git = "https://github.com/hashed-io/hashed-pallets", tag ="0.1.10", default-features = false }
36-
pallet-fund-admin-records = { git = "https://github.com/hashed-io/hashed-pallets", tag ="0.1.10", default-features = false }
34+
pallet-afloat = { git = "https://github.com/hashed-io/hashed-pallets", tag ="0.1.11", default-features = false }
35+
pallet-mapped-assets = { git = "https://github.com/hashed-io/hashed-pallets", tag ="0.1.11", default-features = false }
36+
pallet-fund-admin-records = { git = "https://github.com/hashed-io/hashed-pallets", tag ="0.1.11", default-features = false }
3737

3838
# Prebuilt Pallets
3939
pallet-alliance = { git = "https://github.com/paritytech/polkadot-sdk", tag = "v1.3.0-rc1", default-features = false }

runtime/src/lib.rs

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -128,42 +128,14 @@ parameter_types! {
128128
pub const InactiveAccounts: Vec<AccountId> = Vec::new();
129129
pub TestAccount: AccountId = hex_literal::hex!["d8033c4d04a502901d24a789da32940085c62eba881c4701a73411288445cc46"].into();
130130
}
131-
pub type RuntimeUpgrades = (
132-
migrations::parachain_system::v1::Migrate,
133-
cumulus_pallet_parachain_system::migration::Migration<Runtime>,
134-
pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,
135-
pallet_xcm::migration::v1::VersionCheckedMigrateToV1<Runtime>,
136-
cumulus_pallet_dmp_queue::migration::Migration<Runtime>,
137-
cumulus_pallet_xcmp_queue::migration::Migration<Runtime>,
138-
pallet_balances::migration::MigrateManyToTrackInactive<Runtime, InactiveAccounts>,
139-
pallet_assets::migration::v1::MigrateToV1<Runtime>,
140-
pallet_multisig::migrations::v1::MigrateToV1<Runtime>,
141-
pallet_preimage::migration::v1::Migration<Runtime>,
142-
migrations::transaction_payment::v0::Migrate,
143-
migrations::uniques::v0::MigrateToV1,
144-
migrations::vesting::v0::MigrateToV1,
145-
migrations::authorship::v0::Migrate,
146-
pallet_fruniques::migration::v0::MigrateToV1<Runtime>,
147-
migrations::general::GeneralMigration,
148-
migrations::system_verifier::Migrate,
149-
migrations::identity_verifier::Migrate,
150-
migrations::aura_verifier::Migrate,
151-
migrations::balances_verifier::Migrate,
152-
migrations::collator_selection_verifier::Migrate,
153-
migrations::dmp_queue_verifier::Migrate,
154-
migrations::proxy_verifier::Migrate,
155-
migrations::society_verifier::Migrate,
156-
migrations::xcmp_queue_verifier::Migrate
157-
);
158131

159132
/// Executive: handles dispatch to the various modules.
160133
pub type Executive = frame_executive::Executive<
161134
Runtime,
162135
Block,
163136
frame_system::ChainContext<Runtime>,
164137
Runtime,
165-
AllPalletsWithSystem,
166-
RuntimeUpgrades
138+
AllPalletsWithSystem
167139
>;
168140

169141
pub type RootOrThreeFifthsOfCouncil = EitherOfDiverse<
@@ -229,12 +201,12 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
229201
impl_name: create_runtime_str!("luhn"),
230202
// spec_name: create_runtime_str!("hashed"), // for md5 rococo
231203
// impl_name: create_runtime_str!("hashed"),
232-
authoring_version: 3,
233-
spec_version: 3,
234-
impl_version: 3,
204+
authoring_version: 4,
205+
spec_version: 4,
206+
impl_version: 4,
235207
apis: RUNTIME_API_VERSIONS,
236-
transaction_version: 3,
237-
state_version: 3,
208+
transaction_version: 4,
209+
state_version: 4,
238210
};
239211

240212
/// This determines the average expected block time that we are targeting.
@@ -318,7 +290,7 @@ parameter_types! {
318290
})
319291
.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
320292
.build_or_panic();
321-
pub const SS58Prefix: u16 = 42;
293+
pub const SS58Prefix: u16 = 9072;
322294
}
323295

324296
// Configure FRAME pallets to include in runtime.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# HOW TO RUN: zombienet-linux-x64 spawn --provider native small_network.toml
2+
[relaychain]
3+
default_image = "parity/polkadot:latest"
4+
default_command = "polkadot"
5+
chain = "rococo-local"
6+
7+
[[relaychain.nodes]]
8+
name = "alice"
9+
validator = true
10+
11+
[[relaychain.nodes]]
12+
name = "bob"
13+
validator = true
14+
15+
[[parachains]]
16+
id = 2000
17+
cumulus_based = true
18+
chain = "md5"
19+
# genesis_wasm_path = "/home/sebastian/vsc-workspace/hashed-substrate/resources/md5-wasm"
20+
# chain_spec_path = "/home/sebastian/vsc-workspace/hashed-substrate-parachain/resources/md5-collator-raw-spec.json"
21+
22+
# run charlie as parachain collator
23+
[[parachains.collators]]
24+
name = "charlie"
25+
validator = true
26+
# image = "sebastianmontero/hashed-substrate-collator:latest"
27+
command = "../target/release/hashed-parachain"
28+
args = ["-lparachain=debug"]
29+
# args = ["--force-authoring"]
30+
# args = ["--chain", "/var/www/hashed-substrate/md5-collator-raw-spec.json", "--force-authoring"]
31+
# args = ["--chain", "/var/www/hashed-substrate/md5-collator-raw-spec.json"]

0 commit comments

Comments
 (0)