diff --git a/CHANGELOG.md b/CHANGELOG.md index e1883c99b119..555c932442bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [6.0.0-dev8] + +[6.0.0-dev8]: https://github.com/microsoft/CCF/releases/tag/6.0.0-dev8 + +### Changed + +- All definitions in CCF's public headers are now under the `ccf::` namespace. Any application code which references any of these types directly (notably `StartupConfig`, `http_status`, `LoggerLevel`), they will now need to be prefixed with the `ccf::` namespace. + ## [6.0.0-dev7] [6.0.0-dev7]: https://github.com/microsoft/CCF/releases/tag/6.0.0-dev7 diff --git a/include/ccf/ccf_deprecated.h b/include/ccf/ccf_deprecated.h index 1281af504e37..604f22514c65 100644 --- a/include/ccf/ccf_deprecated.h +++ b/include/ccf/ccf_deprecated.h @@ -3,3 +3,7 @@ #pragma once #define CCF_DEPRECATED(reason) [[deprecated(reason)]] + +// ci-checks exception - only defines a macro +namespace ccf +{} diff --git a/include/ccf/ds/enum_formatter.h b/include/ccf/ds/enum_formatter.h index ba4925298861..2aa16f62a530 100644 --- a/include/ccf/ds/enum_formatter.h +++ b/include/ccf/ds/enum_formatter.h @@ -27,3 +27,7 @@ struct formatter, char>> } }; FMT_END_NAMESPACE + +// ci-checks exception - defines a struct in the fmt namespace +namespace ccf +{} diff --git a/include/ccf/ds/logger.h b/include/ccf/ds/logger.h index cd932820c633..e6bf21014505 100644 --- a/include/ccf/ds/logger.h +++ b/include/ccf/ds/logger.h @@ -344,9 +344,9 @@ namespace ccf::logger // This allows: // CCF_LOG_OUT(DEBUG, "foo") << "this " << "msg"; #define CCF_LOG_OUT(LVL, TAG) \ - ccf::logger::config::ok(LoggerLevel::LVL) && \ + ccf::logger::config::ok(ccf::LoggerLevel::LVL) && \ ccf::logger::Out() == \ - ccf::logger::LogLine(LoggerLevel::LVL, TAG, __FILE__, __LINE__) + ccf::logger::LogLine(ccf::LoggerLevel::LVL, TAG, __FILE__, __LINE__) // To avoid repeating the (s, ...) args for every macro, we cheat with a curried // macro here by ending the macro with another macro name, which then accepts diff --git a/include/ccf/ds/logger_level.h b/include/ccf/ds/logger_level.h index 2b77d1a8395b..0be51f5fdf0a 100644 --- a/include/ccf/ds/logger_level.h +++ b/include/ccf/ds/logger_level.h @@ -2,12 +2,15 @@ // Licensed under the Apache 2.0 License. #pragma once -enum LoggerLevel +namespace ccf { - TRACE, - DEBUG, // events useful for debugging - INFO, // important events that should be logged even in release mode - FAIL, // survivable failures that should always be logged - FATAL, // fatal errors that may be non-recoverable - MAX_LOG_LEVEL -}; + enum LoggerLevel + { + TRACE, + DEBUG, // events useful for debugging + INFO, // important events that should be logged even in release mode + FAIL, // survivable failures that should always be logged + FATAL, // fatal errors that may be non-recoverable + MAX_LOG_LEVEL + }; +} diff --git a/include/ccf/http_status.h b/include/ccf/http_status.h index 10006494c722..9e5affe42de3 100644 --- a/include/ccf/http_status.h +++ b/include/ccf/http_status.h @@ -4,15 +4,18 @@ #include -using http_status = llhttp_status; - -/* Returns a string version of the HTTP status code. */ -static inline const char* http_status_str(http_status s) +namespace ccf { - return llhttp_status_name(s); -} + using http_status = llhttp_status; -static inline bool is_http_status_client_error(http_status s) -{ - return s >= 400 && s < 500; -} \ No newline at end of file + /* Returns a string version of the HTTP status code. */ + static inline const char* http_status_str(http_status s) + { + return llhttp_status_name(s); + } + + static inline bool is_http_status_client_error(http_status s) + { + return s >= 400 && s < 500; + } +} diff --git a/include/ccf/json_handler.h b/include/ccf/json_handler.h index 09576200516c..453fc58cbdbc 100644 --- a/include/ccf/json_handler.h +++ b/include/ccf/json_handler.h @@ -68,9 +68,9 @@ namespace ccf const nlohmann::json& result_payload); jsonhandler::JsonAdapterResponse make_error( - http_status status, const std::string& code, const std::string& msg); + ccf::http_status status, const std::string& code, const std::string& msg); - jsonhandler::JsonAdapterResponse make_redirect(http_status status); + jsonhandler::JsonAdapterResponse make_redirect(ccf::http_status status); using HandlerJsonParamsAndForward = std::function> rpc_interface_regexes; bool initialized = false; diff --git a/include/ccf/node/startup_config.h b/include/ccf/node/startup_config.h index f739b01054ab..4e51467c80ef 100644 --- a/include/ccf/node/startup_config.h +++ b/include/ccf/node/startup_config.h @@ -16,106 +16,109 @@ #include #include -struct CCFConfig +namespace ccf { - size_t worker_threads = 0; - - // 2**24.5 as per RFC8446 Section 5.5 - size_t node_to_node_message_limit = 23'726'566; + struct CCFConfig + { + size_t worker_threads = 0; - ccf::ds::SizeString historical_cache_soft_limit = {"512MB"}; + // 2**24.5 as per RFC8446 Section 5.5 + size_t node_to_node_message_limit = 23'726'566; - ccf::consensus::Configuration consensus = {}; - ccf::NodeInfoNetwork network = {}; + ccf::ds::SizeString historical_cache_soft_limit = {"512MB"}; - struct NodeCertificateInfo - { - std::string subject_name = "CN=CCF Node"; - std::vector subject_alt_names = {}; - ccf::crypto::CurveID curve_id = ccf::crypto::CurveID::SECP384R1; - size_t initial_validity_days = 1; + ccf::consensus::Configuration consensus = {}; + ccf::NodeInfoNetwork network = {}; - bool operator==(const NodeCertificateInfo&) const = default; - }; - NodeCertificateInfo node_certificate = {}; + struct NodeCertificateInfo + { + std::string subject_name = "CN=CCF Node"; + std::vector subject_alt_names = {}; + ccf::crypto::CurveID curve_id = ccf::crypto::CurveID::SECP384R1; + size_t initial_validity_days = 1; - struct LedgerSignatures - { - size_t tx_count = 5000; - ccf::ds::TimeString delay = {"1000ms"}; + bool operator==(const NodeCertificateInfo&) const = default; + }; + NodeCertificateInfo node_certificate = {}; - bool operator==(const LedgerSignatures&) const = default; - }; - LedgerSignatures ledger_signatures = {}; + struct LedgerSignatures + { + size_t tx_count = 5000; + ccf::ds::TimeString delay = {"1000ms"}; - struct JWT - { - ccf::ds::TimeString key_refresh_interval = {"30min"}; + bool operator==(const LedgerSignatures&) const = default; + }; + LedgerSignatures ledger_signatures = {}; - bool operator==(const JWT&) const = default; - }; - JWT jwt = {}; + struct JWT + { + ccf::ds::TimeString key_refresh_interval = {"30min"}; - struct Attestation - { - ccf::pal::snp::EndorsementsServers snp_endorsements_servers = {}; - std::optional snp_security_policy_file = std::nullopt; - std::optional snp_uvm_endorsements_file = std::nullopt; + bool operator==(const JWT&) const = default; + }; + JWT jwt = {}; - struct Environment + struct Attestation { - std::optional security_policy = std::nullopt; - std::optional uvm_endorsements = std::nullopt; + ccf::pal::snp::EndorsementsServers snp_endorsements_servers = {}; + std::optional snp_security_policy_file = std::nullopt; + std::optional snp_uvm_endorsements_file = std::nullopt; - bool operator==(const Environment&) const = default; - }; - Environment environment = {}; + struct Environment + { + std::optional security_policy = std::nullopt; + std::optional uvm_endorsements = std::nullopt; - bool operator==(const Attestation&) const = default; + bool operator==(const Environment&) const = default; + }; + Environment environment = {}; + + bool operator==(const Attestation&) const = default; + }; + Attestation attestation = {}; }; - Attestation attestation = {}; -}; -struct StartupConfig : CCFConfig -{ - StartupConfig() = default; - StartupConfig(const CCFConfig& common_base) : CCFConfig(common_base) {} + struct StartupConfig : CCFConfig + { + StartupConfig() = default; + StartupConfig(const CCFConfig& common_base) : CCFConfig(common_base) {} - std::string startup_host_time; - size_t snapshot_tx_interval = 10'000; + std::string startup_host_time; + size_t snapshot_tx_interval = 10'000; - // Only if starting or recovering - size_t initial_service_certificate_validity_days = 1; - std::string service_subject_name = "CN=CCF Service"; - ccf::COSESignaturesConfig cose_signatures; + // Only if starting or recovering + size_t initial_service_certificate_validity_days = 1; + std::string service_subject_name = "CN=CCF Service"; + ccf::COSESignaturesConfig cose_signatures; - nlohmann::json service_data = nullptr; + nlohmann::json service_data = nullptr; - nlohmann::json node_data = nullptr; + nlohmann::json node_data = nullptr; - struct Start - { - std::vector members; - std::string constitution; - ccf::ServiceConfiguration service_configuration; + struct Start + { + std::vector members; + std::string constitution; + ccf::ServiceConfiguration service_configuration; - bool operator==(const Start& other) const = default; - }; - Start start = {}; + bool operator==(const Start& other) const = default; + }; + Start start = {}; - struct Join - { - ccf::NodeInfoNetwork::NetAddress target_rpc_address; - ccf::ds::TimeString retry_timeout = {"1000ms"}; - std::vector service_cert = {}; - bool follow_redirect = true; - }; - Join join = {}; + struct Join + { + ccf::NodeInfoNetwork::NetAddress target_rpc_address; + ccf::ds::TimeString retry_timeout = {"1000ms"}; + std::vector service_cert = {}; + bool follow_redirect = true; + }; + Join join = {}; - struct Recover - { - std::optional> previous_service_identity = - std::nullopt; + struct Recover + { + std::optional> previous_service_identity = + std::nullopt; + }; + Recover recover = {}; }; - Recover recover = {}; -}; \ No newline at end of file +} diff --git a/include/ccf/service/consensus_type.h b/include/ccf/service/consensus_type.h index 654937f41fb3..c8847b847c80 100644 --- a/include/ccf/service/consensus_type.h +++ b/include/ccf/service/consensus_type.h @@ -2,8 +2,16 @@ // Licensed under the Apache 2.0 License. #pragma once -enum ConsensusType +#include "ccf/ds/json.h" + +namespace ccf { - CFT = 0, - BFT = 1 -}; + enum ConsensusType + { + CFT = 0, + BFT = 1 + }; + + DECLARE_JSON_ENUM( + ConsensusType, {{ConsensusType::CFT, "CFT"}, {ConsensusType::BFT, "BFT"}}) +} diff --git a/include/ccf/service/reconfiguration_type.h b/include/ccf/service/reconfiguration_type.h index fc1159ff03e2..054be36fc25b 100644 --- a/include/ccf/service/reconfiguration_type.h +++ b/include/ccf/service/reconfiguration_type.h @@ -2,8 +2,18 @@ // Licensed under the Apache 2.0 License. #pragma once -enum ReconfigurationType +#include "ccf/ds/json.h" + +namespace ccf { - ONE_TRANSACTION = 0, - TWO_TRANSACTION = 1 -}; + enum ReconfigurationType + { + ONE_TRANSACTION = 0, + TWO_TRANSACTION = 1 + }; + + DECLARE_JSON_ENUM( + ReconfigurationType, + {{ReconfigurationType::ONE_TRANSACTION, "OneTransaction"}, + {ReconfigurationType::TWO_TRANSACTION, "TwoTransaction"}}) +} diff --git a/include/ccf/tx.h b/include/ccf/tx.h index 288fd595669a..1583af8b359f 100644 --- a/include/ccf/tx.h +++ b/include/ccf/tx.h @@ -2,7 +2,6 @@ // Licensed under the Apache 2.0 License. #pragma once -#include "ccf/ccf_assert.h" #include "ccf/crypto/sha256_hash.h" #include "ccf/tx_id.h" diff --git a/python/pyproject.toml b/python/pyproject.toml index bb73609b02c8..c9220c85de37 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "ccf" -version = "6.0.0-dev7" +version = "6.0.0-dev8" authors = [ { name="CCF Team", email="CCF-Sec@microsoft.com" }, ] diff --git a/scripts/ci-checks.sh b/scripts/ci-checks.sh index b0321ae29e11..6cbeb7ab0fb3 100755 --- a/scripts/ci-checks.sh +++ b/scripts/ci-checks.sh @@ -49,7 +49,20 @@ if [[ -n "$violations" ]]; then echo "$violations" exit 1 else - echo "No public header violations" + echo "No public-private include violations" +fi +endgroup + +group "Public header namespaces" +# Enforce that all public headers namespace their exports +# NB: This only greps for a namespace definition in each file, doesn't precisely enforce that no types escape that namespace - mistakes are possible +violations=$(find "$ROOT_DIR/include/ccf" -type f -name "*.h" -print0 | xargs --null grep -L "namespace ccf" | sort || true) +if [[ -n "$violations" ]]; then + echo "Public headers missing ccf namespace:" + echo "$violations" + exit 1 +else + echo "No public header namespace violations" fi endgroup diff --git a/scripts/notice-check.py b/scripts/notice-check.py index 5699cae1bb6f..7c71c278586c 100644 --- a/scripts/notice-check.py +++ b/scripts/notice-check.py @@ -74,8 +74,10 @@ def check_ccf(): missing = [] for file_suffix, notice_lines in PREFIX_BY_FILETYPE.items(): for path in list_files(file_suffix): - if not has_notice(path, notice_lines): - missing.append(path) + # git ls-files returns moved/deleted files - ignore those + if os.path.isfile(path): + if not has_notice(path, notice_lines): + missing.append(path) return missing diff --git a/src/apps/tpcc/clients/tpcc_client.cpp b/src/apps/tpcc/clients/tpcc_client.cpp index 3bc17e16997c..87cfca7bc7b2 100644 --- a/src/apps/tpcc/clients/tpcc_client.cpp +++ b/src/apps/tpcc/clients/tpcc_client.cpp @@ -156,7 +156,7 @@ class TpccClient : public Base int main(int argc, char** argv) { ccf::logger::config::default_init(); - ccf::logger::config::level() = LoggerLevel::INFO; + ccf::logger::config::level() = ccf::LoggerLevel::INFO; ccf::crypto::openssl_sha256_init(); CLI::App cli_app{"Tpcc Client"}; diff --git a/src/clients/perf/timing.h b/src/clients/perf/timing.h index d6ef6d51690f..72a23c70e65f 100644 --- a/src/clients/perf/timing.h +++ b/src/clients/perf/timing.h @@ -245,7 +245,7 @@ namespace timing throw runtime_error(fmt::format( "{} failed with status {}: {}", get_tx_status, - http_status_str(response.status), + ccf::http_status_str(response.status), body.dump())); } diff --git a/src/clients/rpc_tls_client.h b/src/clients/rpc_tls_client.h index 3ca1924fc865..3aa237c6145a 100644 --- a/src/clients/rpc_tls_client.h +++ b/src/clients/rpc_tls_client.h @@ -28,7 +28,7 @@ namespace client struct Response { size_t id; - http_status status; + ccf::http_status status; ccf::http::HeaderMap headers; std::vector body; }; @@ -231,7 +231,7 @@ namespace client } virtual void handle_response( - http_status status, + ccf::http_status status, ccf::http::HeaderMap&& headers, std::vector&& body) override { diff --git a/src/common/configuration.h b/src/common/configuration.h index 7ea0eb9e5109..cde57c319e3a 100644 --- a/src/common/configuration.h +++ b/src/common/configuration.h @@ -9,27 +9,19 @@ #include "ccf/ds/unit_strings.h" #include "ccf/node/startup_config.h" #include "ccf/pal/attestation_sev_snp_endorsements.h" +#include "ccf/service/consensus_type.h" #include "ccf/service/node_info_network.h" +#include "ccf/service/reconfiguration_type.h" #include "ccf/service/tables/members.h" #include "common/enclave_interface_types.h" #include "consensus/consensus_types.h" #include "ds/oversized.h" -#include "enclave/consensus_type.h" -#include "enclave/reconfiguration_type.h" #include "service/tables/config.h" #include #include #include -DECLARE_JSON_ENUM( - LoggerLevel, - {{LoggerLevel::TRACE, "Trace"}, - {LoggerLevel::DEBUG, "Debug"}, - {LoggerLevel::INFO, "Info"}, - {LoggerLevel::FAIL, "Fail"}, - {LoggerLevel::FATAL, "Fatal"}}); - DECLARE_JSON_ENUM( StartType, {{StartType::Start, "Start"}, @@ -51,75 +43,87 @@ struct EnclaveConfig static constexpr auto node_to_node_interface_name = "node_to_node_interface"; -DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(CCFConfig::NodeCertificateInfo); -DECLARE_JSON_REQUIRED_FIELDS(CCFConfig::NodeCertificateInfo) -DECLARE_JSON_OPTIONAL_FIELDS( - CCFConfig::NodeCertificateInfo, - subject_name, - subject_alt_names, - curve_id, - initial_validity_days); - -DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(CCFConfig::LedgerSignatures); -DECLARE_JSON_REQUIRED_FIELDS(CCFConfig::LedgerSignatures); -DECLARE_JSON_OPTIONAL_FIELDS(CCFConfig::LedgerSignatures, tx_count, delay); - -DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(CCFConfig::JWT); -DECLARE_JSON_REQUIRED_FIELDS(CCFConfig::JWT); -DECLARE_JSON_OPTIONAL_FIELDS(CCFConfig::JWT, key_refresh_interval); - -DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(CCFConfig::Attestation::Environment); -DECLARE_JSON_REQUIRED_FIELDS(CCFConfig::Attestation::Environment); -DECLARE_JSON_OPTIONAL_FIELDS( - CCFConfig::Attestation::Environment, security_policy, uvm_endorsements); - -DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(CCFConfig::Attestation); -DECLARE_JSON_REQUIRED_FIELDS(CCFConfig::Attestation); -DECLARE_JSON_OPTIONAL_FIELDS( - CCFConfig::Attestation, - snp_endorsements_servers, - environment, - snp_security_policy_file, - snp_uvm_endorsements_file); - -DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(CCFConfig); -DECLARE_JSON_REQUIRED_FIELDS(CCFConfig, network); -DECLARE_JSON_OPTIONAL_FIELDS( - CCFConfig, - worker_threads, - node_certificate, - consensus, - ledger_signatures, - jwt, - attestation, - node_to_node_message_limit, - historical_cache_soft_limit); - -DECLARE_JSON_TYPE(StartupConfig::Start); -DECLARE_JSON_REQUIRED_FIELDS( - StartupConfig::Start, members, constitution, service_configuration); - -DECLARE_JSON_TYPE(StartupConfig::Join); -DECLARE_JSON_REQUIRED_FIELDS( - StartupConfig::Join, - target_rpc_address, - retry_timeout, - service_cert, - follow_redirect); - -DECLARE_JSON_TYPE(StartupConfig::Recover); -DECLARE_JSON_REQUIRED_FIELDS(StartupConfig::Recover, previous_service_identity); - -DECLARE_JSON_TYPE_WITH_BASE(StartupConfig, CCFConfig); -DECLARE_JSON_REQUIRED_FIELDS( - StartupConfig, - startup_host_time, - snapshot_tx_interval, - initial_service_certificate_validity_days, - service_subject_name, - cose_signatures, - service_data, - node_data, - start, - join, - recover); +namespace ccf +{ + DECLARE_JSON_ENUM( + LoggerLevel, + {{LoggerLevel::TRACE, "Trace"}, + {LoggerLevel::DEBUG, "Debug"}, + {LoggerLevel::INFO, "Info"}, + {LoggerLevel::FAIL, "Fail"}, + {LoggerLevel::FATAL, "Fatal"}}); + + DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(CCFConfig::NodeCertificateInfo); + DECLARE_JSON_REQUIRED_FIELDS(CCFConfig::NodeCertificateInfo) + DECLARE_JSON_OPTIONAL_FIELDS( + CCFConfig::NodeCertificateInfo, + subject_name, + subject_alt_names, + curve_id, + initial_validity_days); + + DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(CCFConfig::LedgerSignatures); + DECLARE_JSON_REQUIRED_FIELDS(CCFConfig::LedgerSignatures); + DECLARE_JSON_OPTIONAL_FIELDS(CCFConfig::LedgerSignatures, tx_count, delay); + + DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(CCFConfig::JWT); + DECLARE_JSON_REQUIRED_FIELDS(CCFConfig::JWT); + DECLARE_JSON_OPTIONAL_FIELDS(CCFConfig::JWT, key_refresh_interval); + + DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(CCFConfig::Attestation::Environment); + DECLARE_JSON_REQUIRED_FIELDS(CCFConfig::Attestation::Environment); + DECLARE_JSON_OPTIONAL_FIELDS( + CCFConfig::Attestation::Environment, security_policy, uvm_endorsements); + + DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(CCFConfig::Attestation); + DECLARE_JSON_REQUIRED_FIELDS(CCFConfig::Attestation); + DECLARE_JSON_OPTIONAL_FIELDS( + CCFConfig::Attestation, + snp_endorsements_servers, + environment, + snp_security_policy_file, + snp_uvm_endorsements_file); + + DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(CCFConfig); + DECLARE_JSON_REQUIRED_FIELDS(CCFConfig, network); + DECLARE_JSON_OPTIONAL_FIELDS( + CCFConfig, + worker_threads, + node_certificate, + consensus, + ledger_signatures, + jwt, + attestation, + node_to_node_message_limit, + historical_cache_soft_limit); + + DECLARE_JSON_TYPE(StartupConfig::Start); + DECLARE_JSON_REQUIRED_FIELDS( + StartupConfig::Start, members, constitution, service_configuration); + + DECLARE_JSON_TYPE(StartupConfig::Join); + DECLARE_JSON_REQUIRED_FIELDS( + StartupConfig::Join, + target_rpc_address, + retry_timeout, + service_cert, + follow_redirect); + + DECLARE_JSON_TYPE(StartupConfig::Recover); + DECLARE_JSON_REQUIRED_FIELDS( + StartupConfig::Recover, previous_service_identity); + + DECLARE_JSON_TYPE_WITH_BASE(StartupConfig, CCFConfig); + DECLARE_JSON_REQUIRED_FIELDS( + StartupConfig, + startup_host_time, + snapshot_tx_interval, + initial_service_certificate_validity_days, + service_subject_name, + cose_signatures, + service_data, + node_data, + start, + join, + recover); +} diff --git a/src/consensus/aft/raft.h b/src/consensus/aft/raft.h index 46d1844f51d5..033f4ca3c581 100644 --- a/src/consensus/aft/raft.h +++ b/src/consensus/aft/raft.h @@ -5,10 +5,10 @@ #include "ccf/ds/ccf_exception.h" #include "ccf/ds/logger.h" #include "ccf/pal/locking.h" +#include "ccf/service/reconfiguration_type.h" #include "ccf/tx_id.h" #include "ccf/tx_status.h" #include "ds/serialized.h" -#include "enclave/reconfiguration_type.h" #include "impl/state.h" #include "kv/kv_types.h" #include "node/node_client.h" @@ -175,7 +175,7 @@ namespace aft // active configuration. std::unordered_map all_other_nodes; std::unordered_map retired_nodes; - ReconfigurationType reconfiguration_type; + ccf::ReconfigurationType reconfiguration_type; // Node client to trigger submission of RPC requests std::shared_ptr node_client; @@ -218,8 +218,8 @@ namespace aft bool public_only_ = false, ccf::kv::MembershipState initial_membership_state_ = ccf::kv::MembershipState::Active, - ReconfigurationType reconfiguration_type_ = - ReconfigurationType::ONE_TRANSACTION) : + ccf::ReconfigurationType reconfiguration_type_ = + ccf::ReconfigurationType::ONE_TRANSACTION) : store(std::move(store_)), timeout_elapsed(0), diff --git a/src/consensus/aft/test/driver.cpp b/src/consensus/aft/test/driver.cpp index c85802a43501..1bae98be99a1 100644 --- a/src/consensus/aft/test/driver.cpp +++ b/src/consensus/aft/test/driver.cpp @@ -44,7 +44,7 @@ int main(int argc, char** argv) #else ccf::logger::config::add_text_console_logger(); #endif - ccf::logger::config::level() = LoggerLevel::DEBUG; + ccf::logger::config::level() = ccf::LoggerLevel::DEBUG; threading::ThreadMessaging::init(1); diff --git a/src/consensus/aft/test/main.cpp b/src/consensus/aft/test/main.cpp index e3a9bac2c6d5..8bdf43430014 100644 --- a/src/consensus/aft/test/main.cpp +++ b/src/consensus/aft/test/main.cpp @@ -780,7 +780,7 @@ DOCTEST_TEST_CASE("Recv append entries logic" * doctest::test_suite("multiple")) DOCTEST_TEST_CASE("Exceed append entries limit") { - ccf::logger::config::level() = LoggerLevel::INFO; + ccf::logger::config::level() = ccf::LoggerLevel::INFO; ccf::NodeId node_id0 = ccf::kv::test::PrimaryNodeId; ccf::NodeId node_id1 = ccf::kv::test::FirstBackupNodeId; diff --git a/src/consensus/consensus_types.h b/src/consensus/consensus_types.h index 1c3ac2bf53d9..d5ff23a82576 100644 --- a/src/consensus/consensus_types.h +++ b/src/consensus/consensus_types.h @@ -4,9 +4,9 @@ #include "ccf/ds/unit_strings.h" #include "ccf/service/consensus_config.h" +#include "ccf/service/consensus_type.h" #include "ccf/service/tables/nodes.h" #include "ccf/tx_id.h" -#include "enclave/consensus_type.h" #include diff --git a/src/consensus/ledger_enclave.h b/src/consensus/ledger_enclave.h index d90c7d1c534e..bb3f708bfc75 100644 --- a/src/consensus/ledger_enclave.h +++ b/src/consensus/ledger_enclave.h @@ -2,8 +2,8 @@ // Licensed under the Apache 2.0 License. #pragma once -#include "ccf/ccf_assert.h" #include "consensus/ledger_enclave_types.h" +#include "ds/ccf_assert.h" #include "ds/serialized.h" #include "kv/kv_types.h" #include "kv/serialised_entry_format.h" diff --git a/include/ccf/ccf_assert.h b/src/ds/ccf_assert.h similarity index 100% rename from include/ccf/ccf_assert.h rename to src/ds/ccf_assert.h diff --git a/src/ds/champ_map.h b/src/ds/champ_map.h index 0334b8b4f450..420244837fda 100644 --- a/src/ds/champ_map.h +++ b/src/ds/champ_map.h @@ -2,8 +2,8 @@ // Licensed under the Apache 2.0 License. #pragma once -#include "ccf/ccf_assert.h" #include "ccf/ds/hash.h" +#include "ds/ccf_assert.h" #include "ds/map_serializers.h" #include diff --git a/src/ds/map_serializers.h b/src/ds/map_serializers.h index fbaaaea7ae37..80dcea36261c 100644 --- a/src/ds/map_serializers.h +++ b/src/ds/map_serializers.h @@ -2,7 +2,7 @@ // Licensed under the Apache 2.0 License. #pragma once -#include "ccf/ccf_assert.h" +#include "ds/ccf_assert.h" #include "ds/serialized.h" #include diff --git a/src/ds/test/logger_bench.cpp b/src/ds/test/logger_bench.cpp index 8eff56c00306..d453bd559a4e 100644 --- a/src/ds/test/logger_bench.cpp +++ b/src/ds/test/logger_bench.cpp @@ -51,7 +51,7 @@ static void log_accepted(picobench::state& s) { prepare_loggers(); - ccf::logger::config::level() = LoggerLevel::DEBUG; + ccf::logger::config::level() = ccf::LoggerLevel::DEBUG; { picobench::scope scope(s); @@ -69,7 +69,7 @@ static void log_accepted_fmt(picobench::state& s) { prepare_loggers(); - ccf::logger::config::level() = LoggerLevel::DEBUG; + ccf::logger::config::level() = ccf::LoggerLevel::DEBUG; { picobench::scope scope(s); @@ -87,7 +87,7 @@ static void log_rejected(picobench::state& s) { prepare_loggers(); - ccf::logger::config::level() = LoggerLevel::FAIL; + ccf::logger::config::level() = ccf::LoggerLevel::FAIL; { picobench::scope scope(s); @@ -105,7 +105,7 @@ static void log_rejected_fmt(picobench::state& s) { prepare_loggers(); - ccf::logger::config::level() = LoggerLevel::FAIL; + ccf::logger::config::level() = ccf::LoggerLevel::FAIL; { picobench::scope scope(s); diff --git a/src/ds/test/logger_json_test.cpp b/src/ds/test/logger_json_test.cpp index 3cd242cb5a60..11aa39bbfab7 100644 --- a/src/ds/test/logger_json_test.cpp +++ b/src/ds/test/logger_json_test.cpp @@ -12,7 +12,7 @@ TEST_CASE("Test custom log format") std::string test_log_file = "./test_json_logger.txt"; remove(test_log_file.c_str()); ccf::logger::config::add_json_console_logger(); - ccf::logger::config::level() = LoggerLevel::DEBUG; + ccf::logger::config::level() = ccf::LoggerLevel::DEBUG; std::string log_msg_dbg = "log_msg_dbg"; std::string log_msg_trace = "log_msg_trace"; diff --git a/src/ds/thread_messaging.h b/src/ds/thread_messaging.h index 818dbd98448a..2823d597d1ee 100644 --- a/src/ds/thread_messaging.h +++ b/src/ds/thread_messaging.h @@ -2,9 +2,9 @@ // Licensed under the Apache 2.0 License. #pragma once -#include "ccf/ccf_assert.h" #include "ccf/ds/logger.h" #include "ccf/threading/thread_ids.h" +#include "ds/ccf_assert.h" #include #include diff --git a/src/enclave/client_session.h b/src/enclave/client_session.h index 8baf7ef26fbe..cd1a629c3681 100644 --- a/src/enclave/client_session.h +++ b/src/enclave/client_session.h @@ -11,7 +11,7 @@ namespace ccf { public: using HandleDataCallback = std::function&& body)>; diff --git a/src/enclave/consensus_type.h b/src/enclave/consensus_type.h deleted file mode 100644 index 86204de75db6..000000000000 --- a/src/enclave/consensus_type.h +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the Apache 2.0 License. -#pragma once - -#include "ccf/ds/json.h" -#include "ccf/service/consensus_type.h" - -DECLARE_JSON_ENUM( - ConsensusType, {{ConsensusType::CFT, "CFT"}, {ConsensusType::BFT, "BFT"}}) diff --git a/src/enclave/enclave.h b/src/enclave/enclave.h index 02ddd02f3819..1ab667d13720 100644 --- a/src/enclave/enclave.h +++ b/src/enclave/enclave.h @@ -219,7 +219,7 @@ namespace ccf CreateNodeStatus create_new_node( StartType start_type_, - StartupConfig&& ccf_config_, + ccf::StartupConfig&& ccf_config_, std::vector&& startup_snapshot, uint8_t* node_cert, size_t node_cert_size, diff --git a/src/enclave/interface.h b/src/enclave/interface.h index 096385e96d57..29451f670257 100644 --- a/src/enclave/interface.h +++ b/src/enclave/interface.h @@ -38,7 +38,7 @@ DECLARE_RINGBUFFER_MESSAGE_PAYLOAD( std::chrono::microseconds::rep, std::string, size_t, - LoggerLevel, + ccf::LoggerLevel, std::string, uint16_t, std::string); diff --git a/src/enclave/main.cpp b/src/enclave/main.cpp index 04944823b967..4aec4bbe9460 100644 --- a/src/enclave/main.cpp +++ b/src/enclave/main.cpp @@ -72,7 +72,7 @@ extern "C" size_t enclave_version_size, size_t* enclave_version_len, StartType start_type, - LoggerLevel enclave_log_level, + ccf::LoggerLevel enclave_log_level, size_t num_worker_threads, void* time_location) { @@ -215,7 +215,7 @@ extern "C" ccf::pal::speculation_barrier(); - StartupConfig cc = + ccf::StartupConfig cc = nlohmann::json::parse(ccf_config, ccf_config + ccf_config_size); // 2-tx reconfiguration is currently experimental, disable it in release @@ -223,7 +223,7 @@ extern "C" if ( cc.start.service_configuration.reconfiguration_type.has_value() && cc.start.service_configuration.reconfiguration_type.value() != - ReconfigurationType::ONE_TRANSACTION) + ccf::ReconfigurationType::ONE_TRANSACTION) { LOG_FAIL_FMT( "2TX reconfiguration is experimental, disabled in release mode"); diff --git a/src/enclave/reconfiguration_type.h b/src/enclave/reconfiguration_type.h deleted file mode 100644 index 820bf9ce9492..000000000000 --- a/src/enclave/reconfiguration_type.h +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the Apache 2.0 License. -#pragma once - -#include "ccf/ds/json.h" -#include "ccf/service/reconfiguration_type.h" - -DECLARE_JSON_ENUM( - ReconfigurationType, - {{ReconfigurationType::ONE_TRANSACTION, "OneTransaction"}, - {ReconfigurationType::TWO_TRANSACTION, "TwoTransaction"}}) diff --git a/src/enclave/virtual_enclave.h b/src/enclave/virtual_enclave.h index 9bafc2b92d15..5e2f010507c8 100644 --- a/src/enclave/virtual_enclave.h +++ b/src/enclave/virtual_enclave.h @@ -6,8 +6,8 @@ # error Should only be included in cchost builds with virtual support #endif +#include "ccf/service/consensus_type.h" #include "common/enclave_interface_types.h" -#include "consensus_type.h" #include #include @@ -115,7 +115,7 @@ extern "C" size_t enclave_version_size, size_t* enclave_version_len, StartType start_type, - LoggerLevel enclave_log_level, + ccf::LoggerLevel enclave_log_level, size_t num_worker_thread, void* time_location) { @@ -135,7 +135,7 @@ extern "C" size_t, size_t*, StartType, - LoggerLevel, + ccf::LoggerLevel, size_t, void*); diff --git a/src/endpoints/endpoint.cpp b/src/endpoints/endpoint.cpp index f0a2bc08017d..2acfcf23daf7 100644 --- a/src/endpoints/endpoint.cpp +++ b/src/endpoints/endpoint.cpp @@ -3,6 +3,8 @@ #include "ccf/endpoint.h" +#include "ccf/ds/logger.h" + namespace ccf::endpoints { Endpoint& Endpoint::set_openapi_hidden(bool hidden) diff --git a/src/endpoints/json_handler.cpp b/src/endpoints/json_handler.cpp index 6e9a7e76387f..f8cdc1fa54fa 100644 --- a/src/endpoints/json_handler.cpp +++ b/src/endpoints/json_handler.cpp @@ -2,6 +2,7 @@ // Licensed under the Apache 2.0 License. #include "ccf/json_handler.h" +#include "ccf/ds/logger.h" #include "ccf/http_consts.h" #include "ccf/odata_error.h" #include "ccf/redirect.h" @@ -116,14 +117,14 @@ namespace ccf } jsonhandler::JsonAdapterResponse make_error( - http_status status, const std::string& code, const std::string& msg) + ccf::http_status status, const std::string& code, const std::string& msg) { LOG_DEBUG_FMT( "Frontend error: status={} code={} msg={}", status, code, msg); return ErrorDetails{status, code, msg}; } - jsonhandler::JsonAdapterResponse make_redirect(http_status status) + jsonhandler::JsonAdapterResponse make_redirect(ccf::http_status status) { return RedirectDetails{status}; } diff --git a/src/endpoints/test/endpoint_registry.cpp b/src/endpoints/test/endpoint_registry.cpp index a3799ac15633..1df8a9630746 100644 --- a/src/endpoints/test/endpoint_registry.cpp +++ b/src/endpoints/test/endpoint_registry.cpp @@ -4,6 +4,7 @@ #include "ccf/endpoint_registry.h" +#include "ccf/ds/logger.h" #include "ds/nonstd.h" #include "endpoint_utils.h" diff --git a/src/endpoints/user_endpoint_registry.cpp b/src/endpoints/user_endpoint_registry.cpp index da69a7adc26a..4bd368bb915f 100644 --- a/src/endpoints/user_endpoint_registry.cpp +++ b/src/endpoints/user_endpoint_registry.cpp @@ -2,6 +2,7 @@ // Licensed under the Apache 2.0 License. #include "ccf/app_interface.h" +#include "ccf/ds/logger.h" #include "ds/actors.h" namespace ccf diff --git a/src/host/configuration.h b/src/host/configuration.h index 31aa4401b9b8..1d39578b3cb8 100644 --- a/src/host/configuration.h +++ b/src/host/configuration.h @@ -57,7 +57,7 @@ namespace host DECLARE_JSON_OPTIONAL_FIELDS( ParsedMemberInfo, encryption_public_key_file, data_json_file); - struct CCHostConfig : CCFConfig + struct CCHostConfig : public ccf::CCFConfig { struct Enclave { @@ -115,7 +115,7 @@ namespace host struct Logging { - LoggerLevel host_level = LoggerLevel::INFO; + ccf::LoggerLevel host_level = ccf::LoggerLevel::INFO; LogFormat format = LogFormat::TEXT; bool operator==(const Logging&) const = default; @@ -230,7 +230,7 @@ namespace host DECLARE_JSON_OPTIONAL_FIELDS( CCHostConfig::Command, service_certificate_file, start, join, recover); - DECLARE_JSON_TYPE_WITH_BASE_AND_OPTIONAL_FIELDS(CCHostConfig, CCFConfig); + DECLARE_JSON_TYPE_WITH_BASE_AND_OPTIONAL_FIELDS(CCHostConfig, ccf::CCFConfig); DECLARE_JSON_REQUIRED_FIELDS(CCHostConfig, enclave, command); DECLARE_JSON_OPTIONAL_FIELDS( CCHostConfig, diff --git a/src/host/enclave.h b/src/host/enclave.h index 5cd23726332c..e87e8d3cfb71 100644 --- a/src/host/enclave.h +++ b/src/host/enclave.h @@ -211,12 +211,12 @@ namespace host CreateNodeStatus create_node( const EnclaveConfig& enclave_config, - const StartupConfig& ccf_config, + const ccf::StartupConfig& ccf_config, std::vector&& startup_snapshot, std::vector& node_cert, std::vector& service_cert, StartType start_type, - LoggerLevel enclave_log_level, + ccf::LoggerLevel enclave_log_level, size_t num_worker_thread, void* time_location) { diff --git a/src/host/main.cpp b/src/host/main.cpp index 614bfecd07d0..5d8ebee8df04 100644 --- a/src/host/main.cpp +++ b/src/host/main.cpp @@ -97,12 +97,13 @@ int main(int argc, char** argv) app.add_flag( "-v, --version", print_version, "Display CCF host version and exit"); - LoggerLevel enclave_log_level = LoggerLevel::INFO; - std::map log_level_options; - for (size_t i = ccf::logger::MOST_VERBOSE; i < LoggerLevel::MAX_LOG_LEVEL; + ccf::LoggerLevel enclave_log_level = ccf::LoggerLevel::INFO; + std::map log_level_options; + for (size_t i = ccf::logger::MOST_VERBOSE; + i < ccf::LoggerLevel::MAX_LOG_LEVEL; ++i) { - const auto l = (LoggerLevel)i; + const auto l = (ccf::LoggerLevel)i; log_level_options[ccf::logger::to_string(l)] = l; } @@ -502,7 +503,7 @@ int main(int argc, char** argv) enclave_config.writer_config = writer_config; - StartupConfig startup_config(config); + ccf::StartupConfig startup_config(config); startup_config.snapshot_tx_interval = config.snapshots.tx_count; diff --git a/src/http/http2_parser.h b/src/http/http2_parser.h index acdb8d7b4089..e4f167d70f37 100644 --- a/src/http/http2_parser.h +++ b/src/http/http2_parser.h @@ -267,14 +267,15 @@ namespace http2 void submit_response( StreamId stream_id, - http_status status, + ccf::http_status status, const ccf::http::HeaderMap& base_headers, const ccf::http::HeaderMap& extra_headers = {}) { std::vector hdrs = {}; auto status_str = fmt::format( - "{}", static_cast::type>(status)); + "{}", + static_cast::type>(status)); hdrs.emplace_back( make_nv(ccf::http2::headers::STATUS, status_str.data())); @@ -325,7 +326,7 @@ namespace http2 void respond( StreamId stream_id, - http_status status, + ccf::http_status status, const ccf::http::HeaderMap& headers, ccf::http::HeaderMap&& trailers, std::span body) @@ -374,7 +375,7 @@ namespace http2 void start_stream( StreamId stream_id, - http_status status, + ccf::http_status status, const ccf::http::HeaderMap& headers) { LOG_TRACE_FMT( @@ -559,12 +560,12 @@ namespace http2 auto& headers = stream_data->incoming.headers; - http_status status = {}; + ccf::http_status status = {}; { const auto status_it = headers.find(ccf::http2::headers::STATUS); if (status_it != headers.end()) { - status = http_status(std::stoi(status_it->second)); + status = ccf::http_status(std::stoi(status_it->second)); } } diff --git a/src/http/http2_session.h b/src/http/http2_session.h index 89b668d6a5e9..d864dd94f779 100644 --- a/src/http/http2_session.h +++ b/src/http/http2_session.h @@ -117,7 +117,7 @@ namespace http {} bool send_response( - http_status status_code, + ccf::http_status status_code, ccf::http::HeaderMap&& headers, ccf::http::HeaderMap&& trailers, std::span body) override @@ -143,7 +143,7 @@ namespace http } bool start_stream( - http_status status, const ccf::http::HeaderMap& headers) override + ccf::http_status status, const ccf::http::HeaderMap& headers) override { auto sp = server_parser.lock(); if (sp) @@ -474,7 +474,7 @@ namespace http } bool send_response( - http_status status_code, + ccf::http_status status_code, ccf::http::HeaderMap&& headers, ccf::http::HeaderMap&& trailers, std::span body) override @@ -485,7 +485,7 @@ namespace http } bool start_stream( - http_status status, const ccf::http::HeaderMap& headers) override + ccf::http_status status, const ccf::http::HeaderMap& headers) override { return get_stream_responder(http2::DEFAULT_STREAM_ID) ->start_stream(status, headers); @@ -565,7 +565,7 @@ namespace http } void handle_response( - http_status status, + ccf::http_status status, ccf::http::HeaderMap&& headers, std::vector&& body) override { diff --git a/src/http/http_builder.h b/src/http/http_builder.h index 3ce285749152..7ca6171e12d5 100644 --- a/src/http/http_builder.h +++ b/src/http/http_builder.h @@ -187,10 +187,10 @@ namespace http class Response : public Message { private: - http_status status; + ccf::http_status status; public: - Response(http_status s = HTTP_STATUS_OK) : status(s) {} + Response(ccf::http_status s = HTTP_STATUS_OK) : status(s) {} std::vector build_response(bool header_only = false) const { @@ -204,7 +204,7 @@ namespace http "\r\n" "{}", status, - http_status_str(status), + ccf::http_status_str(status), get_header_string(headers), body_view); diff --git a/src/http/http_parser.h b/src/http/http_parser.h index 7094f60b7fc6..c4ea34dba0aa 100644 --- a/src/http/http_parser.h +++ b/src/http/http_parser.h @@ -68,7 +68,7 @@ namespace http return s; } - inline bool status_success(http_status status) + inline bool status_success(ccf::http_status status) { return status >= 200 && status < 300; } @@ -102,7 +102,7 @@ namespace http public: struct Response { - http_status status; + ccf::http_status status; ccf::http::HeaderMap headers; std::vector body; }; @@ -110,7 +110,7 @@ namespace http std::queue received; virtual void handle_response( - http_status status, + ccf::http_status status, ccf::http::HeaderMap&& headers, std::vector&& body) override { @@ -462,7 +462,7 @@ namespace http void handle_completed_message() override { proc.handle_response( - http_status(parser.status_code), + ccf::http_status(parser.status_code), std::move(headers), std::move(body_buf)); } diff --git a/src/http/http_proc.h b/src/http/http_proc.h index efbfc4028112..273306d9be56 100644 --- a/src/http/http_proc.h +++ b/src/http/http_proc.h @@ -31,7 +31,7 @@ namespace http { public: virtual void handle_response( - http_status status, + ccf::http_status status, ccf::http::HeaderMap&& headers, std::vector&& body) = 0; }; diff --git a/src/http/http_rpc_context.h b/src/http/http_rpc_context.h index af808a96c9e7..6f663dd16691 100644 --- a/src/http/http_rpc_context.h +++ b/src/http/http_rpc_context.h @@ -29,7 +29,7 @@ namespace http } inline std::vector error( - http_status status, const std::string& code, std::string&& msg) + ccf::http_status status, const std::string& code, std::string&& msg) { return error({status, code, std::move(msg)}); } @@ -56,7 +56,7 @@ namespace http ccf::http::HeaderMap response_headers; ccf::http::HeaderMap response_trailers; std::vector response_body = {}; - http_status response_status = HTTP_STATUS_OK; + ccf::http_status response_status = HTTP_STATUS_OK; bool serialised = false; @@ -136,7 +136,7 @@ namespace http return response_body; } - http_status get_response_http_status() const + ccf::http_status get_response_http_status() const { return response_status; } @@ -237,7 +237,7 @@ namespace http virtual void set_response_status(int status) override { - response_status = (http_status)status; + response_status = (ccf::http_status)status; } virtual int get_response_status() const override diff --git a/src/http/http_session.h b/src/http/http_session.h index dace8fb8d0fa..eeccb399cb73 100644 --- a/src/http/http_session.h +++ b/src/http/http_session.h @@ -268,7 +268,7 @@ namespace http } bool send_response( - http_status status_code, + ccf::http_status status_code, ccf::http::HeaderMap&& headers, ccf::http::HeaderMap&& trailers, std::span body) override @@ -291,7 +291,7 @@ namespace http } bool start_stream( - http_status status, const ccf::http::HeaderMap& headers) override + ccf::http_status status, const ccf::http::HeaderMap& headers) override { throw std::logic_error("Not implemented!"); } @@ -380,7 +380,7 @@ namespace http } void handle_response( - http_status status, + ccf::http_status status, ccf::http::HeaderMap&& headers, std::vector&& body) override { @@ -504,7 +504,7 @@ namespace http } void handle_response( - http_status status, + ccf::http_status status, ccf::http::HeaderMap&& headers, std::vector&& body) override { diff --git a/src/http/test/http_test.cpp b/src/http/test/http_test.cpp index 1c573984cbe4..b4280a8a753c 100644 --- a/src/http/test/http_test.cpp +++ b/src/http/test/http_test.cpp @@ -277,7 +277,7 @@ DOCTEST_TEST_CASE("URL parsing") DOCTEST_TEST_CASE("Pessimal transport") { - ccf::logger::config::level() = LoggerLevel::INFO; + ccf::logger::config::level() = ccf::LoggerLevel::INFO; const ccf::http::HeaderMap h1 = {{"foo", "bar"}, {"baz", "42"}}; const ccf::http::HeaderMap h2 = { diff --git a/src/js/modules/kv_bytecode_module_loader.h b/src/js/modules/kv_bytecode_module_loader.h index f9209ff3e119..c2bed97dd8a1 100644 --- a/src/js/modules/kv_bytecode_module_loader.h +++ b/src/js/modules/kv_bytecode_module_loader.h @@ -2,6 +2,7 @@ // Licensed under the Apache 2.0 License. #pragma once +#include "ccf/ds/logger.h" #include "ccf/js/modules/module_loader_interface.h" #include "ccf/service/tables/modules.h" #include "ccf/tx.h" diff --git a/src/js/modules/kv_module_loader.h b/src/js/modules/kv_module_loader.h index fc76dcff7595..71bbab8de9ec 100644 --- a/src/js/modules/kv_module_loader.h +++ b/src/js/modules/kv_module_loader.h @@ -2,6 +2,7 @@ // Licensed under the Apache 2.0 License. #pragma once +#include "ccf/ds/logger.h" #include "ccf/js/modules/module_loader_interface.h" #include "ccf/service/tables/modules.h" #include "ccf/tx.h" diff --git a/src/kv/generic_serialise_wrapper.h b/src/kv/generic_serialise_wrapper.h index 1fe9722b011a..f0e983fb723a 100644 --- a/src/kv/generic_serialise_wrapper.h +++ b/src/kv/generic_serialise_wrapper.h @@ -2,8 +2,8 @@ // Licensed under the Apache 2.0 License. #pragma once -#include "ccf/ccf_assert.h" #include "ccf/kv/serialisers/serialised_entry.h" +#include "ds/ccf_assert.h" #include "kv_types.h" #include "node/rpc/claims.h" #include "serialised_entry_format.h" diff --git a/src/kv/kv_types.h b/src/kv/kv_types.h index 14c3f77c2992..3ed6c9289c67 100644 --- a/src/kv/kv_types.h +++ b/src/kv/kv_types.h @@ -11,10 +11,10 @@ #include "ccf/kv/hooks.h" #include "ccf/kv/version.h" #include "ccf/node/cose_signatures_config.h" +#include "ccf/service/consensus_type.h" +#include "ccf/service/reconfiguration_type.h" #include "ccf/tx_id.h" #include "crypto/openssl/key_pair.h" -#include "enclave/consensus_type.h" -#include "enclave/reconfiguration_type.h" #include "serialiser_declare.h" #include @@ -194,7 +194,7 @@ namespace ccf::kv std::optional retirement_phase = std::nullopt; std::optional> learners = std::nullopt; - std::optional reconfiguration_type = std::nullopt; + std::optional reconfiguration_type = std::nullopt; std::optional primary_id = std::nullopt; ccf::View current_view = 0; bool ticking = false; @@ -221,7 +221,7 @@ namespace ccf::kv struct ConsensusParameters { - ReconfigurationType reconfiguration_type; + ccf::ReconfigurationType reconfiguration_type; }; class ConfigurableConsensus diff --git a/src/kv/serialised_entry_format.h b/src/kv/serialised_entry_format.h index 0426861f9d28..5641641445cc 100644 --- a/src/kv/serialised_entry_format.h +++ b/src/kv/serialised_entry_format.h @@ -2,7 +2,7 @@ // Licensed under the Apache 2.0 License. #pragma once -#include "ccf/ccf_assert.h" +#include "ds/ccf_assert.h" #include diff --git a/src/kv/test/kv_bench.cpp b/src/kv/test/kv_bench.cpp index 5107156c1e45..673ce53f2a1a 100644 --- a/src/kv/test/kv_bench.cpp +++ b/src/kv/test/kv_bench.cpp @@ -54,7 +54,7 @@ std::string build_map_name( template static void serialise(picobench::state& s) { - ccf::logger::config::level() = LoggerLevel::INFO; + ccf::logger::config::level() = ccf::LoggerLevel::INFO; ccf::kv::Store kv_store; auto secrets = create_ledger_secrets(); @@ -86,7 +86,7 @@ static void serialise(picobench::state& s) template static void deserialise(picobench::state& s) { - ccf::logger::config::level() = LoggerLevel::INFO; + ccf::logger::config::level() = ccf::LoggerLevel::INFO; ccf::kv::Store kv_store; ccf::kv::Store kv_store2; @@ -127,7 +127,7 @@ static void deserialise(picobench::state& s) template static void commit_latency(picobench::state& s) { - ccf::logger::config::level() = LoggerLevel::INFO; + ccf::logger::config::level() = ccf::LoggerLevel::INFO; ccf::kv::Store kv_store; auto secrets = create_ledger_secrets(); @@ -165,7 +165,7 @@ static void commit_latency(picobench::state& s) template static void ser_snap(picobench::state& s) { - ccf::logger::config::level() = LoggerLevel::INFO; + ccf::logger::config::level() = ccf::LoggerLevel::INFO; ccf::kv::Store kv_store; auto secrets = create_ledger_secrets(); @@ -203,7 +203,7 @@ static void ser_snap(picobench::state& s) template static void des_snap(picobench::state& s) { - ccf::logger::config::level() = LoggerLevel::INFO; + ccf::logger::config::level() = ccf::LoggerLevel::INFO; ccf::kv::Store kv_store; ccf::kv::Store kv_store2; diff --git a/src/kv/test/kv_contention.cpp b/src/kv/test/kv_contention.cpp index 272933ec38e7..f7b86da78e7b 100644 --- a/src/kv/test/kv_contention.cpp +++ b/src/kv/test/kv_contention.cpp @@ -36,7 +36,7 @@ class SlowStubConsensus : public ccf::kv::test::StubConsensus DOCTEST_TEST_CASE("Concurrent kv access" * doctest::test_suite("concurrency")) { - ccf::logger::config::level() = LoggerLevel::INFO; + ccf::logger::config::level() = ccf::LoggerLevel::INFO; // Multiple threads write random entries into random tables, and attempt to // commit them. A single thread continually compacts the kv to the latest @@ -252,7 +252,7 @@ DOCTEST_TEST_CASE("Concurrent kv access" * doctest::test_suite("concurrency")) DOCTEST_TEST_CASE( "get_version_of_previous_write ordering" * doctest::test_suite("concurrency")) { - ccf::logger::config::level() = LoggerLevel::INFO; + ccf::logger::config::level() = ccf::LoggerLevel::INFO; // Many threads attempt to produce a chain of transactions pointing at the // previous write to a single key, at that key. diff --git a/src/kv/tx.cpp b/src/kv/tx.cpp index 8501efa53954..e266442edd73 100644 --- a/src/kv/tx.cpp +++ b/src/kv/tx.cpp @@ -3,7 +3,7 @@ #include "ccf/tx.h" -#include "ccf/ccf_assert.h" +#include "ds/ccf_assert.h" #include "kv/compacted_version_conflict.h" #include "kv/kv_types.h" #include "kv/tx_pimpl.h" diff --git a/src/node/acme_challenge_frontend.h b/src/node/acme_challenge_frontend.h index 7a415db729c2..97304203c24d 100644 --- a/src/node/acme_challenge_frontend.h +++ b/src/node/acme_challenge_frontend.h @@ -19,7 +19,7 @@ namespace ccf get_actor_prefix(ActorsType::acme_challenge), context) { auto handler = [this](auto& ctx) { - http_status response_status = HTTP_STATUS_INTERNAL_SERVER_ERROR; + ccf::http_status response_status = HTTP_STATUS_INTERNAL_SERVER_ERROR; std::string response_body; const auto& path_params = ctx.rpc_ctx->get_request_path_params(); diff --git a/src/node/acme_client.h b/src/node/acme_client.h index c5023349e091..2028ceec2e15 100644 --- a/src/node/acme_client.h +++ b/src/node/acme_client.h @@ -173,14 +173,15 @@ namespace ACME const http::URL& url, http::Request&& req, std::function&&)> - callback) = 0; + ccf::http_status status, + ccf::http::HeaderMap&&, + std::vector&&)> callback) = 0; void make_request( llhttp_method method, const http::URL& url, const std::vector& body, - http_status expected_status, + ccf::http_status expected_status, std::function&)> ok_callback) { @@ -210,7 +211,7 @@ namespace ACME url, std::move(r), [this, expected_status, ok_callback]( - http_status status, + ccf::http_status status, ccf::http::HeaderMap&& headers, std::vector&& data) { for (auto& [k, v] : headers) @@ -260,7 +261,7 @@ namespace ACME llhttp_method method, const http::URL& url, const std::vector& body, - http_status expected_status, + ccf::http_status expected_status, std::function< void(const ccf::http::HeaderMap& headers, const nlohmann::json&)> ok_callback) diff --git a/src/node/ccf_acme_client.h b/src/node/ccf_acme_client.h index 467c4d2923de..fb89afb8791e 100644 --- a/src/node/ccf_acme_client.h +++ b/src/node/ccf_acme_client.h @@ -160,8 +160,8 @@ namespace ccf virtual void on_http_request( const ::http::URL& url, ::http::Request&& req, - std::function< - bool(http_status status, http::HeaderMap&&, std::vector&&)> + std::function&&)> callback) override { auto ca = std::make_shared<::tls::CA>(config.ca_certs, true); @@ -172,7 +172,7 @@ namespace ccf url.host, url.port, [callback]( - http_status status, + ccf::http_status status, http::HeaderMap&& headers, std::vector&& data) { return callback(status, std::move(headers), std::move(data)); diff --git a/src/node/gov/handlers/helpers.h b/src/node/gov/handlers/helpers.h index 1e60e7f793a0..3cbabc9f876f 100644 --- a/src/node/gov/handlers/helpers.h +++ b/src/node/gov/handlers/helpers.h @@ -22,7 +22,7 @@ namespace ccf::gov::endpoints::detail // and sets the HTTP response static void set_gov_error( const std::shared_ptr& rpc_ctx, - http_status status, + ccf::http_status status, const std::string& code, std::string&& msg) { diff --git a/src/node/historical_queries.h b/src/node/historical_queries.h index 06d822ae357a..23604e5aba83 100644 --- a/src/node/historical_queries.h +++ b/src/node/historical_queries.h @@ -2,10 +2,10 @@ // Licensed under the Apache 2.0 License. #pragma once -#include "ccf/ccf_assert.h" #include "ccf/historical_queries_interface.h" #include "ccf/pal/locking.h" #include "consensus/ledger_enclave_types.h" +#include "ds/ccf_assert.h" #include "kv/store.h" #include "node/encryptor.h" #include "node/history.h" diff --git a/src/node/hooks.h b/src/node/hooks.h index 2ca2536a0e3b..9432c0ba43db 100644 --- a/src/node/hooks.h +++ b/src/node/hooks.h @@ -4,7 +4,7 @@ #include "ccf/ds/logger.h" #include "ccf/service/node_info_network.h" -#include "enclave/reconfiguration_type.h" +#include "ccf/service/reconfiguration_type.h" #include "service/tables/config.h" #include "service/tables/signatures.h" diff --git a/src/node/jwt_key_auto_refresh.h b/src/node/jwt_key_auto_refresh.h index b81129f79b6d..bf679422c673 100644 --- a/src/node/jwt_key_auto_refresh.h +++ b/src/node/jwt_key_auto_refresh.h @@ -137,7 +137,7 @@ namespace ccf void handle_jwt_jwks_response( const std::string& issuer, const std::optional& issuer_constraint, - http_status status, + ccf::http_status status, std::vector&& data) { if (status != HTTP_STATUS_OK) @@ -145,7 +145,7 @@ namespace ccf LOG_FAIL_FMT( "JWT key auto-refresh: Error while requesting JWKS: {} {}{}", status, - http_status_str(status), + ccf::http_status_str(status), data.empty() ? "" : fmt::format(" '{}'", std::string(data.begin(), data.end()))); @@ -193,7 +193,7 @@ namespace ccf void handle_jwt_metadata_response( const std::string& issuer, std::shared_ptr<::tls::CA> ca, - http_status status, + ccf::http_status status, std::vector&& data) { if (status != HTTP_STATUS_OK) @@ -202,7 +202,7 @@ namespace ccf "JWT key auto-refresh: Error while requesting OpenID metadata: {} " "{}{}", status, - http_status_str(status), + ccf::http_status_str(status), data.empty() ? "" : fmt::format(" '{}'", std::string(data.begin(), data.end()))); @@ -269,7 +269,9 @@ namespace ccf std::string(jwks_url.host), std::string(jwks_url_port), [this, issuer, issuer_constraint]( - http_status status, http::HeaderMap&&, std::vector&& data) { + ccf::http_status status, + http::HeaderMap&&, + std::vector&& data) { handle_jwt_jwks_response( issuer, issuer_constraint, status, std::move(data)); return true; @@ -336,7 +338,7 @@ namespace ccf std::string(metadata_url.host), std::string(metadata_url_port), [this, issuer, ca]( - http_status status, + ccf::http_status status, ccf::http::HeaderMap&&, std::vector&& data) { handle_jwt_metadata_response(issuer, ca, status, std::move(data)); diff --git a/src/node/ledger_secrets.h b/src/node/ledger_secrets.h index c30223d876d9..318f37086156 100644 --- a/src/node/ledger_secrets.h +++ b/src/node/ledger_secrets.h @@ -5,6 +5,7 @@ #include "ccf/crypto/symmetric_key.h" #include "ccf/pal/locking.h" #include "ccf/tx.h" +#include "ds/ccf_assert.h" #include "kv/kv_types.h" #include "ledger_secret.h" #include "service/tables/secrets.h" diff --git a/src/node/node_state.h b/src/node/node_state.h index d5cc300c5c34..92ef948ea41f 100644 --- a/src/node/node_state.h +++ b/src/node/node_state.h @@ -13,6 +13,7 @@ #include "ccf/pal/locking.h" #include "ccf/pal/platform.h" #include "ccf/service/node_info_network.h" +#include "ccf/service/reconfiguration_type.h" #include "ccf/service/tables/acme_certificates.h" #include "ccf/service/tables/service.h" #include "ccf_acme_client.h" @@ -20,7 +21,6 @@ #include "consensus/ledger_enclave.h" #include "crypto/certs.h" #include "ds/state_machine.h" -#include "enclave/reconfiguration_type.h" #include "enclave/rpc_sessions.h" #include "encryptor.h" #include "history.h" @@ -91,7 +91,7 @@ namespace ccf std::optional endorsed_node_cert = std::nullopt; QuoteInfo quote_info; pal::PlatformAttestationMeasurement node_measurement; - StartupConfig config; + ccf::StartupConfig config; std::optional snp_uvm_endorsements = std::nullopt; std::vector startup_snapshot; std::shared_ptr quote_endorsements_client = @@ -462,7 +462,7 @@ namespace ccf NodeCreateInfo create( StartType start_type_, - StartupConfig&& config_, + ccf::StartupConfig&& config_, std::vector&& startup_snapshot_) { std::lock_guard guard(lock); @@ -511,7 +511,7 @@ namespace ccf setup_consensus( ServiceStatus::OPENING, - ReconfigurationType::ONE_TRANSACTION, + ccf::ReconfigurationType::ONE_TRANSACTION, false, endorsed_node_cert); @@ -589,7 +589,7 @@ namespace ccf target_host, target_port, [this]( - http_status status, + ccf::http_status status, http::HeaderMap&& headers, std::vector&& data) { std::lock_guard guard(lock); @@ -629,7 +629,7 @@ namespace ccf LOG_FAIL_FMT( "An error occurred while joining the network: {} {}{}", status, - http_status_str(status), + ccf::http_status_str(status), data.empty() ? "" : fmt::format(" '{}'", std::string(data.begin(), data.end()))); @@ -670,7 +670,7 @@ namespace ccf history->set_service_signing_identity( network.identity->get_key_pair(), resp.network_info->cose_signatures_config.value_or( - COSESignaturesConfig{})); + ccf::COSESignaturesConfig{})); ccf::crypto::Pem n2n_channels_cert; if (!resp.network_info->endorsed_certificate.has_value()) @@ -684,7 +684,7 @@ namespace ccf setup_consensus( resp.network_info->service_status.value_or( ServiceStatus::OPENING), - ReconfigurationType::ONE_TRANSACTION, + ccf::ReconfigurationType::ONE_TRANSACTION, resp.network_info->public_only, n2n_channels_cert); auto_refresh_jwt_keys(); @@ -1059,7 +1059,9 @@ namespace ccf auto service_config = tx.ro(network.config)->get(); setup_consensus( - ServiceStatus::OPENING, ReconfigurationType::ONE_TRANSACTION, true); + ServiceStatus::OPENING, + ccf::ReconfigurationType::ONE_TRANSACTION, + true); auto_refresh_jwt_keys(); LOG_DEBUG_FMT("Restarting consensus at view: {} seqno: {}", view, index); @@ -1978,7 +1980,7 @@ namespace ccf LOG_FAIL_FMT( "Create response is error: {} {}", status, - http_status_str((http_status)status)); + ccf::http_status_str((ccf::http_status)status)); return false; } @@ -2526,7 +2528,7 @@ namespace ccf void setup_consensus( ServiceStatus service_status, - ReconfigurationType reconfiguration_type, + ccf::ReconfigurationType reconfiguration_type, bool public_only = false, const std::optional& endorsed_node_certificate_ = std::nullopt) @@ -2702,7 +2704,7 @@ namespace ccf n2n_channels->set_idle_timeout(idle_timeout); } - virtual const StartupConfig& get_node_config() const override + virtual const ccf::StartupConfig& get_node_config() const override { return config; } @@ -2723,8 +2725,8 @@ namespace ccf virtual void make_http_request( const ::http::URL& url, ::http::Request&& req, - std::function< - bool(http_status status, http::HeaderMap&&, std::vector&&)> + std::function&&)> callback, const std::vector& ca_certs = {}, const std::string& app_protocol = "HTTP1", @@ -2747,7 +2749,7 @@ namespace ccf url.host, url.port, [callback]( - http_status status, + ccf::http_status status, http::HeaderMap&& headers, std::vector&& data) { return callback(status, std::move(headers), std::move(data)); diff --git a/src/node/quote_endorsements_client.h b/src/node/quote_endorsements_client.h index 0d0c2594a39a..9e24649160f8 100644 --- a/src/node/quote_endorsements_client.h +++ b/src/node/quote_endorsements_client.h @@ -240,7 +240,7 @@ namespace ccf endpoint.host, endpoint.port, [this, server, endpoint]( - http_status status, + ccf::http_status status, http::HeaderMap&& headers, std::vector&& data) { last_received_request_id++; diff --git a/src/node/rpc/member_frontend.h b/src/node/rpc/member_frontend.h index 438b8709b45f..05086a79eb71 100644 --- a/src/node/rpc/member_frontend.h +++ b/src/node/rpc/member_frontend.h @@ -98,7 +98,7 @@ namespace ccf // and sets the HTTP response static void set_gov_error( const std::shared_ptr& rpc_ctx, - http_status status, + ccf::http_status status, const std::string& code, std::string&& msg) { diff --git a/src/node/rpc/node_call_types.h b/src/node/rpc/node_call_types.h index 63be38ae6b44..ae033f07a8e5 100644 --- a/src/node/rpc/node_call_types.h +++ b/src/node/rpc/node_call_types.h @@ -73,7 +73,7 @@ namespace ccf ccf::TxID create_txid; // Only set on genesis transaction, but not on recovery - std::optional genesis_info = std::nullopt; + std::optional genesis_info = std::nullopt; }; }; diff --git a/src/node/rpc/node_frontend.h b/src/node/rpc/node_frontend.h index c0ace503f12e..4165e090905f 100644 --- a/src/node/rpc/node_frontend.h +++ b/src/node/rpc/node_frontend.h @@ -11,11 +11,11 @@ #include "ccf/odata_error.h" #include "ccf/pal/attestation.h" #include "ccf/pal/mem.h" +#include "ccf/service/reconfiguration_type.h" #include "ccf/version.h" #include "crypto/certs.h" #include "crypto/csr.h" #include "ds/std_formatters.h" -#include "enclave/reconfiguration_type.h" #include "frontend.h" #include "node/network_state.h" #include "node/rpc/jwt_management.h" @@ -266,7 +266,7 @@ namespace ccf const JoinNetworkNodeToNode::In& in, NodeStatus node_status, ServiceStatus service_status, - ReconfigurationType reconfiguration_type) + ccf::ReconfigurationType reconfiguration_type) { auto nodes = tx.rw(network.nodes); auto node_endorsed_certificates = @@ -532,7 +532,7 @@ namespace ccf in, joining_node_status, active_service->status, - ReconfigurationType::ONE_TRANSACTION); + ccf::ReconfigurationType::ONE_TRANSACTION); } // If the service is open, new nodes are first added as pending and @@ -624,7 +624,7 @@ namespace ccf in, NodeStatus::PENDING, active_service->status, - ReconfigurationType::ONE_TRANSACTION); + ccf::ReconfigurationType::ONE_TRANSACTION); } }; make_endpoint("/join", HTTP_POST, json_adapter(accept), no_auth_required) diff --git a/src/node/rpc/node_interface.h b/src/node/rpc/node_interface.h index 06e659a7b066..a7fa33e83404 100644 --- a/src/node/rpc/node_interface.h +++ b/src/node/rpc/node_interface.h @@ -60,7 +60,7 @@ namespace ccf virtual size_t get_jwt_attempts() = 0; virtual ccf::crypto::Pem get_self_signed_certificate() = 0; virtual const ccf::COSESignaturesConfig& get_cose_signatures_config() = 0; - virtual const StartupConfig& get_node_config() const = 0; + virtual const ccf::StartupConfig& get_node_config() const = 0; virtual ccf::crypto::Pem get_network_cert() = 0; virtual void stop_notice() = 0; virtual bool has_received_stop_notice() = 0; @@ -72,8 +72,9 @@ namespace ccf const ::http::URL& url, ::http::Request&& req, std::function&&)> - callback, + ccf::http_status status, + ccf::http::HeaderMap&&, + std::vector&&)> callback, const std::vector& ca_certs = {}, const std::string& app_protocol = "HTTP1", bool use_node_client_certificate = false) = 0; diff --git a/src/node/rpc/rpc_exception.h b/src/node/rpc/rpc_exception.h index b094b31a9dea..0f6fc02ad1b4 100644 --- a/src/node/rpc/rpc_exception.h +++ b/src/node/rpc/rpc_exception.h @@ -14,7 +14,7 @@ namespace ccf ErrorDetails error; RpcException( - http_status status, const std::string& code, std::string&& msg) : + ccf::http_status status, const std::string& code, std::string&& msg) : error{status, code, std::move(msg)} {} diff --git a/src/node/rpc/serialization.h b/src/node/rpc/serialization.h index cc728e57e7dc..36649beebf19 100644 --- a/src/node/rpc/serialization.h +++ b/src/node/rpc/serialization.h @@ -3,8 +3,8 @@ #pragma once #include "ccf/ds/json.h" +#include "ccf/service/consensus_type.h" #include "ccf/service/tables/code_id.h" -#include "enclave/consensus_type.h" #include "enclave/interface.h" #include "node/rpc/call_types.h" diff --git a/src/node/rpc/test/frontend_test.cpp b/src/node/rpc/test/frontend_test.cpp index 9ae433f84540..b598a641912b 100644 --- a/src/node/rpc/test/frontend_test.cpp +++ b/src/node/rpc/test/frontend_test.cpp @@ -135,10 +135,10 @@ class TestJsonWrappedEndpointFunction : public BaseTestFrontend const auto it = params.find("error"); if (it != params.end()) { - const http_status error_code = (*it)["code"]; + const ccf::http_status error_code = (*it)["code"]; const std::string error_msg = (*it)["message"]; - return make_error((http_status)error_code, "Error", error_msg); + return make_error((ccf::http_status)error_code, "Error", error_msg); } return make_success(true); @@ -731,7 +731,7 @@ TEST_CASE("JsonWrappedEndpointFunction") for (const auto err : { HTTP_STATUS_INTERNAL_SERVER_ERROR, HTTP_STATUS_BAD_REQUEST, - (http_status)418 // Teapot + (ccf::http_status)418 // Teapot }) { INFO("Calling failable, with error"); @@ -871,7 +871,7 @@ TEST_CASE("Explicit commitability") for (const auto status : all_statuses) { - INFO(http_status_str(status)); + INFO(ccf::http_status_str(status)); { INFO("Without override..."); @@ -1559,7 +1559,7 @@ TEST_CASE("Manual conflicts") auto call_pausable = [&]( std::shared_ptr session, - http_status expected_status) { + ccf::http_status expected_status) { ccf::crypto::openssl_sha256_init(); auto req = create_simple_request("/pausable"); auto serialized_call = req.build_request(); @@ -1612,7 +1612,7 @@ TEST_CASE("Manual conflicts") auto run_test = [&]( std::function&& read_write_op, std::shared_ptr session = user_session, - http_status expected_status = HTTP_STATUS_OK) { + ccf::http_status expected_status = HTTP_STATUS_OK) { ccf::crypto::openssl_sha256_init(); frontend.registry.before_read.ready = false; frontend.registry.after_read.ready = false; diff --git a/src/node/rpc/test/frontend_test_infra.h b/src/node/rpc/test/frontend_test_infra.h index 16662648781c..f376f493d54d 100644 --- a/src/node/rpc/test/frontend_test_infra.h +++ b/src/node/rpc/test/frontend_test_infra.h @@ -65,7 +65,7 @@ std::string parse_response_body(const TResponse& r) return std::string(r.body.begin(), r.body.end()); } -void check_error(const TResponse& r, http_status expected) +void check_error(const TResponse& r, ccf::http_status expected) { DOCTEST_CHECK(r.status == expected); } diff --git a/src/node/rpc_context_impl.h b/src/node/rpc_context_impl.h index fa09b7ca766e..c1caf53115d8 100644 --- a/src/node/rpc_context_impl.h +++ b/src/node/rpc_context_impl.h @@ -72,7 +72,7 @@ namespace ccf } virtual void set_error( - http_status status, + ccf::http_status status, const std::string& code, std::string&& msg, const std::vector& details = {}) override @@ -90,7 +90,7 @@ namespace ccf } void set_response_json( - const nlohmann::json& body, http_status status) override + const nlohmann::json& body, ccf::http_status status) override { // Set error_handler to replace, to avoid throwing if the error message // contains non-UTF8 characters. Other args are default values diff --git a/src/node/snapshotter.h b/src/node/snapshotter.h index cabc8f371384..69d59fef124c 100644 --- a/src/node/snapshotter.h +++ b/src/node/snapshotter.h @@ -2,11 +2,11 @@ // Licensed under the Apache 2.0 License. #pragma once -#include "ccf/ccf_assert.h" #include "ccf/ds/logger.h" #include "ccf/pal/enclave.h" #include "ccf/pal/locking.h" #include "consensus/ledger_enclave_types.h" +#include "ds/ccf_assert.h" #include "ds/thread_messaging.h" #include "kv/kv_types.h" #include "kv/store.h" diff --git a/src/node/test/history_bench.cpp b/src/node/test/history_bench.cpp index a340280bc125..2bf85d0c4ccc 100644 --- a/src/node/test/history_bench.cpp +++ b/src/node/test/history_bench.cpp @@ -165,7 +165,7 @@ PICOBENCH(append_compact<1000>).iterations(sizes).samples(10); int main(int argc, char* argv[]) { - ccf::logger::config::level() = LoggerLevel::FATAL; + ccf::logger::config::level() = ccf::LoggerLevel::FATAL; ::threading::ThreadMessaging::init(1); ccf::crypto::openssl_sha256_init(); diff --git a/tests/perf-system/submitter/submit.cpp b/tests/perf-system/submitter/submit.cpp index 1d73a5b60ced..c2fba117d18f 100644 --- a/tests/perf-system/submitter/submit.cpp +++ b/tests/perf-system/submitter/submit.cpp @@ -266,7 +266,7 @@ int main(int argc, char** argv) signal(SIGPIPE, SIG_IGN); ccf::logger::config::default_init(); - ccf::logger::config::level() = LoggerLevel::INFO; + ccf::logger::config::level() = ccf::LoggerLevel::INFO; ccf::crypto::openssl_sha256_init(); CLI::App cli_app{"Perf Tool"}; ArgumentParser args("Perf Tool", cli_app);