Compare commits

..

2 Commits

Author SHA1 Message Date
Nicholas Dudfield
65c6ad4ba3 Merge remote-tracking branch 'origin/dev' into request-id-correlation 2026-06-17 14:35:14 +07:00
Nicholas Dudfield
7ef50e4114 feat(protocol): add request correlation ids 2026-04-30 11:29:28 +07:00
8 changed files with 58 additions and 127 deletions

View File

@@ -95,16 +95,8 @@ if [[ "$4" == "" ]]; then
echo "Non GH, local building, no Action runner magic"
else
# GH Action, runner
if [[ "$(git rev-parse --abbrev-ref HEAD)" == "release" ]]; then
echo "building on the release branch... placing it in builds/candidate"
mkdir /data/builds/candidate
cp /io/release-build/xahaud /data/builds/candidate/$(date +%Y).$(date +%-m).$(date +%-d)-$(git rev-parse --abbrev-ref HEAD)+$4
cp /io/release-build/release.info /data/builds/candidate/$(date +%Y).$(date +%-m).$(date +%-d)-$(git rev-parse --abbrev-ref HEAD)+$4.releaseinfo
else
echo "building non-release branch, placing it in builds root"
cp /io/release-build/xahaud /data/builds/$(date +%Y).$(date +%-m).$(date +%-d)-$(git rev-parse --abbrev-ref HEAD)+$4
cp /io/release-build/release.info /data/builds/$(date +%Y).$(date +%-m).$(date +%-d)-$(git rev-parse --abbrev-ref HEAD)+$4.releaseinfo
fi
cp /io/release-build/xahaud /data/builds/$(date +%Y).$(date +%-m).$(date +%-d)-$(git rev-parse --abbrev-ref HEAD)+$4
cp /io/release-build/release.info /data/builds/$(date +%Y).$(date +%-m).$(date +%-d)-$(git rev-parse --abbrev-ref HEAD)+$4.releaseinfo
echo "Published build to: http://build.xahau.tech/"
echo $(date +%Y).$(date +%-m).$(date +%-d)-$(git rev-parse --abbrev-ref HEAD)+$4
fi

View File

@@ -116,6 +116,11 @@ message TMTransaction
message TMTransactions
{
repeated TMTransaction transactions = 1;
// Optional opaque request/response correlation ID. If present on the
// TMGetObjectByHash(otTRANSACTIONS) request, the responder copies it
// unchanged. This field is not routing state and does not affect message
// processing, resource charging, duplicate suppression, or consensus.
optional uint64 requestId = 2;
}
@@ -267,6 +272,10 @@ message TMGetObjectByHash
optional bytes ledgerHash = 4; // the hash of the ledger these queries are for
optional bool fat = 5; // return related nodes
repeated TMIndexedObject objects = 6; // the specific objects requested
// Optional opaque request/response correlation ID. Responders copy this
// value unchanged when forming a reply. This is distinct from the existing
// uint32 seq field and has no protocol meaning beyond correlation.
optional uint64 requestId = 7;
}
@@ -306,6 +315,10 @@ message TMGetLedger
optional uint64 requestCookie = 6;
optional TMQueryType queryType = 7;
optional uint32 queryDepth = 8; // How deep to go, number of extra levels
// Optional opaque request/response correlation ID. Responders copy this
// value unchanged into TMLedgerData. This is separate from requestCookie:
// requestCookie is relay routing state; requestId is only correlation.
optional uint64 requestId = 9;
}
enum TMReplyError
@@ -323,6 +336,9 @@ message TMLedgerData
repeated TMLedgerNode nodes = 4;
optional uint32 requestCookie = 5;
optional TMReplyError error = 6;
// Optional opaque request/response correlation ID copied from TMGetLedger.
// Receivers must not use it for relay routing or data validation.
optional uint64 requestId = 7;
}
message TMPing
@@ -335,6 +351,9 @@ message TMPing
optional uint32 seq = 2; // detect stale replies, ensure other side is reading
optional uint64 pingTime = 3; // know when we think we sent the ping
optional uint64 netTime = 4;
// Optional opaque request/response correlation ID copied from ptPING to
// ptPONG. The existing seq field remains the ping liveness cookie.
optional uint64 requestId = 5;
}
message TMSquelch
@@ -355,6 +374,8 @@ message TMProofPathRequest
required bytes key = 1;
required bytes ledgerHash = 2;
required TMLedgerMapType type = 3;
// Optional opaque request/response correlation ID copied into the response.
optional uint64 requestId = 4;
}
message TMProofPathResponse
@@ -365,11 +386,15 @@ message TMProofPathResponse
optional bytes ledgerHeader = 4;
repeated bytes path = 5;
optional TMReplyError error = 6;
// Optional opaque request/response correlation ID copied from the request.
optional uint64 requestId = 7;
}
message TMReplayDeltaRequest
{
required bytes ledgerHash = 1;
// Optional opaque request/response correlation ID copied into the response.
optional uint64 requestId = 2;
}
message TMReplayDeltaResponse
@@ -378,6 +403,8 @@ message TMReplayDeltaResponse
optional bytes ledgerHeader = 2;
repeated bytes transaction = 3;
optional TMReplyError error = 4;
// Optional opaque request/response correlation ID copied from the request.
optional uint64 requestId = 5;
}
message TMHaveTransactions

View File

@@ -293,8 +293,6 @@ JSS(effective); // out: ValidatorList
// in: UNL
JSS(elapsed_seconds);
JSS(enabled); // out: AmendmentTable
JSS(ledger_enabled); // out: ServerDefinitions (amendment on-ledger)
JSS(cfg_forced); // out: ServerDefinitions ([features] config stanza)
JSS(engine_result); // out: NetworkOPs, TransactionSign, Submit
JSS(engine_result_code); // out: NetworkOPs, TransactionSign, Submit
JSS(engine_result_message); // out: NetworkOPs, TransactionSign, Submit

View File

@@ -186,13 +186,10 @@ public:
bool expectObsolete =
(votes.at(feature[jss::name].asString()) ==
VoteBehavior::Obsolete);
// "enabled" is now the effective value (ledger_voted || forced);
// this default env votes nothing onto the ledger, so assert on the
// canonical on-ledger flag.
BEAST_EXPECTS(
feature.isMember(jss::ledger_enabled) &&
!feature[jss::ledger_enabled].asBool(),
feature[jss::name].asString() + " ledger_enabled");
feature.isMember(jss::enabled) &&
!feature[jss::enabled].asBool(),
feature[jss::name].asString() + " enabled");
BEAST_EXPECTS(
feature.isMember(jss::vetoed) &&
feature[jss::vetoed].isBool() == !expectObsolete &&
@@ -240,12 +237,10 @@ public:
bool expectObsolete =
(votes.at((*it)[jss::name].asString()) ==
VoteBehavior::Obsolete);
// expectEnabled reflects the on-ledger amendment table, so compare
// against ledger_enabled (enabled is now ledger_voted || forced).
BEAST_EXPECTS(
(*it).isMember(jss::ledger_enabled) &&
(*it)[jss::ledger_enabled].asBool() == expectEnabled,
(*it)[jss::name].asString() + " ledger_enabled");
(*it).isMember(jss::enabled) &&
(*it)[jss::enabled].asBool() == expectEnabled,
(*it)[jss::name].asString() + " enabled");
if (expectEnabled)
BEAST_EXPECTS(
!(*it).isMember(jss::vetoed),
@@ -365,78 +360,12 @@ public:
}
}
void
testConfigForced(FeatureBitset features)
{
testcase("Config-forced features ([features] stanza)");
using namespace test::jtx;
// jtx enables amendments by inserting them into config.features (the
// same presets mechanism as the [features] config stanza), so passing
// a single-feature bitset gives us exactly one config-forced amendment
// and votes nothing onto the ledger. server_definitions must then
// report that one as effectively enabled, distinguishing the source:
// enabled = ledger_enabled || cfg_forced
// ledger_enabled = false (never voted onto the ledger)
// cfg_forced = true (forced via config) for the one feature only
auto const forced = featurePriceOracle;
auto const forcedHex = to_string(forced);
Env env{*this, FeatureBitset(forced)};
auto jrr = env.rpc("server_definitions")[jss::result];
if (!BEAST_EXPECT(jrr.isMember(jss::features)))
return;
bool sawForced = false;
for (auto it = jrr[jss::features].begin();
it != jrr[jss::features].end();
++it)
{
auto const& f = *it;
auto const name = f[jss::name].asString();
// every entry now carries the split flags
if (!BEAST_EXPECTS(
f.isMember(jss::enabled) &&
f.isMember(jss::ledger_enabled) &&
f.isMember(jss::cfg_forced),
name + " split flags"))
return;
// nothing is enabled on-ledger in a fresh env
BEAST_EXPECTS(
!f[jss::ledger_enabled].asBool(), name + " ledger_enabled");
if (it.key().asString() == forcedHex)
{
sawForced = true;
BEAST_EXPECTS(
f[jss::cfg_forced].asBool(), name + " cfg_forced");
// ledger_enabled(false) || cfg_forced(true) == true
BEAST_EXPECTS(f[jss::enabled].asBool(), name + " enabled");
}
else
{
BEAST_EXPECTS(
!f[jss::cfg_forced].asBool(), name + " cfg_forced");
// not forced and not on-ledger => not effectively enabled
BEAST_EXPECTS(
f[jss::enabled].asBool() == f[jss::ledger_enabled].asBool(),
name + " enabled==ledger_enabled");
}
}
BEAST_EXPECT(sawForced);
}
void
testServerFeatures(FeatureBitset features)
{
testNoParams(features);
testSomeEnabled(features);
testWithMajorities(features);
testConfigForced(features);
}
void

View File

@@ -2405,6 +2405,9 @@ LedgerMaster::makeFetchPack(
if (request->has_seq())
reply.set_seq(request->seq());
if (request->has_requestid())
reply.set_requestid(request->requestid());
reply.set_ledgerhash(request->ledgerhash());
reply.set_type(protocol::TMGetObjectByHash::otFETCH_PACK);

View File

@@ -42,6 +42,9 @@ LedgerReplayMsgHandler::processProofPathRequest(
protocol::TMProofPathRequest& packet = *msg;
protocol::TMProofPathResponse reply;
if (packet.has_requestid())
reply.set_requestid(packet.requestid());
if (!packet.has_key() || !packet.has_ledgerhash() || !packet.has_type() ||
packet.ledgerhash().size() != uint256::size() ||
packet.key().size() != uint256::size() ||
@@ -182,6 +185,9 @@ LedgerReplayMsgHandler::processReplayDeltaRequest(
protocol::TMReplayDeltaRequest& packet = *msg;
protocol::TMReplayDeltaResponse reply;
if (packet.has_requestid())
reply.set_requestid(packet.requestid());
if (!packet.has_ledgerhash() ||
packet.ledgerhash().size() != uint256::size())
{

View File

@@ -2436,6 +2436,9 @@ PeerImp::onMessage(std::shared_ptr<protocol::TMGetObjectByHash> const& m)
if (packet.has_seq())
reply.set_seq(packet.seq());
if (packet.has_requestid())
reply.set_requestid(packet.requestid());
reply.set_type(packet.type());
if (packet.has_ledgerhash())
@@ -2748,6 +2751,9 @@ PeerImp::doTransactions(
{
protocol::TMTransactions reply;
if (packet->has_requestid())
reply.set_requestid(packet->requestid());
JLOG(p_journal_.trace()) << "received TMGetObjectByHash requesting tx "
<< packet->objects_size();
@@ -3249,6 +3255,12 @@ PeerImp::processLedgerRequest(std::shared_ptr<protocol::TMGetLedger> const& m)
protocol::TMLedgerData ledgerData;
bool fatLeaves{true};
auto const itype{m->itype()};
auto const copyRequestMetadata = [&] {
if (m->has_requestcookie())
ledgerData.set_requestcookie(m->requestcookie());
if (m->has_requestid())
ledgerData.set_requestid(m->requestid());
};
if (itype == protocol::liTS_CANDIDATE)
{
@@ -3260,8 +3272,7 @@ PeerImp::processLedgerRequest(std::shared_ptr<protocol::TMGetLedger> const& m)
ledgerData.set_ledgerseq(0);
ledgerData.set_ledgerhash(m->ledgerhash());
ledgerData.set_type(protocol::liTS_CANDIDATE);
if (m->has_requestcookie())
ledgerData.set_requestcookie(m->requestcookie());
copyRequestMetadata();
// We'll already have most transactions
fatLeaves = false;
@@ -3288,8 +3299,7 @@ PeerImp::processLedgerRequest(std::shared_ptr<protocol::TMGetLedger> const& m)
ledgerData.set_ledgerhash(ledgerHash.begin(), ledgerHash.size());
ledgerData.set_ledgerseq(ledger->info().seq);
ledgerData.set_type(itype);
if (m->has_requestcookie())
ledgerData.set_requestcookie(m->requestcookie());
copyRequestMetadata();
switch (itype)
{

View File

@@ -22,7 +22,6 @@
#include <xrpld/app/main/Application.h>
#include <xrpld/app/misc/AmendmentTable.h>
#include <xrpld/app/misc/NetworkOPs.h>
#include <xrpld/core/Config.h>
#include <xrpld/rpc/detail/TransactionSign.h>
#include <xrpl/json/json_value.h>
#include <xrpl/json/json_writer.h>
@@ -546,39 +545,6 @@ doServerDefinitions(RPC::JsonContext& context)
features[to_string(h)][jss::majority] =
t.time_since_epoch().count();
// Amendment activation has two independent sources; surface both so a
// consumer isn't misled by a node that force-enables amendments:
// ledger_enabled : recorded in the on-ledger Amendments object
// (network-canonical; what the table reports as
// "enabled")
// cfg_forced : force-activated via the [features] config stanza
// (node-local; active in the Rules regardless of the
// ledger, casts no votes, never written on-ledger)
// enabled : effective for transaction processing on this
// server, i.e. ledger_enabled || cfg_forced
for (auto const& name : features.getMemberNames())
{
Json::Value& entry = features[name];
bool const ledgerEnabled = entry[jss::enabled].asBool();
entry[jss::ledger_enabled] = ledgerEnabled;
entry[jss::cfg_forced] = false;
// entry[jss::enabled] is left == ledgerEnabled here; only
// cfg_forced amendments below flip it.
}
for (auto const& h : context.app.config().features)
{
Json::Value& entry = features[to_string(h)];
if (!entry.isMember(jss::name))
{
if (auto const fname = featureToName(h); !fname.empty())
entry[jss::name] = fname;
}
if (!entry.isMember(jss::ledger_enabled))
entry[jss::ledger_enabled] = false;
entry[jss::cfg_forced] = true;
entry[jss::enabled] = true; // ledger_enabled || cfg_forced
}
lastFeatures = features;
{
const std::string out = Json::FastWriter().write(features);