mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-13 03:30:42 +02:00
kernel: Remove key module from kernel library
The key module's functionality is not used by the kernel library, but currently kernel users are still required to initialize the key module's `secp256k1_context_sign` global as part of the `kernel::Context` through `ECC_Start`.
This commit is contained in:
parent
a08d2b3cb9
commit
41eba5bd71
@ -945,7 +945,6 @@ libbitcoinkernel_la_SOURCES = \
|
|||||||
kernel/disconnected_transactions.cpp \
|
kernel/disconnected_transactions.cpp \
|
||||||
kernel/mempool_persist.cpp \
|
kernel/mempool_persist.cpp \
|
||||||
kernel/mempool_removal_reason.cpp \
|
kernel/mempool_removal_reason.cpp \
|
||||||
key.cpp \
|
|
||||||
logging.cpp \
|
logging.cpp \
|
||||||
node/blockstorage.cpp \
|
node/blockstorage.cpp \
|
||||||
node/chainstate.cpp \
|
node/chainstate.cpp \
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <script/sigcache.h>
|
#include <script/sigcache.h>
|
||||||
#include <util/chaintype.h>
|
#include <util/chaintype.h>
|
||||||
#include <util/fs.h>
|
#include <util/fs.h>
|
||||||
|
#include <util/signalinterrupt.h>
|
||||||
#include <util/task_runner.h>
|
#include <util/task_runner.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
#include <validationinterface.h>
|
#include <validationinterface.h>
|
||||||
|
@ -14,11 +14,13 @@
|
|||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <interfaces/chain.h>
|
#include <interfaces/chain.h>
|
||||||
#include <interfaces/init.h>
|
#include <interfaces/init.h>
|
||||||
|
#include <kernel/context.h>
|
||||||
#include <node/context.h>
|
#include <node/context.h>
|
||||||
#include <node/interface_ui.h>
|
#include <node/interface_ui.h>
|
||||||
#include <noui.h>
|
#include <noui.h>
|
||||||
#include <util/check.h>
|
#include <util/check.h>
|
||||||
#include <util/exception.h>
|
#include <util/exception.h>
|
||||||
|
#include <util/signalinterrupt.h>
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
#include <util/syserror.h>
|
#include <util/syserror.h>
|
||||||
#include <util/threadnames.h>
|
#include <util/threadnames.h>
|
||||||
@ -180,6 +182,7 @@ static bool AppInit(NodeContext& node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
node.kernel = std::make_unique<kernel::Context>();
|
node.kernel = std::make_unique<kernel::Context>();
|
||||||
|
node.ecc_context = std::make_unique<ECC_Context>();
|
||||||
if (!AppInitSanityChecks(*node.kernel))
|
if (!AppInitSanityChecks(*node.kernel))
|
||||||
{
|
{
|
||||||
// InitError will have been called with detailed error, which ends up on console
|
// InitError will have been called with detailed error, which ends up on console
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
#include <interfaces/chain.h>
|
#include <interfaces/chain.h>
|
||||||
#include <interfaces/init.h>
|
#include <interfaces/init.h>
|
||||||
#include <interfaces/node.h>
|
#include <interfaces/node.h>
|
||||||
|
#include <kernel/context.h>
|
||||||
|
#include <key.h>
|
||||||
#include <logging.h>
|
#include <logging.h>
|
||||||
#include <mapport.h>
|
#include <mapport.h>
|
||||||
#include <net.h>
|
#include <net.h>
|
||||||
@ -75,6 +77,7 @@
|
|||||||
#include <util/fs_helpers.h>
|
#include <util/fs_helpers.h>
|
||||||
#include <util/moneystr.h>
|
#include <util/moneystr.h>
|
||||||
#include <util/result.h>
|
#include <util/result.h>
|
||||||
|
#include <util/signalinterrupt.h>
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
#include <util/syserror.h>
|
#include <util/syserror.h>
|
||||||
@ -371,6 +374,7 @@ void Shutdown(NodeContext& node)
|
|||||||
node.chainman.reset();
|
node.chainman.reset();
|
||||||
node.validation_signals.reset();
|
node.validation_signals.reset();
|
||||||
node.scheduler.reset();
|
node.scheduler.reset();
|
||||||
|
node.ecc_context.reset();
|
||||||
node.kernel.reset();
|
node.kernel.reset();
|
||||||
|
|
||||||
RemovePidFile(*node.args);
|
RemovePidFile(*node.args);
|
||||||
@ -1084,6 +1088,10 @@ bool AppInitSanityChecks(const kernel::Context& kernel)
|
|||||||
return InitError(strprintf(_("Initialization sanity check failed. %s is shutting down."), PACKAGE_NAME));
|
return InitError(strprintf(_("Initialization sanity check failed. %s is shutting down."), PACKAGE_NAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ECC_InitSanityCheck()) {
|
||||||
|
return InitError(strprintf(_("Elliptic curve cryptography sanity check failure. %s is shutting down."), PACKAGE_NAME));
|
||||||
|
}
|
||||||
|
|
||||||
// Probe the data directory lock to give an early error message, if possible
|
// Probe the data directory lock to give an early error message, if possible
|
||||||
// We cannot hold the data directory lock here, as the forking for daemon() hasn't yet happened,
|
// We cannot hold the data directory lock here, as the forking for daemon() hasn't yet happened,
|
||||||
// and a fork will cause weird behavior to it.
|
// and a fork will cause weird behavior to it.
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
#include <kernel/checks.h>
|
#include <kernel/checks.h>
|
||||||
|
|
||||||
#include <key.h>
|
|
||||||
#include <random.h>
|
#include <random.h>
|
||||||
|
#include <util/result.h>
|
||||||
#include <util/translation.h>
|
#include <util/translation.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -14,10 +14,6 @@ namespace kernel {
|
|||||||
|
|
||||||
util::Result<void> SanityChecks(const Context&)
|
util::Result<void> SanityChecks(const Context&)
|
||||||
{
|
{
|
||||||
if (!ECC_InitSanityCheck()) {
|
|
||||||
return util::Error{Untranslated("Elliptic curve cryptography sanity check failure. Aborting.")};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Random_SanityCheck()) {
|
if (!Random_SanityCheck()) {
|
||||||
return util::Error{Untranslated("OS cryptographic RNG sanity check failure. Aborting.")};
|
return util::Error{Untranslated("OS cryptographic RNG sanity check failure. Aborting.")};
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,7 @@
|
|||||||
#include <kernel/context.h>
|
#include <kernel/context.h>
|
||||||
|
|
||||||
#include <crypto/sha256.h>
|
#include <crypto/sha256.h>
|
||||||
#include <key.h>
|
|
||||||
#include <logging.h>
|
#include <logging.h>
|
||||||
#include <pubkey.h>
|
|
||||||
#include <random.h>
|
#include <random.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -19,12 +17,7 @@ Context::Context()
|
|||||||
std::string sha256_algo = SHA256AutoDetect();
|
std::string sha256_algo = SHA256AutoDetect();
|
||||||
LogPrintf("Using the '%s' SHA256 implementation\n", sha256_algo);
|
LogPrintf("Using the '%s' SHA256 implementation\n", sha256_algo);
|
||||||
RandomInit();
|
RandomInit();
|
||||||
ECC_Start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Context::~Context()
|
|
||||||
{
|
|
||||||
ECC_Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace kernel
|
} // namespace kernel
|
||||||
|
@ -5,10 +5,6 @@
|
|||||||
#ifndef BITCOIN_KERNEL_CONTEXT_H
|
#ifndef BITCOIN_KERNEL_CONTEXT_H
|
||||||
#define BITCOIN_KERNEL_CONTEXT_H
|
#define BITCOIN_KERNEL_CONTEXT_H
|
||||||
|
|
||||||
#include <util/signalinterrupt.h>
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace kernel {
|
namespace kernel {
|
||||||
//! Context struct holding the kernel library's logically global state, and
|
//! Context struct holding the kernel library's logically global state, and
|
||||||
//! passed to external libbitcoin_kernel functions which need access to this
|
//! passed to external libbitcoin_kernel functions which need access to this
|
||||||
@ -19,7 +15,6 @@ namespace kernel {
|
|||||||
//! should be stored to std::unique_ptr members pointing to opaque types.
|
//! should be stored to std::unique_ptr members pointing to opaque types.
|
||||||
struct Context {
|
struct Context {
|
||||||
Context();
|
Context();
|
||||||
~Context();
|
|
||||||
};
|
};
|
||||||
} // namespace kernel
|
} // namespace kernel
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <banman.h>
|
#include <banman.h>
|
||||||
#include <interfaces/chain.h>
|
#include <interfaces/chain.h>
|
||||||
#include <kernel/context.h>
|
#include <kernel/context.h>
|
||||||
|
#include <key.h>
|
||||||
#include <net.h>
|
#include <net.h>
|
||||||
#include <net_processing.h>
|
#include <net_processing.h>
|
||||||
#include <netgroup.h>
|
#include <netgroup.h>
|
||||||
@ -16,6 +17,7 @@
|
|||||||
#include <scheduler.h>
|
#include <scheduler.h>
|
||||||
#include <txmempool.h>
|
#include <txmempool.h>
|
||||||
#include <validation.h>
|
#include <validation.h>
|
||||||
|
#include <validationinterface.h>
|
||||||
|
|
||||||
namespace node {
|
namespace node {
|
||||||
NodeContext::NodeContext() = default;
|
NodeContext::NodeContext() = default;
|
||||||
|
@ -5,10 +5,7 @@
|
|||||||
#ifndef BITCOIN_NODE_CONTEXT_H
|
#ifndef BITCOIN_NODE_CONTEXT_H
|
||||||
#define BITCOIN_NODE_CONTEXT_H
|
#define BITCOIN_NODE_CONTEXT_H
|
||||||
|
|
||||||
#include <kernel/context.h>
|
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <cassert>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -24,6 +21,7 @@ class ValidationSignals;
|
|||||||
class CScheduler;
|
class CScheduler;
|
||||||
class CTxMemPool;
|
class CTxMemPool;
|
||||||
class ChainstateManager;
|
class ChainstateManager;
|
||||||
|
class ECC_Context;
|
||||||
class NetGroupManager;
|
class NetGroupManager;
|
||||||
class PeerManager;
|
class PeerManager;
|
||||||
namespace interfaces {
|
namespace interfaces {
|
||||||
@ -32,6 +30,12 @@ class ChainClient;
|
|||||||
class Init;
|
class Init;
|
||||||
class WalletLoader;
|
class WalletLoader;
|
||||||
} // namespace interfaces
|
} // namespace interfaces
|
||||||
|
namespace kernel {
|
||||||
|
struct Context;
|
||||||
|
}
|
||||||
|
namespace util {
|
||||||
|
class SignalInterrupt;
|
||||||
|
}
|
||||||
|
|
||||||
namespace node {
|
namespace node {
|
||||||
class KernelNotifications;
|
class KernelNotifications;
|
||||||
@ -49,6 +53,7 @@ class KernelNotifications;
|
|||||||
struct NodeContext {
|
struct NodeContext {
|
||||||
//! libbitcoin_kernel context
|
//! libbitcoin_kernel context
|
||||||
std::unique_ptr<kernel::Context> kernel;
|
std::unique_ptr<kernel::Context> kernel;
|
||||||
|
std::unique_ptr<ECC_Context> ecc_context;
|
||||||
//! Init interface for initializing current process and connecting to other processes.
|
//! Init interface for initializing current process and connecting to other processes.
|
||||||
interfaces::Init* init{nullptr};
|
interfaces::Init* init{nullptr};
|
||||||
//! Interrupt object used to track whether node shutdown was requested.
|
//! Interrupt object used to track whether node shutdown was requested.
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include <interfaces/node.h>
|
#include <interfaces/node.h>
|
||||||
#include <interfaces/wallet.h>
|
#include <interfaces/wallet.h>
|
||||||
#include <kernel/chain.h>
|
#include <kernel/chain.h>
|
||||||
|
#include <kernel/context.h>
|
||||||
#include <kernel/mempool_entry.h>
|
#include <kernel/mempool_entry.h>
|
||||||
#include <logging.h>
|
#include <logging.h>
|
||||||
#include <mapport.h>
|
#include <mapport.h>
|
||||||
@ -99,6 +100,7 @@ public:
|
|||||||
if (!AppInitParameterInteraction(args())) return false;
|
if (!AppInitParameterInteraction(args())) return false;
|
||||||
|
|
||||||
m_context->kernel = std::make_unique<kernel::Context>();
|
m_context->kernel = std::make_unique<kernel::Context>();
|
||||||
|
m_context->ecc_context = std::make_unique<ECC_Context>();
|
||||||
if (!AppInitSanityChecks(*m_context->kernel)) return false;
|
if (!AppInitSanityChecks(*m_context->kernel)) return false;
|
||||||
|
|
||||||
if (!AppInitLockDataDirectory()) return false;
|
if (!AppInitLockDataDirectory()) return false;
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <node/abort.h>
|
#include <node/abort.h>
|
||||||
#include <node/interface_ui.h>
|
#include <node/interface_ui.h>
|
||||||
#include <util/check.h>
|
#include <util/check.h>
|
||||||
|
#include <util/signalinterrupt.h>
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
#include <util/translation.h>
|
#include <util/translation.h>
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <script/signingprovider.h>
|
#include <script/signingprovider.h>
|
||||||
#include <txmempool.h>
|
#include <txmempool.h>
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
|
#include <util/signalinterrupt.h>
|
||||||
#include <util/strencodings.h>
|
#include <util/strencodings.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
#include <util/time.h>
|
#include <util/time.h>
|
||||||
|
@ -183,6 +183,7 @@ BasicTestingSetup::BasicTestingSetup(const ChainType chainType, const std::vecto
|
|||||||
AppInitParameterInteraction(*m_node.args);
|
AppInitParameterInteraction(*m_node.args);
|
||||||
LogInstance().StartLogging();
|
LogInstance().StartLogging();
|
||||||
m_node.kernel = std::make_unique<kernel::Context>();
|
m_node.kernel = std::make_unique<kernel::Context>();
|
||||||
|
m_node.ecc_context = std::make_unique<ECC_Context>();
|
||||||
SetupEnvironment();
|
SetupEnvironment();
|
||||||
|
|
||||||
ValidationCacheSizes validation_cache_sizes{};
|
ValidationCacheSizes validation_cache_sizes{};
|
||||||
@ -200,6 +201,7 @@ BasicTestingSetup::BasicTestingSetup(const ChainType chainType, const std::vecto
|
|||||||
|
|
||||||
BasicTestingSetup::~BasicTestingSetup()
|
BasicTestingSetup::~BasicTestingSetup()
|
||||||
{
|
{
|
||||||
|
m_node.ecc_context.reset();
|
||||||
m_node.kernel.reset();
|
m_node.kernel.reset();
|
||||||
SetMockTime(0s); // Reset mocktime for following tests
|
SetMockTime(0s); // Reset mocktime for following tests
|
||||||
LogInstance().DisconnectTestLogger();
|
LogInstance().DisconnectTestLogger();
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#define BITCOIN_TEST_UTIL_SETUP_COMMON_H
|
#define BITCOIN_TEST_UTIL_SETUP_COMMON_H
|
||||||
|
|
||||||
#include <common/args.h> // IWYU pragma: export
|
#include <common/args.h> // IWYU pragma: export
|
||||||
|
#include <kernel/context.h>
|
||||||
#include <key.h>
|
#include <key.h>
|
||||||
#include <node/caches.h>
|
#include <node/caches.h>
|
||||||
#include <node/context.h> // IWYU pragma: export
|
#include <node/context.h> // IWYU pragma: export
|
||||||
@ -15,6 +16,7 @@
|
|||||||
#include <util/chaintype.h> // IWYU pragma: export
|
#include <util/chaintype.h> // IWYU pragma: export
|
||||||
#include <util/check.h>
|
#include <util/check.h>
|
||||||
#include <util/fs.h>
|
#include <util/fs.h>
|
||||||
|
#include <util/signalinterrupt.h>
|
||||||
#include <util/string.h>
|
#include <util/string.h>
|
||||||
#include <util/vector.h>
|
#include <util/vector.h>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user