Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 5 additions & 2 deletions .ci/.env
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ LINUX_PACKAGES="make \
python3-pip \
unzip \
zip \
nano"
nano \
nasm"

MACOS_PACKAGES="make \
autoconf \
Expand All @@ -27,7 +28,9 @@ MACOS_PACKAGES="make \
pkg-config \
[email protected] \
unzip \
zip"
zip \
nasm \
go"

CMAKE_VERSION=3.31.1
DEBIAN_FRONTEND=noninteractive
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ find_package(soralog CONFIG REQUIRED)
find_package(Boost.DI CONFIG REQUIRED)
find_package(qtils CONFIG REQUIRED)
find_package(prometheus-cpp CONFIG REQUIRED)
find_package(OpenSSL CONFIG REQUIRED)
find_package(xxHash CONFIG REQUIRED)
find_package(RocksDB CONFIG REQUIRED)

# TODO Temporarily commented out until gcc is updated (gcc-13 crashes because of this).
Expand Down
7 changes: 6 additions & 1 deletion example/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ logging:
- name: rpc
- name: metrics
- name: threads
- name: storage
- name: storage
children:
- name: block_storage
- name: blockchain
children:
- name: block_tree
13 changes: 9 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
# SPDX-License-Identifier: Apache-2.0
#

include_directories(${CMAKE_SOURCE_DIR})
include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${CMAKE_BINARY_DIR}/generated)

# Executables (should contain `main()` function)
add_subdirectory(executable)

# Application's thinks
add_subdirectory(app)

# Blockchain
add_subdirectory(blockchain)

# Cryptography thinks
add_subdirectory(crypto)

# Dependency injection
add_subdirectory(injector)

Expand All @@ -37,3 +39,6 @@ add_subdirectory(storage)

# Utilities
add_subdirectory(utils)

# 3rd-party things
add_subdirectory(third_party)
9 changes: 7 additions & 2 deletions src/app/impl/application_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ namespace jam::app {
qtils::SharedRef<StateManager> state_manager,
qtils::SharedRef<Watchdog> watchdog,
qtils::SharedRef<metrics::Exposer> metrics_exposer,
qtils::SharedRef<clock::SystemClock> system_clock,
std::shared_ptr<SeHolder>)
qtils::SharedRef<clock::SystemClock> system_clock

,
qtils::SharedRef<blockchain::BlockTree>
// qtils::SharedRef<blockchain::BlockTreeInitializer>

)
: logger_(logsys->getLogger("Application", "application")),
app_config_(std::move(config)),
state_manager_(std::move(state_manager)),
Expand Down
13 changes: 10 additions & 3 deletions src/app/impl/application_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

#include <memory>

#include <blockchain/block_tree.hpp>
#include <metrics/registry.hpp>
#include <qtils/shared_ref.hpp>

#include <metrics/registry.hpp>
#include "app/application.hpp"

#include "app/application.hpp"
#include "se/subscription_fwd.hpp"
Expand Down Expand Up @@ -82,8 +84,13 @@ namespace jam::app {
qtils::SharedRef<StateManager> state_manager,
qtils::SharedRef<Watchdog> watchdog,
qtils::SharedRef<metrics::Exposer> metrics_exposer,
qtils::SharedRef<clock::SystemClock> system_clock,
std::shared_ptr<SeHolder>);
qtils::SharedRef<clock::SystemClock> system_clock

,
qtils::SharedRef<blockchain::BlockTree>
// qtils::SharedRef<blockchain::BlockTreeInitializer>

);

void run() override;

Expand Down
2 changes: 1 addition & 1 deletion src/app/impl/chain_spec_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace jam::app {

class ChainSpecImpl : public ChainSpec {
public:
enum class Error {
enum class Error : uint8_t {
MISSING_ENTRY = 1,
MISSING_PEER_ID,
PARSER_ERROR,
Expand Down
2 changes: 1 addition & 1 deletion src/app/impl/state_manager_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace jam::log {

namespace jam::app {

class StateManagerImpl final
class StateManagerImpl // left non-final on purpose to be accessible in tests
: Singleton<StateManager>,
public StateManager,
public std::enable_shared_from_this<StateManagerImpl> {
Expand Down
24 changes: 24 additions & 0 deletions src/blockchain/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright Quadrivium LLC
# All Rights Reserved
# SPDX-License-Identifier: Apache-2.0
#

add_library(blockchain
impl/storage_util.cpp
impl/block_storage_error.cpp
impl/block_storage_impl.cpp
impl/block_storage_initializer.cpp
impl/genesis_block_header_impl.cpp
impl/block_tree_error.cpp
impl/justification_storage_policy.cpp
impl/cached_tree.cpp
impl/block_tree_impl.cpp
impl/block_tree_initializer.cpp
)
target_link_libraries(blockchain
Boost::boost
)
add_dependencies(blockchain
generate_common_types
)
99 changes: 99 additions & 0 deletions src/blockchain/block_header_repository.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/**
* Copyright Quadrivium LLC
* All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once

#include <optional>

#include <qtils/byte_arr.hpp>
// #include "common/visitor.hpp"
// #include <qtils/outcome.hpp>
#include "jam_types/block_header.hpp"
// #include "primitives/block_id.hpp"

namespace jam::blockchain {

/**
* Status of a block
*/
enum class BlockStatus : uint8_t {
InChain,
Unknown,
};

/**
* An interface to a storage with block headers that provides several
* convenience methods, such as getting bloch number by its hash and vice
* versa or getting a block status
*/
class BlockHeaderRepository {
public:
virtual ~BlockHeaderRepository() = default;

/**
* @return the number of the block with the provided {@param block_hash}
* in case one is in the storage or an error
*/
virtual outcome::result<BlockNumber> getNumberByHash(
const BlockHash &block_hash) const = 0;

// /**
// * @param block_number - the number of a block, contained in a block
// header
// * @return the hash of the block with the provided number in case one is
// * in the storage or an error
// */
// virtual outcome::result<BlockHash> getHashByNumber(
// BlockNumber block_number) const = 0;

/**
* @return block header with corresponding {@param block_hash} or an error
*/
[[nodiscard]] virtual outcome::result<BlockHeader> getBlockHeader(
const BlockHash &block_hash) const = 0;

// /**
// * @return block header with corresponding {@param block_hash} or a none
// * optional if the corresponding block header is not in storage or a
// * storage error
// */
// virtual outcome::result<std::optional<BlockHeader>>
// tryGetBlockHeader(const BlockHash &block_hash) const = 0;

// /**
// * @param id of a block which number is returned
// * @return block number or a none optional if the corresponding block
// * header is not in storage or a storage error
// */
// outcome::result<BlockNumber> getNumberById(
// const BlockId &block_id) const {
// return visit_in_place(
// block_id,
// [](const BlockNumber &block_number) {
// return block_number;
// },
// [this](const BlockHash &block_hash) {
// return getNumberByHash(block_hash);
// });
// }
//
// /**
// * @param id of a block which hash is returned
// * @return block hash or a none optional if the corresponding block
// * header is not in storage or a storage error
// */
// outcome::result<BlockHash> getHashById(
// const BlockId &id) const {
// return visit_in_place(
// id,
// [this](const BlockNumber &n) {
// return getHashByNumber(n);
// },
// [](const BlockHash &hash) { return hash; });
// }
};

} // namespace jam::blockchain
Loading
Loading