Skip to content

Commit abe1cc6

Browse files
committed
sim-rs: implement full-with-tx-references variant
1 parent 0c8a0ab commit abe1cc6

File tree

12 files changed

+51
-18
lines changed

12 files changed

+51
-18
lines changed

data/simulation/config.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ export enum LeiosVariant {
252252
Full = "full",
253253
/** Full Leios Without IBs: EBs reference TXs directly, as well as other EBs */
254254
FullWithoutIbs = "full-without-ibs",
255+
/** Full Leios With TX References: IBs only contain references to TXs instead of the whole body */
256+
FullWithTXReferences = "full-with-tx-references"
255257
}
256258

257259
export enum MempoolSamplingStrategy {

data/simulation/config.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"type": "object"
7474
},
7575
"LeiosVariant": {
76-
"enum": ["short", "full", "full-without-ibs"],
76+
"enum": ["short", "full", "full-without-ibs", "full-with-tx-references"],
7777
"type": "string"
7878
},
7979
"LogNormalDistribution": {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
leios-variant: full-with-tx-references

sim-rs/parameters/no-ibs.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
leios-variant: full-without-ibs
2+
leios-mempool-strategy: random
23
leios-late-ib-inclusion: true
3-
praos-chain-quality: 40
4+
praos-chain-quality: 100

sim-rs/parameters/tx-references.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
leios-variant: full-with-tx-references
2+
leios-mempool-strategy: random
3+
leios-late-ib-inclusion: true
4+
praos-chain-quality: 100

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ use std::{
88
use anyhow::{anyhow, bail, Result};
99
use serde::{Deserialize, Serialize};
1010

11-
use crate::{clock::Timestamp, model::TransactionId, probability::FloatDistribution};
11+
use crate::{
12+
clock::Timestamp,
13+
model::{Transaction, TransactionId},
14+
probability::FloatDistribution,
15+
};
1216

1317
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1418
pub struct NodeId(usize);
@@ -141,6 +145,7 @@ pub enum LeiosVariant {
141145
Short,
142146
Full,
143147
FullWithoutIbs,
148+
FullWithTxReferences,
144149
}
145150

146151
#[derive(Debug, Copy, Clone, Deserialize, PartialEq, Eq)]
@@ -338,6 +343,7 @@ impl CpuTimeConfig {
338343

339344
#[derive(Debug, Clone)]
340345
pub(crate) struct BlockSizeConfig {
346+
variant: LeiosVariant,
341347
pub block_header: u64,
342348
cert_constant: u64,
343349
cert_per_node: u64,
@@ -351,6 +357,7 @@ pub(crate) struct BlockSizeConfig {
351357
impl BlockSizeConfig {
352358
fn new(params: &RawParameters) -> Self {
353359
Self {
360+
variant: params.leios_variant,
354361
block_header: params.rb_head_size_bytes,
355362
cert_constant: params.cert_size_bytes_constant,
356363
cert_per_node: params.cert_size_bytes_per_node,
@@ -366,6 +373,13 @@ impl BlockSizeConfig {
366373
self.cert_constant + self.cert_per_node * nodes as u64
367374
}
368375

376+
pub fn ib_payload(&self, txs: &[Arc<Transaction>]) -> u64 {
377+
match self.variant {
378+
LeiosVariant::FullWithTxReferences => txs.len() as u64 * self.eb_per_ib,
379+
_ => txs.iter().map(|tx| tx.bytes).sum(),
380+
}
381+
}
382+
369383
pub fn eb(&self, txs: usize, ibs: usize, ebs: usize) -> u64 {
370384
self.eb_constant + self.eb_per_ib * (txs + ibs + ebs) as u64
371385
}

sim-rs/sim-core/src/events.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ impl EventTracker {
462462

463463
pub fn track_ib_generated(&self, block: &crate::model::InputBlock) {
464464
let header_bytes = block.header.bytes;
465-
let tx_payload_bytes = block.transactions.iter().map(|tx| tx.bytes).sum();
465+
let tx_payload_bytes = block.tx_payload_bytes;
466466
self.send(Event::IBGenerated {
467467
id: self.to_input_block(block.header.id),
468468
slot: block.header.id.slot,

sim-rs/sim-core/src/model.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,12 @@ pub struct InputBlockHeader {
133133
#[derive(Debug)]
134134
pub struct InputBlock {
135135
pub header: InputBlockHeader,
136+
pub tx_payload_bytes: u64,
136137
pub transactions: Vec<Arc<Transaction>>,
137138
}
138139
impl InputBlock {
139140
pub fn bytes(&self) -> u64 {
140-
self.header.bytes + self.transactions.iter().map(|tx| tx.bytes).sum::<u64>()
141+
self.header.bytes + self.tx_payload_bytes
141142
}
142143
}
143144

@@ -215,6 +216,7 @@ pub enum NoVoteReason {
215216
MissingIB,
216217
MissingEB,
217218
ExtraTX,
219+
MissingTX,
218220
UncertifiedEBReference,
219221
}
220222

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ impl HasBytesSize for SimulationMessage {
178178

179179
Self::AnnounceVotes(_) => 8,
180180
Self::RequestVotes(_) => 8,
181-
Self::Votes(v) => 8 * v.ebs.len() as u64,
181+
Self::Votes(v) => v.bytes,
182182
}
183183
}
184184
}

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,7 @@ impl Node {
723723
let transactions = self.select_txs_for_ib(header.shard);
724724
let ib = InputBlock {
725725
header,
726+
tx_payload_bytes: self.sim_config.sizes.ib_payload(&transactions),
726727
transactions,
727728
};
728729
self.schedule_cpu_task(CpuTaskType::IBBlockGenerated(ib));
@@ -828,7 +829,9 @@ impl Node {
828829
let (&block, _, _) = match self.sim_config.variant {
829830
LeiosVariant::Short => candidates
830831
.max_by_key(|(eb, age, votes)| (*age, self.count_txs_in_eb(eb), *votes))?,
831-
LeiosVariant::Full | LeiosVariant::FullWithoutIbs => candidates
832+
LeiosVariant::Full
833+
| LeiosVariant::FullWithoutIbs
834+
| LeiosVariant::FullWithTxReferences => candidates
832835
.max_by_key(|(eb, age, votes)| (Reverse(*age), self.count_txs_in_eb(eb), *votes))?,
833836
};
834837

@@ -1538,14 +1541,21 @@ impl Node {
15381541
}
15391542
}
15401543

1541-
for ib in &eb.ibs {
1542-
if !matches!(self.leios.ibs.get(ib), Some(InputBlockState::Received(_))) {
1544+
for ib_id in &eb.ibs {
1545+
let Some(InputBlockState::Received(ib)) = self.leios.ibs.get(ib_id) else {
15431546
return Err(NoVoteReason::MissingIB);
1544-
}
1545-
if !expected_ib_pipelines.contains(&ib.pipeline) {
1547+
};
1548+
if !expected_ib_pipelines.contains(&ib_id.pipeline) {
15461549
return Err(NoVoteReason::InvalidSlot);
15471550
}
1548-
ib_set.insert(*ib);
1551+
if matches!(self.sim_config.variant, LeiosVariant::FullWithTxReferences) {
1552+
for tx in &ib.transactions {
1553+
if !matches!(self.txs.get(&tx.id), Some(TransactionView::Received(_))) {
1554+
return Err(NoVoteReason::MissingTX);
1555+
}
1556+
}
1557+
}
1558+
ib_set.insert(*ib_id);
15491559
}
15501560

15511561
if let Some(expected_eb_pipelines) = self.pipelines_for_eb_references(eb.pipeline) {

0 commit comments

Comments
 (0)