Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
868c07b
tests
cl0w5 Apr 29, 2026
800dd65
Merge branch 'master' into 2s
cl0w5 Apr 30, 2026
2091735
runtime support for 2s blocktime
cl0w5 Apr 30, 2026
33262e0
node support for 2s blocktime
cl0w5 Apr 30, 2026
40a67ac
zombienet support for 2s blocktime
cl0w5 Apr 30, 2026
c74765d
add script to assign cores
cl0w5 Apr 30, 2026
ee18986
frontier at 2s
cl0w5 May 4, 2026
f12ae34
comment
cl0w5 May 4, 2026
c430633
pallet-staking at 2s
cl0w5 May 7, 2026
9c38d40
pallet-dca at 2s
cl0w5 May 19, 2026
07d32c3
scheduler at 2s
cl0w5 May 19, 2026
1c3c630
pallet-conviction-voting at 2s
cl0w5 May 25, 2026
97436f3
bounded conviction voting migration
cl0w5 May 25, 2026
df679de
Merge branch 'master' into 2s
cl0w5 May 25, 2026
a4ea87c
pallet-ema-oracle at 2s
cl0w5 May 25, 2026
fd3a0eb
fix scheduler test
cl0w5 May 25, 2026
5c75735
Tx fees AdjustmentVariable at 2s
cl0w5 Jun 1, 2026
55583a5
pallet-circuit-breaker at 2s
cl0w5 Jun 1, 2026
b39be1a
frame-system at 2s
cl0w5 Jun 1, 2026
334990c
stableswap max_peg_update at 2s
cl0w5 Jun 1, 2026
90ac3a2
pallet-referenda at 2s
cl0w5 Jun 1, 2026
4c621a2
scripts at 2s
cl0w5 Jun 8, 2026
6ac1091
evm retention at 2s blocktime
cl0w5 Jun 8, 2026
5a1b2fd
dca limits at 2s blocktime
cl0w5 Jun 8, 2026
5a60fa9
fix tests
cl0w5 Jun 8, 2026
d0eae7e
Merge branch 'master' into 2s
cl0w5 Jun 8, 2026
84d42bf
GIGAHDX at 2s
cl0w5 Jun 8, 2026
ecd9384
GIGAHDX at 2s
cl0w5 Jun 8, 2026
1f0b5ed
dca tests at 2s
cl0w5 Jun 8, 2026
ef477aa
dont check version on gigahdx
cl0w5 Jun 12, 2026
776058d
add record count log to 2s migrations
cl0w5 Jun 12, 2026
0c56595
fix tests
cl0w5 Jun 12, 2026
c18a8ee
add scripts/opengov-force-remove-votes
cl0w5 Jun 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ format:
.PHONY: try-runtime
try-runtime:
$(cargo) build --release --features try-runtime
try-runtime --runtime ./target/release/wbuild/hydradx-runtime/hydradx_runtime.wasm on-runtime-upgrade --blocktime 6000 --checks all live --uri wss://archive.rpc.hydration.cloud
try-runtime --runtime ./target/release/wbuild/hydradx-runtime/hydradx_runtime.wasm on-runtime-upgrade --blocktime 2000 --checks all live --uri wss://archive.rpc.hydration.cloud

.PHONY: build-docs
build-docs:
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,12 @@ Grab `zombienet` utility used to start network from [releases](https://github.co

Start local testnet with 4 relay chain validators and HydraDX as a parachain with 2 collators.

```
```bash
cd launch-configs/zombienet/
zombienet spawn local.json

# Enable 2s block time
npm exec --yes --package=@polkadot/api --package=@polkadot/util-crypto -- node scripts/assign_cores.js
```

## Interaction with the node
Expand Down
6 changes: 5 additions & 1 deletion launch-configs/zombienet/local.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
"patch": {
"configuration": {
"config": {
"scheduler_params": {
"num_cores": 3
},
"async_backing_params": {
"max_candidate_depth": 3,
"max_candidate_depth": 6,
"allowed_ancestry_len": 2
}
}
Expand All @@ -31,6 +34,7 @@
"--pruning=archive"
],
"ws_port": 9944,
"rpc_port": 9945,
"invulnerable": true
},
{
Expand Down
36 changes: 27 additions & 9 deletions math/src/staking/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,40 @@ pub fn calculate_slashed_points(
/// Function calculates period number from block number and period size.
///
/// Parameters:
/// - `period_length`: length of the one period in blocks
/// - `period_length`: length of one period based on 12s blocks (this was the initial default)
/// - `block_number`: block number to calculate period for
/// - `six_sec_block_since`: block number when staking switched to 6 sec. blocks and period
/// - `period_length` should be doubled
/// - `six_sec_blocks_since`: block number when staking switched to 6s blocks
/// - `two_sec_blocks_since`: block number when staking switched to 2s blocks
pub fn calculate_period_number(
period_length: NonZeroU128,
block_number: u128,
six_sec_block_since: NonZeroU128,
six_sec_blocks_since: NonZeroU128,
two_sec_blocks_since: NonZeroU128,
) -> Period {
if block_number.le(&Into::<u128>::into(six_sec_block_since)) {
return block_number.saturating_div(period_length.get());
let period_length = period_length.get();
let six_sec_blocks_since = six_sec_blocks_since.get();
let two_sec_blocks_since = two_sec_blocks_since.get();

if block_number.le(&six_sec_blocks_since) {
return block_number.saturating_div(period_length);
}

if block_number.le(&two_sec_blocks_since) || two_sec_blocks_since <= six_sec_blocks_since {
return six_sec_blocks_since
.saturating_add(block_number)
.saturating_div(period_length.saturating_mul(2));
}

Into::<u128>::into(six_sec_block_since)
.saturating_add(block_number)
.saturating_div(period_length.get().saturating_mul(2))
let normalized_blocks = six_sec_blocks_since
.saturating_mul(6)
.saturating_add(
two_sec_blocks_since
.saturating_sub(six_sec_blocks_since)
.saturating_mul(3),
)
.saturating_add(block_number.saturating_sub(two_sec_blocks_since));

normalized_blocks.saturating_div(period_length.saturating_mul(6))
}

/// Function calculates total amount of `Points` user have accumulated until now.
Expand Down
74 changes: 68 additions & 6 deletions math/src/staking/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ fn calculate_period_number_should_work_when_period_length_is_not_zero() {
calculate_period_number(
NonZeroU128::try_from(1_u128).unwrap(),
12_341_u128,
NonZeroU128::try_from(12_341_u128).unwrap()
NonZeroU128::try_from(12_341_u128).unwrap(),
NonZeroU128::try_from(u32::MAX as u128).unwrap()
),
12_341_u128
);
Expand All @@ -97,7 +98,8 @@ fn calculate_period_number_should_work_when_period_length_is_not_zero() {
calculate_period_number(
NonZeroU128::try_from(1_000_u128).unwrap(),
12_341_u128,
NonZeroU128::try_from(12_342_u128).unwrap()
NonZeroU128::try_from(12_342_u128).unwrap(),
NonZeroU128::try_from(u32::MAX as u128).unwrap()
),
12_u128
);
Expand All @@ -106,7 +108,8 @@ fn calculate_period_number_should_work_when_period_length_is_not_zero() {
calculate_period_number(
NonZeroU128::try_from(1_000_u128).unwrap(),
1_u128,
NonZeroU128::try_from(1).unwrap()
NonZeroU128::try_from(1).unwrap(),
NonZeroU128::try_from(u32::MAX as u128).unwrap()
),
0_u128
);
Expand All @@ -115,7 +118,8 @@ fn calculate_period_number_should_work_when_period_length_is_not_zero() {
calculate_period_number(
NonZeroU128::try_from(82_u128).unwrap(),
12_341_u128,
NonZeroU128::try_from(12_341_u128).unwrap()
NonZeroU128::try_from(12_341_u128).unwrap(),
NonZeroU128::try_from(u32::MAX as u128).unwrap()
),
150_u128
);
Expand All @@ -126,7 +130,8 @@ fn calculate_period_number_should_work_when_period_length_is_not_zero() {
calculate_period_number(
NonZeroU128::try_from(41_u128).unwrap(),
12_341_u128,
NonZeroU128::try_from(5_001_u128).unwrap()
NonZeroU128::try_from(5_001_u128).unwrap(),
NonZeroU128::try_from(u32::MAX as u128).unwrap()
),
211_u128
);
Expand All @@ -138,12 +143,69 @@ fn calculate_period_number_should_work_when_period_length_is_not_zero() {
calculate_period_number(
NonZeroU128::try_from(2_617_u128).unwrap(),
678_789_789_u128,
NonZeroU128::try_from(89_789_124_u128).unwrap()
NonZeroU128::try_from(89_789_124_u128).unwrap(),
NonZeroU128::try_from(u32::MAX as u128).unwrap()
),
146_843_u128
);
}

#[test]
fn calculate_period_number_should_work_after_two_sec_transition() {
assert_eq!(
calculate_period_number(
NonZeroU128::try_from(10_u128).unwrap(),
100_u128,
NonZeroU128::try_from(100_u128).unwrap(),
NonZeroU128::try_from(200_u128).unwrap()
),
10_u128
);

assert_eq!(
calculate_period_number(
NonZeroU128::try_from(10_u128).unwrap(),
200_u128,
NonZeroU128::try_from(100_u128).unwrap(),
NonZeroU128::try_from(200_u128).unwrap()
),
15_u128
);

assert_eq!(
calculate_period_number(
NonZeroU128::try_from(10_u128).unwrap(),
259_u128,
NonZeroU128::try_from(100_u128).unwrap(),
NonZeroU128::try_from(200_u128).unwrap()
),
15_u128
);

assert_eq!(
calculate_period_number(
NonZeroU128::try_from(10_u128).unwrap(),
260_u128,
NonZeroU128::try_from(100_u128).unwrap(),
NonZeroU128::try_from(200_u128).unwrap()
),
16_u128
);
}

#[test]
fn calculate_period_number_should_fall_back_when_two_sec_transition_is_invalid() {
assert_eq!(
calculate_period_number(
NonZeroU128::try_from(10_u128).unwrap(),
200_u128,
NonZeroU128::try_from(100_u128).unwrap(),
NonZeroU128::try_from(50_u128).unwrap()
),
15_u128
);
}

#[test]
fn calculate_points_should_work() {
let time_points_per_period = 2_u8;
Expand Down
2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hydradx"
version = "15.0.2"
version = "15.1.0"
description = "Hydration node"
authors = ["GalacticCouncil"]
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ fn start_consensus(
para_id,
proposer,
collator_service,
authoring_duration: Duration::from_millis(1500),
authoring_duration: Duration::from_millis(2000),
reinitialize: false,
slot_offset: Duration::from_secs(1),
block_import_handle,
Expand Down
8 changes: 4 additions & 4 deletions node/src/service/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub struct EthereumConfig {
pub max_past_logs: u32,

/// Maximum fee history cache size.
#[clap(long, default_value = "2048")]
#[clap(long, default_value = "6144")]
pub fee_history_limit: u64,

#[clap(long)]
Expand Down Expand Up @@ -161,7 +161,7 @@ pub fn spawn_frontier_tasks(
None,
MappingSyncWorker::new(
client.import_notification_stream(),
Duration::new(6, 0),
Duration::new(2, 0),
client.clone(),
backend,
overrides.clone(),
Expand All @@ -176,8 +176,8 @@ pub fn spawn_frontier_tasks(
);

// Spawn Frontier EthFilterApi maintenance task.
// Each filter is allowed to stay in the pool for 100 blocks.
const FILTER_RETAIN_THRESHOLD: u64 = 100;
// Each filter is allowed to stay in the pool for about 10 minutes with 2s blocks.
const FILTER_RETAIN_THRESHOLD: u64 = 300;
task_manager.spawn_essential_handle().spawn(
"frontier-filter-pool",
None,
Expand Down
2 changes: 1 addition & 1 deletion pallets/dca/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = 'pallet-dca'
version = "1.18.1"
version = "1.19.0"
description = 'A pallet to manage DCA scheduling'
authors = ['GalacticCouncil']
edition = '2021'
Expand Down
2 changes: 1 addition & 1 deletion pallets/dca/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub mod pallet {

use super::*;

const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);
const STORAGE_VERSION: StorageVersion = StorageVersion::new(3);

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
Expand Down
Loading
Loading