Skip to content
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

Proposed 1.6.0-b7 #3422

Closed
wants to merge 9 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
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,8 @@ cache:
- $CACHE_DIR

before_install:
- if [ "$(uname)" = "Darwin" ] ; then export NUM_PROCESSORS=$(sysctl -n hw.physicalcpu); else export NUM_PROCESSORS=$(nproc); fi
# NUM_PROCESSORS was set to 1 due to problems in parallel launch of unit tests on Mac platform
- if [ "$(uname)" = "Darwin" ] ; then export NUM_PROCESSORS=1; else export NUM_PROCESSORS=$(nproc); fi
- echo "NUM PROC is ${NUM_PROCESSORS}"
- if [ "$(uname)" = "Linux" ] ; then docker pull ${DOCKER_IMAGE}; fi
- if [ "${MATRIX_EVAL}" != "" ] ; then eval "${MATRIX_EVAL}"; fi
Expand Down
1 change: 1 addition & 0 deletions Builds/CMake/RippledCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,7 @@ target_sources (rippled PRIVATE
#]===============================]
src/test/nodestore/Backend_test.cpp
src/test/nodestore/Basics_test.cpp
src/test/nodestore/DatabaseShard_test.cpp
src/test/nodestore/Database_test.cpp
src/test/nodestore/Timing_test.cpp
src/test/nodestore/import_test.cpp
Expand Down
2 changes: 1 addition & 1 deletion Builds/CMake/deps/Findlibarchive_pc.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
find_package (PkgConfig REQUIRED)
pkg_search_module (libarchive_PC QUIET libarchive>=3.3.3)
pkg_search_module (libarchive_PC QUIET libarchive>=3.4.3)

if(static)
set(LIBARCHIVE_LIB libarchive.a)
Expand Down
2 changes: 1 addition & 1 deletion Builds/CMake/deps/Findlz4.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
find_package (PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_search_module (lz4_PC QUIET liblz4>=1.8)
pkg_search_module (lz4_PC QUIET liblz4>=1.9)
endif ()

if(static)
Expand Down
4 changes: 2 additions & 2 deletions Builds/CMake/deps/Libarchive.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if (NOT local_libarchive)
endif ()
else ()
## now try searching using the minimal find module that cmake provides
find_package(LibArchive 3.3.3 QUIET)
find_package(LibArchive 3.4.3 QUIET)
if (LibArchive_FOUND)
if (static)
# find module doesn't find static libs currently, so we re-search
Expand Down Expand Up @@ -70,7 +70,7 @@ if (local_libarchive)
ExternalProject_Add (libarchive
PREFIX ${nih_cache_path}
GIT_REPOSITORY https://github.com/libarchive/libarchive.git
GIT_TAG v3.3.3
GIT_TAG v3.4.3
CMAKE_ARGS
# passing the compiler seems to be needed for windows CI, sadly
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
Expand Down
2 changes: 1 addition & 1 deletion Builds/CMake/deps/Lz4.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ else()
ExternalProject_Add (lz4
PREFIX ${nih_cache_path}
GIT_REPOSITORY https://github.com/lz4/lz4.git
GIT_TAG v1.8.2
GIT_TAG v1.9.2
SOURCE_SUBDIR contrib/cmake_unofficial
CMAKE_ARGS
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
Expand Down
2 changes: 1 addition & 1 deletion Builds/containers/gitlab-ci/pkgbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ tag_bld_images:
variables:
docker_driver: overlay2
image:
name: docker:latest
name: docker:19.03.8
services:
# workaround for TLS issues - consider going back
# back to unversioned `dind` when issues are resolved
Expand Down
16 changes: 9 additions & 7 deletions src/ripple/nodestore/impl/DatabaseShardImp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,12 @@ DatabaseShardImp::init()
std::make_unique<Shard>(app_, *this, shardIndex, j_)};
if (!shard->open(scheduler_, *ctx_))
{
if (!shard->isLegacy())
return false;

// Remove legacy shard
// Remove corrupted or legacy shard
shard->removeOnDestroy();
JLOG(j_.warn())
<< "shard " << shardIndex << " removed, legacy shard";
<< "shard " << shardIndex << " removed, "
<< (shard->isLegacy() ? "legacy" : "corrupted")
<< " shard";
continue;
}

Expand Down Expand Up @@ -276,11 +275,11 @@ DatabaseShardImp::prepareShard(std::uint32_t shardIndex)
// is greater or equal to the current shard.
auto seqCheck = [&](std::uint32_t seq) {
// seq will be greater than zero if valid
if (seq > earliestLedgerSeq() && shardIndex >= seqToShardIndex(seq))
if (seq >= earliestLedgerSeq() && shardIndex >= seqToShardIndex(seq))
return fail("has an invalid index");
return true;
};
if (!seqCheck(app_.getLedgerMaster().getValidLedgerIndex()) ||
if (!seqCheck(app_.getLedgerMaster().getValidLedgerIndex() + 1) ||
!seqCheck(app_.getLedgerMaster().getCurrentLedgerIndex()))
{
return false;
Expand Down Expand Up @@ -1100,6 +1099,9 @@ DatabaseShardImp::initConfig(std::lock_guard<std::mutex>&)
ledgersPerShard_ = get<std::uint32_t>(section, "ledgers_per_shard");
if (ledgersPerShard_ == 0 || ledgersPerShard_ % 256 != 0)
return fail("'ledgers_per_shard' must be a multiple of 256");

earliestShardIndex_ = seqToShardIndex(earliestLedgerSeq());
avgShardFileSz_ = ledgersPerShard_ * kilobytes(192);
}

// NuDB is the default and only supported permanent storage backend
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/nodestore/impl/DatabaseShardImp.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class DatabaseShardImp : public DatabaseShard
std::uint32_t ledgersPerShard_ = ledgersPerShardDefault;

// The earliest shard index
std::uint32_t const earliestShardIndex_;
std::uint32_t earliestShardIndex_;

// Average storage space required by a shard (in bytes)
std::uint64_t avgShardFileSz_;
Expand Down
9 changes: 4 additions & 5 deletions src/ripple/nodestore/impl/codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,12 @@ lz4_decompress(void const* in, std::size_t in_size, BufferFactory&& bf)
Throw<std::runtime_error>("lz4 decompress: n == 0");
void* const out = bf(result.second);
result.first = out;
if (LZ4_decompress_fast(
if (LZ4_decompress_safe(
reinterpret_cast<char const*>(in) + n,
reinterpret_cast<char*>(out),
result.second) +
n !=
in_size)
Throw<std::runtime_error>("lz4 decompress: LZ4_decompress_fast");
in_size - n,
result.second) != result.second)
Throw<std::runtime_error>("lz4 decompress: LZ4_decompress_safe");
return result;
}

Expand Down
115 changes: 104 additions & 11 deletions src/ripple/overlay/impl/OverlayImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,14 +554,9 @@ OverlayImpl::onPrepare()
for (auto const& addr : addresses)
{
if (addr.port() == 0)
{
Throw<std::runtime_error>(
"Port not specified for "
"address:" +
addr.to_string());
}

ips.push_back(to_string(addr));
ips.push_back(to_string(addr.at_port(DEFAULT_PEER_PORT)));
else
ips.push_back(to_string(addr));
}

std::string const base("config: ");
Expand All @@ -577,8 +572,19 @@ OverlayImpl::onPrepare()
[this](
std::string const& name,
std::vector<beast::IP::Endpoint> const& addresses) {
if (!addresses.empty())
m_peerFinder->addFixedPeer(name, addresses);
std::vector<beast::IP::Endpoint> ips;
ips.reserve(addresses.size());

for (auto& addr : addresses)
{
if (addr.port() == 0)
ips.emplace_back(addr.address(), DEFAULT_PEER_PORT);
else
ips.emplace_back(addr);
}

if (!ips.empty())
m_peerFinder->addFixedPeer(name, ips);
});
}
}
Expand Down Expand Up @@ -1075,11 +1081,98 @@ OverlayImpl::processValidatorList(
return true;
}

bool
OverlayImpl::processHealth(http_request_type const& req, Handoff& handoff)
{
if (req.target() != "/health")
return false;
boost::beast::http::response<json_body> msg;
msg.version(req.version());
msg.insert("Server", BuildInfo::getFullVersionString());
msg.insert("Content-Type", "application/json");
msg.insert("Connection", "close");

auto info = getServerInfo();

int last_validated_ledger_age = std::numeric_limits<int>::max();
if (info.isMember("validated_ledger"))
last_validated_ledger_age = info["validated_ledger"]["age"].asInt();
bool amendment_blocked = false;
if (info.isMember("amendment_blocked"))
amendment_blocked = true;
int number_peers = info["peers"].asInt();
std::string server_state = info["server_state"].asString();
auto load_factor = info["load_factor"].asDouble();

enum { healthy, warning, critical };
int health = healthy;
auto set_health = [&health](int state) {
if (health < state)
health = state;
};

if (last_validated_ledger_age >= 7)
{
msg.body()[jss::info]["validated_ledger"] = last_validated_ledger_age;
if (last_validated_ledger_age < 20)
set_health(warning);
else
set_health(critical);
}

if (amendment_blocked)
{
msg.body()[jss::info]["amendment_blocked"] = true;
set_health(critical);
}

if (number_peers <= 7)
{
msg.body()[jss::info]["peers"] = number_peers;
if (number_peers != 0)
set_health(warning);
else
set_health(critical);
}

if (!(server_state == "full" || server_state == "validating" ||
server_state == "proposing"))
{
msg.body()[jss::info]["server_state"] = server_state;
if (server_state == "syncing" || server_state == "tracking" ||
server_state == "connected")
{
set_health(warning);
}
else
set_health(critical);
}

if (load_factor > 100)
{
msg.body()[jss::info]["load_factor"] = load_factor;
if (load_factor < 1000)
set_health(warning);
else
set_health(critical);
}

if (health != critical)
msg.result(boost::beast::http::status::ok);
else
msg.result(boost::beast::http::status::service_unavailable);

msg.prepare_payload();
handoff.response = std::make_shared<SimpleWriter>(msg);
return true;
}

bool
OverlayImpl::processRequest(http_request_type const& req, Handoff& handoff)
{
// Take advantage of || short-circuiting
return processCrawl(req, handoff) || processValidatorList(req, handoff);
return processCrawl(req, handoff) || processValidatorList(req, handoff) ||
processHealth(req, handoff);
}

Overlay::PeerSequence
Expand Down
8 changes: 8 additions & 0 deletions src/ripple/overlay/impl/OverlayImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,14 @@ class OverlayImpl : public Overlay
bool
processValidatorList(http_request_type const& req, Handoff& handoff);

/** Handles health requests. Health returns information about the
health of the node.

@return true if the request was handled.
*/
bool
processHealth(http_request_type const& req, Handoff& handoff);

/** Handles non-peer protocol requests.

@return true if the request was handled.
Expand Down
3 changes: 3 additions & 0 deletions src/ripple/protocol/SystemParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,7 @@ static std::uint32_t constexpr XRP_LEDGER_EARLIEST_SEQ{32570};

} // namespace ripple

/** Default peer port (IANA registered) */
inline std::uint16_t constexpr DEFAULT_PEER_PORT{2459};

#endif
2 changes: 1 addition & 1 deletion src/ripple/protocol/impl/BuildInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace BuildInfo {
// and follow the format described at http://semver.org/
//------------------------------------------------------------------------------
// clang-format off
char const* const versionString = "1.6.0-b6"
char const* const versionString = "1.6.0-b7"
// clang-format on

#if defined(DEBUG) || defined(SANITIZER)
Expand Down
3 changes: 2 additions & 1 deletion src/ripple/rpc/handlers/Connect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <ripple/net/RPCErr.h>
#include <ripple/overlay/Overlay.h>
#include <ripple/protocol/ErrorCodes.h>
#include <ripple/protocol/SystemParameters.h>
#include <ripple/protocol/jss.h>
#include <ripple/rpc/Context.h>
#include <ripple/rpc/impl/Handler.h>
Expand Down Expand Up @@ -53,7 +54,7 @@ doConnect(RPC::JsonContext& context)
if (context.params.isMember(jss::port))
iPort = context.params[jss::port].asInt();
else
iPort = 6561;
iPort = DEFAULT_PEER_PORT;

auto ip =
beast::IP::Endpoint::from_string(context.params[jss::ip].asString());
Expand Down
4 changes: 1 addition & 3 deletions src/test/app/AccountTxPaging_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1871,9 +1871,7 @@ class AccountTxPaging_test : public beast::unit_test::suite
if (!BEAST_EXPECT(status.error_code() == 0))
return;

if (!BEAST_EXPECT(
res.transactions().size() ==
std::extent<decltype(txCheck)>::value))
if (!BEAST_EXPECT(res.transactions().size() == std::size(txCheck)))
return;
for (int i = 0; i < res.transactions().size(); ++i)
{
Expand Down
7 changes: 2 additions & 5 deletions src/test/core/SociDB_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,8 @@ class SociDB_test final : public TestSuite
LedgerSeq BIGINT UNSIGNED \
);",
"CREATE INDEX SeqLedger ON Ledgers(LedgerSeq);"};
int dbInitCount = std::extent<decltype(dbInit)>::value;
for (int i = 0; i < dbInitCount; ++i)
{
s << dbInit[i];
}
for (auto const c : dbInit)
s << c;
char lh[65];
memset(lh, 'a', 64);
lh[64] = '\0';
Expand Down
16 changes: 11 additions & 5 deletions src/test/jtx/Env.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,10 @@ class Env

The Application network time is set to
the close time of the resulting ledger.

@return true if no error, false if error
*/
void
bool
close(
NetClock::time_point closeTime,
boost::optional<std::chrono::milliseconds> consensusDelay =
Expand All @@ -336,25 +338,29 @@ class Env

The time is calculated as the duration from
the previous ledger closing time.

@return true if no error, false if error
*/
template <class Rep, class Period>
void
bool
close(std::chrono::duration<Rep, Period> const& elapsed)
{
// VFALCO Is this the correct time?
close(now() + elapsed);
return close(now() + elapsed);
}

/** Close and advance the ledger.

The time is calculated as five seconds from
the previous ledger closing time.

@return true if no error, false if error
*/
void
bool
close()
{
// VFALCO Is this the correct time?
close(std::chrono::seconds(5));
return close(std::chrono::seconds(5));
}

/** Turn on JSON tracing.
Expand Down
Loading