Skip to content

Commit 591ec75

Browse files
committed
Variant: linear leios with TX references
1 parent ab65869 commit 591ec75

File tree

9 files changed

+29
-6
lines changed

9 files changed

+29
-6
lines changed

data/simulation/config.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ export enum LeiosVariant {
300300
FullWithTXReferences = "full-with-tx-references",
301301
/** Linear Leios: Leios with as little concurrency as possible. */
302302
Linear = "linear",
303+
/** Linear Leios, but blocks include transaction references instead of full TXs */
304+
LinearWithTxReferences = "linear-with-tx-references",
303305
}
304306

305307
export enum MempoolSamplingStrategy {

data/simulation/config.default.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ praos-fallback-enabled: true
3838

3939
linear-vote-stage-length-slots: 5
4040
linear-diffuse-stage-length-slots: 5
41+
store-txs-as-references: false
4142

4243
################################################################################
4344
# Transaction Configuration

data/simulation/config.schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@
7878
"full",
7979
"full-without-ibs",
8080
"full-with-tx-references",
81-
"linear"
81+
"linear",
82+
"linear-with-tx-references"
8283
],
8384
"type": "string"
8485
},
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
leios-variant: linear-with-tx-references
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
leios-variant: linear-with-tx-references
2+
timestamp-resolution-ms: 0.05

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ pub enum LeiosVariant {
159159
FullWithoutIbs,
160160
FullWithTxReferences,
161161
Linear,
162+
LinearWithTxReferences,
162163
}
163164

164165
#[derive(Debug, Copy, Clone, Deserialize, PartialEq, Eq)]
@@ -429,7 +430,11 @@ impl BlockSizeConfig {
429430
}
430431

431432
pub fn linear_eb(&self, txs: &[Arc<Transaction>]) -> u64 {
432-
self.eb_constant + txs.iter().map(|tx| tx.bytes).sum::<u64>()
433+
let body_size = match self.variant {
434+
LeiosVariant::LinearWithTxReferences => txs.len() as u64 * self.eb_per_ib,
435+
_ => txs.iter().map(|tx| tx.bytes).sum::<u64>(),
436+
};
437+
self.eb_constant + body_size
433438
}
434439

435440
pub fn vote_bundle(&self, ebs: usize) -> u64 {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl Simulation {
8484
let clock = clock_coordinator.clock();
8585

8686
let (network, nodes, tx_producer) = match config.variant {
87-
LeiosVariant::Linear => Self::init(
87+
LeiosVariant::Linear | LeiosVariant::LinearWithTxReferences => Self::init(
8888
&config,
8989
&tracker,
9090
&clock,

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,9 @@ impl LeiosNode {
870870
| LeiosVariant::FullWithoutIbs
871871
| LeiosVariant::FullWithTxReferences => candidates
872872
.max_by_key(|(eb, age, votes)| (Reverse(*age), self.count_txs_in_eb(eb), *votes))?,
873-
LeiosVariant::Linear => unreachable!("wrong implementation"),
873+
LeiosVariant::Linear | LeiosVariant::LinearWithTxReferences => {
874+
unreachable!("wrong implementation")
875+
}
874876
};
875877

876878
let votes = self.leios.votes_by_eb.get(&block)?.clone();

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use rand_chacha::ChaChaRng;
1010
use crate::{
1111
clock::{Clock, Timestamp},
1212
config::{
13-
CpuTimeConfig, MempoolSamplingStrategy, NodeConfiguration, NodeId, RelayStrategy,
14-
SimConfiguration, TransactionConfig,
13+
CpuTimeConfig, LeiosVariant, MempoolSamplingStrategy, NodeConfiguration, NodeId,
14+
RelayStrategy, SimConfiguration, TransactionConfig,
1515
},
1616
events::EventTracker,
1717
model::{
@@ -892,6 +892,15 @@ impl LinearLeiosNode {
892892
// We only vote for whichever EB we was referenced by the head of the current chain.
893893
return Err(NoVoteReason::WrongEB);
894894
}
895+
896+
if self.sim_config.variant == LeiosVariant::LinearWithTxReferences {
897+
for tx in &eb.txs {
898+
if !matches!(self.txs.get(&tx.id), Some(TransactionView::Received(_))) {
899+
// We won't vote for an EB if we don't have all the TXs it references
900+
return Err(NoVoteReason::MissingTX);
901+
}
902+
}
903+
}
895904
Ok(())
896905
}
897906

0 commit comments

Comments
 (0)