Skip to content
Merged
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
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ if (STATISTICS)
add_definitions(-DKTH_STATISTICS_ENABLED)
endif()

# is it possible to get the current timestamp in cmake?
add_definitions(-DKTH_BUILD_TIME="xxxxxxxxxxxx")

add_definitions(-DKTH_MICROARCHITECTURE_STR="${MARCH_ID}")
set(MARCH_ID "" CACHE STRING "Specify the Microarchitecture ID (x86_64|...).")
message( STATUS "Knuth: Compiling for Microarchitecture ID ${MARCH_ID}")
Expand Down
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def validate(self):

def build_requirements(self):
if self.options.tests:
self.test_requires("catch2/3.6.0")
self.test_requires("catch2/3.7.1")

def requirements(self):
self.requires("blockchain/0.47.0", transitive_headers=True, transitive_libs=True)
Expand Down
5 changes: 0 additions & 5 deletions include/kth/node/protocols/protocol_block_in.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ class BCN_API protocol_block_in : public network::protocol_timer, track<protocol
bool const compact_from_peer_;
bool const blocks_from_peer_;

#if ! defined(KTH_CURRENCY_BCH)
bool const require_witness_;
bool const peer_witness_;
#endif

// This is protected by mutex.
hash_queue backlog_;
mutable upgrade_mutex mutex;
Expand Down
1 change: 0 additions & 1 deletion include/kth/node/protocols/protocol_block_out.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class BCN_API protocol_block_out : public network::protocol_events, track<protoc
kth::atomic<hash_digest> last_locator_top_;
std::atomic<bool> compact_to_peer_;
std::atomic<bool> headers_to_peer_;
bool const enable_witness_;
std::atomic<bool> compact_high_bandwidth_;
std::atomic<uint64_t> compact_version_;
};
Expand Down
5 changes: 0 additions & 5 deletions include/kth/node/protocols/protocol_transaction_in.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ class BCN_API protocol_transaction_in : public network::protocol_events, track<p
const uint64_t minimum_relay_fee_;
bool const relay_from_peer_;
bool const refresh_pool_;

#if defined(KTH_SEGWIT_ENABLED)
bool const require_witness_;
bool const peer_witness_;
#endif
};

} // namespace kth::node
Expand Down
2 changes: 1 addition & 1 deletion include/kth/node/protocols/protocol_transaction_out.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class BCN_API protocol_transaction_out : public network::protocol_events, track<
blockchain::safe_chain& chain_;
std::atomic<uint64_t> minimum_peer_fee_;
bool const relay_to_peer_;
bool const enable_witness_;
// bool const enable_witness_;
};

} // namespace kth::node
Expand Down
27 changes: 2 additions & 25 deletions src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,9 @@ void parser::set_default_configuration() {

// A node allows 1000 host names by default.
configured.network.host_pool_capacity = 1000;
#if defined(KTH_CURRENCY_BCH)

// Expose full node (1) services by default.
configured.network.services = serve::node_network;
#else
// Expose full node (1) and witness (8) network services by default.
configured.network.services = serve::node_network | serve::node_witness;
#endif
#endif
}

Expand Down Expand Up @@ -226,7 +222,7 @@ options_metadata parser::load_settings() {
)(
"network.services",
value<uint64_t>(&configured.network.services),
"The services exposed by network connections, defaults to 9 BTC (full node, witness). and 1 (full node BCH)"
"The services exposed by network connections, defaults to 1 (full node BCH)"
)(
"network.invalid_services",
value<uint64_t>(&configured.network.invalid_services),
Expand Down Expand Up @@ -423,22 +419,6 @@ options_metadata parser::load_settings() {
"Use median time past for locktime, defaults to true (soft fork)."
)

#if ! defined(KTH_CURRENCY_BCH)
// BTC only things
(
"fork.bip141",
value<bool>(&configured.chain.bip141),
"Segregated witness consensus layer, defaults to true (soft fork)."
)(
"fork.bip143",
value<bool>(&configured.chain.bip143),
"Version 0 transaction digest, defaults to true (soft fork)."
)(
"fork.bip147",
value<bool>(&configured.chain.bip147),
"Prevent dummy value malleability, defaults to true (soft fork)."
)
#else
// BCH only things

// (
Expand Down Expand Up @@ -520,9 +500,6 @@ options_metadata parser::load_settings() {
"The half life for the ASERTi3-2d DAA. For every (asert_half_life) seconds behind schedule the blockchain gets, difficulty is cut in half. Doubled if blocks are ahead of schedule. Defaults to: 2 * 24 * 60 * 60 = 172800 (two days)."
)

#endif //KTH_CURRENCY_BCH




/* [node] */
Expand Down
59 changes: 9 additions & 50 deletions src/protocols/protocol_block_in.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@ using namespace kth::network;
using namespace std::chrono;
using namespace std::placeholders;

constexpr
bool is_witness(uint64_t services) {
#if defined(KTH_CURRENCY_BCH)
return false;
#else
return (services & version::service::node_witness) != 0;
#endif
}

constexpr
uint64_t get_compact_blocks_version() {
#if defined(KTH_CURRENCY_BCH)
Expand Down Expand Up @@ -74,12 +65,6 @@ protocol_block_in::protocol_block_in(full_node& node, channel::ptr channel, safe
negotiated_version() > version::level::no_blocks_end ||
negotiated_version() < version::level::no_blocks_start),

#if ! defined(KTH_CURRENCY_BCH)
// Witness must be requested if possibly enforced.
require_witness_(is_witness(node.network_settings().services)),
peer_witness_(is_witness(channel->peer_version()->services())),
#endif

CONSTRUCT_TRACK(protocol_block_in)
{}

Expand All @@ -90,15 +75,6 @@ void protocol_block_in::start() {
// Use timer to drop slow peers.
protocol_timer::start(block_latency_, BIND1(handle_timeout, _1));


#if ! defined(KTH_CURRENCY_BCH)
// Do not process incoming blocks if required witness is unavailable.
// The channel will remain active outbound unless node becomes stale.
if (require_witness_ && !peer_witness_) {
return;
}
#endif

// TODO: move headers to a derived class protocol_block_in_31800.
SUBSCRIBE2(headers, handle_receive_headers, _1, _2);

Expand Down Expand Up @@ -282,13 +258,6 @@ void protocol_block_in::send_get_data(code const& ec, get_data_ptr message) {
mutex.unlock();
///////////////////////////////////////////////////////////////////////////

#if ! defined(KTH_CURRENCY_BCH)
// Convert requested message types to corresponding witness types.
if (require_witness_) {
message->to_witness();
}
#endif

// There was no backlog so the timer must be started now.
if (fresh) {
reset_timer();
Expand Down Expand Up @@ -379,16 +348,6 @@ bool protocol_block_in::handle_receive_block(code const& ec, block_const_ptr mes
return false;
}

#if ! defined(KTH_CURRENCY_BCH)
if ( ! require_witness_ && message->is_segregated()) {
LOG_DEBUG(LOG_NODE
, "Block [", encode_hash(message->hash())
, "] contains unrequested witness from [", authority(), "]");
stop(error::channel_stopped);
return false;
}
#endif

// message->validation.originator = nonce();
// chain_.organize(message, BIND2(handle_store_block, _1, message));
organize_block(message);
Expand Down Expand Up @@ -862,31 +821,31 @@ void protocol_block_in::report(domain::chain::block const& block) {
"{:>4} wms {:>5} vms {:>4} vus {:>4} rus {:>4} cus {:>4} pus "
"{:>4} aus {:>4} sus {:>4} dus {:f}", height, transactions, inputs,

// wait total (ms)
// wms: wait total (ms)
total_cost_ms(times.end_deserialize, times.start_check),

// validation total (ms)
// vms: validation total (ms)
total_cost_ms(start_validate, times.start_notify),

// validation per input (µs)
// vus: validation per input (µs)
unit_cost(start_validate, times.start_notify, inputs),

// deserialization (read) per input (µs)
// rus: deserialization (read) per input (µs)
unit_cost(times.start_deserialize, times.end_deserialize, inputs),

// check per input (µs)
// cus: check per input (µs)
unit_cost(times.start_check, times.start_populate, inputs),

// population per input (µs)
// pus: population per input (µs)
unit_cost(times.start_populate, times.start_accept, inputs),

// accept per input (µs)
// aus: accept per input (µs)
unit_cost(times.start_accept, times.start_connect, inputs),

// connect (script) per input (µs)
// sus: connect (script) per input (µs)
unit_cost(times.start_connect, times.start_notify, inputs),

// deposit per input (µs)
// dus: deposit per input (µs)
unit_cost(times.start_push, times.end_push, inputs),

// this block transaction cache efficiency (hits/queries)
Expand Down
41 changes: 2 additions & 39 deletions src/protocols/protocol_block_out.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@ using namespace kth::network;
using namespace boost::adaptors;
using namespace std::placeholders;

constexpr
bool is_witness(uint64_t services) {
#if defined(KTH_CURRENCY_BCH)
return false;
#else
return (services & version::service::node_witness) != 0;
#endif
}

protocol_block_out::protocol_block_out(full_node& node, channel::ptr channel, safe_chain& chain)
: protocol_events(node, channel, NAME),
node_(node),
Expand All @@ -57,8 +48,6 @@ protocol_block_out::protocol_block_out(full_node& node, channel::ptr channel, sa
// TODO: move send_headers to a derived class protocol_block_out_70012.
headers_to_peer_(false),

// Witness requests must be allowed if advertising the service.
enable_witness_(is_witness(node.network_settings().services)),
CONSTRUCT_TRACK(protocol_block_out)
{}

Expand Down Expand Up @@ -181,17 +170,12 @@ void protocol_block_out::handle_fetch_locator_headers(code const& ec, headers_pt
}

bool protocol_block_out::handle_receive_get_block_transactions(code const& ec, get_block_transactions_const_ptr message) {
#if defined(KTH_CURRENCY_BCH)
bool witness = false;
#else
bool witness = true;
#endif
if (stopped(ec))
return false;

auto block_hash = message->block_hash();

chain_.fetch_block(block_hash, witness, [this, message](code const& ec, block_const_ptr block, uint64_t) {
chain_.fetch_block(block_hash, [this, message](code const& ec, block_const_ptr block, uint64_t) {

if (ec == error::success) {

Expand Down Expand Up @@ -358,19 +342,8 @@ void protocol_block_out::send_next_data(inventory_ptr inventory) {
auto const& entry = inventory->inventories().back();

switch (entry.type()) {
#if defined(KTH_SEGWIT_ENABLED)
case inventory::type_id::witness_block: {
if ( ! enable_witness_) {
stop(error::channel_stopped);
return;
}
chain_.fetch_block(entry.hash(), true, BIND4(send_block, _1, _2, _3, inventory));
break;
}
#endif // #if defined(KTH_SEGWIT_ENABLED)

case inventory::type_id::block: {
chain_.fetch_block(entry.hash(), false, BIND4(send_block, _1, _2, _3, inventory));
chain_.fetch_block(entry.hash(), BIND4(send_block, _1, _2, _3, inventory));
break;
} case inventory::type_id::filtered_block: {
chain_.fetch_merkle_block(entry.hash(), BIND4(send_merkle_block, _1, _2, _3, inventory));
Expand Down Expand Up @@ -540,17 +513,7 @@ bool protocol_block_out::handle_reorganized(code ec, size_t fork_height, block_c

for (auto const block: *incoming) {
if (block->validation.originator != nonce()) {
#if defined(KTH_CURRENCY_BCH)
announce.inventories().push_back({ inventory::type_id::block, block->header().hash() });
#else
// TODO: the witness flag should only be set if the block is segregated?
//// block->is_segregated() ? inventory::type_id::witness_block : inventory::type_id::block
if (enable_witness_){
announce.inventories().push_back({ inventory::type_id::witness_block, block->header().hash() });
} else {
announce.inventories().push_back({ inventory::type_id::block, block->header().hash() });
}
#endif
}
}

Expand Down
Loading
Loading