rippled
compression_test.cpp
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright 2020 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #include <ripple/app/ledger/Ledger.h>
21 #include <ripple/app/ledger/LedgerMaster.h>
22 #include <ripple/app/misc/Manifest.h>
23 #include <ripple/basics/random.h>
24 #include <ripple/beast/unit_test.h>
25 #include <ripple/beast/utility/Journal.h>
26 #include <ripple/overlay/Compression.h>
27 #include <ripple/overlay/Message.h>
28 #include <ripple/overlay/impl/Handshake.h>
29 #include <ripple/overlay/impl/ProtocolMessage.h>
30 #include <ripple/overlay/impl/ZeroCopyStream.h>
31 #include <ripple/protocol/HashPrefix.h>
32 #include <ripple/protocol/PublicKey.h>
33 #include <ripple/protocol/SecretKey.h>
34 #include <ripple/protocol/Sign.h>
35 #include <ripple/protocol/digest.h>
36 #include <ripple/protocol/jss.h>
37 #include <ripple/protocol/messages.h>
38 #include <ripple/shamap/SHAMapNodeID.h>
39 #include <boost/asio/ip/address_v4.hpp>
40 #include <boost/beast/core/multi_buffer.hpp>
41 #include <boost/endian/conversion.hpp>
42 #include <algorithm>
43 #include <test/jtx/Account.h>
44 #include <test/jtx/Env.h>
45 #include <test/jtx/WSClient.h>
46 #include <test/jtx/amount.h>
47 #include <test/jtx/pay.h>
48 
49 namespace ripple {
50 
51 namespace test {
52 
53 using namespace ripple::test;
54 using namespace ripple::test::jtx;
55 
56 static uint256
57 ledgerHash(LedgerInfo const& info)
58 {
59  return ripple::sha512Half(
61  std::uint32_t(info.seq),
62  std::uint64_t(info.drops.drops()),
63  info.parentHash,
64  info.txHash,
65  info.accountHash,
69  std::uint8_t(info.closeFlags));
70 }
71 
72 class compression_test : public beast::unit_test::suite
73 {
76 
77 public:
79  {
80  }
81 
82  template <typename T>
83  void
85  std::shared_ptr<T> proto,
86  protocol::MessageType mt,
87  uint16_t nbuffers,
88  std::string msg)
89  {
90  testcase("Compress/Decompress: " + msg);
91 
92  Message m(*proto, mt);
93 
94  auto& buffer = m.getBuffer(Compressed::On);
95 
96  boost::beast::multi_buffer buffers;
97 
98  // simulate multi-buffer
99  auto sz = buffer.size() / nbuffers;
100  for (int i = 0; i < nbuffers; i++)
101  {
102  auto start = buffer.begin() + sz * i;
103  auto end = i < nbuffers - 1 ? (buffer.begin() + sz * (i + 1))
104  : buffer.end();
105  std::vector<std::uint8_t> slice(start, end);
106  buffers.commit(boost::asio::buffer_copy(
107  buffers.prepare(slice.size()), boost::asio::buffer(slice)));
108  }
109 
110  boost::system::error_code ec;
112  ec, buffers.data(), buffer.size());
113 
114  BEAST_EXPECT(header);
115 
116  if (!header || header->algorithm == Algorithm::None)
117  return;
118 
119  std::vector<std::uint8_t> decompressed;
120  decompressed.resize(header->uncompressed_size);
121 
122  BEAST_EXPECT(
123  header->payload_wire_size == buffer.size() - header->header_size);
124 
125  ZeroCopyInputStream stream(buffers.data());
126  stream.Skip(header->header_size);
127 
128  auto decompressedSize = ripple::compression::decompress(
129  stream,
130  header->payload_wire_size,
131  decompressed.data(),
132  header->uncompressed_size);
133  BEAST_EXPECT(decompressedSize == header->uncompressed_size);
134  auto const proto1 = std::make_shared<T>();
135 
136  BEAST_EXPECT(
137  proto1->ParseFromArray(decompressed.data(), decompressedSize));
138  auto uncompressed = m.getBuffer(Compressed::Off);
139  BEAST_EXPECT(std::equal(
140  uncompressed.begin() + ripple::compression::headerBytes,
141  uncompressed.end(),
142  decompressed.begin()));
143  }
144 
147  {
148  auto manifests = std::make_shared<protocol::TMManifests>();
149  manifests->mutable_list()->Reserve(n);
150  for (int i = 0; i < n; i++)
151  {
152  auto master = randomKeyPair(KeyType::ed25519);
153  auto signing = randomKeyPair(KeyType::ed25519);
154  STObject st(sfGeneric);
155  st[sfSequence] = i;
156  st[sfPublicKey] = std::get<0>(master);
157  st[sfSigningPubKey] = std::get<0>(signing);
158  st[sfDomain] = makeSlice(
159  std::string("example") + std::to_string(i) +
160  std::string(".com"));
161  sign(
162  st,
165  std::get<1>(master),
167  sign(
168  st,
171  std::get<1>(signing));
172  Serializer s;
173  st.add(s);
174  auto* manifest = manifests->add_list();
175  manifest->set_stobject(s.data(), s.size());
176  }
177  return manifests;
178  }
179 
182  {
183  auto endpoints = std::make_shared<protocol::TMEndpoints>();
184  endpoints->mutable_endpoints_v2()->Reserve(n);
185  for (int i = 0; i < n; i++)
186  {
187  auto ep = endpoints->add_endpoints_v2();
188  ep->set_endpoint(std::string("10.0.1.") + std::to_string(i));
189  ep->set_hops(i);
190  }
191  endpoints->set_version(2);
192 
193  return endpoints;
194  }
195 
198  {
199  Env env(*this, envconfig());
200  int fund = 10000;
201  auto const alice = Account("alice");
202  auto const bob = Account("bob");
203  env.fund(XRP(fund), "alice", "bob");
204  env.trust(bob["USD"](fund), alice);
205  env.close();
206 
207  auto toBinary = [this](std::string const& text) {
208  auto blob = strUnHex(text);
209  BEAST_EXPECT(blob);
210  return std::string{
211  reinterpret_cast<char const*>(blob->data()), blob->size()};
212  };
213 
214  std::string usdTxBlob = "";
215  auto wsc = makeWSClient(env.app().config());
216  {
217  Json::Value jrequestUsd;
218  jrequestUsd[jss::secret] = toBase58(generateSeed("bob"));
219  jrequestUsd[jss::tx_json] =
220  pay("bob", "alice", bob["USD"](fund / 2));
221  Json::Value jreply_usd = wsc->invoke("sign", jrequestUsd);
222 
223  usdTxBlob =
224  toBinary(jreply_usd[jss::result][jss::tx_blob].asString());
225  }
226 
227  auto transaction = std::make_shared<protocol::TMTransaction>();
228  transaction->set_rawtransaction(usdTxBlob);
229  transaction->set_status(protocol::tsNEW);
230  transaction->set_receivetimestamp(rand_int<std::uint64_t>());
231  transaction->set_deferred(true);
232 
233  return transaction;
234  }
235 
238  {
239  auto getLedger = std::make_shared<protocol::TMGetLedger>();
240  getLedger->set_itype(protocol::liTS_CANDIDATE);
241  getLedger->set_ltype(protocol::TMLedgerType::ltACCEPTED);
242  uint256 const hash(ripple::sha512Half(123456789));
243  getLedger->set_ledgerhash(hash.begin(), hash.size());
244  getLedger->set_ledgerseq(123456789);
245  ripple::SHAMapNodeID sha(64, hash);
246  getLedger->add_nodeids(sha.getRawString());
247  getLedger->set_requestcookie(123456789);
248  getLedger->set_querytype(protocol::qtINDIRECT);
249  getLedger->set_querydepth(3);
250  return getLedger;
251  }
252 
254  buildLedgerData(uint32_t n, Logs& logs)
255  {
256  auto ledgerData = std::make_shared<protocol::TMLedgerData>();
257  uint256 const hash(ripple::sha512Half(12356789));
258  ledgerData->set_ledgerhash(hash.data(), hash.size());
259  ledgerData->set_ledgerseq(123456789);
260  ledgerData->set_type(protocol::TMLedgerInfoType::liAS_NODE);
261  ledgerData->set_requestcookie(123456789);
262  ledgerData->set_error(protocol::TMReplyError::reNO_LEDGER);
263  ledgerData->mutable_nodes()->Reserve(n);
264  uint256 parentHash(0);
265 
266  NetClock::duration const resolution{10};
267  NetClock::time_point ct{resolution};
268 
269  for (int i = 0; i < n; i++)
270  {
271  LedgerInfo info;
272  info.seq = i;
273  info.parentCloseTime = ct;
274  info.hash = ripple::sha512Half(i);
275  info.txHash = ripple::sha512Half(i + 1);
276  info.accountHash = ripple::sha512Half(i + 2);
277  info.parentHash = parentHash;
278  info.drops = XRPAmount(10);
279  info.closeTimeResolution = resolution;
280  info.closeTime = ct;
281  ct += resolution;
282  parentHash = ledgerHash(info);
283  Serializer nData;
284  ripple::addRaw(info, nData);
285  ledgerData->add_nodes()->set_nodedata(
286  nData.getDataPtr(), nData.getLength());
287  }
288 
289  return ledgerData;
290  }
291 
294  {
295  auto getObject = std::make_shared<protocol::TMGetObjectByHash>();
296 
297  getObject->set_type(protocol::TMGetObjectByHash_ObjectType::
298  TMGetObjectByHash_ObjectType_otTRANSACTION);
299  getObject->set_query(true);
300  getObject->set_seq(123456789);
301  uint256 hash(ripple::sha512Half(123456789));
302  getObject->set_ledgerhash(hash.data(), hash.size());
303  getObject->set_fat(true);
304  for (int i = 0; i < 100; i++)
305  {
306  uint256 hash(ripple::sha512Half(i));
307  auto object = getObject->add_objects();
308  object->set_hash(hash.data(), hash.size());
309  ripple::SHAMapNodeID sha(64, hash);
310  object->set_nodeid(sha.getRawString());
311  object->set_index("");
312  object->set_data("");
313  object->set_ledgerseq(i);
314  }
315  return getObject;
316  }
317 
320  {
321  auto list = std::make_shared<protocol::TMValidatorList>();
322 
323  auto master = randomKeyPair(KeyType::ed25519);
324  auto signing = randomKeyPair(KeyType::ed25519);
325  STObject st(sfGeneric);
326  st[sfSequence] = 0;
327  st[sfPublicKey] = std::get<0>(master);
328  st[sfSigningPubKey] = std::get<0>(signing);
329  st[sfDomain] = makeSlice(std::string("example.com"));
330  sign(
331  st,
334  std::get<1>(master),
336  sign(st, HashPrefix::manifest, KeyType::ed25519, std::get<1>(signing));
337  Serializer s;
338  st.add(s);
339  list->set_manifest(s.data(), s.size());
340  list->set_version(3);
341  STObject signature(sfSignature);
342  ripple::sign(
343  st, HashPrefix::manifest, KeyType::ed25519, std::get<1>(signing));
344  Serializer s1;
345  st.add(s1);
346  list->set_signature(s1.data(), s1.size());
347  list->set_blob(strHex(s.slice()));
348  return list;
349  }
350 
353  {
354  auto list = std::make_shared<protocol::TMValidatorListCollection>();
355 
356  auto master = randomKeyPair(KeyType::ed25519);
357  auto signing = randomKeyPair(KeyType::ed25519);
358  STObject st(sfGeneric);
359  st[sfSequence] = 0;
360  st[sfPublicKey] = std::get<0>(master);
361  st[sfSigningPubKey] = std::get<0>(signing);
362  st[sfDomain] = makeSlice(std::string("example.com"));
363  sign(
364  st,
367  std::get<1>(master),
369  sign(st, HashPrefix::manifest, KeyType::ed25519, std::get<1>(signing));
370  Serializer s;
371  st.add(s);
372  list->set_manifest(s.data(), s.size());
373  list->set_version(4);
374  STObject signature(sfSignature);
375  ripple::sign(
376  st, HashPrefix::manifest, KeyType::ed25519, std::get<1>(signing));
377  Serializer s1;
378  st.add(s1);
379  auto& blob = *list->add_blobs();
380  blob.set_signature(s1.data(), s1.size());
381  blob.set_blob(strHex(s.slice()));
382  return list;
383  }
384 
385  void
387  {
388  auto thresh = beast::severities::Severity::kInfo;
389  auto logs = std::make_unique<Logs>(thresh);
390 
391  protocol::TMManifests manifests;
392  protocol::TMEndpoints endpoints;
393  protocol::TMTransaction transaction;
394  protocol::TMGetLedger get_ledger;
395  protocol::TMLedgerData ledger_data;
396  protocol::TMGetObjectByHash get_object;
397  protocol::TMValidatorList validator_list;
398  protocol::TMValidatorListCollection validator_list_collection;
399 
400  // 4.5KB
401  doTest(buildManifests(20), protocol::mtMANIFESTS, 4, "TMManifests20");
402  // 22KB
403  doTest(buildManifests(100), protocol::mtMANIFESTS, 4, "TMManifests100");
404  // 131B
405  doTest(buildEndpoints(10), protocol::mtENDPOINTS, 4, "TMEndpoints10");
406  // 1.3KB
407  doTest(buildEndpoints(100), protocol::mtENDPOINTS, 4, "TMEndpoints100");
408  // 242B
409  doTest(
410  buildTransaction(*logs),
411  protocol::mtTRANSACTION,
412  1,
413  "TMTransaction");
414  // 87B
415  doTest(buildGetLedger(), protocol::mtGET_LEDGER, 1, "TMGetLedger");
416  // 61KB
417  doTest(
418  buildLedgerData(500, *logs),
419  protocol::mtLEDGER_DATA,
420  10,
421  "TMLedgerData500");
422  // 122 KB
423  doTest(
424  buildLedgerData(1000, *logs),
425  protocol::mtLEDGER_DATA,
426  20,
427  "TMLedgerData1000");
428  // 1.2MB
429  doTest(
430  buildLedgerData(10000, *logs),
431  protocol::mtLEDGER_DATA,
432  50,
433  "TMLedgerData10000");
434  // 12MB
435  doTest(
436  buildLedgerData(100000, *logs),
437  protocol::mtLEDGER_DATA,
438  100,
439  "TMLedgerData100000");
440  // 61MB
441  doTest(
442  buildLedgerData(500000, *logs),
443  protocol::mtLEDGER_DATA,
444  100,
445  "TMLedgerData500000");
446  // 7.7KB
447  doTest(
448  buildGetObjectByHash(),
449  protocol::mtGET_OBJECTS,
450  4,
451  "TMGetObjectByHash");
452  // 895B
453  doTest(
454  buildValidatorList(),
455  protocol::mtVALIDATORLIST,
456  4,
457  "TMValidatorList");
458  doTest(
459  buildValidatorListCollection(),
460  protocol::mtVALIDATORLISTCOLLECTION,
461  4,
462  "TMValidatorListCollection");
463  }
464 
465  void
467  {
468  testcase("Handshake");
469  auto getEnv = [&](bool enable) {
470  Config c;
471  std::stringstream str;
472  str << "[reduce_relay]\n"
473  << "vp_enable=1\n"
474  << "vp_squelch=1\n"
475  << "[compression]\n"
476  << enable << "\n";
477  c.loadFromString(str.str());
478  auto env = std::make_shared<jtx::Env>(*this);
479  env->app().config().COMPRESSION = c.COMPRESSION;
480  env->app().config().VP_REDUCE_RELAY_ENABLE =
482  env->app().config().VP_REDUCE_RELAY_SQUELCH =
484  return env;
485  };
486  auto handshake = [&](int outboundEnable, int inboundEnable) {
487  beast::IP::Address addr =
488  boost::asio::ip::address::from_string("172.1.1.100");
489 
490  auto env = getEnv(outboundEnable);
491  auto request = ripple::makeRequest(
492  true,
493  env->app().config().COMPRESSION,
494  false,
495  env->app().config().TX_REDUCE_RELAY_ENABLE,
496  env->app().config().VP_REDUCE_RELAY_ENABLE);
497  http_request_type http_request;
498  http_request.version(request.version());
499  http_request.base() = request.base();
500  // feature enabled on the peer's connection only if both sides are
501  // enabled
502  auto const peerEnabled = inboundEnable && outboundEnable;
503  // inbound is enabled if the request's header has the feature
504  // enabled and the peer's configuration is enabled
505  auto const inboundEnabled = peerFeatureEnabled(
506  http_request, FEATURE_COMPR, "lz4", inboundEnable);
507  BEAST_EXPECT(!(peerEnabled ^ inboundEnabled));
508 
509  env.reset();
510  env = getEnv(inboundEnable);
511  auto http_resp = ripple::makeResponse(
512  true,
513  http_request,
514  addr,
515  addr,
516  uint256{1},
517  1,
518  {1, 0},
519  env->app());
520  // outbound is enabled if the response's header has the feature
521  // enabled and the peer's configuration is enabled
522  auto const outboundEnabled = peerFeatureEnabled(
523  http_resp, FEATURE_COMPR, "lz4", outboundEnable);
524  BEAST_EXPECT(!(peerEnabled ^ outboundEnabled));
525  };
526  handshake(1, 1);
527  handshake(1, 0);
528  handshake(0, 1);
529  handshake(0, 0);
530  }
531 
532  void
533  run() override
534  {
535  testProtocol();
536  testHandshake();
537  }
538 };
539 
540 BEAST_DEFINE_TESTSUITE_MANUAL(compression, ripple_data, ripple);
541 
542 } // namespace test
543 } // namespace ripple
ripple::test::ledgerHash
static uint256 ledgerHash(LedgerInfo const &info)
Definition: compression_test.cpp:57
std::vector::resize
T resize(T... args)
ripple::HashPrefix::ledgerMaster
@ ledgerMaster
ledger master data for signing
ripple::test::jtx::XRP
const XRP_t XRP
Converts to XRP Issue or STAmount.
Definition: amount.cpp:105
ripple::Message::getBuffer
std::vector< uint8_t > const & getBuffer(Compressed tryCompressed)
Retrieve the packed message data.
Definition: Message.cpp:210
ripple::makeSlice
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)
Definition: Slice.h:241
std::string
STL class.
std::equal
T equal(T... args)
std::shared_ptr
STL class.
ripple::test::compression_test::doTest
void doTest(std::shared_ptr< T > proto, protocol::MessageType mt, uint16_t nbuffers, std::string msg)
Definition: compression_test.cpp:84
ripple::LedgerHeader::closeFlags
int closeFlags
Definition: LedgerHeader.h:63
ripple::Logs
Manages partitions for logging.
Definition: Log.h:48
ripple::test::compression_test::buildEndpoints
std::shared_ptr< protocol::TMEndpoints > buildEndpoints(int n)
Definition: compression_test.cpp:181
ripple::sfGeneric
const SField sfGeneric(access, 0)
Definition: SField.h:356
ripple::test::compression_test::testProtocol
void testProtocol()
Definition: compression_test.cpp:386
ripple::test::compression_test::buildLedgerData
std::shared_ptr< protocol::TMLedgerData > buildLedgerData(uint32_t n, Logs &logs)
Definition: compression_test.cpp:254
ripple::XRPAmount::drops
constexpr value_type drops() const
Returns the number of drops.
Definition: XRPAmount.h:172
ripple::sfSequence
const SF_UINT32 sfSequence
ripple::HashPrefix::manifest
@ manifest
Manifest.
std::vector
STL class.
std::vector::size
T size(T... args)
ripple::LedgerHeader::parentHash
uint256 parentHash
Definition: LedgerHeader.h:52
ripple::compression::headerBytes
constexpr std::size_t headerBytes
Definition: Compression.h:31
ripple::sfSigningPubKey
const SF_VL sfSigningPubKey
std::chrono::duration
ripple::toBase58
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Definition: AccountID.cpp:104
ripple::LedgerHeader::seq
LedgerIndex seq
Definition: LedgerHeader.h:41
std::stringstream
STL class.
ripple::test::compression_test::buildValidatorList
std::shared_ptr< protocol::TMValidatorList > buildValidatorList()
Definition: compression_test.cpp:319
ripple::test::compression_test::compression_test
compression_test()
Definition: compression_test.cpp:78
ripple::LedgerHeader::accountHash
uint256 accountHash
Definition: LedgerHeader.h:51
ripple::ZeroCopyInputStream
Implements ZeroCopyInputStream around a buffer sequence.
Definition: ZeroCopyStream.h:35
ripple::test::jtx::Env::app
Application & app()
Definition: Env.h:242
ripple::test::compression_test::buildGetObjectByHash
std::shared_ptr< protocol::TMGetObjectByHash > buildGetObjectByHash()
Definition: compression_test.cpp:293
ripple::SHAMapNodeID
Identifies a node inside a SHAMap.
Definition: SHAMapNodeID.h:33
ripple::test::jtx::envconfig
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
Definition: envconfig.h:49
ripple::test::jtx::sign
void sign(Json::Value &jv, Account const &account)
Sign automatically.
Definition: utility.cpp:46
ripple::LedgerHeader::txHash
uint256 txHash
Definition: LedgerHeader.h:50
ripple::test::compression_test
Definition: compression_test.cpp:72
ripple::base_uint::data
pointer data()
Definition: base_uint.h:122
ripple::test::jtx::Env::trust
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
Definition: Env.cpp:259
algorithm
ripple::base_uint::size
constexpr static std::size_t size()
Definition: base_uint.h:519
ripple::Config::VP_REDUCE_RELAY_SQUELCH
bool VP_REDUCE_RELAY_SQUELCH
Definition: Config.h:267
ripple::Serializer::data
void const * data() const noexcept
Definition: Serializer.h:76
ripple::uint256
base_uint< 256 > uint256
Definition: base_uint.h:550
ripple::KeyType::ed25519
@ ed25519
ripple::LedgerHeader::hash
uint256 hash
Definition: LedgerHeader.h:49
ripple::base_uint< 256 >
ripple::test::compression_test::run
void run() override
Definition: compression_test.cpp:533
std::chrono::time_point::time_since_epoch
T time_since_epoch(T... args)
ripple::LedgerHeader::parentCloseTime
NetClock::time_point parentCloseTime
Definition: LedgerHeader.h:42
ripple::test::compression_test::buildValidatorListCollection
std::shared_ptr< protocol::TMValidatorListCollection > buildValidatorListCollection()
Definition: compression_test.cpp:352
ripple::Config::loadFromString
void loadFromString(std::string const &fileContents)
Load the config from the contents of the string.
Definition: Config.cpp:447
beast::IP::Address
boost::asio::ip::address Address
Definition: IPAddress.h:41
ripple::Config
Definition: Config.h:92
ripple::Serializer::getDataPtr
const void * getDataPtr() const
Definition: Serializer.h:190
ripple::sfMasterSignature
const SF_VL sfMasterSignature
ripple::Application::config
virtual Config & config()=0
ripple::SHAMapNodeID::getRawString
std::string getRawString() const
Definition: SHAMapNodeID.cpp:65
std::to_string
T to_string(T... args)
ripple::test::jtx::Env::close
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
Definition: Env.cpp:121
ripple::FEATURE_COMPR
static constexpr char FEATURE_COMPR[]
Definition: Handshake.h:142
ripple::compression::Compressed
Compressed
Definition: Compression.h:38
ripple::Serializer::slice
Slice slice() const noexcept
Definition: Serializer.h:64
std::chrono::time_point
ripple::peerFeatureEnabled
bool peerFeatureEnabled(headers const &request, std::string const &feature, std::string value, bool config)
Check if a feature should be enabled for a peer.
Definition: Handshake.h:199
std::uint32_t
ripple::compression::Algorithm
Algorithm
Definition: Compression.h:36
ripple::test::compression_test::buildTransaction
std::shared_ptr< protocol::TMTransaction > buildTransaction(Logs &logs)
Definition: compression_test.cpp:197
ripple::LedgerHeader::closeTime
NetClock::time_point closeTime
Definition: LedgerHeader.h:72
ripple::LedgerHeader
Information about the notional ledger backing the view.
Definition: LedgerHeader.h:33
ripple::Config::VP_REDUCE_RELAY_ENABLE
bool VP_REDUCE_RELAY_ENABLE
Definition: Config.h:258
ripple::Serializer
Definition: Serializer.h:40
ripple::Message
Definition: overlay/Message.h:53
ripple::randomKeyPair
std::pair< PublicKey, SecretKey > randomKeyPair(KeyType type)
Create a key pair using secure random numbers.
Definition: SecretKey.cpp:368
ripple::generateSeed
Seed generateSeed(std::string const &passPhrase)
Generate a seed deterministically.
Definition: Seed.cpp:69
ripple::test::compression_test::buildGetLedger
std::shared_ptr< protocol::TMGetLedger > buildGetLedger()
Definition: compression_test.cpp:237
ripple::STObject::add
void add(Serializer &s) const override
Definition: STObject.cpp:85
ripple::STObject
Definition: STObject.h:53
ripple::compression::decompress
std::size_t decompress(InputStream &in, std::size_t inSize, std::uint8_t *decompressed, std::size_t decompressedSize, Algorithm algorithm=Algorithm::LZ4)
Decompress input stream.
Definition: Compression.h:50
ripple::test::jtx
Definition: Check_test.cpp:26
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::test
Definition: LedgerDeltaAcquire.h:35
ripple::addRaw
void addRaw(LedgerHeader const &info, Serializer &s, bool includeHash)
Definition: protocol/impl/LedgerHeader.cpp:25
ripple::LedgerHeader::drops
XRPAmount drops
Definition: LedgerHeader.h:54
ripple::LedgerHeader::closeTimeResolution
NetClock::duration closeTimeResolution
Definition: LedgerHeader.h:66
ripple::Serializer::size
std::size_t size() const noexcept
Definition: Serializer.h:70
ripple::base_uint::begin
iterator begin()
Definition: base_uint.h:133
ripple::sign
Buffer sign(PublicKey const &pk, SecretKey const &sk, Slice const &m)
Generate a signature for a message.
Definition: SecretKey.cpp:238
std::vector::begin
T begin(T... args)
ripple::sha512Half
sha512_half_hasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.
Definition: digest.h:216
ripple::test::jtx::Env::fund
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
Definition: Env.cpp:228
ripple::sfSignature
const SF_VL sfSignature
ripple::test::jtx::fund
void fund(jtx::Env &env, jtx::Account const &gw, std::vector< jtx::Account > const &accounts, std::vector< STAmount > const &amts, Fund how)
Definition: AMMTest.cpp:35
ripple::Config::COMPRESSION
bool COMPRESSION
Definition: Config.h:230
std::chrono::duration::count
T count(T... args)
ripple::test::compression_test::buildManifests
std::shared_ptr< protocol::TMManifests > buildManifests(int n)
Definition: compression_test.cpp:146
ripple::test::jtx::pay
Json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
Definition: pay.cpp:29
ripple::test::makeWSClient
std::unique_ptr< WSClient > makeWSClient(Config const &cfg, bool v2, unsigned rpc_version, std::unordered_map< std::string, std::string > const &headers)
Returns a client operating through WebSockets/S.
Definition: WSClient.cpp:300
std::stringstream::str
T str(T... args)
ripple::test::jtx::Account
Immutable cryptographic account descriptor.
Definition: Account.h:37
ripple::strHex
std::string strHex(FwdIt begin, FwdIt end)
Definition: strHex.h:30
ripple::test::BEAST_DEFINE_TESTSUITE_MANUAL
BEAST_DEFINE_TESTSUITE_MANUAL(AMMCalc, app, ripple)
ripple::test::compression_test::testHandshake
void testHandshake()
Definition: compression_test.cpp:466
ripple::Serializer::getLength
int getLength() const
Definition: Serializer.h:200
ripple::sfDomain
const SF_VL sfDomain
ripple::makeRequest
auto makeRequest(bool crawlPublic, bool comprEnabled, bool ledgerReplayEnabled, bool txReduceRelayEnabled, bool vpReduceRelayEnabled) -> request_type
Make outbound http request.
Definition: Handshake.cpp:367
ripple::makeResponse
http_response_type makeResponse(bool crawlPublic, http_request_type const &req, beast::IP::Address public_ip, beast::IP::Address remote_ip, uint256 const &sharedValue, std::optional< std::uint32_t > networkID, ProtocolVersion protocol, Application &app)
Make http response.
Definition: Handshake.cpp:394
ripple::http_request_type
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
Definition: Handshake.h:47
ripple::strUnHex
std::optional< Blob > strUnHex(std::size_t strSize, Iterator begin, Iterator end)
Definition: StringUtilities.h:52
std::vector::data
T data(T... args)
ripple::sfPublicKey
const SF_VL sfPublicKey
ripple::detail::parseMessageHeader
std::optional< MessageHeader > parseMessageHeader(boost::system::error_code &ec, BufferSequence const &bufs, std::size_t size)
Parse a message header.
Definition: ProtocolMessage.h:177
ripple::test::jtx::Env
A transaction testing environment.
Definition: Env.h:117
Json::Value
Represents a JSON value.
Definition: json_value.h:145
ripple::XRPAmount
Definition: XRPAmount.h:46