Skip to content

Commit af63bef

Browse files
committed
sim-rs: make EB propagation criteria configurable
1 parent 0538201 commit af63bef

File tree

6 files changed

+213
-105
lines changed

6 files changed

+213
-105
lines changed

data/simulation/config.d.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ export interface Config {
9191
*/
9292
"linear-diffuse-stage-length-slots": bigint;
9393

94+
/**
95+
* Which conditions must be met before a node will send an EB to peers?
96+
* - "eb-received": the EB must only go through basic validation
97+
* - "txs-received": all TXs in the EB must have been received
98+
* - "fully-valid": the EB must be fully validated
99+
*/
100+
"linear-eb-propagation-criteria": EBPropagationCriteria;
101+
94102
// Transaction Configuration
95103
/** Only supported by Rust simulation. */
96104
"tx-generation-distribution": Distribution;
@@ -326,6 +334,15 @@ export enum MempoolSamplingStrategy {
326334
Random = "random",
327335
}
328336

337+
export enum EBPropagationCriteria {
338+
/** the EB must only go through basic validation */
339+
EBReceived = "eb-received",
340+
/** all TXs in the EB must have been received */
341+
TXsReceived = "txs-received",
342+
/** the EB must be fully validated */
343+
FullyValid = "fully-valid",
344+
}
345+
329346
/**
330347
* Configuration for a "late EB" attack,
331348
* where nodes deliberately withhold EBs until near the end of the voting phase.

data/simulation/config.default.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ praos-fallback-enabled: true
3838

3939
linear-vote-stage-length-slots: 5
4040
linear-diffuse-stage-length-slots: 5
41+
# Which conditions must be met before a node will send an EB to peers?
42+
# - "eb-received": the EB must only go through basic validation
43+
# - "txs-received": all TXs in the EB must have been received
44+
# - "fully-valid": the EB must be fully validated
45+
linear-eb-propagation-criteria: eb-received
4146
store-txs-as-references: false
4247

4348
################################################################################

data/simulation/config.schema.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@
5757
}
5858
]
5959
},
60+
"EBPropagationCriteria": {
61+
"enum": ["eb-received", "txs-received", "fully-valid"],
62+
"type": "string"
63+
},
6064
"ExpDistribution": {
6165
"properties": {
6266
"distribution": {
@@ -384,6 +388,10 @@
384388
"properties": {},
385389
"type": "number"
386390
},
391+
"linear-eb-propagation-criteria": {
392+
"$ref": "#/definitions/EBPropagationCriteria",
393+
"description": "Which conditions must be met before a node will send an EB to peers?\n - \"eb-received\": the EB must only go through basic validation\n - \"txs-received\": all TXs in the EB must have been received\n - \"fully-valid\": the EB must be fully validated"
394+
},
387395
"linear-vote-stage-length-slots": {
388396
"additionalProperties": false,
389397
"description": "How long the EB voting stage is allowed to last.\nShould be more than 3x leios-header-diffusion-time-ms.\nMatches L_vote from the paper.",

sim-rs/parameters/late-eb-attack.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ late-tx-attack:
2121
tx-generation-distribution:
2222
distribution: constant
2323
value: 3
24+
linear-eb-propagation-criteria: fully-valid

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ pub struct RawParameters {
7777
pub praos_fallback_enabled: bool,
7878
pub linear_vote_stage_length_slots: u64,
7979
pub linear_diffuse_stage_length_slots: u64,
80+
pub linear_eb_propagation_criteria: EBPropagationCriteria,
8081

8182
// Transaction configuration
8283
pub tx_generation_distribution: DistributionConfig,
@@ -184,6 +185,14 @@ pub enum MempoolSamplingStrategy {
184185
Random,
185186
}
186187

188+
#[derive(Debug, Copy, Clone, Deserialize, PartialEq, Eq)]
189+
#[serde(rename_all = "kebab-case")]
190+
pub enum EBPropagationCriteria {
191+
EbReceived,
192+
TxsReceived,
193+
FullyValid,
194+
}
195+
187196
#[derive(Deserialize)]
188197
#[serde(rename_all = "kebab-case")]
189198
pub struct RawLateEBAttackConfig {
@@ -681,6 +690,7 @@ pub struct SimConfiguration {
681690
pub(crate) eb_include_txs_from_previous_stage: bool,
682691
pub(crate) linear_vote_stage_length: u64,
683692
pub(crate) linear_diffuse_stage_length: u64,
693+
pub(crate) linear_eb_propagation_criteria: EBPropagationCriteria,
684694
pub(crate) max_block_size: u64,
685695
pub(crate) max_ib_size: u64,
686696
pub(crate) max_eb_size: u64,
@@ -747,6 +757,7 @@ impl SimConfiguration {
747757
eb_include_txs_from_previous_stage: params.eb_include_txs_from_previous_stage,
748758
linear_vote_stage_length: params.linear_vote_stage_length_slots,
749759
linear_diffuse_stage_length: params.linear_diffuse_stage_length_slots,
760+
linear_eb_propagation_criteria: params.linear_eb_propagation_criteria,
750761
max_block_size: params.rb_body_max_size_bytes,
751762
max_ib_size: params.ib_body_max_size_bytes,
752763
max_eb_size: params.eb_referenced_txs_max_size_bytes,

0 commit comments

Comments
 (0)