Skip to content

Proposed 1.10.0-b1 #4265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Builds/CMake/RippledCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,6 @@ target_sources (rippled PRIVATE
src/ripple/rpc/handlers/AccountObjects.cpp
src/ripple/rpc/handlers/AccountOffers.cpp
src/ripple/rpc/handlers/AccountTx.cpp
src/ripple/rpc/handlers/AccountTxOld.cpp
src/ripple/rpc/handlers/BlackList.cpp
src/ripple/rpc/handlers/BookOffers.cpp
src/ripple/rpc/handlers/CanDelete.cpp
Expand Down Expand Up @@ -798,7 +797,6 @@ if (tests)
src/test/core/CryptoPRNG_test.cpp
src/test/core/JobQueue_test.cpp
src/test/core/SociDB_test.cpp
src/test/core/Workers_test.cpp
#[===============================[
test sources:
subdir: csf
Expand Down
1 change: 0 additions & 1 deletion Builds/levelization/results/ordering.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ test.core > ripple.basics
test.core > ripple.beast
test.core > ripple.core
test.core > ripple.crypto
test.core > ripple.json
test.core > ripple.server
test.core > test.jtx
test.core > test.toplevel
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ git-subtree. See those directories' README files for more details.

* [XRP Ledger Dev Portal](https://xrpl.org/)
* [Setup and Installation](https://xrpl.org/install-rippled.html)
* [Source Documentation (Doxygen)](https://ripple.github.io/rippled)
* [Source Documentation (Doxygen)](https://xrplf.github.io/rippled/)
* [Learn more about the XRP Ledger (YouTube)](https://www.youtube.com/playlist?list=PLJQ55Tj1hIVZtJ_JdTvSum2qMTsedWkNi)
19 changes: 8 additions & 11 deletions src/ripple/app/consensus/RCLConsensus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ RCLConsensus::Adaptor::Adaptor(
, inboundTransactions_{inboundTransactions}
, j_(journal)
, validatorKeys_(validatorKeys)
, valCookie_{rand_int<std::uint64_t>(
1,
std::numeric_limits<std::uint64_t>::max())}
, valCookie_(
1 +
rand_int(
crypto_prng(),
std::numeric_limits<std::uint64_t>::max() - 1))
, nUnlVote_(validatorKeys_.nodeID, j_)
{
assert(valCookie_ != 0);
Expand Down Expand Up @@ -211,15 +213,10 @@ RCLConsensus::Adaptor::propose(RCLCxPeerPos::Proposal const& proposal)
prop.set_nodepubkey(
validatorKeys_.publicKey.data(), validatorKeys_.publicKey.size());

auto signingHash = sha512Half(
HashPrefix::proposal,
std::uint32_t(proposal.proposeSeq()),
proposal.closeTime().time_since_epoch().count(),
proposal.prevLedger(),
proposal.position());

auto sig = signDigest(
validatorKeys_.publicKey, validatorKeys_.secretKey, signingHash);
validatorKeys_.publicKey,
validatorKeys_.secretKey,
proposal.signingHash());

prop.set_signature(sig.data(), sig.size());

Expand Down
38 changes: 10 additions & 28 deletions src/ripple/app/consensus/RCLCxPeerPos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,23 @@ RCLCxPeerPos::RCLCxPeerPos(
Slice const& signature,
uint256 const& suppression,
Proposal&& proposal)
: data_{std::make_shared<Data>(
publicKey,
signature,
suppression,
std::move(proposal))}
: publicKey_(publicKey)
, suppression_(suppression)
, proposal_(std::move(proposal))
{
}
// The maximum allowed size of a signature is 72 bytes; we verify
// this elsewhere, but we want to be extra careful here:
assert(signature.size() != 0 && signature.size() <= signature_.capacity());

uint256
RCLCxPeerPos::signingHash() const
{
return sha512Half(
HashPrefix::proposal,
std::uint32_t(proposal().proposeSeq()),
proposal().closeTime().time_since_epoch().count(),
proposal().prevLedger(),
proposal().position());
if (signature.size() != 0 && signature.size() <= signature_.capacity())
signature_.assign(signature.begin(), signature.end());
}

bool
RCLCxPeerPos::checkSign() const
{
return verifyDigest(publicKey(), signingHash(), signature(), false);
return verifyDigest(
publicKey(), proposal_.signingHash(), signature(), false);
}

Json::Value
Expand Down Expand Up @@ -88,16 +82,4 @@ proposalUniqueId(
return s.getSHA512Half();
}

RCLCxPeerPos::Data::Data(
PublicKey const& publicKey,
Slice const& signature,
uint256 const& suppress,
Proposal&& proposal)
: publicKey_{publicKey}
, signature_{signature}
, suppression_{suppress}
, proposal_{std::move(proposal)}
{
}

} // namespace ripple
32 changes: 9 additions & 23 deletions src/ripple/app/consensus/RCLCxPeerPos.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <ripple/protocol/HashPrefix.h>
#include <ripple/protocol/PublicKey.h>
#include <ripple/protocol/SecretKey.h>
#include <boost/container/static_vector.hpp>
#include <chrono>
#include <cstdint>
#include <string>
Expand Down Expand Up @@ -61,10 +62,6 @@ class RCLCxPeerPos
uint256 const& suppress,
Proposal&& proposal);

//! Create the signing hash for the proposal
uint256
signingHash() const;

//! Verify the signing hash of the proposal
bool
checkSign() const;
Expand All @@ -73,49 +70,38 @@ class RCLCxPeerPos
Slice
signature() const
{
return data_->signature_;
return {signature_.data(), signature_.size()};
}

//! Public key of peer that sent the proposal
PublicKey const&
publicKey() const
{
return data_->publicKey_;
return publicKey_;
}

//! Unique id used by hash router to suppress duplicates
uint256 const&
suppressionID() const
{
return data_->suppression_;
return suppression_;
}

Proposal const&
proposal() const
{
return data_->proposal_;
return proposal_;
}

//! JSON representation of proposal
Json::Value
getJson() const;

private:
struct Data : public CountedObject<Data>
{
PublicKey publicKey_;
Buffer signature_;
uint256 suppression_;
Proposal proposal_;

Data(
PublicKey const& publicKey,
Slice const& signature,
uint256 const& suppress,
Proposal&& proposal);
};

std::shared_ptr<Data> data_;
PublicKey publicKey_;
uint256 suppression_;
Proposal proposal_;
boost::container::static_vector<std::uint8_t, 72> signature_;

template <class Hasher>
void
Expand Down
4 changes: 1 addition & 3 deletions src/ripple/app/ledger/AcceptedLedger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ AcceptedLedger::AcceptedLedger(
transactions_.reserve(256);

auto insertAll = [&](auto const& txns) {
auto const& idcache = app.accountIDCache();

for (auto const& item : txns)
transactions_.emplace_back(std::make_unique<AcceptedLedgerTx>(
ledger, item.first, item.second, idcache));
ledger, item.first, item.second));
};

if (app.config().reporting())
Expand Down
5 changes: 2 additions & 3 deletions src/ripple/app/ledger/AcceptedLedgerTx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ namespace ripple {
AcceptedLedgerTx::AcceptedLedgerTx(
std::shared_ptr<ReadView const> const& ledger,
std::shared_ptr<STTx const> const& txn,
std::shared_ptr<STObject const> const& met,
AccountIDCache const& accountCache)
std::shared_ptr<STObject const> const& met)
: mTxn(txn)
, mMeta(txn->getTransactionID(), ledger->seq(), *met)
, mAffected(mMeta.getAffectedAccounts())
Expand All @@ -52,7 +51,7 @@ AcceptedLedgerTx::AcceptedLedgerTx(
{
Json::Value& affected = (mJson[jss::affected] = Json::arrayValue);
for (auto const& account : mAffected)
affected.append(accountCache.toBase58(account));
affected.append(toBase58(account));
}

if (mTxn->getTxnType() == ttOFFER_CREATE)
Expand Down
3 changes: 1 addition & 2 deletions src/ripple/app/ledger/AcceptedLedgerTx.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ class AcceptedLedgerTx : public CountedObject<AcceptedLedgerTx>
AcceptedLedgerTx(
std::shared_ptr<ReadView const> const& ledger,
std::shared_ptr<STTx const> const&,
std::shared_ptr<STObject const> const&,
AccountIDCache const&);
std::shared_ptr<STObject const> const&);

std::shared_ptr<STTx const> const&
getTxn() const
Expand Down
49 changes: 33 additions & 16 deletions src/ripple/app/main/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@
#include <ripple/basics/ByteUtilities.h>
#include <ripple/basics/PerfLog.h>
#include <ripple/basics/ResolverAsio.h>
#include <ripple/basics/random.h>
#include <ripple/basics/safe_cast.h>
#include <ripple/beast/asio/io_latency_probe.h>
#include <ripple/beast/core/LexicalCast.h>
#include <ripple/core/DatabaseCon.h>
#include <ripple/crypto/csprng.h>
#include <ripple/json/json_reader.h>
#include <ripple/nodestore/DatabaseShard.h>
#include <ripple/nodestore/DummyScheduler.h>
Expand Down Expand Up @@ -165,6 +167,8 @@ class ApplicationImp : public Application, public BasicApp
std::unique_ptr<Logs> logs_;
std::unique_ptr<TimeKeeper> timeKeeper_;

std::uint64_t const instanceCookie_;

beast::Journal m_journal;
std::unique_ptr<perf::PerfLog> perfLog_;
Application::MutexType m_masterMutex;
Expand All @@ -177,7 +181,6 @@ class ApplicationImp : public Application, public BasicApp
NodeStoreScheduler m_nodeStoreScheduler;
std::unique_ptr<SHAMapStore> m_shaMapStore;
PendingSaves pendingSaves_;
AccountIDCache accountIDCache_;
std::optional<OpenLedger> openLedger_;

NodeCache m_tempNodeCache;
Expand Down Expand Up @@ -274,6 +277,11 @@ class ApplicationImp : public Application, public BasicApp
, config_(std::move(config))
, logs_(std::move(logs))
, timeKeeper_(std::move(timeKeeper))
, instanceCookie_(
1 +
rand_int(
crypto_prng(),
std::numeric_limits<std::uint64_t>::max() - 1))
, m_journal(logs_->journal("Application"))

// PerfLog must be started before any other threads are launched.
Expand Down Expand Up @@ -327,8 +335,6 @@ class ApplicationImp : public Application, public BasicApp
m_nodeStoreScheduler,
logs_->journal("SHAMapStore")))

, accountIDCache_(128000)

, m_tempNodeCache(
"NodeCache",
16384,
Expand Down Expand Up @@ -485,6 +491,8 @@ class ApplicationImp : public Application, public BasicApp
config_->reporting() ? std::make_unique<ReportingETL>(*this)
: nullptr)
{
initAccountIdCache(config_->getValueFor(SizedItem::accountIdCacheSize));

add(m_resourceManager.get());

//
Expand All @@ -508,13 +516,13 @@ class ApplicationImp : public Application, public BasicApp
//--------------------------------------------------------------------------

bool
setup() override;
setup(boost::program_options::variables_map const& cmdline) override;
void
start(bool withTimers) override;
void
run() override;
void
signalStop() override;
signalStop(std::string msg = "") override;
bool
checkSigs() const override;
void
Expand All @@ -526,6 +534,12 @@ class ApplicationImp : public Application, public BasicApp

//--------------------------------------------------------------------------

std::uint64_t
instanceID() const override
{
return instanceCookie_;
}

Logs&
logs() override
{
Expand Down Expand Up @@ -841,12 +855,6 @@ class ApplicationImp : public Application, public BasicApp
return pendingSaves_;
}

AccountIDCache const&
accountIDCache() const override
{
return accountIDCache_;
}

OpenLedger&
openLedger() override
{
Expand Down Expand Up @@ -1108,7 +1116,7 @@ class ApplicationImp : public Application, public BasicApp

// TODO Break this up into smaller, more digestible initialization segments.
bool
ApplicationImp::setup()
ApplicationImp::setup(boost::program_options::variables_map const& cmdline)
{
// We want to intercept CTRL-C and the standard termination signal SIGTERM
// and terminate the process. This handler will NEVER be invoked twice.
Expand Down Expand Up @@ -1146,8 +1154,10 @@ ApplicationImp::setup()
if (logs_->threshold() > kDebug)
logs_->threshold(kDebug);
}
JLOG(m_journal.info()) << "process starting: "
<< BuildInfo::getFullVersionString();

JLOG(m_journal.info()) << "Process starting: "
<< BuildInfo::getFullVersionString()
<< ", Instance Cookie: " << instanceCookie_;

if (numberOfThreads(*config_) < 2)
{
Expand Down Expand Up @@ -1265,7 +1275,7 @@ ApplicationImp::setup()
if (!config().reporting())
m_orderBookDB.setup(getLedgerMaster().getCurrentLedger());

nodeIdentity_ = getNodeIdentity(*this);
nodeIdentity_ = getNodeIdentity(*this, cmdline);

if (!cluster_->load(config().section(SECTION_CLUSTER_NODES)))
{
Expand Down Expand Up @@ -1627,10 +1637,17 @@ ApplicationImp::run()
}

void
ApplicationImp::signalStop()
ApplicationImp::signalStop(std::string msg)
{
if (!isTimeToStop.exchange(true))
{
if (msg.empty())
JLOG(m_journal.warn()) << "Server stopping";
else
JLOG(m_journal.warn()) << "Server stopping: " << msg;

stoppingCondition_.notify_all();
}
}

bool
Expand Down
Loading