Skip to content

Commit

Permalink
sim-rs: make uniform IB generation an option
Browse files Browse the repository at this point in the history
  • Loading branch information
SupernaviX committed Nov 7, 2024
1 parent 76837f0 commit 985c753
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions sim-rs/sim-cli/src/bin/gen-test-data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ fn main() -> Result<()> {
ib_shards: 8,
max_block_size: 90112,
stage_length: 2,
uniform_ib_generation: true,
max_ib_requests_per_peer: 1,
max_ib_size: 327680,
max_tx_size: 16384,
Expand Down
3 changes: 3 additions & 0 deletions sim-rs/sim-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub struct RawConfig {
pub max_block_size: u64,
pub max_tx_size: u64,
pub stage_length: u64,
pub uniform_ib_generation: bool,
pub max_ib_size: u64,
pub max_ib_requests_per_peer: usize,
pub ib_shards: u64,
Expand Down Expand Up @@ -116,6 +117,7 @@ impl From<RawConfig> for SimConfiguration {
max_block_size: value.max_block_size,
max_tx_size: value.max_tx_size,
stage_length: value.stage_length,
uniform_ib_generation: value.uniform_ib_generation,
max_ib_size: value.max_ib_size,
max_ib_requests_per_peer: value.max_ib_requests_per_peer,
ib_shards: value.ib_shards,
Expand All @@ -138,6 +140,7 @@ pub struct SimConfiguration {
pub max_block_size: u64,
pub max_tx_size: u64,
pub stage_length: u64,
pub uniform_ib_generation: bool,
pub max_ib_size: u64,
pub max_ib_requests_per_peer: usize,
pub ib_shards: u64,
Expand Down
8 changes: 7 additions & 1 deletion sim-rs/sim-core/src/sim/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,13 @@ impl Node {
while probability > 0.0 {
let next_p = f64::min(probability, 1.0);
if let Some(vrf) = self.run_vrf(next_p) {
let vrf_slot = slot + self.rng.gen_range(0..self.sim_config.stage_length);
let vrf_slot = if self.sim_config.uniform_ib_generation {
// IBs are generated at the start of any slot within this stage
slot + self.rng.gen_range(0..self.sim_config.stage_length)
} else {
// IBs are generated at the start of the first slot of this stage
slot
};
slot_vrfs.entry(vrf_slot).or_default().push(vrf);
}
probability -= 1.0;
Expand Down
1 change: 1 addition & 0 deletions sim-rs/test_data/realistic.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ max_ib_requests_per_peer = 1
max_ib_size = 327680
max_tx_size = 16384
stage_length = 3
uniform_ib_generation = true

[transaction_frequency_ms]
distribution = "exp"
Expand Down
1 change: 1 addition & 0 deletions sim-rs/test_data/simple.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ max_block_size = 90112

# IB parameters
stage_length = 2
uniform_ib_generation = true
ib_generation_probability = 0.5 # corresponds to 𝑓I in the model
ib_shards = 2
max_ib_size = 327680
Expand Down
1 change: 1 addition & 0 deletions sim-rs/test_data/small.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ max_ib_size = 327680
max_ib_requests_per_peer = 1
ib_shards = 8
stage_length = 2
uniform_ib_generation = true

[[nodes]]
location = [
Expand Down

0 comments on commit 985c753

Please sign in to comment.