Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions data/simulation/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export interface Config {
* If true, transactions will be removed from the Leios mempool if they conflict with in-flight IBs.
*/
"leios-mempool-aggressive-pruning": boolean;
/**
* The maximum size of a mempool, in bytes
*/
"leios-mempool-size-bytes"?: bigint | null;
/**
* Praos blockchain quality parameter.
* This is η from the Leios paper.
Expand Down
1 change: 1 addition & 0 deletions data/simulation/config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ leios-header-diffusion-time-ms: 1000.0
leios-ib-generation-time-ms: 130.0
leios-mempool-sampling-strategy: ordered-by-id
leios-mempool-aggressive-pruning: false
leios-mempool-size-bytes: null
# TODO: revise default
praos-chain-quality: 40
praos-fallback-enabled: true
Expand Down
6 changes: 6 additions & 0 deletions data/simulation/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,12 @@
"$ref": "#/definitions/MempoolSamplingStrategy",
"description": "The strategy to use when selecting TXs from the Leios mempool."
},
"leios-mempool-size-bytes": {
"additionalProperties": false,
"description": "The maximum size of a mempool, in bytes",
"properties": {},
"type": "number"
},
"leios-stage-active-voting-slots": {
"additionalProperties": false,
"properties": {},
Expand Down
10 changes: 10 additions & 0 deletions sim-rs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## v1.4.0

### Linear Leios

- Add bounded mempools. Configure them with by setting `leios-mempool-size-bytes`. Incoming transactions which don't fit in the mempool will be queued for inclusion in the mempool when there is space. Transactions referenced by an EB which are not yet in the mempool will still be forwarded to peers.

### Other

- Fix warnings from new rust version

## v1.3.1

### Linear Leios
Expand Down
4 changes: 2 additions & 2 deletions sim-rs/Cargo.lock

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

6 changes: 6 additions & 0 deletions sim-rs/implementations/LINEAR_LEIOS.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ When a node creates an RB, it will follow these steps in order:

When a node receives an RB body, it immediately removes all referenced/conflicting transactions from its mempool. If the RB has an EB certificate, it also removes that EB’s transactions from its mempool. If the certified EB arrives after the RB body, we remove its TXs from the mempool once it arrives.

### Bounded mempools

The mempool can be configured with an optional size limit, through the `leios-mempool-size-bytes` parameter. When a node tries adding a transaction to a full mempool, the transaction will go into an (unbounded) queue instead. Nodes will only announce transactions to their peers once those transactions have actually reached the mempool.

If a node has received an EB which references transactions, and those transactions are in the queue but not yet in the mempool, the node will announce those transactions to its peer as well. This is to simulate the behavior of the real protocol, where nodes may request transactions from an EB separately from the TxSubmission mini-protocol.

## New parameters

|Name|Description|Default value|
Expand Down
2 changes: 1 addition & 1 deletion sim-rs/sim-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sim-cli"
version = "1.3.1"
version = "1.4.0"
edition = "2024"
default-run = "sim-cli"
rust-version = "1.88"
Expand Down
2 changes: 1 addition & 1 deletion sim-rs/sim-cli/src/events/aggregate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl TraceAggregator {
let new_chunk = (event.time_s - Timestamp::zero()).as_millis() / 250;
self.current_time = event.time_s;
if current_chunk != new_chunk {
if new_chunk % 4 == 0 {
if new_chunk.is_multiple_of(4) {
let timestamp = Timestamp::from_secs((new_chunk / 4) as u64);
self.tx_counts.push(self.produce_tx_counts(timestamp));
}
Expand Down
2 changes: 1 addition & 1 deletion sim-rs/sim-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sim-core"
version = "1.3.1"
version = "1.4.0"
edition = "2024"
rust-version = "1.88"

Expand Down
9 changes: 7 additions & 2 deletions sim-rs/sim-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub struct RawParameters {
pub leios_ib_generation_time_ms: f64,
pub leios_mempool_sampling_strategy: MempoolSamplingStrategy,
pub leios_mempool_aggressive_pruning: bool,
pub leios_mempool_size_bytes: Option<u64>,
pub praos_chain_quality: u64,
pub praos_fallback_enabled: bool,
pub linear_vote_stage_length_slots: u64,
Expand Down Expand Up @@ -716,6 +717,7 @@ pub struct SimConfiguration {
pub(crate) relay_strategy: RelayStrategy,
pub(crate) mempool_strategy: MempoolSamplingStrategy,
pub(crate) mempool_aggressive_pruning: bool,
pub(crate) mempool_size_bytes: u64,
pub(crate) praos_chain_quality: u64,
pub(crate) block_generation_probability: f64,
pub(crate) ib_generation_probability: f64,
Expand All @@ -742,7 +744,7 @@ pub struct SimConfiguration {

impl SimConfiguration {
pub fn build(params: RawParameters, mut topology: Topology) -> Result<Self> {
if params.ib_shards % params.ib_shard_group_count != 0 {
if !params.ib_shards.is_multiple_of(params.ib_shard_group_count) {
bail!(
"ib-shards ({}) is not divisible by ib-shard-group-count ({})",
params.ib_shards,
Expand All @@ -751,7 +753,9 @@ impl SimConfiguration {
}
if matches!(params.leios_variant, LeiosVariant::FullWithoutIbs)
&& params.ib_shard_group_count != 1
&& params.ib_shard_period_length_slots % params.leios_stage_length_slots != 0
&& !params
.ib_shard_period_length_slots
.is_multiple_of(params.leios_stage_length_slots)
{
bail!(
"Invalid sharding configuration. EBs are generated every {} slot(s). This sim is configured to choose EB shards from 1 of {} groups, using a different group every {} slot(s). Some groups would never be chosen.",
Expand Down Expand Up @@ -782,6 +786,7 @@ impl SimConfiguration {
relay_strategy: params.relay_strategy,
mempool_strategy: params.leios_mempool_sampling_strategy,
mempool_aggressive_pruning: params.leios_mempool_aggressive_pruning,
mempool_size_bytes: params.leios_mempool_size_bytes.unwrap_or(u64::MAX),
praos_chain_quality: params.praos_chain_quality,
block_generation_probability: params.rb_generation_probability,
ib_generation_probability: params.ib_generation_probability,
Expand Down
2 changes: 1 addition & 1 deletion sim-rs/sim-core/src/sim/leios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ impl NodeImpl for LeiosNode {
}

fn handle_new_slot(&mut self, slot: u64) -> EventResult {
if slot % self.sim_config.stage_length == 0 {
if slot.is_multiple_of(self.sim_config.stage_length) {
// A new stage has begun.

// Decide how many votes to generate in each slot
Expand Down
Loading