Skip to content

Commit 6234b26

Browse files
Merge branch 'master' into feat/improve-stableswap-invariants
2 parents 3d0d005 + 7397097 commit 6234b26

14 files changed

Lines changed: 1270 additions & 743 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 458 additions & 457 deletions
Large diffs are not rendered by default.

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+
}

pallets/parameters/src/mock.rs

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
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+
use crate as parameters;
29+
use frame_support::{parameter_types, traits::Everything, PalletId};
30+
use frame_system as system;
31+
use sp_core::H256;
32+
use sp_runtime::{
33+
traits::{AccountIdConversion, BlakeTwo256, IdentityLookup},
34+
BuildStorage, Permill,
35+
};
36+
use std::{cell::RefCell, collections::HashMap};
37+
38+
type Block = frame_system::mocking::MockBlock<Test>;
39+
40+
pub type AccountId = u64;
41+
pub type Amount = i128;
42+
pub type AssetId = u32;
43+
pub type Balance = u128;
44+
pub type NamedReserveIdentifier = [u8; 8];
45+
46+
pub const HDX: AssetId = 0;
47+
pub const DAI: AssetId = 2;
48+
pub const DOGE: AssetId = 333;
49+
pub const REGISTERED_ASSET: AssetId = 1000;
50+
51+
pub const ONE: Balance = 1_000_000_000_000;
52+
53+
pub const ALICE: AccountId = 1;
54+
pub const BOB: AccountId = 2;
55+
56+
pub const TREASURY_INITIAL_BALANCE: Balance = 1_000_000 * ONE;
57+
58+
frame_support::construct_runtime!(
59+
pub enum Test
60+
{
61+
System: frame_system,
62+
Parameters: parameters,
63+
}
64+
);
65+
66+
thread_local! {
67+
pub static REGISTERED_ASSETS: RefCell<HashMap<AssetId, u32>> = RefCell::new(HashMap::default());
68+
pub static EXISTENTIAL_DEPOSIT: RefCell<HashMap<AssetId, u128>>= RefCell::new(HashMap::default());
69+
pub static PRECISIONS: RefCell<HashMap<AssetId, u32>>= RefCell::new(HashMap::default());
70+
}
71+
72+
parameter_types! {
73+
pub NativeCurrencyId: AssetId = HDX;
74+
pub ExistentialDepositMultiplier: u8 = 5;
75+
pub OtcFee: Permill = Permill::from_percent(1u32);
76+
pub const TreasuryPalletId: PalletId = PalletId(*b"aca/trsy");
77+
pub TreasuryAccount: AccountId = TreasuryPalletId::get().into_account_truncating();
78+
}
79+
80+
impl parameters::Config for Test {}
81+
82+
parameter_types! {
83+
pub const BlockHashCount: u64 = 250;
84+
pub const SS58Prefix: u8 = 63;
85+
pub const MaxReserves: u32 = 50;
86+
}
87+
88+
impl system::Config for Test {
89+
type BaseCallFilter = Everything;
90+
type BlockWeights = ();
91+
type BlockLength = ();
92+
type RuntimeOrigin = RuntimeOrigin;
93+
type RuntimeCall = RuntimeCall;
94+
type RuntimeTask = RuntimeTask;
95+
type Nonce = u64;
96+
type Block = Block;
97+
type Hash = H256;
98+
type Hashing = BlakeTwo256;
99+
type AccountId = AccountId;
100+
type Lookup = IdentityLookup<Self::AccountId>;
101+
type RuntimeEvent = RuntimeEvent;
102+
type BlockHashCount = BlockHashCount;
103+
type DbWeight = ();
104+
type Version = ();
105+
type PalletInfo = PalletInfo;
106+
type AccountData = ();
107+
type OnNewAccount = ();
108+
type OnKilledAccount = ();
109+
type SystemWeightInfo = ();
110+
type SS58Prefix = SS58Prefix;
111+
type OnSetCode = ();
112+
type MaxConsumers = frame_support::traits::ConstU32<16>;
113+
type SingleBlockMigrations = ();
114+
type MultiBlockMigrator = ();
115+
type PreInherents = ();
116+
type PostInherents = ();
117+
type PostTransactions = ();
118+
}
119+
120+
pub struct ExtBuilder;
121+
122+
impl Default for ExtBuilder {
123+
fn default() -> Self {
124+
Self {}
125+
}
126+
}
127+
128+
impl ExtBuilder {
129+
pub fn build(self) -> sp_io::TestExternalities {
130+
let t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
131+
let mut r: sp_io::TestExternalities = t.into();
132+
133+
r.execute_with(|| {
134+
System::set_block_number(1);
135+
});
136+
r
137+
}
138+
}

0 commit comments

Comments
 (0)