Skip to content

Commit 04e94ce

Browse files
Phase 4: Consensus tracing — round lifecycle, proposals, validations
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 587d312 commit 04e94ce

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/xrpld/app/consensus/RCLConsensus.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <xrpld/consensus/LedgerTiming.h>
1515
#include <xrpld/overlay/Overlay.h>
1616
#include <xrpld/overlay/predicates.h>
17+
#include <xrpld/telemetry/TracingInstrumentation.h>
1718

1819
#include <xrpl/basics/random.h>
1920
#include <xrpl/beast/core/LexicalCast.h>
@@ -173,6 +174,9 @@ RCLConsensus::Adaptor::share(RCLCxTx const& tx)
173174
void
174175
RCLConsensus::Adaptor::propose(RCLCxPeerPos::Proposal const& proposal)
175176
{
177+
XRPL_TRACE_CONSENSUS(app_.getTelemetry(), "consensus.proposal.send");
178+
XRPL_TRACE_SET_ATTR("xrpl.consensus.round", static_cast<int64_t>(proposal.proposeSeq()));
179+
176180
JLOG(j_.trace()) << (proposal.isBowOut() ? "We bow out: " : "We propose: ")
177181
<< xrpl::to_string(proposal.prevLedger()) << " -> "
178182
<< xrpl::to_string(proposal.position());
@@ -275,6 +279,11 @@ RCLConsensus::Adaptor::onClose(
275279
NetClock::time_point const& closeTime,
276280
ConsensusMode mode) -> Result
277281
{
282+
XRPL_TRACE_CONSENSUS(app_.getTelemetry(), "consensus.ledger_close");
283+
XRPL_TRACE_SET_ATTR(
284+
"xrpl.consensus.ledger.seq", static_cast<int64_t>(ledger.ledger_->header().seq + 1));
285+
XRPL_TRACE_SET_ATTR("xrpl.consensus.mode", to_string(mode).c_str());
286+
278287
bool const wrongLCL = mode == ConsensusMode::wrongLedger;
279288
bool const proposing = mode == ConsensusMode::proposing;
280289

@@ -383,6 +392,11 @@ RCLConsensus::Adaptor::onAccept(
383392
Json::Value&& consensusJson,
384393
bool const validating)
385394
{
395+
XRPL_TRACE_CONSENSUS(app_.getTelemetry(), "consensus.accept");
396+
XRPL_TRACE_SET_ATTR("xrpl.consensus.proposers", static_cast<int64_t>(result.proposers));
397+
XRPL_TRACE_SET_ATTR(
398+
"xrpl.consensus.round_time_ms", static_cast<int64_t>(result.roundTime.read().count()));
399+
386400
app_.getJobQueue().addJob(
387401
jtACCEPT, "AcceptLedger", [=, this, cj = std::move(consensusJson)]() mutable {
388402
// Note that no lock is held or acquired during this job.
@@ -736,6 +750,10 @@ RCLConsensus::Adaptor::buildLCL(
736750
void
737751
RCLConsensus::Adaptor::validate(RCLCxLedger const& ledger, RCLTxSet const& txns, bool proposing)
738752
{
753+
XRPL_TRACE_CONSENSUS(app_.getTelemetry(), "consensus.validation.send");
754+
XRPL_TRACE_SET_ATTR("xrpl.consensus.ledger.seq", static_cast<int64_t>(ledger.seq()));
755+
XRPL_TRACE_SET_ATTR("xrpl.consensus.proposing", proposing);
756+
739757
using namespace std::chrono_literals;
740758

741759
auto validationTime = app_.timeKeeper().closeTime();

0 commit comments

Comments
 (0)