Skip to content

Commit e21c42c

Browse files
committed
revert wrong merge
1 parent d6257fb commit e21c42c

Some content is hidden

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

73 files changed

+5254
-80
lines changed

scripts/asn1.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,11 @@ def asn_sequence_of(t):
187187
if type(size) is int:
188188
return "qtils::BytesN<%u>" % size
189189
else:
190-
return "::morum::ConfigVec<uint8_t, Config::Field::%s>" % c_dash(size)
190+
return "::jam::ConfigVec<uint8_t, Config::Field::%s>" % c_dash(size)
191191
return "qtils::Bytes"
192192
if fixed:
193193
if isinstance(size, str):
194-
return "::morum::ConfigVec<%s, Config::Field::%s>" % (T, c_dash(size))
194+
return "::jam::ConfigVec<%s, Config::Field::%s>" % (T, c_dash(size))
195195
return "std::array<%s, %s>" % (T, c_dash(size))
196196
return "std::vector<%s>" % T
197197

@@ -497,23 +497,23 @@ def write(self, name: str):
497497

498498
def constants():
499499
g = GenConstants(
500-
"morum::test_vectors",
500+
"jam::test_vectors",
501501
"jam-types-asn",
502502
)
503503
g.write()
504504

505505

506506
def types():
507507
g = GenCommonTypes(
508-
"morum::test_vectors",
508+
"jam::test_vectors",
509509
"jam-types-asn",
510510
)
511511
g.write()
512512

513513

514514
def history():
515515
g = GenSpecialTypes(
516-
"morum::test_vectors",
516+
"jam::test_vectors",
517517
"history",
518518
"history/history",
519519
"HistoryModule",
@@ -523,7 +523,7 @@ def history():
523523

524524
def safrole():
525525
g = GenSpecialTypes(
526-
"morum::test_vectors",
526+
"jam::test_vectors",
527527
"safrole",
528528
"safrole/safrole",
529529
"SafroleModule",
@@ -533,7 +533,7 @@ def safrole():
533533

534534
def disputes():
535535
g = GenSpecialTypes(
536-
"morum::test_vectors",
536+
"jam::test_vectors",
537537
"disputes",
538538
"disputes/disputes",
539539
"DisputesModule",
@@ -543,7 +543,7 @@ def disputes():
543543

544544
def authorizations():
545545
g = GenSpecialTypes(
546-
"morum::test_vectors",
546+
"jam::test_vectors",
547547
"authorizations",
548548
"authorizations/authorizations",
549549
"AuthorizationsModule",

scripts/get_version.sh

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/sh -eu
2+
#
3+
# Copyright Quadrivium LLC
4+
# All Rights Reserved
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
#
8+
# Version String Generator for Git Repositories
9+
#
10+
# This script generates a version string based on the current Git state.
11+
# It retrieves the latest tag, calculates the number of commits since the last tag,
12+
# includes the current branch (if different from master), and appends the commit hash.
13+
# If the working directory has uncommitted changes, it marks the version as "dirty".
14+
#
15+
# Usage:
16+
# ./get_version.sh [--sanitized]
17+
#
18+
# Options:
19+
# --sanitized Replaces non-alphanumeric characters in the version string
20+
# with hyphens for compatibility with package managers.
21+
#
22+
# Output:
23+
# Prints a version string in the format:
24+
# <latest_tag>-<commits_since_tag>-<branch>-<commits_since_fork>-<commit_hash>
25+
# If the repository is dirty, "-dirty" is appended.
26+
#
27+
# Example:
28+
# v1.2.3-5-feature-branch-2-a1b2c3d-dirty
29+
#
30+
# Requirements:
31+
# - Git
32+
# - sed (for --sanitized mode)
33+
#
34+
# Notes:
35+
# - If the repository has no tags, an initial tag "_init" is created.
36+
# - If the repository is not a Git repo, outputs "Unknown(no git)".
37+
# - If Git is not installed, it exits with an error.
38+
#
39+
40+
sanitize_version() {
41+
echo "$1" | sed -E 's/[^a-zA-Z0-9.+~:-]/-/g'
42+
}
43+
44+
realpath() {
45+
case "$1" in
46+
/*) echo "$1" ;;
47+
*) echo "$(pwd)/$1" ;;
48+
esac
49+
}
50+
51+
cd "$(dirname "$(realpath "$0")")"
52+
53+
SANITIZED=false
54+
[ "$#" -gt 0 ] && [ "$1" = "--sanitized" ] && SANITIZED=true
55+
56+
if [ -x "$(command -v git)" ] && [ -d "$(git rev-parse --git-dir 2>/dev/null)" ]; then
57+
HEAD=$(git rev-parse --short HEAD)
58+
59+
# Determine the main branch (fallback to default names if necessary)
60+
MAIN_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')
61+
if [ -z "$MAIN_BRANCH" ]; then
62+
MAIN_BRANCH=$(git branch --format='%(refname:short)' | grep -E '^(main|master)$' | head -n1)
63+
fi
64+
if [ -z "$MAIN_BRANCH" ]; then
65+
MAIN_BRANCH="master" # Fallback to "master" if no main branch detected
66+
fi
67+
68+
COMMON=$(git merge-base HEAD "$MAIN_BRANCH" 2>/dev/null || echo "$HEAD")
69+
70+
if ! git tag | grep -q .; then
71+
ROOT_COMMIT=$(git rev-list --max-parents=0 HEAD || echo "")
72+
[ -n "$ROOT_COMMIT" ] && ! git tag | grep -q "_init" && git tag _init "$ROOT_COMMIT"
73+
fi
74+
75+
DESCR=$(git describe --tags --long "$COMMON" 2>/dev/null || echo "")
76+
[ -z "$DESCR" ] && DESCR="$HEAD-0-g$HEAD"
77+
78+
TAG_IN_MASTER=$(echo "$DESCR" | sed -E "s/v?(.*)-([0-9]+)-g[a-f0-9]+/\1/")
79+
TAG_TO_FORK_DISTANCE=$(echo "$DESCR" | sed -E "s/v?(.*)-([0-9]+)-g[a-f0-9]+/\2/")
80+
81+
BRANCH=$(git branch --show-current 2>/dev/null || echo "$HEAD")
82+
FORK_TO_HEAD_DISTANCE=$(git rev-list --count "$COMMON..HEAD" 2>/dev/null || echo "0")
83+
84+
RESULT=$TAG_IN_MASTER
85+
[ "$TAG_TO_FORK_DISTANCE" != "0" ] && RESULT="$RESULT-$TAG_TO_FORK_DISTANCE"
86+
[ "$BRANCH" != "$MAIN_BRANCH" ] && RESULT="$RESULT-$BRANCH-$FORK_TO_HEAD_DISTANCE-$HEAD"
87+
88+
git diff --quiet || DIRTY="-dirty"
89+
RESULT="$RESULT${DIRTY:-}"
90+
else
91+
RESULT="Unknown(no git)"
92+
fi
93+
94+
[ "$SANITIZED" = true ] && RESULT=$(sanitize_version "$RESULT")
95+
96+
printf "%s" "$RESULT"

src/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,3 @@ add_subdirectory(metrics)
2424
# Clocks and time subsystem
2525
add_subdirectory(clock)
2626

27-
# Merkle tree DB
28-
add_subdirectory(merkle_tree)

src/app/CMakeLists.txt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#
2+
# Copyright Quadrivium LLC
3+
# All Rights Reserved
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
set(BUILD_VERSION_CPP "${CMAKE_BINARY_DIR}/generated/app/build_version.cpp")
8+
set(GET_VERSION_SCRIPT "${CMAKE_SOURCE_DIR}/scripts/get_version.sh")
9+
add_custom_command(
10+
OUTPUT ${BUILD_VERSION_CPP}
11+
COMMAND echo "// Auto-generated file\\n" > ${BUILD_VERSION_CPP}
12+
COMMAND echo "#include <string>\\n" >> ${BUILD_VERSION_CPP}
13+
COMMAND echo "namespace jam {" >> ${BUILD_VERSION_CPP}
14+
COMMAND echo " const std::string &buildVersion() {" >> ${BUILD_VERSION_CPP}
15+
COMMAND printf " static const std::string buildVersion(\"" >> ${BUILD_VERSION_CPP}
16+
COMMAND ${GET_VERSION_SCRIPT} >> ${BUILD_VERSION_CPP}
17+
COMMAND echo "\");" >> ${BUILD_VERSION_CPP}
18+
COMMAND echo " return buildVersion;" >> ${BUILD_VERSION_CPP}
19+
COMMAND echo " }" >> ${BUILD_VERSION_CPP}
20+
COMMAND echo "}" >> ${BUILD_VERSION_CPP}
21+
COMMENT "Generate build_version.cpp"
22+
DEPENDS ${GET_VERSION_SCRIPT}
23+
VERBATIM
24+
)
25+
add_library(build_version
26+
${CMAKE_BINARY_DIR}/generated/app/build_version.cpp
27+
)
28+
29+
add_library(app_configuration SHARED configuration.cpp)
30+
target_link_libraries(app_configuration
31+
Boost::boost)
32+
33+
add_library(app_configurator SHARED configurator.cpp)
34+
target_link_libraries(app_configurator
35+
app_configuration
36+
yaml-cpp::yaml-cpp
37+
Boost::program_options
38+
build_version
39+
)
40+
41+
add_library(app_state_manager SHARED impl/state_manager_impl.cpp)
42+
target_link_libraries(app_state_manager
43+
logger
44+
)
45+
46+
add_library(application SHARED impl/application_impl.cpp)
47+
target_link_libraries(application
48+
qtils::qtils
49+
app_configuration
50+
metrics
51+
)

src/app/application.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Copyright Quadrivium LLC
3+
* All Rights Reserved
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#pragma once
8+
9+
#include <utils/ctor_limiters.hpp>
10+
11+
namespace jam::app {
12+
13+
/// @class Application - JAM-application interface
14+
class Application : private Singleton<Application> {
15+
public:
16+
virtual ~Application() = default;
17+
18+
/// Runs node
19+
virtual void run() = 0;
20+
};
21+
22+
} // namespace jam::app

src/app/build_version.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Copyright Quadrivium LLC
3+
* All Rights Reserved
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#pragma once
8+
9+
#include <string>
10+
11+
namespace jam {
12+
/**
13+
* @returns String indicating current build version. Might to contain: tag,
14+
* number of commits from tag to fork, commit branch and number of commits
15+
* from fork to current commit.
16+
* @note Definition is generating by cmake
17+
*/
18+
const std::string &buildVersion();
19+
} // namespace jam

src/app/configuration.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Copyright Soramitsu Co., Ltd. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include "app/configuration.hpp"
7+
8+
namespace jam::app {
9+
10+
Configuration::Configuration()
11+
: version_("undefined"), name_("unnamed"), metrics_endpoint_() {}
12+
13+
std::string Configuration::nodeVersion() const {
14+
return version_;
15+
}
16+
17+
std::string Configuration::nodeName() const {
18+
return name_;
19+
}
20+
21+
std::optional<Configuration::Endpoint> Configuration::metricsEndpoint()
22+
const {
23+
return metrics_endpoint_;
24+
}
25+
26+
} // namespace jam::app

src/app/configuration.hpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Copyright Soramitsu Co., Ltd. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#pragma once
7+
8+
#include <string>
9+
10+
#include <boost/asio/ip/tcp.hpp>
11+
#include <utils/ctor_limiters.hpp>
12+
13+
namespace jam::app {
14+
class Configuration final : Singleton<Configuration> {
15+
public:
16+
using Endpoint = boost::asio::ip::tcp::endpoint;
17+
18+
Configuration();
19+
20+
// /// Generate yaml-file with actual config
21+
// virtual void generateConfigFile() const = 0;
22+
23+
[[nodiscard]] std::string nodeVersion() const;
24+
[[nodiscard]] std::string nodeName() const;
25+
[[nodiscard]] std::optional<Endpoint> metricsEndpoint() const;
26+
27+
private:
28+
friend class Configurator; // for external configure
29+
30+
std::string version_;
31+
std::string name_;
32+
33+
Endpoint metrics_endpoint_;
34+
std::optional<bool> metrics_enabled_;
35+
};
36+
37+
} // namespace jam::app

0 commit comments

Comments
 (0)