Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into ximinez/fix/vali…
Browse files Browse the repository at this point in the history
…dator-cache

* upstream/develop:
  chore: Move "assert" and "werr" flags from "actions/build" (5325)
  Log detailed correlated consensus data together (5302)
  • Loading branch information
ximinez committed Feb 28, 2025
2 parents e1f8395 + c1c2b5b commit d78aacb
Show file tree
Hide file tree
Showing 24 changed files with 552 additions and 140 deletions.
2 changes: 0 additions & 2 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ runs:
${{ inputs.generator && format('-G "{0}"', inputs.generator) || '' }} \
-DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake \
-DCMAKE_BUILD_TYPE=${{ inputs.configuration }} \
-Dassert=TRUE \
-Dwerr=TRUE \
-Dtests=TRUE \
-Dxrpld=TRUE \
${{ inputs.cmake-args }} \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
with:
generator: ${{ matrix.generator }}
configuration: ${{ matrix.configuration }}
cmake-args: ${{ matrix.cmake-args }}
cmake-args: "-Dassert=TRUE -Dwerr=TRUE ${{ matrix.cmake-args }}"
- name: test
run: |
n=$(nproc)
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ jobs:
with:
generator: Ninja
configuration: ${{ matrix.configuration }}
cmake-args: ${{ matrix.cmake-args }}
cmake-args: "-Dassert=TRUE -Dwerr=TRUE ${{ matrix.cmake-args }}"
- name: test
run: |
${build_dir}/rippled --unittest --unittest-jobs $(nproc)
Expand Down Expand Up @@ -214,6 +214,8 @@ jobs:
generator: Ninja
configuration: ${{ matrix.configuration }}
cmake-args: >-
-Dassert=TRUE
-Dwerr=TRUE
-Dcoverage=ON
-Dcoverage_format=xml
-DCODE_COVERAGE_VERBOSE=ON
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
generator: '${{ matrix.version.generator }}'
configuration: ${{ matrix.configuration.type }}
# Hard code for now. Move to the matrix if varied options are needed
cmake-args: '-Dassert=ON -Dreporting=OFF -Dunity=ON'
cmake-args: '-Dassert=TRUE -Dwerr=TRUE -Dreporting=OFF -Dunity=ON'
cmake-target: install
- name: test
shell: bash
Expand Down
12 changes: 12 additions & 0 deletions include/xrpl/basics/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ class Logs
void
write(beast::severities::Severity level, std::string const& text)
override;

void
writeAlways(beast::severities::Severity level, std::string const& text)
override;
};

/** Manages a system file containing logged output.
Expand Down Expand Up @@ -256,6 +260,14 @@ class Logs
x
#endif

#ifndef CLOG
#define CLOG(ss) \
if (!ss) \
; \
else \
*ss
#endif

//------------------------------------------------------------------------------
// Debug logging:

Expand Down
10 changes: 10 additions & 0 deletions include/xrpl/beast/utility/Journal.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ class Journal
virtual void
write(Severity level, std::string const& text) = 0;

/** Bypass filter and write text to the sink at the specified severity.
* Always write the message, but maintain the same formatting as if
* it passed through a level filter.
*
* @param level Level to display in message.
* @param text Text to write to sink.
*/
virtual void
writeAlways(Severity level, std::string const& text) = 0;

private:
Severity thresh_;
bool m_console;
Expand Down
7 changes: 7 additions & 0 deletions include/xrpl/beast/utility/WrappedSink.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ class WrappedSink : public beast::Journal::Sink
using beast::Journal;
sink_.write(level, prefix_ + text);
}

void
writeAlways(severities::Severity level, std::string const& text) override
{
using beast::Journal;
sink_.writeAlways(level, prefix_ + text);
}
};

} // namespace beast
Expand Down
8 changes: 8 additions & 0 deletions src/libxrpl/basics/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ Logs::Sink::write(beast::severities::Severity level, std::string const& text)
logs_.write(level, partition_, text, console());
}

void
Logs::Sink::writeAlways(
beast::severities::Severity level,
std::string const& text)
{
logs_.write(level, partition_, text, console());
}

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

Logs::File::File() : m_stream(nullptr)
Expand Down
5 changes: 5 additions & 0 deletions src/libxrpl/beast/utility/src/beast_Journal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ class NullJournalSink : public Journal::Sink
write(severities::Severity, std::string const&) override
{
}

void
writeAlways(severities::Severity, std::string const&) override
{
}
};

//------------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions src/test/beast/beast_Journal_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ class Journal_test : public unit_test::suite
if (level >= threshold())
++m_count;
}

void
writeAlways(severities::Severity level, std::string const&) override
{
++m_count;
}
};

void
Expand Down
19 changes: 16 additions & 3 deletions src/test/csf/Peer.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ struct Peer
}
};

class TestConsensusLogger
{
};

/** Generic Validations adaptor that simply ignores recently stale
* validations
*/
Expand Down Expand Up @@ -532,7 +536,8 @@ struct Peer
closeResolution,
rawCloseTimes,
mode,
std::move(consensusJson));
std::move(consensusJson),
validating());
}

void
Expand All @@ -542,7 +547,8 @@ struct Peer
NetClock::duration const& closeResolution,
ConsensusCloseTimes const& rawCloseTimes,
ConsensusMode const& mode,
Json::Value&& consensusJson)
Json::Value&& consensusJson,
const bool validating)
{
schedule(delays.ledgerAccept, [=, this]() {
const bool proposing = mode == ConsensusMode::proposing;
Expand Down Expand Up @@ -877,6 +883,13 @@ struct Peer
{
}

bool
validating() const
{
// does not matter
return false;
}

//--------------------------------------------------------------------------
// A locally submitted transaction
void
Expand Down Expand Up @@ -917,7 +930,7 @@ struct Peer
// Not yet modeling dynamic UNL.
hash_set<PeerID> nowUntrusted;
consensus.startRound(
now(), bestLCL, lastClosedLedger, nowUntrusted, runAsValidator);
now(), bestLCL, lastClosedLedger, nowUntrusted, runAsValidator, {});
}

// Start the consensus process assuming it is not yet running
Expand Down
8 changes: 8 additions & 0 deletions src/test/csf/Sim.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ class BasicSink : public beast::Journal::Sink
std::cout << clock_.now().time_since_epoch().count() << " " << text
<< std::endl;
}

void
writeAlways(beast::severities::Severity level, std::string const& text)
override
{
std::cout << clock_.now().time_since_epoch().count() << " " << text
<< std::endl;
}
};

class Sim
Expand Down
8 changes: 8 additions & 0 deletions src/test/jtx/CaptureLogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ class CaptureLogs : public Logs
std::lock_guard lock(strmMutex_);
strm_ << text;
}

void
writeAlways(beast::severities::Severity level, std::string const& text)
override
{
std::lock_guard lock(strmMutex_);
strm_ << text;
}
};

public:
Expand Down
7 changes: 7 additions & 0 deletions src/test/jtx/CheckMessageLogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ class CheckMessageLogs : public Logs
if (text.find(owner_.msg_) != std::string::npos)
*owner_.pFound_ = true;
}

void
writeAlways(beast::severities::Severity level, std::string const& text)
override
{
write(level, text);
}
};

public:
Expand Down
4 changes: 2 additions & 2 deletions src/test/server/ServerStatus_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ class ServerStatus_test : public beast::unit_test::suite,

// mark the Network as having an Amendment Warning, but won't fail
env.app().getOPs().setAmendmentWarned();
env.app().getOPs().beginConsensus(env.closed()->info().hash);
env.app().getOPs().beginConsensus(env.closed()->info().hash, {});

// consensus doesn't change
BEAST_EXPECT(
Expand Down Expand Up @@ -991,7 +991,7 @@ class ServerStatus_test : public beast::unit_test::suite,
// mark the Network as Amendment Blocked, but still won't fail until
// ELB is enabled (next step)
env.app().getOPs().setAmendmentBlocked();
env.app().getOPs().beginConsensus(env.closed()->info().hash);
env.app().getOPs().beginConsensus(env.closed()->info().hash, {});

// consensus now sees validation disabled
BEAST_EXPECT(
Expand Down
7 changes: 7 additions & 0 deletions src/test/server/Server_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ class Server_test : public beast::unit_test::suite

suite_.log << text << std::endl;
}

void
writeAlways(beast::severities::Severity level, std::string const& text)
override
{
suite_.log << text << std::endl;
}
};

//--------------------------------------------------------------------------
Expand Down
25 changes: 22 additions & 3 deletions src/test/unit_test/SuiteJournal.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,26 @@ class SuiteJournalSink : public beast::Journal::Sink

void
write(beast::severities::Severity level, std::string const& text) override;

void
writeAlways(beast::severities::Severity level, std::string const& text)
override;
};

inline void
SuiteJournalSink::write(
beast::severities::Severity level,
std::string const& text)
{
// Only write the string if the level at least equals the threshold.
if (level >= threshold())
writeAlways(level, text);
}

inline void
SuiteJournalSink::writeAlways(
beast::severities::Severity level,
std::string const& text)
{
using namespace beast::severities;

Expand All @@ -80,9 +94,7 @@ SuiteJournalSink::write(
return "FTL:";
}();

// Only write the string if the level at least equals the threshold.
if (level >= threshold())
suite_.log << s << partition_ << text << std::endl;
suite_.log << s << partition_ << text << std::endl;
}

class SuiteJournal
Expand Down Expand Up @@ -127,9 +139,16 @@ class StreamSink : public beast::Journal::Sink
{
if (level < threshold())
return;
writeAlways(level, text);
}

inline void
writeAlways(beast::severities::Severity level, std::string const& text)
override
{
strm_ << text << std::endl;
}

std::stringstream const&
messages() const
{
Expand Down
Loading

0 comments on commit d78aacb

Please sign in to comment.