You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: simulation/docs/SimulatorModel.md
+76-29Lines changed: 76 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ Certificates are not explicit; for example, a certificate's computational cost i
16
16
Within a single simulated node, the lifetime of every such object follows a common sequence.
17
17
18
18
-*Generate*, the duration when the node is generating an object.
19
-
-*Receive*, the moment a node receives (the entirety of) an ojbect from a peer.
19
+
-*Receive*, the moment a node receives (the entirety of) an object from a peer.
20
20
(It is often useful to consider a node to have received an object when it finished generating that object.)
21
21
-*Wait*, the duration when the node cannot yet validate an object (eg a known necessary input is missing).
22
22
-*Validate*, the duration when when node is computing whether the object is valid.
@@ -178,7 +178,7 @@ If the node should validate its VB before diffusion and adoption, then that cost
178
178
179
179
## Leios diffusion threads
180
180
181
-
IBs, VBs, and EBs are each diffused via a corresonding instance of the Relay mini protocol and Relay buffer.
181
+
IBs, VBs, and EBs are each diffused via a corresponding instance of the Relay mini protocol and Relay buffer.
182
182
This is a generalization of the TxSubmission mini protocol and the Mempool in `ouroboros-network` and `ouroboros-consensus`.
183
183
184
184
Each Relay instance involves one thread per inbound connection (aka "peers") and one thread per outbound connection (aka "followers").
@@ -273,30 +273,77 @@ The Relay component invokes the given callback when some object arrives, and tha
273
273
274
274
The `LeiosProtocol.Short.Node.LeiosNodeState` record type declares the state shared by the threads.
275
275
276
-
## Leios Diffusion state
277
-
278
-
TODO `relayIBState`, `relayEBState`, `relayVoteState`
279
-
280
-
## Waiting&Validation state
281
-
282
-
TODO `ibsNeededForEBVar`, `waitingForRBVar`, `waitingForLedgerStateVar`, `ledgerStateVar`, `ibsValidationActionsVar`
283
-
284
-
TODO include `taskQueue`
285
-
286
-
## Adopted IBs state
287
-
288
-
TODO `relayIBState` abuse
289
-
290
-
TODO `iBsForEBsAndVotesVar`
291
-
292
-
## Adopted EBs state
293
-
294
-
TODO `relayEBState` abuse
295
-
296
-
## Adopted VBs state
297
-
298
-
TODO `votesForEBVar`
299
-
300
-
## Adopted RBs & Praos Diffusion state
301
-
302
-
TODO
276
+
These components accumulate data over time as the protocol executes.
277
+
Many of the statements in this section are redundant with the Threads section above, so those statements will be terse.
278
+
However, this section is more granular/concrete, and so has some non-redundant information and explains some design decisions.
279
+
280
+
The components are as follows.
281
+
282
+
## Diffuse state & Praos state
283
+
284
+
These variables maintain the diffusion state, and also the base protocol state.
285
+
286
+
-`praosState`.
287
+
The state of the Praos components, including Praos diffusion.
288
+
TODO elaborate on the Praos state
289
+
-`relayIBState`, `relayEBState`, and `relayVoteState`.
290
+
The IB, EB, and VB Relay buffers.
291
+
-`prunedUncertifiedEBStateToVar` and `prunedVoteStateToVar`.
292
+
Records the slot of EBs and VBs that the summarizes which objects the node has stopped diffusing due to age.
293
+
These are used to prevent requesting EBs/VBs that should have already stopped diffusing.
294
+
Since the relevant Relay header and the wall clock contain enough information to do determine that, these variables are just a convenience/optimization.
295
+
296
+
## Adopt state
297
+
298
+
These variables reflect the consequence of adopting an IB, EB, or VB.
299
+
300
+
-`ibsNeededForEBVar`.
301
+
A map from an EB ID to the set of IDs of its IBs that have not yet been adopted.
302
+
Adopting an EB inserts a new entry.
303
+
Pruning an EB removes its entry.
304
+
Adopting an IB removes it from all sets.
305
+
Pruning an IB must **not** reinsert it.
306
+
- There is no analogous state for as-of-yet missing EBs needed by EBs/RBs.
307
+
- This is because EBs are relatively small, and so, _most of the time_ the EBs will have arrived before they're needed.
308
+
A Leios implementation would need to deal with this case---at least for EBs required by the best RB---but it doesn't seem worthwhile to complicate the simulators so far.
309
+
- If the simulations included an adversary who released EBs at the latest possible second, then it might be necessary.
310
+
But so far they don't, so if some EBs are failing to diffuse in time, other aspects should already be looking quite bad.
311
+
-`iBsForEBsAndVotesVar`.
312
+
A map from an ID of an adopted IB ID to when that IB arrived.
313
+
Adopting an IB inserts an entry; the adoption might happen much later than the arrival.
314
+
Pruning an IB removes its entry.
315
+
- This variable---and the IB pruning logic in general---only enables logic for EBs and VBs.
316
+
In particular, some IBs that are too old to be included in this variable might still be needed in order to apply some RB, which motivates another variable; see `ibsValidationActionsVar`.
317
+
-`votesForEBVar`.
318
+
A map from an EB ID to its progress towards a quorum of votes.
319
+
Pruning an EB removes its entry.
320
+
Adopting a VB increments the progress of all of its EB IDs that have not already reached quorum.
321
+
Pruning a VB does not affect this variable.
322
+
323
+
## Wait-Validate state
324
+
325
+
These variables maintain tasks blocked on some missing input.
326
+
327
+
-`ibsValidationActionsVar`.
328
+
A map from IB ID to validate-and-adopt tasks that are blocked on a missing RB ledger state.
329
+
It is not pruned _per se_; tasks are only removed once they're executed.
330
+
- Usually, the tasks are executed ASAP once the necessary RB ledger state is no longer missing.
331
+
However, when the node computes the ledger state of an RB that includes an IB that is still in this map, it executes the validation logic _even if the necessary RB ledger state is still missing_.
332
+
- A Leios implementation would require the node to somehow urgently fetch the missing RB's chain and its prerequisites from the network, but that would add a great deal of complexity to the simulator.
333
+
So, despite being unfaithful, the relevant bandwidth is never consumed and the relevant CPU is consumed just-in-time.
334
+
- If an IB's RB's ledger state is never computed and no ledger state is subsequently computed for an RB that contains that IB, then that IB's entry will remain in this map indefinitely.
335
+
-`waitingForRBVar`.
336
+
A map from RB header hash to a task.
337
+
This is used to trigger tasks waiting on the adoption of some RB.
338
+
Tasks are only removed when they are executed.
339
+
-`waitingForLedgerStateVar`
340
+
A map from RB header hash to a task.
341
+
This is used to trigger tasks waiting on the availability of some RB's ledger state.
342
+
Tasks are only removed when they are executed.
343
+
-`ledgerStateVar`.
344
+
All RB ledger states that have ever been computed.
345
+
Note that ledger states are a currently isomorphic to the unit type `()`, so this is effectively a set.
346
+
It is never pruned.
347
+
-`taskQueue`.
348
+
A queue of tasks scheduled for the CPU, labeled according to what they model (eg "validate an RB").
0 commit comments