Skip to content

Commit cdf6a22

Browse files
committed
refactor: extract MAX_BLOCK_INTERVAL to constant
1 parent 0118bae commit cdf6a22

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

sugondat/chain/node/src/proposer.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ use cumulus_pallet_parachain_system::relay_state_snapshot::RelayChainStateProof;
2424
use cumulus_primitives_core::ParaId;
2525
use cumulus_primitives_parachain_inherent::ParachainInherentData;
2626

27-
use sugondat_primitives::opaque::{Block, Header};
27+
use sugondat_primitives::{
28+
opaque::{Block, Header},
29+
MAX_SKIPPED_BLOCKS,
30+
};
2831

2932
use std::sync::Arc;
3033
use std::time::Duration;
@@ -116,15 +119,6 @@ where
116119
};
117120
let relay_block_number = paras_inherent_data.validation_data.relay_parent_number;
118121

119-
// TODO: Change 3600 to 7200 (half a day)
120-
// and `n_skipped_blocks = relay_parent_distance.saturating_sub(1)`
121-
// when updating to asynchronous backing
122-
// https://github.com/thrumdev/blobs/issues/166
123-
124-
// The accepted error is less than 10^(-2) for an expected
125-
// maximum of 3600 skipped blocks (half a day)
126-
const MAX_SKIPPED_BLOCKS: u32 = 3600;
127-
128122
let relay_parent_distance = relay_block_number.saturating_sub(last_relay_block_number);
129123
let n_skipped_blocks = relay_parent_distance.saturating_sub(2) / 2;
130124
n_skipped_blocks >= MAX_SKIPPED_BLOCKS

sugondat/chain/primitives/src/lib.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@ use sp_runtime::{
88
// Maximum Length of the Block in bytes
99
pub const MAXIMUM_BLOCK_LENGTH: u32 = 5 * 1024 * 1024;
1010

11+
/// The maximum acceptable number of skipped parachain blocks.
12+
///
13+
/// This is not a hard limit, but it should be respected by block proposers
14+
/// in order to ensure that the error in fee calculations does not exceed
15+
/// 10^(-2). Blob runtimes use an imperfect approximation of e^x when updating fee
16+
/// levels after long periods of inactivity. This approximation loses
17+
/// fidelity when many blocks are skipped.
18+
/// (https://github.com/thrumdev/blobs/issues/165)
19+
///
20+
/// The value of 3600 has been chosen as it is half a day's worth of blocks
21+
/// at a 12-second block interval.
22+
// TODO: Change 3600 to 7200 (half a day)
23+
// when updating to asynchronous backing
24+
// https://github.com/thrumdev/blobs/issues/166
25+
pub const MAX_SKIPPED_BLOCKS: BlockNumber = 3600;
26+
1127
/// An index to a block.
1228
pub type BlockNumber = u32;
1329

0 commit comments

Comments
 (0)