Skip to content

Commit 2312c25

Browse files
authored
chore: Revert extra commits for 2.4.1 (#2133)
2 parents 317b3e2 + 8d76a05 commit 2312c25

27 files changed

+153
-293
lines changed

src/etl/ETLService.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,6 @@ class ETLService : public etlng::ETLServiceInterface, ETLServiceTag {
182182
ret = std::make_shared<etl::ETLService>(config, ioc, backend, subscriptions, balancer, ledgers);
183183
}
184184

185-
// inject networkID into subscriptions, as transaction feed require it to inject CTID in response
186-
if (auto const state = ret->getETLState(); state)
187-
subscriptions->setNetworkID(state->networkID);
188-
189185
ret->run();
190186
return ret;
191187
}

src/etl/ETLState.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ tag_invoke(boost::json::value_to_tag<ETLState>, boost::json::value const& jv)
4040
if (jsonObject.contains(JS(result)) && jsonObject.at(JS(result)).as_object().contains(JS(info))) {
4141
auto const rippledInfo = jsonObject.at(JS(result)).as_object().at(JS(info)).as_object();
4242
if (rippledInfo.contains(JS(network_id)))
43-
state.networkID = boost::json::value_to<int64_t>(rippledInfo.at(JS(network_id)));
43+
state.networkID.emplace(boost::json::value_to<int64_t>(rippledInfo.at(JS(network_id))));
4444
}
4545

4646
return state;

src/etl/ETLState.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,7 @@ namespace etl {
3838
* @brief This class is responsible for fetching and storing the state of the ETL information, such as the network id
3939
*/
4040
struct ETLState {
41-
/*
42-
* NOTE: Rippled NetworkID: Mainnet = 0; Testnet = 1; Devnet = 2
43-
* However, if rippled is running on neither of these (ie. standalone mode) rippled will default to 0, but
44-
* is not included in the stateOpt response. Must manually add it here.
45-
*/
46-
uint32_t networkID{0};
41+
std::optional<uint32_t> networkID;
4742

4843
/**
4944
* @brief Fetch the ETL state from the rippled server

src/etl/LoadBalancer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,12 @@ LoadBalancer::LoadBalancer(
174174
if (!stateOpt) {
175175
LOG(log_.warn()) << "Failed to fetch ETL state from source = " << source->toString()
176176
<< " Please check the configuration and network";
177-
} else if (etlState_ && etlState_->networkID != stateOpt->networkID) {
177+
} else if (etlState_ && etlState_->networkID && stateOpt->networkID &&
178+
etlState_->networkID != stateOpt->networkID) {
178179
checkOnETLFailure(fmt::format(
179180
"ETL sources must be on the same network. Source network id = {} does not match others network id = {}",
180-
stateOpt->networkID,
181-
etlState_->networkID
181+
*(stateOpt->networkID),
182+
*(etlState_->networkID)
182183
));
183184
} else {
184185
etlState_ = stateOpt;

src/etlng/LoadBalancer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,12 @@ LoadBalancer::LoadBalancer(
142142
if (!stateOpt) {
143143
LOG(log_.warn()) << "Failed to fetch ETL state from source = " << source->toString()
144144
<< " Please check the configuration and network";
145-
} else if (etlState_ && etlState_->networkID != stateOpt->networkID) {
145+
} else if (etlState_ && etlState_->networkID && stateOpt->networkID &&
146+
etlState_->networkID != stateOpt->networkID) {
146147
checkOnETLFailure(fmt::format(
147148
"ETL sources must be on the same network. Source network id = {} does not match others network id = {}",
148-
stateOpt->networkID,
149-
etlState_->networkID
149+
*(stateOpt->networkID),
150+
*(etlState_->networkID)
150151
));
151152
} else {
152153
etlState_ = stateOpt;

src/feed/SubscriptionManager.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ SubscriptionManager::unsubBook(ripple::Book const& book, SubscriberSharedPtr con
191191
void
192192
SubscriptionManager::pubTransaction(data::TransactionAndMetadata const& txMeta, ripple::LedgerHeader const& lgrInfo)
193193
{
194-
transactionFeed_.pub(txMeta, lgrInfo, backend_, amendmentCenter_, networkID_);
194+
transactionFeed_.pub(txMeta, lgrInfo, backend_, amendmentCenter_);
195195
}
196196

197197
boost::json::object
@@ -210,16 +210,4 @@ SubscriptionManager::report() const
210210
};
211211
}
212212

213-
void
214-
SubscriptionManager::setNetworkID(uint32_t const networkID)
215-
{
216-
networkID_ = networkID;
217-
}
218-
219-
uint32_t
220-
SubscriptionManager::getNetworkID() const
221-
{
222-
return networkID_;
223-
}
224-
225213
} // namespace feed

src/feed/SubscriptionManager.hpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ class SubscriptionManager : public SubscriptionManagerInterface {
6969
impl::BookChangesFeed bookChangesFeed_;
7070
impl::TransactionFeed transactionFeed_;
7171
impl::ProposedTransactionFeed proposedTransactionFeed_;
72-
uint32_t networkID_{0};
7372

7473
public:
7574
/**
@@ -333,21 +332,6 @@ class SubscriptionManager : public SubscriptionManagerInterface {
333332
*/
334333
boost::json::object
335334
report() const final;
336-
337-
/**
338-
* @brief Set the networkID.
339-
* @param networkID The network id to set.
340-
*/
341-
void
342-
setNetworkID(uint32_t networkID) final;
343-
344-
/**
345-
* @brief Get the networkID.
346-
*
347-
* @return The network id.
348-
*/
349-
uint32_t
350-
getNetworkID() const final;
351335
};
352336

353337
} // namespace feed

src/feed/SubscriptionManagerInterface.hpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -244,25 +244,10 @@ class SubscriptionManagerInterface {
244244
/**
245245
* @brief Get the number of subscribers.
246246
*
247-
* @return The report of the number of subscribers.
247+
* @return The report of the number of subscribers
248248
*/
249249
virtual boost::json::object
250250
report() const = 0;
251-
252-
/**
253-
* @brief Set the networkID.
254-
* @param networkID The network id to set.
255-
*/
256-
virtual void
257-
setNetworkID(uint32_t networkID) = 0;
258-
259-
/**
260-
* @brief Get the networkID.
261-
*
262-
* @return The network id.
263-
*/
264-
virtual uint32_t
265-
getNetworkID() const = 0;
266251
};
267252

268253
} // namespace feed

src/feed/impl/TransactionFeed.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "feed/Types.hpp"
2626
#include "rpc/JS.hpp"
2727
#include "rpc/RPCHelpers.hpp"
28-
#include "util/Assert.hpp"
2928
#include "util/log/Logger.hpp"
3029

3130
#include <boost/asio/spawn.hpp>
@@ -177,8 +176,7 @@ TransactionFeed::pub(
177176
data::TransactionAndMetadata const& txMeta,
178177
ripple::LedgerHeader const& lgrInfo,
179178
std::shared_ptr<data::BackendInterface const> const& backend,
180-
std::shared_ptr<data::AmendmentCenterInterface const> const& amendmentCenter,
181-
uint32_t const networkID
179+
std::shared_ptr<data::AmendmentCenterInterface const> const& amendmentCenter
182180
)
183181
{
184182
auto [tx, meta] = rpc::deserializeTxPlusMeta(txMeta, lgrInfo.seq);
@@ -207,15 +205,6 @@ TransactionFeed::pub(
207205
rpc::insertDeliverMaxAlias(pubObj[txKey].as_object(), version);
208206
rpc::insertMPTIssuanceID(pubObj[JS(meta)].as_object(), tx, meta);
209207

210-
auto const& metaObj = pubObj[JS(meta)];
211-
ASSERT(metaObj.is_object(), "meta must be an obj in rippled and clio");
212-
if (metaObj.as_object().contains("TransactionIndex") && metaObj.as_object().at("TransactionIndex").is_int64()) {
213-
if (auto const& ctid =
214-
rpc::encodeCTID(lgrInfo.seq, metaObj.as_object().at("TransactionIndex").as_int64(), networkID);
215-
ctid)
216-
pubObj[JS(ctid)] = ctid.value();
217-
}
218-
219208
pubObj[JS(type)] = "transaction";
220209
pubObj[JS(validated)] = true;
221210
pubObj[JS(status)] = "closed";

src/feed/impl/TransactionFeed.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,12 @@ class TransactionFeed {
182182
* @param txMeta The transaction and metadata.
183183
* @param lgrInfo The ledger header.
184184
* @param backend The backend.
185-
* @param networkID The network ID.
186185
*/
187186
void
188187
pub(data::TransactionAndMetadata const& txMeta,
189188
ripple::LedgerHeader const& lgrInfo,
190189
std::shared_ptr<data::BackendInterface const> const& backend,
191-
std::shared_ptr<data::AmendmentCenterInterface const> const& amendmentCenter,
192-
uint32_t networkID);
190+
std::shared_ptr<data::AmendmentCenterInterface const> const& amendmentCenter);
193191

194192
/**
195193
* @brief Get the number of subscribers of the transaction feed.

src/rpc/RPCHelpers.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,7 @@ std::optional<std::string>
290290
encodeCTID(uint32_t ledgerSeq, uint16_t txnIndex, uint16_t networkId) noexcept
291291
{
292292
static constexpr uint32_t kMAX_LEDGER_SEQ = 0x0FFF'FFFF;
293-
static constexpr uint32_t kMAX_TXN_INDEX = 0xFFFF;
294-
static constexpr uint32_t kMAX_NETWORK_ID = 0xFFFF;
295-
296-
if (ledgerSeq > kMAX_LEDGER_SEQ || txnIndex > kMAX_TXN_INDEX || networkId > kMAX_NETWORK_ID)
293+
if (ledgerSeq > kMAX_LEDGER_SEQ)
297294
return {};
298295

299296
static constexpr uint64_t kCTID_PREFIX = 0xC000'0000;

src/rpc/common/impl/HandlerProvider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ ProductionHandlerProvider::ProductionHandlerProvider(
8787
{"account_nfts", {.handler = AccountNFTsHandler{backend}}},
8888
{"account_objects", {.handler = AccountObjectsHandler{backend}}},
8989
{"account_offers", {.handler = AccountOffersHandler{backend}}},
90-
{"account_tx", {.handler = AccountTxHandler{backend, etl}}},
90+
{"account_tx", {.handler = AccountTxHandler{backend}}},
9191
{"amm_info", {.handler = AMMInfoHandler{backend, amendmentCenter}}},
9292
{"book_changes", {.handler = BookChangesHandler{backend}}},
9393
{"book_offers", {.handler = BookOffersHandler{backend, amendmentCenter}}},

src/rpc/handlers/AccountLines.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,6 @@ AccountLinesHandler::addLine(
103103
line.qualityIn = lineQualityIn;
104104
line.qualityOut = lineQualityOut;
105105

106-
if (lineNoRipple)
107-
line.noRipple = true;
108-
109-
if (lineNoRipplePeer)
110-
line.noRipplePeer = true;
111-
112106
if (lineAuth)
113107
line.authorized = true;
114108

@@ -127,6 +121,8 @@ AccountLinesHandler::addLine(
127121
if (lineDeepFreezePeer)
128122
line.deepFreezePeer = true;
129123

124+
line.noRipple = lineNoRipple;
125+
line.noRipplePeer = lineNoRipplePeer;
130126
lines.push_back(line);
131127
}
132128

@@ -262,11 +258,8 @@ tag_invoke(
262258
{JS(quality_out), line.qualityOut},
263259
};
264260

265-
if (line.noRipple)
266-
obj[JS(no_ripple)] = *(line.noRipple);
267-
268-
if (line.noRipplePeer)
269-
obj[JS(no_ripple_peer)] = *(line.noRipplePeer);
261+
obj[JS(no_ripple)] = line.noRipple;
262+
obj[JS(no_ripple_peer)] = line.noRipplePeer;
270263

271264
if (line.authorized)
272265
obj[JS(authorized)] = *(line.authorized);

src/rpc/handlers/AccountLines.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ class AccountLinesHandler {
7070
std::string limitPeer;
7171
uint32_t qualityIn{};
7272
uint32_t qualityOut{};
73-
std::optional<bool> noRipple;
74-
std::optional<bool> noRipplePeer;
73+
bool noRipple{};
74+
bool noRipplePeer{};
7575
std::optional<bool> authorized;
7676
std::optional<bool> peerAuthorized;
7777
std::optional<bool> freeze;

src/rpc/handlers/AccountTx.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,6 @@ AccountTxHandler::process(AccountTxHandler::Input input, Context const& ctx) con
161161
auto const txKey = ctx.apiVersion < 2u ? JS(tx) : JS(tx_json);
162162
obj[JS(meta)] = std::move(meta);
163163
obj[txKey] = std::move(txn);
164-
165-
// Put CTID into tx or tx_json
166-
if (obj[JS(meta)].as_object().contains("TransactionIndex")) {
167-
auto networkID = 0u;
168-
if (auto const& etlState = etl_->getETLState(); etlState.has_value())
169-
networkID = etlState->networkID;
170-
171-
auto const txnIdx = obj[JS(meta)].as_object().at("TransactionIndex").as_int64();
172-
if (auto const& ctid = rpc::encodeCTID(txnPlusMeta.ledgerSequence, txnIdx, networkID); ctid)
173-
obj[txKey].as_object()[JS(ctid)] = ctid.value();
174-
}
175-
176164
obj[txKey].as_object()[JS(date)] = txnPlusMeta.date;
177165
obj[txKey].as_object()[JS(ledger_index)] = txnPlusMeta.ledgerSequence;
178166

src/rpc/handlers/AccountTx.hpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#pragma once
2121

2222
#include "data/BackendInterface.hpp"
23-
#include "etlng/ETLServiceInterface.hpp"
2423
#include "rpc/Errors.hpp"
2524
#include "rpc/JS.hpp"
2625
#include "rpc/common/JsonBool.hpp"
@@ -56,7 +55,6 @@ namespace rpc {
5655
class AccountTxHandler {
5756
util::Logger log_{"RPC"};
5857
std::shared_ptr<BackendInterface> sharedPtrBackend_;
59-
std::shared_ptr<etlng::ETLServiceInterface const> etl_;
6058

6159
public:
6260
static constexpr auto kLIMIT_MIN = 1;
@@ -111,13 +109,8 @@ class AccountTxHandler {
111109
* @brief Construct a new AccountTxHandler object
112110
*
113111
* @param sharedPtrBackend The backend to use
114-
* @param etl The ETL service to use
115112
*/
116-
AccountTxHandler(
117-
std::shared_ptr<BackendInterface> const& sharedPtrBackend,
118-
std::shared_ptr<etlng::ETLServiceInterface const> const& etl
119-
)
120-
: sharedPtrBackend_(sharedPtrBackend), etl_{etl}
113+
AccountTxHandler(std::shared_ptr<BackendInterface> const& sharedPtrBackend) : sharedPtrBackend_(sharedPtrBackend)
121114
{
122115
}
123116

@@ -137,7 +130,6 @@ class AccountTxHandler {
137130
{JS(ledger_index), validation::CustomValidators::ledgerIndexValidator},
138131
{JS(ledger_index_min), validation::Type<int32_t>{}},
139132
{JS(ledger_index_max), validation::Type<int32_t>{}},
140-
{JS(ctid), validation::Type<std::string>{}},
141133
{JS(limit),
142134
validation::Type<uint32_t>{},
143135
validation::Min(1u),

src/rpc/handlers/Tx.hpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include "data/BackendInterface.hpp"
2323
#include "data/Types.hpp"
24+
#include "etl/ETLService.hpp"
2425
#include "etlng/ETLServiceInterface.hpp"
2526
#include "rpc/Errors.hpp"
2627
#include "rpc/JS.hpp"
@@ -37,9 +38,7 @@
3738
#include <boost/json/object.hpp>
3839
#include <boost/json/value.hpp>
3940
#include <boost/json/value_to.hpp>
40-
#include <fmt/core.h>
4141
#include <xrpl/basics/base_uint.h>
42-
#include <xrpl/basics/chrono.h>
4342
#include <xrpl/basics/strHex.h>
4443
#include <xrpl/protocol/ErrorCodes.h>
4544
#include <xrpl/protocol/LedgerHeader.h>
@@ -215,15 +214,17 @@ class TxHandler {
215214
// input.transaction might be not available, get hash via tx object
216215
if (txn.contains(JS(hash)))
217216
output.hash = txn.at(JS(hash)).as_string();
218-
}
219217

220-
// append ctid here to mimic rippled behavior
221-
auto const txnIdx = boost::json::value_to<uint64_t>(meta.at("TransactionIndex"));
222-
if (txnIdx <= 0xFFFFU && dbResponse->ledgerSequence < 0x0FFF'FFFFUL && currentNetId &&
223-
*currentNetId <= 0xFFFFU) {
224-
output.ctid = rpc::encodeCTID(
225-
dbResponse->ledgerSequence, static_cast<uint16_t>(txnIdx), static_cast<uint16_t>(*currentNetId)
226-
);
218+
// append ctid here to mimic rippled 1.12 behavior: return ctid even binary=true
219+
// rippled will change it in the future, ctid should be part of tx json which not available in binary
220+
// mode
221+
auto const txnIdx = boost::json::value_to<uint64_t>(meta.at("TransactionIndex"));
222+
if (txnIdx <= 0xFFFFU && dbResponse->ledgerSequence < 0x0FFF'FFFFUL && currentNetId &&
223+
*currentNetId <= 0xFFFFU) {
224+
output.ctid = rpc::encodeCTID(
225+
dbResponse->ledgerSequence, static_cast<uint16_t>(txnIdx), static_cast<uint16_t>(*currentNetId)
226+
);
227+
}
227228
}
228229

229230
output.date = dbResponse->date;
@@ -280,10 +281,12 @@ class TxHandler {
280281
if (output.tx) {
281282
obj[JS(tx_json)] = *output.tx;
282283
obj[JS(tx_json)].as_object()[JS(date)] = output.date;
283-
if (output.ctid)
284-
obj[JS(tx_json)].as_object()[JS(ctid)] = *output.ctid;
285-
286284
obj[JS(tx_json)].as_object()[JS(ledger_index)] = output.ledgerIndex;
285+
// move ctid from tx_json to root
286+
if (obj[JS(tx_json)].as_object().contains(JS(ctid))) {
287+
obj[JS(ctid)] = obj[JS(tx_json)].as_object()[JS(ctid)];
288+
obj[JS(tx_json)].as_object().erase(JS(ctid));
289+
}
287290
// move hash from tx_json to root
288291
if (obj[JS(tx_json)].as_object().contains(JS(hash))) {
289292
obj[JS(hash)] = obj[JS(tx_json)].as_object()[JS(hash)];

tests/common/util/MockSubscriptionManager.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ struct MockSubscriptionManager : feed::SubscriptionManagerInterface {
103103

104104
MOCK_METHOD(boost::json::object, report, (), (const, override));
105105

106-
MOCK_METHOD(void, setNetworkID, (uint32_t), (override));
107-
108-
MOCK_METHOD(uint32_t, getNetworkID, (), (const, override));
109-
110106
MOCK_METHOD(void, stop, (), (override));
111107
};
112108

0 commit comments

Comments
 (0)