Skip to content

Commit

Permalink
Log proposals and validations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Travis authored and Mark Travis committed Feb 14, 2025
1 parent 7c9d652 commit e7dff04
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 0 deletions.
20 changes: 20 additions & 0 deletions include/xrpl/protocol/STValidation.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <functional>
#include <memory>
#include <optional>
#include <sstream>

namespace ripple {

Expand Down Expand Up @@ -141,6 +142,25 @@ class STValidation final : public STObject, public CountedObject<STValidation>
Blob
getSignature() const;

std::string
render() const

Check warning on line 146 in include/xrpl/protocol/STValidation.h

View check run for this annotation

Codecov / codecov/patch

include/xrpl/protocol/STValidation.h#L146

Added line #L146 was not covered by tests
{
std::stringstream ss;
ss << "validation: "
<< " ledger_hash: " << getLedgerHash()
<< " consensus_hash: " << getConsensusHash()
<< " sign_time: " << to_string(getSignTime())
<< " seen_time: " << to_string(getSeenTime())
<< " signer_public_key: " << getSignerPublic()
<< " node_id: " << getNodeID()
<< " is_valid: " << isValid()
<< " is_full: " << isFull()
<< " is_trusted: " << isTrusted()
<< " signing_hash: " << getSigningHash()
<< " base58: " << toBase58(TokenType::NodePublic, getSignerPublic());
return ss.str();
}

private:
static SOTemplate const&
validationFormat();
Expand Down
6 changes: 6 additions & 0 deletions src/test/csf/Peer.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ struct Peer
return proposal_.getJson();
}

std::string
render() const
{
return "";
}

private:
Proposal proposal_;
};
Expand Down
6 changes: 6 additions & 0 deletions src/xrpld/app/consensus/RCLCxPeerPos.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ class RCLCxPeerPos
Json::Value
getJson() const;

std::string
render() const

Check warning on line 101 in src/xrpld/app/consensus/RCLCxPeerPos.h

View check run for this annotation

Codecov / codecov/patch

src/xrpld/app/consensus/RCLCxPeerPos.h#L101

Added line #L101 was not covered by tests
{
return proposal_.render();

Check warning on line 103 in src/xrpld/app/consensus/RCLCxPeerPos.h

View check run for this annotation

Codecov / codecov/patch

src/xrpld/app/consensus/RCLCxPeerPos.h#L103

Added line #L103 was not covered by tests
}

private:
PublicKey publicKey_;
uint256 suppression_;
Expand Down
15 changes: 15 additions & 0 deletions src/xrpld/app/misc/NetworkOPs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2355,6 +2355,21 @@ NetworkOPsImp::recvValidation(

pubValidation(val);

JLOG(m_journal.debug()) << [this, &val]() -> auto {
std::stringstream ss;
ss << "VALIDATION: " << val->render() << " master_key: ";
auto master = app_.validators().getTrustedKey(val->getSignerPublic());
if (master)
{
ss << toBase58(TokenType::NodePublic, *master);
}
else
{
ss << "none";
}
return ss.str();
}();

// We will always relay trusted validations; if configured, we will
// also relay all untrusted validations.
return app_.config().RELAY_UNTRUSTED_VALIDATIONS == 1 || val->isTrusted();
Expand Down
1 change: 1 addition & 0 deletions src/xrpld/consensus/Consensus.h
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@ Consensus<Adaptor>::peerProposal(
NetClock::time_point const& now,
PeerPosition_t const& newPeerPos)
{
JLOG(j_.debug()) << "PROPOSAL " << newPeerPos.render();
auto const& peerID = newPeerPos.proposal().nodeID();

// Always need to store recent positions
Expand Down
15 changes: 15 additions & 0 deletions src/xrpld/consensus/ConsensusProposal.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <xrpl/protocol/HashPrefix.h>
#include <xrpl/protocol/jss.h>
#include <cstdint>
#include <sstream>
#include <optional>

namespace ripple {
Expand Down Expand Up @@ -194,6 +195,20 @@ class ConsensusProposal
proposeSeq_ = seqLeave;
}

std::string
render() const

Check warning on line 199 in src/xrpld/consensus/ConsensusProposal.h

View check run for this annotation

Codecov / codecov/patch

src/xrpld/consensus/ConsensusProposal.h#L199

Added line #L199 was not covered by tests
{
std::stringstream ss;
ss << "proposal: previous_ledger: " << previousLedger_
<< " proposal_seq: " << proposeSeq_
<< " position: " << position_
<< " close_time: " << to_string(closeTime_)
<< " now: " << to_string(time_)
<< " is_bow_out:" << isBowOut()
<< " node_id: " << nodeID_;
return ss.str();
}

//! Get JSON representation for debugging
Json::Value
getJson() const
Expand Down

0 comments on commit e7dff04

Please sign in to comment.