Skip to content

Commit ad34d88

Browse files
authored
JAM node skeleton (#19)
* draft Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * draft Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * draft Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * draft Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * feature: watchdog Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * draft Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * feature: metrics Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * feature: git-hooks Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * draft Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * draft Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * feature: extend format config Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * draft Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * format config Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * x Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * draft Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * refactor: simplifying ConfigVec Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * fix: mutual dependency of generated files Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * draft Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * aggregate Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * draft Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * refactor: no generate *-scale.hpp Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * refactor: no generate *-scale.hpp [2] Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * scale::en|decode Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * no conf types scale Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * x Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * x Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * fix: libs deduplicate Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * refactor: use new qtils Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * refactor: move crypto to jam source Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * refactor: move generated files to artifacts directory Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * refactor: move scripts and add docs Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * fix: pythot setup Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * fix: get_version Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * fix: get_version Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * fix: get_version Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * refactor: compile PIC Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * update: qtils Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * update: qtils Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * update: qtils Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * fix: asn1 code-generating Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * fix: ambiguous diff function Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * update: scale Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * update: scale Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * update: scale & qtils Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> * fix: review issues Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]> --------- Signed-off-by: Dmitriy Khaustov aka xDimon <[email protected]>
1 parent 7c57b37 commit ad34d88

File tree

112 files changed

+5571
-691
lines changed

Some content is hidden

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

112 files changed

+5571
-691
lines changed

.ci/scripts/init_py.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ init_py() {
77
python3 -m venv "$VENV"
88
source $VENV/bin/activate
99
pip3 install cmake==${CMAKE_VERSION}
10-
pip3 install --no-cache-dir -r ${PROJECT}/python/requirements.txt
10+
pip3 install --no-cache-dir asn1tools
1111
}
1212

1313
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then

.clang-format

+68-10
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,88 @@
44
# SPDX-License-Identifier: Apache-2.0
55
#
66

7+
Language: Cpp
78
BasedOnStyle: Google
8-
9+
AccessModifierOffset: -1
910
AlignAfterOpenBracket: Align
11+
AlignConsecutiveAssignments: false
12+
AlignConsecutiveDeclarations: false
1013
AlignOperands: AlignAfterOperator
14+
AlignTrailingComments: true
1115
AllowShortFunctionsOnASingleLine: Empty
1216
BinPackArguments: false
1317
BinPackParameters: false
18+
BraceWrapping:
19+
AfterCaseLabel: false
20+
AfterClass: false
21+
AfterControlStatement: false
22+
AfterEnum: false
23+
AfterFunction: false
24+
AfterNamespace: false
25+
AfterStruct: false
26+
AfterUnion: false
27+
AfterExternBlock: false
28+
BeforeCatch: false
29+
BeforeElse: false
30+
BeforeLambdaBody: false
31+
BeforeWhile: false
32+
SplitEmptyFunction: true
33+
SplitEmptyRecord: true
34+
SplitEmptyNamespace: true
1435
BreakBeforeBinaryOperators: NonAssignment
36+
BreakBeforeBraces: Custom
37+
BreakConstructorInitializers: BeforeColon
38+
BreakConstructorInitializersBeforeComma: false
39+
BreakStringLiterals: true
40+
ColumnLimit: 80
41+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
42+
ContinuationIndentWidth: 4
1543
DerivePointerAlignment: false
1644
FixNamespaceComments: true
17-
IncludeBlocks: Preserve
45+
IncludeBlocks: Regroup
46+
IncludeCategories:
47+
- Regex: '^["<]MAIN_INCLUDE_FILE[">]$'
48+
Priority: 1
49+
- Regex: '^((<gtest/gtest\.h>)|(<gmock/gmock\.h>))$'
50+
Priority: 2
51+
- Regex: '^<[^/]*>$'
52+
Priority: 3
53+
- Regex: '^<.*>$'
54+
Priority: 4
55+
- Regex: '^".*"$'
56+
Priority: 5
57+
- Regex: '.*'
58+
Priority: 6
59+
IndentWidth: 2
1860
InsertBraces: true
61+
InsertNewlineAtEOF: true
1962
InsertTrailingCommas: Wrapped
63+
MacroBlockBegin: ''
64+
MacroBlockEnd: ''
65+
MaxEmptyLinesToKeep: 2
2066
NamespaceIndentation: All
2167
PointerAlignment: Right
2268
QualifierAlignment: Custom
23-
QualifierOrder: ['inline', 'static', 'constexpr', 'const', 'volatile', 'type', 'restrict']
69+
QualifierOrder:
70+
- inline
71+
- static
72+
- constexpr
73+
- const
74+
- volatile
75+
- type
76+
- restrict
2477
ReferenceAlignment: Right
2578
ReflowComments: true
26-
ShortNamespaceLines: 0
79+
ShortNamespaceLines: 2
2780
SortIncludes: CaseSensitive
28-
29-
# use "// clang-format off" + "// clang-format on"
30-
BreakStringLiterals: true
31-
32-
# comment if not supported
33-
InsertNewlineAtEOF: true
81+
SpaceAfterCStyleCast: false
82+
SpaceAfterTemplateKeyword: true
83+
SpaceBeforeRangeBasedForLoopColon: true
84+
SpaceInEmptyParentheses: false
85+
SpacesBeforeTrailingComments: 2
86+
SpacesInAngles: false
87+
SpacesInConditionalStatement: false
88+
SpacesInCStyleCastParentheses: false
89+
SpacesInParentheses: false
90+
TabWidth: 2
91+
...

.githooks/README.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[//]: # (
2+
Copyright Quadrivium LLC
3+
All Rights Reserved
4+
SPDX-License-Identifier: Apache-2.0
5+
)
6+
7+
# Git Hooks
8+
9+
This folder _might_ contain some git-hooks to execute various checkup in Kagome.
10+
11+
To activate presented (_and all future_) hooks just execute **once** shell-script [activate_hooks.sh](./activate_hooks.sh) from Kagome project root path.
12+
13+
## pre-commit
14+
15+
This hook check existing `clang-format` and `cmake-format` and their versions.
16+
If they have recommended version, specific checkup is enabled.
17+
18+
Each changed C++ file (`.hpp` and `.cpp` extensions) gets processed by `clang-format`.
19+
20+
Each changed CMake file (`CMakeLists.txt` and `.cmake` extension) gets processed by `cmake-format`
21+
22+
Commit will be blocked while there are any differences between original files and `clang-format/cmake-format` output files.
23+
24+
## etc.
25+
26+
_Other hooks might be provided by maintainers in the future._
27+

.githooks/activate_hooks.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
#
3+
# Copyright Quadrivium LLC
4+
# All Rights Reserved
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
8+
GIT=$(which git)
9+
10+
if [ -z "${GIT}" ]; then
11+
echo "Command ``git'' command not found"
12+
exit 1
13+
fi
14+
15+
cd "$(dirname "$0")/.." || (echo "Run script from file" | exit 1)
16+
17+
chmod +x .githooks/*
18+
19+
${GIT} config --local core.hooksPath .githooks || (echo "Hooks activation has failed" | exit 1)
20+
21+
echo "Hooks activated successfully"
22+
exit 0

.githooks/pre-commit_

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/sh
2+
#
3+
# Copyright Quadrivium LLC
4+
# All Rights Reserved
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
8+
if git rev-parse --verify HEAD >/dev/null 2>&1; then
9+
BASE=HEAD
10+
else
11+
# Initial commit: diff BASE an empty tree object
12+
BASE=$(git hash-object -t tree /dev/null)
13+
fi
14+
15+
# check clang-format binary
16+
CLANG_FORMAT_ENABLED=1
17+
CLANG_FORMAT=$(which clang-format-16 2>/dev/null)
18+
if [ -z "${CLANG_FORMAT}" ]; then
19+
CLANG_FORMAT=$(which clang-format)
20+
if [ -z "${CLANG_FORMAT}" ]; then
21+
echo "Command clang-format is not found" >&2
22+
echo "Please, install clang-format version 16 to enable checkup C++-files formatting over git pre-commit hook" >&2
23+
CLANG_FORMAT_ENABLED=0
24+
fi
25+
fi
26+
27+
# check clang-format version
28+
if [ $CLANG_FORMAT_ENABLED ]; then
29+
CLANG_FORMAT_VERSION=$($CLANG_FORMAT --version | sed -r "s/.*version ([[:digit:]]+).*/\1/")
30+
31+
if [ "$CLANG_FORMAT_VERSION" != "16" ]; then
32+
echo "clang-format version 16 is recommended" >&2
33+
fi
34+
fi
35+
36+
FILES=$(git diff --staged --diff-filter=ACMR --name-only)
37+
38+
# check c++ files' format with clang-format
39+
CXX_RES=0
40+
if [ $CLANG_FORMAT_ENABLED ]; then
41+
# for FILE in $(git diff-index --name-only "${BASE}" --diff-filter=ACMR | grep -e "\\.[ch]pp$"); do
42+
for FILE in $(echo "$FILES" | grep -e "\\.[ch]pp$"); do
43+
O_HASH=$(shasum <"${FILE}")
44+
F_HASH=$(${CLANG_FORMAT} --style=file "$FILE" | shasum)
45+
if [ "${O_HASH}" != "${F_HASH}" ]; then
46+
echo "File looks nonformatted: $FILE"
47+
CXX_RES=1
48+
fi
49+
done
50+
51+
if [ $CXX_RES = 1 ]; then
52+
CLANG_FORMAT_VERSION_FULL=$($CLANG_FORMAT --version | sed -r "s/.*version ([[:digit:]\.]+).*/\1/")
53+
echo "Used clang-format version $CLANG_FORMAT_VERSION_FULL" >&2
54+
fi
55+
fi
56+
57+
## check cmake-format binary
58+
#CMAKE_FORMAT_ENABLED=1
59+
#CMAKE_FORMAT=$(which cmake-format)
60+
#if [ -z "${CMAKE_FORMAT}" ]; then
61+
# echo "Command cmake-format is not found" >&2
62+
# echo "Please, install cmake-format version 15 to enable checkup cmake-files formatting over git pre-commit hook" >&2
63+
# CMAKE_FORMAT_ENABLED=0
64+
#fi
65+
#
66+
## check cmake-files' format with cmake-format
67+
#CMAKE_RES=0
68+
#if [ $CMAKE_FORMAT_ENABLED ]; then
69+
# for FILE in $(echo "$FILES" | grep -e "\(\(CMakeLists\\.txt\)\|\(\\.cmake\)\)$"); do
70+
# O_HASH=$(shasum <"${FILE}")
71+
# F_HASH=$(${CMAKE_FORMAT} "$FILE" | shasum)
72+
# if [ "${O_HASH}" != "${F_HASH}" ]; then
73+
# echo "File looks nonformatted: $FILE"
74+
# CMAKE_RES=1
75+
# fi
76+
# done
77+
#
78+
# if [ $CMAKE_RES = 1 ]; then
79+
# CMAKE_FORMAT_VERSION_FULL=$($CMAKE_FORMAT --version)
80+
# echo "Used cmake-format version $CMAKE_FORMAT_VERSION_FULL" >&2
81+
# fi
82+
#fi
83+
84+
# result of checks
85+
if [ "$CXX_RES" = "1" ] || [ "$CMAKE_RES" = "1" ]; then
86+
echo "Formatter required" >&2
87+
exit 1
88+
fi
89+
90+
exit 0

CMakeLists.txt

+25-14
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,53 @@
77
cmake_minimum_required(VERSION 3.25)
88

99
option(TESTING "Build and run test suite" ON)
10-
if(TESTING)
11-
list(APPEND VCPKG_MANIFEST_FEATURES test)
12-
endif()
10+
if (TESTING)
11+
list(APPEND VCPKG_MANIFEST_FEATURES test)
12+
endif ()
1313

14-
project(cpp-jam
15-
VERSION 0.0.1
16-
LANGUAGES C CXX
17-
)
1814
set(CMAKE_CXX_STANDARD 20)
1915
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2016
set(CMAKE_CXX_EXTENSIONS OFF)
17+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
18+
19+
project(cpp-jam
20+
VERSION 0.0.1
21+
LANGUAGES CXX
22+
)
23+
24+
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
25+
message(STATUS "Boost_DIR: ${Boost_DIR}")
2126

2227
find_package(Python3 REQUIRED)
2328

2429
find_package(PkgConfig REQUIRED)
2530
pkg_check_modules(libb2 REQUIRED IMPORTED_TARGET GLOBAL libb2)
2631

27-
find_package(Boost CONFIG REQUIRED)
32+
find_package(Boost CONFIG REQUIRED COMPONENTS algorithm outcome program_options)
2833
find_package(fmt CONFIG REQUIRED)
34+
find_package(yaml-cpp CONFIG REQUIRED)
2935
find_package(jam_crust CONFIG REQUIRED)
3036
find_package(scale CONFIG REQUIRED)
37+
find_package(soralog CONFIG REQUIRED)
3138
find_package(schnorrkel_crust CONFIG REQUIRED)
39+
find_package(Boost.DI CONFIG REQUIRED)
40+
find_package(qtils CONFIG REQUIRED)
41+
find_package(prometheus-cpp CONFIG REQUIRED)
3242

3343
add_library(headers INTERFACE)
3444
target_include_directories(headers INTERFACE
35-
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
45+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src_>
3646
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
3747
)
3848

3949
add_subdirectory(src)
4050

41-
if(TESTING)
42-
enable_testing()
51+
if (TESTING)
52+
enable_testing()
4353

44-
find_package(GTest CONFIG REQUIRED)
45-
set(GTEST_DEPS GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main)
54+
find_package(GTest CONFIG REQUIRED)
55+
set(GTEST_DEPS GTest::gtest_main)
4656

47-
add_subdirectory(test-vectors)
57+
add_subdirectory(test-vectors)
58+
add_subdirectory(tests)
4859
endif ()

0 commit comments

Comments
 (0)