Skip to content

Commit 1047ac8

Browse files
committed
sim-rs: reference praos-chain-quality
1 parent 71ad991 commit 1047ac8

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

data/simulation/config.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ export interface Config {
4646
* Controls the pipelines EBs should reference in Full leios:
4747
* i - ⌈3η/L⌉, …, i-3
4848
* where i is the index of the current pipeline.
49-
*
50-
* Only supported by Haskell simulation */
49+
* */
5150
"praos-chain-quality": number;
5251
// Transaction Configuration
5352
/** Only supported by Rust simulation. */

data/simulation/config.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@
275275
"type": "boolean"
276276
},
277277
"praos-chain-quality": {
278-
"description": "Praos blockchain quality parameter.\nThis is η from the Leios paper.\nControls the pipelines EBs should reference in Full leios:\n i - ⌈3η/L⌉, …, i-3\nwhere i is the index of the current pipeline.\n\nOnly supported by Haskell simulation",
278+
"description": "Praos blockchain quality parameter.\nThis is η from the Leios paper.\nControls the pipelines EBs should reference in Full leios:\n i - ⌈3η/L⌉, …, i-3\nwhere i is the index of the current pipeline.",
279279
"type": "number"
280280
},
281281
"rb-body-legacy-praos-payload-avg-size-bytes": {

sim-rs/sim-core/src/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ pub struct RawParameters {
6161
pub leios_stage_length_slots: u64,
6262
pub leios_stage_active_voting_slots: u64,
6363
pub leios_header_diffusion_time_ms: f64,
64+
pub praos_chain_quality: u64,
6465

6566
// Transaction configuration
6667
pub tx_generation_distribution: DistributionConfig,
@@ -416,6 +417,7 @@ pub struct SimConfiguration {
416417
pub(crate) variant: LeiosVariant,
417418
pub(crate) header_diffusion_time: Duration,
418419
pub(crate) relay_strategy: RelayStrategy,
420+
pub(crate) praos_chain_quality: u64,
419421
pub(crate) block_generation_probability: f64,
420422
pub(crate) ib_generation_probability: f64,
421423
pub(crate) eb_generation_probability: f64,
@@ -443,6 +445,7 @@ impl SimConfiguration {
443445
variant: params.leios_variant,
444446
header_diffusion_time: duration_ms(params.leios_header_diffusion_time_ms),
445447
relay_strategy: params.relay_strategy,
448+
praos_chain_quality: params.praos_chain_quality,
446449
block_generation_probability: params.rb_generation_probability,
447450
ib_generation_probability: params.ib_generation_probability,
448451
eb_generation_probability: params.eb_generation_probability,

sim-rs/sim-core/src/sim/node.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use std::{
88

99
use anyhow::{bail, Result};
1010
use netsim_async::HasBytesSize as _;
11-
use num_traits::Inv;
1211
use priority_queue::PriorityQueue;
1312
use rand::Rng as _;
1413
use rand_chacha::ChaChaRng;
@@ -1317,9 +1316,8 @@ impl Node {
13171316

13181317
// the oldest pipeline is i-⌈3η/L⌉, where i is the current pipeline,
13191318
// η is the "quality parameter" (expected block rate), and L is stage length.
1320-
let old_pipelines = (3.0 * self.sim_config.block_generation_probability.inv()
1321-
/ self.sim_config.stage_length as f64)
1322-
.ceil() as u64;
1319+
let old_pipelines =
1320+
(3 * self.sim_config.praos_chain_quality).div_ceil(self.sim_config.stage_length);
13231321
let oldest_included_pipeline = current_pipeline
13241322
.checked_sub(old_pipelines)
13251323
.unwrap_or(newest_included_pipeline);

0 commit comments

Comments
 (0)