Skip to content

Commit 5b417bd

Browse files
legleuxgodexsoftcjcobb23officialfrancismendozacindyyan317
authored
1.0.4 Release Candidate 2 (#465)
* Implement logging abstraction (#371) Fixes #290 * Fix pre-commit to only check staged files * Implement account ownership check and fix paging (#383) Fixes #222 * Remove the github action package signing step This will be done elsewhere. * include searched_all in error response of tx (#407) * helper function for subscribe to ensure cleanup (#402) * Add closed to header for all paths of ledger_data (#416) Fixes #219 * Add custom error for malformed owner and request (#417) Fixes #274 * Use custom malformedAddress error in ledger_entry (#419) Fixes #272 * Return lgrIdxsInvalid error for ledger_max_index less than ledger_min_index (#339) Fixes #263 * Update headers to use #pragma once * Add custom error for malformed request (#414) Fixes #276 * Return srcCurMalformed on invalid taker_pays in book_offers (#413) Fixes #267 * Fix source_location issue on MacOSX and Debug build (#431) Fixes #428 * Implement always adding git ref to version string (#430) Fixes #427 * add connection counting (#433) * Fix malformed output format over ws rpc (#426) Fixes #405 * Remove branch name from version string (#437) Fixes a bug from #430 * Implement cli parsing using boost::po (#436) Fixes #367 * Update documentation and config with ssl_cert_file and ssl_key_file (#443) Fixes #424 * Fix gateway balances to match rippled output (#441) Fixes #271 * Update README and example config to describe start_sequence (#438) Fixes #250 * Add copyright to top of each source file (#444) Fixes #411 * Increase file descriptor limit (#449) * Update readme with more log configurations (#447) Fixes #446 * Document dos_guard in example config. Log when client surpasses rate limit (#451) * Add unit tests for DOSGuard (#453) Fixes #452 * Build macOS and Ubuntu 22.04 (#456) build release/x.y.z branches * Add time measurement profiler (#458) Rebase * Match format to rippled error code (#461) Fixes #263 * Change error message to match rippled (#463) Fixes #263 * Add requests limit to DosGuard (#462) Fixing #448 * Set version to 1.0.4-rc2 Co-authored-by: Alex Kremer <akremer@ripple.com> Co-authored-by: CJ Cobb <46455409+cjcobb23@users.noreply.github.com> Co-authored-by: Francis Mendoza <francissamuelmendoza7@gmail.com> Co-authored-by: cyan317 <120398799+cindyyan317@users.noreply.github.com>
1 parent ce631a1 commit 5b417bd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+4412
-1689
lines changed

.githooks/pre-commit

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
exec 1>&2
44

5-
# format all relevant sources
6-
find src unittests -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.ipp' \) -print0 | xargs -0 clang-format -i
5+
# paths to check and re-format
6+
sources="src unittests"
7+
formatter="clang-format -i"
78

8-
# check how many lines differ
9-
lines=$(git diff src unittests | wc -l)
9+
first=$(git diff $sources)
10+
find $sources -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.ipp' \) -print0 | xargs -0 $formatter
11+
second=$(git diff $sources)
12+
changes=$(diff <(echo "$first") <(echo "$second") | wc -l | sed -e 's/^[[:space:]]*//')
1013

11-
# check if there is any updated files
12-
if [ "$lines" != "0" ]; then
14+
if [ "$changes" != "0" ]; then
1315
cat <<\EOF
1416
1517
WARNING

.github/actions/sign/action.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 56 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: Build Clio
22
on:
33
push:
4-
branches: [master, release, develop, develop-next]
4+
branches: [master, release/*, develop, develop-next]
55
pull_request:
6-
branches: [master, release, develop, develop-next]
6+
branches: [master, release/*, develop, develop-next]
77
workflow_dispatch:
88

99
jobs:
@@ -29,6 +29,7 @@ jobs:
2929
- suffix: rpm
3030
image: rippleci/clio-rpm-builder:2022-09-17
3131
script: rpm
32+
3233
container:
3334
image: ${{ matrix.type.image }}
3435

@@ -67,59 +68,63 @@ jobs:
6768
name: clio_tests-${{ matrix.type.suffix }}
6869
path: ${{ github.workspace }}/clio_tests
6970

70-
sign:
71-
name: Sign packages
72-
needs: build_clio
73-
runs-on: ubuntu-20.04
74-
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/release' || github.ref == 'refs/heads/develop'
75-
env:
76-
GPG_KEY_B64: ${{ secrets.GPG_KEY_B64 }}
77-
GPG_KEY_PASS_B64: ${{ secrets.GPG_KEY_PASS_B64 }}
71+
build_dev:
72+
name: ${{ matrix.os.name }} test
73+
needs: lint
74+
continue-on-error: ${{ matrix.os.experimental }}
7875
strategy:
7976
fail-fast: false
8077
matrix:
81-
type:
82-
- suffix: deb
83-
image: ubuntu:20.04
84-
script: dpkg
85-
# - suffix: rpm
86-
# image: centos:7
87-
# script: rpm
88-
container:
89-
image: ${{ matrix.type.image }}
90-
steps:
91-
- uses: actions/checkout@v3
92-
- name: Install dpkg-sig
93-
run: |
94-
apt-get update && apt-get install -y dpkg-sig gnupg
95-
- name: Get package artifact
96-
uses: actions/download-artifact@v3
97-
with:
98-
name: clio_${{ matrix.type.suffix }}_packages
99-
100-
- name: find packages
101-
run: find . -name "*.${{ matrix.type.suffix }}"
102-
103-
- name: Sign packages
104-
uses: ./.github/actions/sign
105-
78+
os:
79+
- name: ubuntu-22.04
80+
experimental: true
81+
- name: macos-11
82+
experimental: true
83+
- name: macos-12
84+
experimental: false
85+
runs-on: ${{ matrix.os.name }}
10686

107-
- name: Verify the signature
108-
run: |
109-
set -e
110-
for PKG in $(ls *.deb); do
111-
gpg --verify "${PKG}"
112-
done
113-
114-
- name: Get short SHA
115-
id: shortsha
116-
run: echo "::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)"
117-
118-
- name: Artifact signed packages
119-
uses: actions/upload-artifact@v2
120-
with:
121-
name: signed-clio-deb-packages-${{ steps.shortsha.outputs.sha8 }}
122-
path: ${{ github.workspace }}/*.deb
87+
steps:
88+
- uses: actions/checkout@v3
89+
with:
90+
path: clio
91+
92+
- name: Check Boost cache
93+
id: boost
94+
uses: actions/cache@v3
95+
with:
96+
path: boost
97+
key: ${{ runner.os }}-boost
98+
99+
- name: Build boost
100+
if: steps.boost.outputs.cache-hit != 'true'
101+
run: |
102+
curl -s -OJL "https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/boost_1_77_0.tar.gz"
103+
tar zxf boost_1_77_0.tar.gz
104+
mv boost_1_77_0 boost
105+
cd boost
106+
./bootstrap.sh
107+
if [[ ${{ matrix.os.name }} =~ mac ]];then
108+
mac_flags='cxxflags="-std=c++14"'
109+
fi
110+
./b2 ${mac_flags}
111+
112+
- name: install deps
113+
run: |
114+
if [[ ${{ matrix.os.name }} =~ mac ]];then
115+
brew install pkg-config protobuf openssl ninja cassandra-cpp-driver bison
116+
elif [[ ${{matrix.os.name }} =~ ubuntu ]];then
117+
sudo apt-get -y install git pkg-config protobuf-compiler libprotobuf-dev libssl-dev wget build-essential doxygen bison flex autoconf clang-format
118+
fi
119+
120+
- name: Build clio
121+
run: |
122+
export BOOST_ROOT=$(pwd)/boost
123+
cd clio
124+
cmake -B build
125+
if ! cmake --build build -j$(nproc); then
126+
echo '# 🔥${{ matrix.os.name }}🔥 failed!💥' >> $GITHUB_STEP_SUMMARY
127+
fi
123128
124129
test_clio:
125130
name: Test Clio

CMake/deps/SourceLocation.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
include(CheckIncludeFileCXX)
2+
3+
check_include_file_cxx("source_location" SOURCE_LOCATION_AVAILABLE)
4+
if(SOURCE_LOCATION_AVAILABLE)
5+
target_compile_definitions(clio PUBLIC "HAS_SOURCE_LOCATION")
6+
endif()
7+
8+
check_include_file_cxx("experimental/source_location" EXPERIMENTAL_SOURCE_LOCATION_AVAILABLE)
9+
if(EXPERIMENTAL_SOURCE_LOCATION_AVAILABLE)
10+
target_compile_definitions(clio PUBLIC "HAS_EXPERIMENTAL_SOURCE_LOCATION")
11+
endif()

CMake/deps/gtest.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ if(NOT googletest_POPULATED)
1010
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL)
1111
endif()
1212

13-
target_link_libraries(clio_tests PUBLIC clio gtest_main)
13+
target_link_libraries(clio_tests PUBLIC clio gmock_main)
14+
target_include_directories(clio_tests PRIVATE unittests)
1415

1516
enable_testing()
1617

CMake/install/clio.service.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ ExecStart=@CLIO_INSTALL_DIR@/bin/clio_server @CLIO_INSTALL_DIR@/etc/config.json
1111
Restart=on-failure
1212
User=clio
1313
Group=clio
14+
LimitNOFILE=65536
1415

1516
[Install]
16-
WantedBy=multi-user.target
17+
WantedBy=multi-user.target

CMake/settings.cmake

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing -Wall -Werror -Wno-dangling-else")
1+
target_compile_options(clio
2+
PUBLIC -Wall
3+
-Werror
4+
-Wno-narrowing
5+
-Wno-deprecated-declarations
6+
-Wno-dangling-else)

CMakeLists.txt

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,18 @@ if(NOT GIT_COMMIT_HASH)
2121
find_package(Git)
2222
if(Git_FOUND)
2323
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
24-
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE gch)
25-
if(gch)
26-
set(GIT_COMMIT_HASH "${gch}")
27-
message(STATUS "Git commit: ${GIT_COMMIT_HASH}")
28-
add_definitions(-DCLIO_GIT_COMMIT_HASH="${GIT_COMMIT_HASH}")
24+
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE git-ref)
25+
if(git-ref)
26+
set(BUILD "${git-ref}")
27+
message(STATUS "Build version: ${BUILD}")
28+
add_definitions(-DCLIO_BUILD="${BUILD}")
2929
endif()
3030
endif()
3131
endif() #git
3232
if(PACKAGING)
3333
add_definitions(-DPKG=1)
3434
endif()
3535

36-
3736
add_library(clio)
3837
target_compile_features(clio PUBLIC cxx_std_20)
3938
target_include_directories(clio PUBLIC src)
@@ -45,6 +44,7 @@ include(CMake/ClioVersion.cmake)
4544
include(CMake/deps/rippled.cmake)
4645
include(CMake/deps/Boost.cmake)
4746
include(CMake/deps/cassandra.cmake)
47+
include(CMake/deps/SourceLocation.cmake)
4848

4949
target_sources(clio PRIVATE
5050
## Main
@@ -99,19 +99,23 @@ target_sources(clio PRIVATE
9999
src/rpc/handlers/Subscribe.cpp
100100
# Server
101101
src/rpc/handlers/ServerInfo.cpp
102-
# Utility
102+
# Utilities
103103
src/rpc/handlers/Random.cpp
104-
src/util/Taggable.cpp
105-
src/config/Config.cpp)
104+
src/config/Config.cpp
105+
src/log/Logger.cpp
106+
src/util/Taggable.cpp)
106107

107108
add_executable(clio_server src/main/main.cpp)
108109
target_link_libraries(clio_server PUBLIC clio)
109110

110111
if(BUILD_TESTS)
111112
add_executable(clio_tests
112-
unittests/RPCErrors.cpp
113-
unittests/config.cpp
114-
unittests/main.cpp)
113+
unittests/RPCErrors.cpp
114+
unittests/Backend.cpp
115+
unittests/Logger.cpp
116+
unittests/Config.cpp
117+
unittests/ProfilerTest.cpp
118+
unittests/DOSGuard.cpp)
115119
include(CMake/deps/gtest.cmake)
116120
endif()
117121

README.md

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ from which data can be extracted. The rippled node does not need to be running o
2222

2323
## Building
2424

25-
Clio is built with CMake. Clio requires at least GCC-11 (C++20), and Boost 1.75.0 or later.
25+
Clio is built with CMake. Clio requires at least GCC-11/clang-14.0.0 (C++20), and Boost 1.75.0.
2626

2727
Use these instructions to build a Clio executable from the source. These instructions were tested on Ubuntu 20.04 LTS.
2828

@@ -72,6 +72,36 @@ server is running
7272
to the IP of your Clio server. This entry can take the form of a comma-separated list if
7373
you are running multiple Clio nodes.
7474

75+
76+
In addition, the parameter `start_sequence` can be included and configured within the top level of the config file. This parameter specifies the sequence of first ledger to extract if the database is empty. Note that ETL extracts ledgers in order and that no backfilling functionality currently exists, meaning Clio will not retroactively learn ledgers older than the one you specify. Choosing to specify this or not will yield the following behavior:
77+
- If this setting is absent and the database is empty, ETL will start with the next ledger validated by the network.
78+
- If this setting is present and the database is not empty, an exception is thrown.
79+
80+
In addition, the optional parameter `finish_sequence` can be added to the json file as well, specifying where the ledger can stop.
81+
82+
To add `start_sequence` and/or `finish_sequence` to the config.json file appropriately, they will be on the same top level of precedence as other parameters (such as `database`, `etl_sources`, `read_only`, etc.) and be specified with an integer. Here is an example snippet from the config file:
83+
84+
```json
85+
"start_sequence": 12345,
86+
"finish_sequence": 54321
87+
```
88+
89+
The parameters `ssl_cert_file` and `ssl_key_file` can also be added to the top level of precedence of our Clio config. `ssl_cert_file` specifies the filepath for your SSL cert while `ssl_key_file` specifies the filepath for your SSL key. It is up to you how to change ownership of these folders for your designated Clio user. Your options include:
90+
- Copying the two files as root somewhere that's accessible by the Clio user, then running `sudo chown` to your user
91+
- Changing the permissions directly so it's readable by your Clio user
92+
- Running Clio as root (strongly discouraged)
93+
94+
An example of how to specify `ssl_cert_file` and `ssl_key_file` in the config:
95+
96+
```json
97+
"server":{
98+
"ip": "0.0.0.0",
99+
"port": 51233
100+
},
101+
"ssl_cert_file" : "/full/path/to/cert.file",
102+
"ssl_key_file" : "/full/path/to/key.file"
103+
```
104+
75105
Once your config files are ready, start rippled and Clio. It doesn't matter which you
76106
start first, and it's fine to stop one or the other and restart at any given time.
77107

@@ -152,9 +182,33 @@ You must:
152182
## Logging
153183
Clio provides several logging options, all are configurable via the config file and are detailed below.
154184

155-
`log_level`: The minimum level of severity at which the log message will be outputted.
185+
`log_level`: The minimum level of severity at which the log message will be outputted by default.
156186
Severity options are `trace`, `debug`, `info`, `warning`, `error`, `fatal`. Defaults to `info`.
157187

188+
`log_format`: The format of log lines produced by clio. Defaults to `"%TimeStamp% (%SourceLocation%) [%ThreadID%] %Channel%:%Severity% %Message%"`.
189+
Each of the variables expands like so
190+
- `TimeStamp`: The full date and time of the log entry
191+
- `SourceLocation`: A partial path to the c++ file and the line number in said file (`source/file/path:linenumber`)
192+
- `ThreadID`: The ID of the thread the log entry is written from
193+
- `Channel`: The channel that this log entry was sent to
194+
- `Severity`: The severity (aka log level) the entry was sent at
195+
- `Message`: The actual log message
196+
197+
`log_channels`: An array of json objects, each overriding properties for a logging `channel`.
198+
At the moment of writing, only `log_level` can be overriden using this mechanism.
199+
200+
Each object is of this format:
201+
```json
202+
{
203+
"channel": "Backend",
204+
"log_level": "fatal"
205+
}
206+
```
207+
If no override is present for a given channel, that channel will log at the severity specified by the global `log_level`.
208+
Overridable log channels: `Backend`, `WebServer`, `Subscriptions`, `RPC`, `ETL` and `Performance`.
209+
210+
> **Note:** See `example-config.json` for more details.
211+
158212
`log_to_console`: Enable/disable log output to console. Options are `true`/`false`. Defaults to true.
159213

160214
`log_directory`: Path to the directory where log files are stored. If such directory doesn't exist, Clio will create it. If not specified, logs are not written to a file.
@@ -170,6 +224,11 @@ rotate the current log file. Defaults to 12 hours.
170224
Note, time-based log rotation occurs dependently on size-based log rotation, where if a
171225
size-based log rotation occurs, the timer for the time-based rotation will reset.
172226

227+
`log_tag_style`: Tag implementation to use. Must be one of:
228+
- `uint`: Lock free and threadsafe but outputs just a simple unsigned integer
229+
- `uuid`: Threadsafe and outputs a UUID tag
230+
- `none`: Don't use tagging at all
231+
173232
## Cassandra / Scylla Administration
174233

175234
Since Clio relies on either Cassandra or Scylla for its database backend, here are some important considerations:

0 commit comments

Comments
 (0)