Skip to content

Commit

Permalink
[WIP] Placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
ximinez committed Feb 7, 2025
1 parent 7c5822b commit 17b1c53
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
36 changes: 36 additions & 0 deletions src/test/consensus/Consensus_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,41 @@ class Consensus_test : public beast::unit_test::suite
BEAST_EXPECT(sim.synchronized());
}

void
testDisputes()
{
using namespace csf;
using namespace std::chrono;

std::uint32_t numPeers = 35;

ConsensusParms const parms{};
Sim sim;

PeerGroup peers = sim.createGroup(numPeers);

SimDuration delay = round<milliseconds>(0.2 * parms.ledgerGRANULARITY);
peers.trustAndConnect(peers, delay);

// Initial round to set prior state
sim.run(1);
for (Peer* peer : peers)
{
// Every transaction will be seen by every node but two.
// To accomplish that, every peer will add the ids of every peer
// except itself, and the one following.
auto const myId = peer->id;
auto const nextId = (peer->id + PeerID(1)) % PeerID(numPeers);
for (Peer* to : sim.trustGraph.trustedPeers(peer))
{
if (to->id == myId || to->id == nextId)
continue;
peer->openTxs.insert(Tx{static_cast<std::uint32_t>(to->id)});
}
}
sim.run(1);
}

void
run() override
{
Expand All @@ -1073,6 +1108,7 @@ class Consensus_test : public beast::unit_test::suite
testHubNetwork();
testPreferredByBranch();
testPauseForLaggards();
testDisputes();
}
};

Expand Down
5 changes: 3 additions & 2 deletions src/xrpld/app/consensus/RCLValidations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,9 @@ handleNewValidation(
auto& validations = app.getValidations();

// masterKey is seated only if validator is trusted or listed
auto const outcome =
validations.add(calcNodeID(masterKey.value_or(signingKey)), val);
auto const nodeKey = masterKey.value_or(signingKey);
assert(nodeKey != app.getValidationPublicKey());
auto const outcome = validations.add(calcNodeID(nodeKey), val);

if (outcome == ValStatus::current)
{
Expand Down
3 changes: 2 additions & 1 deletion src/xrpld/consensus/Consensus.h
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,8 @@ Consensus<Adaptor>::haveConsensus()
}
else
{
JLOG(j_.debug()) << nodeId << " has " << peerProp.position();
JLOG(j_.debug()) << "Proposal disagreement: Peer " << nodeId
<< " has " << peerProp.position();
++disagree;
}
}
Expand Down

0 comments on commit 17b1c53

Please sign in to comment.