Consensus sim flatten distributed#3
Consensus sim flatten distributed#3jmmcgee wants to merge 15 commits intobachase:consensus-sim-flattenfrom
Conversation
bachase
left a comment
There was a problem hiding this comment.
I've only focused on the randomized link changes in the last commit so far. I think there are some issues with dangling references. As a result, that makes me believe having DurationDistributionRef not hold a reference but instead hold a full copy so that it ends up owning the instance of the distrubution. This matches your comment that a distribution should be light-weight and copyable. If a user wants shared state between links, they can use a shared_ptr inside their distribution.
src/test/csf/Peer.h
Outdated
| { | ||
| return net.connect(this, &o, dur); | ||
| return connect(o, | ||
| DurationDistributionRef{ConstantDuration{delay}}); |
There was a problem hiding this comment.
If DurationDistributionRef takes its argument by reference, won't that reference be dangling since ConstantDuration{Delay} is a local temporary?
src/test/csf/timers.h
Outdated
| operator()(); | ||
| }; | ||
|
|
||
| Note T should be light-weight, trivially copyable and movable, etc. |
src/test/csf/BasicNetwork.h
Outdated
| connect( | ||
| Peer const& from, | ||
| Peer const& to, | ||
| DurationDistributionRef delayGen); |
There was a problem hiding this comment.
Since the link constructor is templated on DurationDistribution, should this be too? I like that idea for all the various layers of connect; template all the way down except the last layer in connect, which stores things into the link as a type-erased holder.
src/test/csf/timers.h
Outdated
|
|
||
| template <class T> | ||
| explicit | ||
| DurationDistributionRef(T&& t) : impl_{new Any<T>(t)} |
There was a problem hiding this comment.
I think this constructor might not do as you expect. Since Any<T> is taking its argument by reference, it will end up referring to something that no longer exists.
These are changes to the generic consensus code to support the redesign of the consensus simulation framework (CSF). They are in a standalone changeset to simplify reviewing that the changes are safe. As a result, the motivation for some changes may not be clear. Changes include - Rename Consenus::relay to Consensus::share in preparation for routing layer in CSF. - Define ledger sequence as a type (Ledger::Seq) in preparation for using tagged integers in CSF. In this changeset, it remains a simple type alias. - Use a flat_map for tracking DisputedTx votes. This gives a significant performance improvement in simulations. - Single getPreferredLedger for determing when to switch ledgers
* Adds an event/collector framework for monitoring invariants and doing calculating statistics. * Allows distinct network and trust connections between Peers * Adds a simple routing strategy to support broadcasting arbitrary messages * Adds a common directed graph (`Digraph`) class for representing network and trust topologies * Adds a `PeerGroup` class for simpler specification of the trust and network topologies * Adds a `LedgerOracle` class to ensure distinct ledger histories and simplify branch checking * Adds a `Submitter` to send transactions in at fixed or random intervals to fixed or random peers Co-authored-by: Brad Chase <bchase@ripple.com>
1d946c3 to
53d4bda
Compare
53d4bda to
73dba2e
Compare
abc8fe6 to
c3af030
Compare
Codecov Report
@@ Coverage Diff @@
## consensus-sim-flatten #3 +/- ##
========================================================
Coverage ? 70.06%
========================================================
Files ? 689
Lines ? 50744
Branches ? 0
========================================================
Hits ? 35556
Misses ? 15188
Partials ? 0
Continue to review full report at Codecov.
|
cbc612d to
8ee281b
Compare
bachase
left a comment
There was a problem hiding this comment.
Just a few comments questions. I think this will be added in the next set of changes after the existing PR for ripple/rippled is complete.
| ledgerLog(prefix + "_ledger.csv", std::ofstream::app); | ||
|
|
||
| // title | ||
| mutex.lock(); |
There was a problem hiding this comment.
Consider using lock_guard instead of explicit lock and unlock throughout this simulation.
There was a problem hiding this comment.
I looked into lock_guards before. I removed them because I had them in their own scope and so everything was indented, and I didn't like that for purely ascetic reasons. But that's not really a justification I suppose. I'll add the lock_guards.
src/test/csf/BasicNetwork.h
Outdated
| time_point const sent = scheduler.now(); | ||
| scheduler.in( | ||
| link->delay, | ||
| std::max(0ns, link->delayGen()), |
There was a problem hiding this comment.
Should we also enforce that messages are always sent in order? I believe the following is currently possible
t = 1 : send(a,b, mesg1); with random delay of 50 seconds
t = 10 : send(a,b,mesg2); with random delay of 30 seconds
...
t= 40: mesg2 delivered
t= 51: mesg1 delievered
This might be an important degree of freedom to model, but I'm not sure whether reordering should be explicitly modeled instead. Curious what you think.
There was a problem hiding this comment.
I think things make sense the way they are currently. In the future, if we want to model messages being reordered by a different policy/distribution than that which generates the delays, then we can consider constraining messages to be sent in order (since messages being sent out of order only makes sense if the modeling of reordering is wrapped into the generated delay). But then, in order to segment out the effects of the network on message delivery, we would almost need an intermediate entity to intercept all messages and apply some non-ideal policy (reordering, congestion, attacks, etc.). I think that would eventually be a useful feature, but I think it requires a lot more thought.
There was a problem hiding this comment.
I agree. I believe we use TCP for all the peer protocol layer, so probably not worth modeling reordering at this stage. In that case, I think we still need to change the proposed implementation to prevent reordering. I think we can just store a SimTime nextDelivery in the link and then ensure that
SimTime when = now() + std::max(0ns, link->delayGen());
when = std::max(when, link->nextDelivery + 1ns);
link->nextDelivery = when;
scheduler.at(when,...)
src/test/csf/timers.h
Outdated
| // of simulation-specific details. | ||
| /* | ||
| We should consider making DurationDistribution conform to | ||
| RandomNumberDistribution concept and moving to beast. |
There was a problem hiding this comment.
What do you mean by move to beast? Is there something there we can reuse?
There was a problem hiding this comment.
When I was originally constructing the DurationDistribution concept, I had it as templated, such that the object returned by operator() could be of any type. The idea was to have a concept:
template <class T>
Distribution
{
T
operator();
};
that could represent a random distribution of any object. But I didn't go through with that level of genericness in order to focus on getting things working.
There was a problem hiding this comment.
I do think, however, that the idea of having the concept of a random (the precise sense in which it is random is not too important) distribution, that any type of object can be sampled from is very powerful and worth generalizing either in beast or in the C++ standard.
But I'm not expert and I didn't look very hard so It's entirely possible that something like that already exists and I just didn't look hard enough.
| pdf.savefig(fig) | ||
| pdf.close() | ||
|
|
||
| txStats = ( |
There was a problem hiding this comment.
Is it worth inferring the keys from the file itself?
There was a problem hiding this comment.
Definitely worth it and possible with a bit more effort. I'll look into it.
13ad5b0 to
6320998
Compare
6320998 to
7f39dce
Compare
- '|' is separator in csv output to allow for json field
7f39dce to
88a8094
Compare
|
Sorry about the constant rebasing. I suppose I don't have much else to do. |
8bc1c62 to
212bd2d
Compare
212bd2d to
59f28e6
Compare
59f28e6 to
ad62c13
Compare
Changes