Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 57 additions & 3 deletions Builds/VisualStudio2015/RippleD.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -4475,14 +4475,26 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\test\consensus\ByzantineFailureSim_test.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\test\consensus\Consensus_test.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\test\consensus\DistributedValidatorsSim_test.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\test\consensus\LedgerTiming_test.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\test\consensus\ScaleFreeSim_test.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\test\consensus\Validations_test.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
Expand Down Expand Up @@ -4531,19 +4543,61 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\test\csf\impl\UNL.cpp">
<ClInclude Include="..\..\src\test\csf\CollectorRef.h">
</ClInclude>
<ClInclude Include="..\..\src\test\csf\collectors.h">
</ClInclude>
<ClInclude Include="..\..\src\test\csf\Digraph.h">
</ClInclude>
<ClCompile Include="..\..\src\test\csf\Digraph_test.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\test\csf\events.h">
</ClInclude>
<ClInclude Include="..\..\src\test\csf\Histogram.h">
</ClInclude>
<ClCompile Include="..\..\src\test\csf\Histogram_test.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\test\csf\impl\ledgers.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\test\csf\Ledger.h">
<ClCompile Include="..\..\src\test\csf\impl\Sim.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\test\csf\ledgers.h">
</ClInclude>
<ClInclude Include="..\..\src\test\csf\Peer.h">
</ClInclude>
<ClInclude Include="..\..\src\test\csf\PeerGroup.h">
</ClInclude>
<ClInclude Include="..\..\src\test\csf\Proposal.h">
</ClInclude>
<ClInclude Include="..\..\src\test\csf\random.h">
</ClInclude>
<ClInclude Include="..\..\src\test\csf\Scheduler.h">
</ClInclude>
<ClCompile Include="..\..\src\test\csf\Scheduler_test.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\test\csf\Sim.h">
</ClInclude>
<ClInclude Include="..\..\src\test\csf\SimTime.h">
</ClInclude>
<ClInclude Include="..\..\src\test\csf\submitters.h">
</ClInclude>
<ClInclude Include="..\..\src\test\csf\timers.h">
</ClInclude>
<ClInclude Include="..\..\src\test\csf\TrustGraph.h">
</ClInclude>
<ClInclude Include="..\..\src\test\csf\Tx.h">
</ClInclude>
<ClInclude Include="..\..\src\test\csf\UNL.h">
<ClInclude Include="..\..\src\test\csf\Validation.h">
</ClInclude>
<ClCompile Include="..\..\src\test\json\json_value_test.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
Expand Down
66 changes: 63 additions & 3 deletions Builds/VisualStudio2015/RippleD.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -5238,12 +5238,21 @@
<ClCompile Include="..\..\src\test\conditions\PreimageSha256_test.cpp">
<Filter>test\conditions</Filter>
</ClCompile>
<ClCompile Include="..\..\src\test\consensus\ByzantineFailureSim_test.cpp">
<Filter>test\consensus</Filter>
</ClCompile>
<ClCompile Include="..\..\src\test\consensus\Consensus_test.cpp">
<Filter>test\consensus</Filter>
</ClCompile>
<ClCompile Include="..\..\src\test\consensus\DistributedValidatorsSim_test.cpp">
<Filter>test\consensus</Filter>
</ClCompile>
<ClCompile Include="..\..\src\test\consensus\LedgerTiming_test.cpp">
<Filter>test\consensus</Filter>
</ClCompile>
<ClCompile Include="..\..\src\test\consensus\ScaleFreeSim_test.cpp">
<Filter>test\consensus</Filter>
</ClCompile>
<ClCompile Include="..\..\src\test\consensus\Validations_test.cpp">
<Filter>test\consensus</Filter>
</ClCompile>
Expand Down Expand Up @@ -5283,22 +5292,73 @@
<ClCompile Include="..\..\src\test\csf\BasicNetwork_test.cpp">
<Filter>test\csf</Filter>
</ClCompile>
<ClCompile Include="..\..\src\test\csf\impl\UNL.cpp">
<ClInclude Include="..\..\src\test\csf\CollectorRef.h">
<Filter>test\csf</Filter>
</ClInclude>
<ClInclude Include="..\..\src\test\csf\collectors.h">
<Filter>test\csf</Filter>
</ClInclude>
<ClInclude Include="..\..\src\test\csf\Digraph.h">
<Filter>test\csf</Filter>
</ClInclude>
<ClCompile Include="..\..\src\test\csf\Digraph_test.cpp">
<Filter>test\csf</Filter>
</ClCompile>
<ClInclude Include="..\..\src\test\csf\events.h">
<Filter>test\csf</Filter>
</ClInclude>
<ClInclude Include="..\..\src\test\csf\Histogram.h">
<Filter>test\csf</Filter>
</ClInclude>
<ClCompile Include="..\..\src\test\csf\Histogram_test.cpp">
<Filter>test\csf</Filter>
</ClCompile>
<ClCompile Include="..\..\src\test\csf\impl\ledgers.cpp">
<Filter>test\csf\impl</Filter>
</ClCompile>
<ClInclude Include="..\..\src\test\csf\Ledger.h">
<ClCompile Include="..\..\src\test\csf\impl\Sim.cpp">
<Filter>test\csf\impl</Filter>
</ClCompile>
<ClInclude Include="..\..\src\test\csf\ledgers.h">
<Filter>test\csf</Filter>
</ClInclude>
<ClInclude Include="..\..\src\test\csf\Peer.h">
<Filter>test\csf</Filter>
</ClInclude>
<ClInclude Include="..\..\src\test\csf\PeerGroup.h">
<Filter>test\csf</Filter>
</ClInclude>
<ClInclude Include="..\..\src\test\csf\Proposal.h">
<Filter>test\csf</Filter>
</ClInclude>
<ClInclude Include="..\..\src\test\csf\random.h">
<Filter>test\csf</Filter>
</ClInclude>
<ClInclude Include="..\..\src\test\csf\Scheduler.h">
<Filter>test\csf</Filter>
</ClInclude>
<ClCompile Include="..\..\src\test\csf\Scheduler_test.cpp">
<Filter>test\csf</Filter>
</ClCompile>
<ClInclude Include="..\..\src\test\csf\Sim.h">
<Filter>test\csf</Filter>
</ClInclude>
<ClInclude Include="..\..\src\test\csf\SimTime.h">
<Filter>test\csf</Filter>
</ClInclude>
<ClInclude Include="..\..\src\test\csf\submitters.h">
<Filter>test\csf</Filter>
</ClInclude>
<ClInclude Include="..\..\src\test\csf\timers.h">
<Filter>test\csf</Filter>
</ClInclude>
<ClInclude Include="..\..\src\test\csf\TrustGraph.h">
<Filter>test\csf</Filter>
</ClInclude>
<ClInclude Include="..\..\src\test\csf\Tx.h">
<Filter>test\csf</Filter>
</ClInclude>
<ClInclude Include="..\..\src\test\csf\UNL.h">
<ClInclude Include="..\..\src\test\csf\Validation.h">
<Filter>test\csf</Filter>
</ClInclude>
<ClCompile Include="..\..\src\test\json\json_value_test.cpp">
Expand Down
101 changes: 101 additions & 0 deletions bin/visualize_sim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import sys
import csv
import json
import matplotlib

import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages

def plotGraph(report, keys):
with open(report, 'rb') as csvfile:
csvReader = csv.reader(csvfile, delimiter='|', quotechar='$')
dictReader = csv.DictReader(csvfile, delimiter='|', quotechar='$')

byN = dict()
byDelay = dict()

# populate byN
for row in dictReader:
tag = json.loads(row["tag"])
numPeers = tag["numPeers"]
delay = tag["delay"]

if not numPeers in byN:
byN[numPeers] = dict()
byN[numPeers][delay] = row
if not delay in byDelay:
byDelay[delay] = dict()
byDelay[delay][numPeers] = row

## tx.csv
for (numPeers, delayRows) in sorted(byN.iteritems()):
delays = list()
values = dict()
for key in keys:
values[key] = list()

# collect measured values into lists by delay for a given numPeers
for (delay, row) in sorted(delayRows.iteritems()):
delays.append(delay)
for key in keys:
values[key].append(row[key])

# plot one line on each figure corresponding to run of sim with fixed
# numPeers and varying delays for a given measure

for key in keys:
plt.figure(key)
plt.plot(delays, values[key], alpha=0.2, label=str(numPeers))

pdf = PdfPages(report + ".pdf")

for key in keys:
fig = plt.figure(key)
plt.title(report + "\n" + key)
plt.xlabel("delays")
plt.ylabel(key)
#plt.legend(loc='best')

pdf.savefig(fig)
pdf.close()

txStats = (
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth inferring the keys from the file itself?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely worth it and possible with a bit more effort. I'll look into it.

"txNumSubmitted",
"txNumAccepted",
"txNumValidated",
"txNumOrphaned",
"txUnvalidated",
"txRateSumbitted",
"txRateAccepted",
"txRateValidated",
"txLatencySubmitToAccept10Pctl",
"txLatencySubmitToAccept50Pctl",
"txLatencySubmitToAccept90Pctl",
"txLatencySubmitToValidate10Pctl",
"txLatencySubmitToValidate50Pctl",
"txLatencySubmitToValidate90Pctl",
)

ledgerStats = (
"ledgerNumAccepted",
"ledgerNumFullyValidated",
"ledgerRateAccepted",
"ledgerRateFullyValidated",
"ledgerLatencyAcceptToAccept10Pctl",
"ledgerLatencyAcceptToAccept50Pctl",
"ledgerLatencyAcceptToAccept90Pctl",
"ledgerLatencyFullyValidToFullyValid10Pctl",
"ledgerLatencyFullyValidToFullyValid50Pctl",
"ledgerLatencyFullyValidToFullyValid90Pctl",
)

for report in sys.argv[1:]:
if "tx" in report:
keys = txStats
print("Generating tx graphs from '" + report + "'")
elif "ledger" in report:
keys = ledgerStats
print("Generating ledger graphs from '" + report + "'")
plotGraph(report, keys)


20 changes: 11 additions & 9 deletions docs/consensus.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,12 @@ struct Ledger
{
using ID = ...;

using Seq = //std::uint32_t?...;

ID const & id() const;

// Sequence number that is 1 more than the parent ledger's seq()
std::size_t seq() const;
Seq seq() const;

// Whether the ledger's close time was a non-trivial consensus result
bool closeAgree() const;
Expand Down Expand Up @@ -633,14 +635,14 @@ struct Adaptor
// Propose the position to peers.
void propose(ConsensusProposal<...> const & pos);

// Relay a received peer proposal on to other peer's.
void relay(PeerPosition_t const & pos);
// Share a received peer proposal with other peers.
void share(PeerPosition_t const & pos);

// Relay a disputed transaction to peers
void relay(TxSet::Tx const & tx);
// Share a disputed transaction with peers
void share(TxSet::Tx const & tx);

// Realy given transaction set with peers
void relay(TxSet const &s);
// Share given transaction set with peers
void share(TxSet const &s);

//... implementation specific
};
Expand All @@ -649,9 +651,9 @@ struct Adaptor
The implementing class hides many details of the peer communication
model from the generic code.

* The =relay= member functions are responsible for sharing the given type with a
* The =share= member functions are responsible for sharing the given type with a
node's peers, but are agnostic to the mechanism. Ideally, messages are delivered
faster than =LEDGER_GRANULARITY=.
faster than =LEDGER_GRANULARITY=.
* The generic code does not specify how transactions are submitted by clients,
propagated through the network or stored in the open ledger. Indeed, the open
ledger is only conceptual from the perspective of the generic code---the
Expand Down
20 changes: 4 additions & 16 deletions src/ripple/app/consensus/RCLConsensus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ RCLConsensus::Adaptor::acquireLedger(LedgerHash const& ledger)


void
RCLConsensus::Adaptor::relay(RCLCxPeerPos const& peerPos)
RCLConsensus::Adaptor::share(RCLCxPeerPos const& peerPos)
{
protocol::TMProposeSet prop;

Expand All @@ -147,7 +147,7 @@ RCLConsensus::Adaptor::relay(RCLCxPeerPos const& peerPos)
}

void
RCLConsensus::Adaptor::relay(RCLCxTx const& tx)
RCLConsensus::Adaptor::share(RCLCxTx const& tx)
{
// If we didn't relay this transaction recently, relay it to all peers
if (app_.getHashRouter().shouldRelay(tx.id()))
Expand Down Expand Up @@ -196,7 +196,7 @@ RCLConsensus::Adaptor::propose(RCLCxPeerPos::Proposal const& proposal)
}

void
RCLConsensus::Adaptor::relay(RCLTxSet const& set)
RCLConsensus::Adaptor::share(RCLTxSet const& set)
{
inboundTransactions_.giveSet(set.id(), set.map_, false);
}
Expand Down Expand Up @@ -246,19 +246,7 @@ RCLConsensus::Adaptor::getPrevLedger(
app_.getValidations().currentTrustedDistribution(
ledgerID, parentID, ledgerMaster_.getValidLedgerIndex());

uint256 netLgr = ledgerID;
int netLgrCount = 0;
for (auto const & it : ledgerCounts)
{
// Switch to ledger supported by more peers
// Or stick with ours on a tie
if ((it.second > netLgrCount) ||
((it.second == netLgrCount) && (it.first == ledgerID)))
{
netLgr = it.first;
netLgrCount = it.second;
}
}
uint256 netLgr = getPreferredLedger(ledgerID, ledgerCounts);

if (netLgr != ledgerID)
{
Expand Down
Loading