hiero-ledger / hiero-ledger/hiero-consensus-node
Turtle SimulatedNetwork might be reordering events randomly
- Dominant language
- Java
- Stars
- 406
- Forks
- 226
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 210
Description
SimulatedNetwork code is emulating network delays. In the current implementation, each event is given
```
final Instant deliveryTime = now.plusNanos(
(long) (averageDelayNanos + random.nextGaussian() * standardDeviationDelayNanos));
```
The problem is that there is no guarantee that the next event is delivered after the previous one - the random part can be big at an earlier event and small at a later event, and this will cause events to be reordered.
It is not critical, as the orphan buffer will sort it back, but I think it is unintended. Additionally, for future work, where we will use SimulatedNetwork to exchange messages other than just events, this can be catastrophic (as there is no way things are reordered on TCP stream, some code might rely on the order of messages in some cases, outside of the event use case).
A suggestion would be to fix the code to never reorder events.
Contributor guide
Research direction
Start by locating the SimulatedNetwork implementation referenced in the issue and inspect how deliveryTime is calculated and events are queued. Confirm the behavior with the existing tests or test entry points for Turtle networking; done means simulated messages are not delivered out of order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100