Skip to content
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3e14281
draft
xDimon Jan 10, 2025
51825a0
draft
xDimon Jan 14, 2025
103d7a9
draft
xDimon Jan 15, 2025
c35f7eb
draft
xDimon Jan 15, 2025
59627ae
feature: watchdog
xDimon Jan 16, 2025
6081ea3
draft
xDimon Jan 16, 2025
f9e0a2c
feature: metrics
xDimon Jan 16, 2025
8df207f
feature: git-hooks
xDimon Jan 17, 2025
8a81f67
draft
xDimon Jan 17, 2025
b7fa1ab
draft
xDimon Jan 20, 2025
330a5bb
feature: extend format config
xDimon Jan 20, 2025
8b2b63c
draft
xDimon Jan 21, 2025
f2e3b28
format config
xDimon Jan 21, 2025
bb85738
x
xDimon Jan 23, 2025
f82919b
draft
xDimon Jan 23, 2025
9467566
refactor: simplifying ConfigVec
xDimon Jan 24, 2025
35dcd91
fix: mutual dependency of generated files
xDimon Jan 24, 2025
5c0f444
draft
xDimon Jan 24, 2025
809f44e
aggregate
xDimon Jan 24, 2025
70175da
draft
xDimon Jan 24, 2025
47b525d
refactor: no generate *-scale.hpp
xDimon Jan 24, 2025
c63a7ce
refactor: no generate *-scale.hpp [2]
xDimon Jan 24, 2025
fd10423
scale::en|decode
xDimon Jan 24, 2025
3d0ebc2
no conf types scale
xDimon Jan 24, 2025
344a3fe
x
xDimon Jan 24, 2025
9745d54
x
xDimon Jan 24, 2025
1f96cf7
fix: libs deduplicate
xDimon Jan 27, 2025
a043e3f
refactor: use new qtils
xDimon Jan 30, 2025
12c017d
refactor: move crypto to jam source
xDimon Jan 31, 2025
91ea1c7
refactor: move generated files to artifacts directory
xDimon Jan 31, 2025
018f824
refactor: move scripts and add docs
xDimon Jan 31, 2025
397c0ff
fix: pythot setup
xDimon Jan 31, 2025
f7e1c19
fix: get_version
xDimon Jan 31, 2025
2311e8d
fix: get_version
xDimon Jan 31, 2025
fa3b75b
fix: get_version
xDimon Jan 31, 2025
605dd7a
refactor: compile PIC
xDimon Jan 31, 2025
0ff63aa
update: qtils
xDimon Jan 31, 2025
8332f52
update: qtils
xDimon Feb 1, 2025
a4d972f
update: qtils
xDimon Feb 2, 2025
7570f96
fix: asn1 code-generating
xDimon Feb 9, 2025
75b130a
fix: ambiguous diff function
xDimon Feb 9, 2025
70f8192
update: scale
xDimon Feb 9, 2025
d5cf1f0
update: scale
xDimon Feb 10, 2025
4aa207e
update: scale & qtils
xDimon Feb 11, 2025
f0ced11
fix: review issues
xDimon Feb 11, 2025
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: 1 addition & 1 deletion .ci/scripts/init_py.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ init_py() {
python3 -m venv "$VENV"
source $VENV/bin/activate
pip3 install cmake==${CMAKE_VERSION}
pip3 install --no-cache-dir -r ${PROJECT}/python/requirements.txt
pip3 install --no-cache-dir asn1tools
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
Expand Down
78 changes: 68 additions & 10 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,88 @@
# SPDX-License-Identifier: Apache-2.0
#

Language: Cpp
BasedOnStyle: Google

AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignOperands: AlignAfterOperator
AlignTrailingComments: true
AllowShortFunctionsOnASingleLine: Empty
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakConstructorInitializers: BeforeColon
BreakConstructorInitializersBeforeComma: false
BreakStringLiterals: true
ColumnLimit: 80
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ContinuationIndentWidth: 4
DerivePointerAlignment: false
FixNamespaceComments: true
IncludeBlocks: Preserve
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^["<]MAIN_INCLUDE_FILE[">]$'
Priority: 1
- Regex: '^((<gtest/gtest\.h>)|(<gmock/gmock\.h>))$'
Priority: 2
- Regex: '^<[^/]*>$'
Priority: 3
- Regex: '^<.*>$'
Priority: 4
- Regex: '^".*"$'
Priority: 5
- Regex: '.*'
Priority: 6
IndentWidth: 2
InsertBraces: true
InsertNewlineAtEOF: true
InsertTrailingCommas: Wrapped
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
PointerAlignment: Right
QualifierAlignment: Custom
QualifierOrder: ['inline', 'static', 'constexpr', 'const', 'volatile', 'type', 'restrict']
QualifierOrder:
- inline
- static
- constexpr
- const
- volatile
- type
- restrict
ReferenceAlignment: Right
ReflowComments: true
ShortNamespaceLines: 0
ShortNamespaceLines: 2
SortIncludes: CaseSensitive

# use "// clang-format off" + "// clang-format on"
BreakStringLiterals: true

# comment if not supported
InsertNewlineAtEOF: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
TabWidth: 2
...
27 changes: 27 additions & 0 deletions .githooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[//]: # (
Copyright Quadrivium LLC
All Rights Reserved
SPDX-License-Identifier: Apache-2.0
)

# Git Hooks

This folder _might_ contain some git-hooks to execute various checkup in Kagome.

To activate presented (_and all future_) hooks just execute **once** shell-script [activate_hooks.sh](./activate_hooks.sh) from Kagome project root path.

## pre-commit

This hook check existing `clang-format` and `cmake-format` and their versions.
If they have recommended version, specific checkup is enabled.

Each changed C++ file (`.hpp` and `.cpp` extensions) gets processed by `clang-format`.

Each changed CMake file (`CMakeLists.txt` and `.cmake` extension) gets processed by `cmake-format`

Commit will be blocked while there are any differences between original files and `clang-format/cmake-format` output files.

## etc.

_Other hooks might be provided by maintainers in the future._

22 changes: 22 additions & 0 deletions .githooks/activate_hooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
#
# Copyright Quadrivium LLC
# All Rights Reserved
# SPDX-License-Identifier: Apache-2.0
#

GIT=$(which git)

if [ -z "${GIT}" ]; then
echo "Command ``git'' command not found"
exit 1
fi

cd "$(dirname "$0")/.." || (echo "Run script from file" | exit 1)

chmod +x .githooks/*

${GIT} config --local core.hooksPath .githooks || (echo "Hooks activation has failed" | exit 1)

echo "Hooks activated successfully"
exit 0
90 changes: 90 additions & 0 deletions .githooks/pre-commit_
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/bin/sh
#
# Copyright Quadrivium LLC
# All Rights Reserved
# SPDX-License-Identifier: Apache-2.0
#

if git rev-parse --verify HEAD >/dev/null 2>&1; then
BASE=HEAD
else
# Initial commit: diff BASE an empty tree object
BASE=$(git hash-object -t tree /dev/null)
fi

# check clang-format binary
CLANG_FORMAT_ENABLED=1
CLANG_FORMAT=$(which clang-format-16 2>/dev/null)
if [ -z "${CLANG_FORMAT}" ]; then
CLANG_FORMAT=$(which clang-format)
if [ -z "${CLANG_FORMAT}" ]; then
echo "Command clang-format is not found" >&2
echo "Please, install clang-format version 16 to enable checkup C++-files formatting over git pre-commit hook" >&2
CLANG_FORMAT_ENABLED=0
fi
fi

# check clang-format version
if [ $CLANG_FORMAT_ENABLED ]; then
CLANG_FORMAT_VERSION=$($CLANG_FORMAT --version | sed -r "s/.*version ([[:digit:]]+).*/\1/")

if [ "$CLANG_FORMAT_VERSION" != "16" ]; then
echo "clang-format version 16 is recommended" >&2
fi
fi

FILES=$(git diff --staged --diff-filter=ACMR --name-only)

# check c++ files' format with clang-format
CXX_RES=0
if [ $CLANG_FORMAT_ENABLED ]; then
# for FILE in $(git diff-index --name-only "${BASE}" --diff-filter=ACMR | grep -e "\\.[ch]pp$"); do
for FILE in $(echo "$FILES" | grep -e "\\.[ch]pp$"); do
O_HASH=$(shasum <"${FILE}")
F_HASH=$(${CLANG_FORMAT} --style=file "$FILE" | shasum)
if [ "${O_HASH}" != "${F_HASH}" ]; then
echo "File looks nonformatted: $FILE"
CXX_RES=1
fi
done

if [ $CXX_RES = 1 ]; then
CLANG_FORMAT_VERSION_FULL=$($CLANG_FORMAT --version | sed -r "s/.*version ([[:digit:]\.]+).*/\1/")
echo "Used clang-format version $CLANG_FORMAT_VERSION_FULL" >&2
fi
fi

## check cmake-format binary
#CMAKE_FORMAT_ENABLED=1
#CMAKE_FORMAT=$(which cmake-format)
#if [ -z "${CMAKE_FORMAT}" ]; then
# echo "Command cmake-format is not found" >&2
# echo "Please, install cmake-format version 15 to enable checkup cmake-files formatting over git pre-commit hook" >&2
# CMAKE_FORMAT_ENABLED=0
#fi
#
## check cmake-files' format with cmake-format
#CMAKE_RES=0
#if [ $CMAKE_FORMAT_ENABLED ]; then
# for FILE in $(echo "$FILES" | grep -e "\(\(CMakeLists\\.txt\)\|\(\\.cmake\)\)$"); do
# O_HASH=$(shasum <"${FILE}")
# F_HASH=$(${CMAKE_FORMAT} "$FILE" | shasum)
# if [ "${O_HASH}" != "${F_HASH}" ]; then
# echo "File looks nonformatted: $FILE"
# CMAKE_RES=1
# fi
# done
#
# if [ $CMAKE_RES = 1 ]; then
# CMAKE_FORMAT_VERSION_FULL=$($CMAKE_FORMAT --version)
# echo "Used cmake-format version $CMAKE_FORMAT_VERSION_FULL" >&2
# fi
#fi

# result of checks
if [ "$CXX_RES" = "1" ] || [ "$CMAKE_RES" = "1" ]; then
echo "Formatter required" >&2
exit 1
fi

exit 0
39 changes: 25 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,53 @@
cmake_minimum_required(VERSION 3.25)

option(TESTING "Build and run test suite" ON)
if(TESTING)
list(APPEND VCPKG_MANIFEST_FEATURES test)
endif()
if (TESTING)
list(APPEND VCPKG_MANIFEST_FEATURES test)
endif ()

project(cpp-jam
VERSION 0.0.1
LANGUAGES C CXX
)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

project(cpp-jam
VERSION 0.0.1
LANGUAGES CXX
)

message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS "Boost_DIR: ${Boost_DIR}")

find_package(Python3 REQUIRED)

find_package(PkgConfig REQUIRED)
pkg_check_modules(libb2 REQUIRED IMPORTED_TARGET GLOBAL libb2)

find_package(Boost CONFIG REQUIRED)
find_package(Boost CONFIG REQUIRED COMPONENTS algorithm outcome program_options)
find_package(fmt CONFIG REQUIRED)
find_package(yaml-cpp CONFIG REQUIRED)
find_package(jam_crust CONFIG REQUIRED)
find_package(scale CONFIG REQUIRED)
find_package(soralog CONFIG REQUIRED)
find_package(schnorrkel_crust CONFIG REQUIRED)
find_package(Boost.DI CONFIG REQUIRED)
find_package(qtils CONFIG REQUIRED)
find_package(prometheus-cpp CONFIG REQUIRED)

add_library(headers INTERFACE)
target_include_directories(headers INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src_>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

add_subdirectory(src)

if(TESTING)
enable_testing()
if (TESTING)
enable_testing()

find_package(GTest CONFIG REQUIRED)
set(GTEST_DEPS GTest::gtest GTest::gtest_main GTest::gmock GTest::gmock_main)
find_package(GTest CONFIG REQUIRED)
set(GTEST_DEPS GTest::gtest_main)

add_subdirectory(test-vectors)
add_subdirectory(test-vectors)
add_subdirectory(tests)
endif ()
Loading
Loading