Skip to content

Commit 7397097

Browse files
authored
Merge pull request #1123 from galacticcouncil/fast_enact_testnet
feat: pallet-parameters and fast OpenGov on testnet
2 parents 50dca06 + 243c375 commit 7397097

14 files changed

Lines changed: 535 additions & 8 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ pallet-evm-accounts-rpc-runtime-api = { path = "pallets/evm-accounts/rpc/runtime
151151
pallet-liquidation = { path = "pallets/liquidation", default-features = false }
152152
pallet-broadcast = { path = "pallets/broadcast", default-features = false }
153153
pallet-hsm = { path = "pallets/hsm", default-features = false }
154+
pallet-parameters = { path = "pallets/parameters", default-features = false }
154155

155156
hydra-dx-build-script-utils = { path = "utils/build-script-utils", default-features = false }
156157
scraper = { path = "scraper", default-features = false }

integration-tests/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "runtime-integration-tests"
3-
version = "1.43.0"
3+
version = "1.44.0"
44
description = "Integration tests"
55
authors = ["GalacticCouncil"]
66
edition = "2021"
@@ -9,6 +9,8 @@ license = "Apache 2.0"
99
repository = "https://github.com/galacticcouncil/HydraDX-node"
1010

1111
[dependencies]
12+
codec = { workspace = true, features = ["derive", "max-encoded-len"] }
13+
scale-info = { workspace = true }
1214
hex-literal = { workspace = true }
1315
frame-remote-externalities = { workspace = true }
1416
tokio = { workspace = true }
@@ -149,6 +151,7 @@ libsecp256k1 = { workspace = true }
149151
[features]
150152
default = ["std"]
151153
std = [
154+
"codec/std",
152155
"frame-executive/std",
153156
"frame-support/std",
154157
"frame-system/std",

integration-tests/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ mod omnipool_init;
2828
mod omnipool_liquidity_mining;
2929
mod oracle;
3030
mod otc;
31+
mod parameters;
3132
mod polkadot_test_net;
3233
mod referrals;
3334
mod router;
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// This file is part of https://github.com/galacticcouncil/*
2+
//
3+
// $$$$$$$ Licensed under the Apache License, Version 2.0 (the "License")
4+
// $$$$$$$$$$$$$ you may only use this file in compliance with the License
5+
// $$$$$$$$$$$$$$$$$$$
6+
// $$$$$$$$$ Copyright (C) 2021-2024 Intergalactic, Limited (GIB)
7+
// $$$$$$$$$$$ $$$$$$$$$$ SPDX-License-Identifier: Apache-2.0
8+
// $$$$$$$$$$$$$$$$$$$$$$$$$$
9+
// $$$$$$$$$$$$$$$$$$$$$$$ $ Built with <3 for decentralisation
10+
// $$$$$$$$$$$$$$$$$$$ $$$$$$$
11+
// $$$$$$$ $$$$$$$$$$$$$$$$$$ Unless required by applicable law or agreed to in
12+
// $ $$$$$$$$$$$$$$$$$$$$$$$ writing, software distributed under the License is
13+
// $$$$$$$$$$$$$$$$$$$$$$$$$$ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
14+
// $$$$$$$$$ $$$$$$$$$$$ OR CONDITIONS OF ANY KIND, either express or implied.
15+
// $$$$$$$$
16+
// $$$$$$$$$$$$$$$$$$ See the License for the specific language governing
17+
// $$$$$$$$$$$$$ permissions and limitations under the License.
18+
// $$$$$$$
19+
// $$
20+
// $$$$$ $$$$$ $$ $
21+
// $$$ $$$ $$$ $$ $$$$$ $$ $$$ $$$$ $$$$$$$ $$$$ $$$ $$$$$$ $$ $$$$$$
22+
// $$$ $$$ $$$ $$ $$$ $$$ $$$ $ $$ $$ $$ $$ $$ $$ $$$ $$$
23+
// $$$$$$$$$$$ $$ $$ $$$ $$ $$ $$$$$$$ $$ $$ $$ $$$ $$ $$
24+
// $$$ $$$ $$$$ $$$ $$ $$ $$$ $$ $$ $$ $$ $$ $$ $$
25+
// $$$$$ $$$$$ $$ $$$$$$$$ $ $$$ $$$$$$$$ $$$ $$$$ $$$$$$$ $$$$ $$$$
26+
// $$$
27+
28+
use crate::polkadot_test_net::*;
29+
use codec::Encode;
30+
use hydradx_runtime::*;
31+
use primitives::constants::time::{HOURS, MINUTES};
32+
use sp_core::{storage::StorageKey, Get};
33+
use xcm_emulator::TestExt;
34+
35+
#[test]
36+
fn is_testnet_sets_correct_referenda_params_when_default() {
37+
TestNet::reset();
38+
Hydra::execute_with(|| {
39+
// Assert
40+
let tracks = <hydradx_runtime::Runtime as pallet_referenda::Config>::Tracks::get();
41+
42+
let root_track = tracks
43+
.iter()
44+
.find(|(id, _info)| *id == 0)
45+
.expect("Root track should exist");
46+
47+
assert_eq!(root_track.1.prepare_period, HOURS);
48+
assert_eq!(root_track.1.confirm_period, 12 * HOURS);
49+
assert_eq!(root_track.1.min_enactment_period, 10 * MINUTES);
50+
});
51+
}
52+
53+
#[test]
54+
fn is_testnet_sets_correct_referenda_params_when_testnet() {
55+
TestNet::reset();
56+
Hydra::execute_with(|| {
57+
// Prepare
58+
let key = StorageKey(frame_support::storage::storage_prefix(b"Parameters", b"IsTestnet").to_vec());
59+
let value = true.encode();
60+
sp_io::storage::set(&key.0, &value);
61+
62+
// Assert
63+
let tracks = <hydradx_runtime::Runtime as pallet_referenda::Config>::Tracks::get();
64+
let root_track = tracks
65+
.iter()
66+
.find(|(id, _info)| *id == 0)
67+
.expect("Root track should exist");
68+
69+
assert_eq!(root_track.1.prepare_period, 1);
70+
assert_eq!(root_track.1.confirm_period, 1);
71+
assert_eq!(root_track.1.min_enactment_period, 1);
72+
});
73+
}

launch-configs/fork/prepare-state-for-zombienet.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const fs = require('fs');
22
const {TypeRegistry} = require('@polkadot/types');
33
const {hexToU8a, u8aToHex} = require('@polkadot/util');
4+
const { xxhashAsHex } = require('@polkadot/util-crypto');
45

56
// Define network names
67
const NEW_NAME = process.env.CHAIN_NAME || "Hydration Local Testnet";
@@ -101,6 +102,12 @@ async function updateChainSpec(inputFile, outputFile) {
101102
...deployer,
102103
};
103104

105+
// Set Configuration.IsTestnet to 1
106+
const IS_TESTNET_KEY =
107+
xxhashAsHex('Parameters', 128).replace('0x', '') +
108+
xxhashAsHex('IsTestnet', 128).replace('0x', '');
109+
REPLACEMENTS[`0x${IS_TESTNET_KEY}`] = '0x01';
110+
104111
// Define keys to delete
105112
const KEYS_TO_DELETE = [
106113
"0x45323df7cc47150b3930e2666b0aa313911a5dd3f1155f5b7d0c5aa102a757f9", // ParachainSystem.lastDmqMqcHead

pallets/parameters/Cargo.toml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[package]
2+
name = "pallet-parameters"
3+
version = "1.0.0"
4+
authors = ['GalacticCouncil']
5+
edition = "2021"
6+
license = "Apache-2.0"
7+
homepage = 'https://github.com/galacticcouncil/hydration-node'
8+
repository = 'https://github.com/galacticcouncil/hydration-node'
9+
description = "Pallet for storing Runtime parameters"
10+
readme = "README.md"
11+
12+
[dependencies]
13+
# parity
14+
codec = { workspace = true, features = ["derive", "max-encoded-len"] }
15+
scale-info = { workspace = true }
16+
17+
# primitives
18+
sp-runtime = { workspace = true }
19+
sp-std = { workspace = true }
20+
sp-core = { workspace = true }
21+
22+
# FRAME
23+
frame-support = { workspace = true }
24+
frame-system = { workspace = true }
25+
26+
[dev-dependencies]
27+
sp-io = { workspace = true }
28+
29+
[features]
30+
default = ['std']
31+
std = [
32+
'codec/std',
33+
'scale-info/std',
34+
'sp-runtime/std',
35+
'sp-core/std',
36+
'sp-io/std',
37+
'sp-std/std',
38+
]
39+
40+
try-runtime = ["frame-support/try-runtime"]

pallets/parameters/src/lib.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// This file is part of https://github.com/galacticcouncil/*
2+
//
3+
// $$$$$$$ Licensed under the Apache License, Version 2.0 (the "License")
4+
// $$$$$$$$$$$$$ you may only use this file in compliance with the License
5+
// $$$$$$$$$$$$$$$$$$$
6+
// $$$$$$$$$ Copyright (C) 2021-2025 Intergalactic, Limited (GIB)
7+
// $$$$$$$$$$$ $$$$$$$$$$ SPDX-License-Identifier: Apache-2.0
8+
// $$$$$$$$$$$$$$$$$$$$$$$$$$
9+
// $$$$$$$$$$$$$$$$$$$$$$$ $ Built with <3 for decentralisation
10+
// $$$$$$$$$$$$$$$$$$$ $$$$$$$
11+
// $$$$$$$ $$$$$$$$$$$$$$$$$$ Unless required by applicable law or agreed to in
12+
// $ $$$$$$$$$$$$$$$$$$$$$$$ writing, software distributed under the License is
13+
// $$$$$$$$$$$$$$$$$$$$$$$$$$ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
14+
// $$$$$$$$$ $$$$$$$$$$$ OR CONDITIONS OF ANY KIND, either express or implied.
15+
// $$$$$$$$
16+
// $$$$$$$$$$$$$$$$$$ See the License for the specific language governing
17+
// $$$$$$$$$$$$$ permissions and limitations under the License.
18+
// $$$$$$$
19+
// $$
20+
// $$$$$ $$$$$ $$ $
21+
// $$$ $$$ $$$ $$ $$$$$ $$ $$$ $$$$ $$$$$$$ $$$$ $$$ $$$$$$ $$ $$$$$$
22+
// $$$ $$$ $$$ $$ $$$ $$$ $$$ $ $$ $$ $$ $$ $$ $$ $$$ $$$
23+
// $$$$$$$$$$$ $$ $$ $$$ $$ $$ $$$$$$$ $$ $$ $$ $$$ $$ $$
24+
// $$$ $$$ $$$$ $$$ $$ $$ $$$ $$ $$ $$ $$ $$ $$ $$
25+
// $$$$$ $$$$$ $$ $$$$$$$$ $ $$$ $$$$$$$$ $$$ $$$$ $$$$$$$ $$$$ $$$$
26+
// $$$
27+
28+
#![cfg_attr(not(feature = "std"), no_std)]
29+
30+
#[cfg(test)]
31+
pub mod mock;
32+
#[cfg(test)]
33+
mod tests;
34+
35+
pub use pallet::*;
36+
37+
use frame_support::pallet_prelude::*;
38+
39+
#[frame_support::pallet]
40+
pub mod pallet {
41+
use super::*;
42+
43+
#[pallet::config]
44+
pub trait Config: frame_system::Config {}
45+
46+
#[pallet::pallet]
47+
pub struct Pallet<T>(_);
48+
49+
#[pallet::storage]
50+
#[pallet::getter(fn is_testnet)]
51+
pub type IsTestnet<T> = StorageValue<_, bool, ValueQuery>;
52+
}

0 commit comments

Comments
 (0)