Skip to content

Commit

Permalink
Merge branch 'develop' into aec-vote-map-result
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Mar 21, 2024
2 parents 418c9b3 + e8beaa8 commit 15fe391
Show file tree
Hide file tree
Showing 59 changed files with 523 additions and 341 deletions.
1 change: 1 addition & 0 deletions nano/core_test/active_transactions.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <nano/lib/blocks.hpp>
#include <nano/lib/jsonconfig.hpp>
#include <nano/node/active_transactions.hpp>
#include <nano/node/election.hpp>
#include <nano/node/scheduler/component.hpp>
#include <nano/node/scheduler/manual.hpp>
Expand Down
1 change: 1 addition & 0 deletions nano/core_test/bootstrap.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <nano/lib/blocks.hpp>
#include <nano/node/active_transactions.hpp>
#include <nano/node/bootstrap/block_deserializer.hpp>
#include <nano/node/bootstrap/bootstrap_frontier.hpp>
#include <nano/node/bootstrap/bootstrap_lazy.hpp>
Expand Down
1 change: 1 addition & 0 deletions nano/core_test/confirmation_height.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <nano/lib/blocks.hpp>
#include <nano/lib/logging.hpp>
#include <nano/node/active_transactions.hpp>
#include <nano/node/election.hpp>
#include <nano/node/make_store.hpp>
#include <nano/secure/ledger.hpp>
Expand Down
2 changes: 2 additions & 0 deletions nano/core_test/confirmation_solicitor.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <nano/lib/blocks.hpp>
#include <nano/lib/jsonconfig.hpp>
#include <nano/node/active_transactions.hpp>
#include <nano/node/confirmation_solicitor.hpp>
#include <nano/node/election.hpp>
#include <nano/node/transport/inproc.hpp>
#include <nano/test_common/network.hpp>
#include <nano/test_common/system.hpp>
Expand Down
1 change: 1 addition & 0 deletions nano/core_test/conflicts.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <nano/lib/blocks.hpp>
#include <nano/node/active_transactions.hpp>
#include <nano/node/election.hpp>
#include <nano/node/scheduler/component.hpp>
#include <nano/node/scheduler/priority.hpp>
Expand Down
1 change: 1 addition & 0 deletions nano/core_test/election.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <nano/lib/blocks.hpp>
#include <nano/node/active_transactions.hpp>
#include <nano/node/election.hpp>
#include <nano/node/scheduler/component.hpp>
#include <nano/node/scheduler/priority.hpp>
Expand Down
2 changes: 2 additions & 0 deletions nano/core_test/election_scheduler.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include <nano/lib/blocks.hpp>
#include <nano/node/active_transactions.hpp>
#include <nano/node/election.hpp>
#include <nano/node/scheduler/component.hpp>
#include <nano/node/scheduler/priority.hpp>
#include <nano/secure/ledger.hpp>
Expand Down
1 change: 1 addition & 0 deletions nano/core_test/ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <nano/lib/logging.hpp>
#include <nano/lib/stats.hpp>
#include <nano/lib/threading.hpp>
#include <nano/node/active_transactions.hpp>
#include <nano/node/election.hpp>
#include <nano/node/make_store.hpp>
#include <nano/node/scheduler/component.hpp>
Expand Down
3 changes: 3 additions & 0 deletions nano/core_test/node.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#include <nano/lib/blocks.hpp>
#include <nano/lib/config.hpp>
#include <nano/lib/logging.hpp>
#include <nano/node/active_transactions.hpp>
#include <nano/node/election.hpp>
#include <nano/node/local_vote_history.hpp>
#include <nano/node/make_store.hpp>
#include <nano/node/scheduler/component.hpp>
#include <nano/node/scheduler/manual.hpp>
#include <nano/node/scheduler/priority.hpp>
#include <nano/node/transport/fake.hpp>
#include <nano/node/transport/inproc.hpp>
#include <nano/node/vote_generator.hpp>
#include <nano/secure/ledger.hpp>
#include <nano/test_common/network.hpp>
#include <nano/test_common/system.hpp>
Expand Down
1 change: 1 addition & 0 deletions nano/core_test/optimistic_scheduler.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <nano/lib/blocks.hpp>
#include <nano/node/active_transactions.hpp>
#include <nano/node/election.hpp>
#include <nano/test_common/chains.hpp>
#include <nano/test_common/system.hpp>
Expand Down
1 change: 1 addition & 0 deletions nano/core_test/rep_crawler.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <nano/lib/blocks.hpp>
#include <nano/lib/config.hpp>
#include <nano/lib/logging.hpp>
#include <nano/node/active_transactions.hpp>
#include <nano/node/repcrawler.hpp>
#include <nano/node/transport/fake.hpp>
#include <nano/node/transport/inproc.hpp>
Expand Down
3 changes: 3 additions & 0 deletions nano/core_test/request_aggregator.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include <nano/lib/blocks.hpp>
#include <nano/lib/jsonconfig.hpp>
#include <nano/node/active_transactions.hpp>
#include <nano/node/election.hpp>
#include <nano/node/local_vote_history.hpp>
#include <nano/node/request_aggregator.hpp>
#include <nano/node/transport/inproc.hpp>
#include <nano/secure/ledger.hpp>
Expand Down
2 changes: 2 additions & 0 deletions nano/core_test/vote_processor.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <nano/lib/blocks.hpp>
#include <nano/lib/jsonconfig.hpp>
#include <nano/node/active_transactions.hpp>
#include <nano/node/election.hpp>
#include <nano/node/transport/inproc.hpp>
#include <nano/node/vote_processor.hpp>
#include <nano/secure/ledger.hpp>
Expand Down
4 changes: 3 additions & 1 deletion nano/core_test/voting.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <nano/lib/blocks.hpp>
#include <nano/node/common.hpp>
#include <nano/node/voting.hpp>
#include <nano/node/local_vote_history.hpp>
#include <nano/node/vote_generator.hpp>
#include <nano/node/vote_spacing.hpp>
#include <nano/secure/ledger.hpp>
#include <nano/test_common/system.hpp>
#include <nano/test_common/testutil.hpp>
Expand Down
2 changes: 2 additions & 0 deletions nano/core_test/wallet.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <nano/crypto_lib/random_pool.hpp>
#include <nano/lib/blocks.hpp>
#include <nano/lib/thread_runner.hpp>
#include <nano/node/active_transactions.hpp>
#include <nano/node/election.hpp>
#include <nano/secure/ledger.hpp>
#include <nano/store/lmdb/wallet_value.hpp>
#include <nano/test_common/system.hpp>
Expand Down
2 changes: 2 additions & 0 deletions nano/core_test/wallets.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include <nano/lib/blocks.hpp>
#include <nano/node/active_transactions.hpp>
#include <nano/node/election.hpp>
#include <nano/secure/ledger.hpp>
#include <nano/store/versioning.hpp>
#include <nano/test_common/system.hpp>
Expand Down
1 change: 1 addition & 0 deletions nano/core_test/websocket.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <nano/core_test/fakes/websocket_client.hpp>
#include <nano/lib/blocks.hpp>
#include <nano/node/active_transactions.hpp>
#include <nano/node/transport/fake.hpp>
#include <nano/node/websocket.hpp>
#include <nano/test_common/network.hpp>
Expand Down
8 changes: 8 additions & 0 deletions nano/lib/numbers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,4 +389,12 @@ struct hash<std::reference_wrapper<::nano::block_hash const>>
return hash (hash_a);
}
};
template <>
struct hash<::nano::root>
{
size_t operator() (::nano::root const & value_a) const
{
return std::hash<::nano::root> () (value_a);
}
};
}
2 changes: 1 addition & 1 deletion nano/lib/processing_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class processing_queue final
}

public: // Container info
std::unique_ptr<container_info_component> collect_container_info (std::string const & name)
std::unique_ptr<container_info_component> collect_container_info (std::string const & name) const
{
nano::lock_guard<nano::mutex> guard{ mutex };

Expand Down
1 change: 1 addition & 0 deletions nano/nano_node/entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <nano/lib/thread_runner.hpp>
#include <nano/lib/utility.hpp>
#include <nano/nano_node/daemon.hpp>
#include <nano/node/active_transactions.hpp>
#include <nano/node/cli.hpp>
#include <nano/node/daemonconfig.hpp>
#include <nano/node/ipc/ipc_server.hpp>
Expand Down
11 changes: 9 additions & 2 deletions nano/node/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ add_library(
distributed_work_factory.cpp
election.hpp
election.cpp
election_behavior.hpp
election_insertion_result.hpp
election_status.hpp
epoch_upgrader.hpp
epoch_upgrader.cpp
ipc/action_handler.hpp
Expand All @@ -96,6 +98,8 @@ add_library(
json_handler.cpp
local_block_broadcaster.cpp
local_block_broadcaster.hpp
local_vote_history.cpp
local_vote_history.hpp
make_store.hpp
make_store.cpp
network.hpp
Expand Down Expand Up @@ -162,10 +166,13 @@ add_library(
unchecked_map.hpp
vote_cache.hpp
vote_cache.cpp
vote_generator.hpp
vote_generator.cpp
vote_processor.hpp
vote_processor.cpp
voting.hpp
voting.cpp
vote_spacing.hpp
vote_spacing.cpp
vote_with_weight_info.hpp
wallet.hpp
wallet.cpp
websocket.hpp
Expand Down
16 changes: 13 additions & 3 deletions nano/node/active_transactions.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#pragma once

#include <nano/lib/numbers.hpp>
#include <nano/node/election.hpp>
#include <nano/node/election_behavior.hpp>
#include <nano/node/election_insertion_result.hpp>
#include <nano/node/voting.hpp>
#include <nano/node/election_status.hpp>
#include <nano/node/vote_with_weight_info.hpp>
#include <nano/secure/common.hpp>

#include <boost/multi_index/hashed_index.hpp>
Expand All @@ -15,6 +16,7 @@
#include <condition_variable>
#include <deque>
#include <memory>
#include <thread>
#include <unordered_map>

namespace mi = boost::multi_index;
Expand All @@ -30,7 +32,14 @@ class election;
class vote;
class confirmation_height_processor;
class stats;
}
namespace nano::store
{
class read_transaction;
}

namespace nano
{
class recently_confirmed_cache final
{
public:
Expand All @@ -51,8 +60,9 @@ class recently_confirmed_cache final

private:
// clang-format off
class tag_root {};
class tag_hash {};
class tag_root {};
class tag_sequence {};

using ordered_recent_confirmations = boost::multi_index_container<entry_t,
mi::indexed_by<
Expand Down
2 changes: 2 additions & 0 deletions nano/node/backlog_population.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
#include <nano/node/backlog_population.hpp>
#include <nano/node/nodeconfig.hpp>
#include <nano/node/scheduler/priority.hpp>
#include <nano/store/account.hpp>
#include <nano/store/component.hpp>
#include <nano/store/confirmation_height.hpp>

nano::backlog_population::backlog_population (const config & config_a, nano::store::component & store_a, nano::stats & stats_a) :
config_m{ config_a },
Expand Down
2 changes: 2 additions & 0 deletions nano/node/blockprocessor.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include <nano/lib/blocks.hpp>
#include <nano/lib/threading.hpp>
#include <nano/lib/timer.hpp>
#include <nano/node/active_transactions.hpp>
#include <nano/node/blockprocessor.hpp>
#include <nano/node/local_vote_history.hpp>
#include <nano/node/node.hpp>
#include <nano/secure/ledger.hpp>
#include <nano/store/component.hpp>
Expand Down
3 changes: 3 additions & 0 deletions nano/node/election.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include <nano/lib/blocks.hpp>
#include <nano/node/active_transactions.hpp>
#include <nano/node/confirmation_solicitor.hpp>
#include <nano/node/election.hpp>
#include <nano/node/local_vote_history.hpp>
#include <nano/node/network.hpp>
#include <nano/node/node.hpp>
#include <nano/node/vote_generator.hpp>
#include <nano/secure/ledger.hpp>

#include <boost/format.hpp>
Expand Down
35 changes: 5 additions & 30 deletions nano/node/election.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@

#include <nano/lib/id_dispenser.hpp>
#include <nano/lib/logging.hpp>
#include <nano/secure/common.hpp>
#include <nano/store/component.hpp>
#include <nano/lib/stats_enums.hpp>
#include <nano/node/election_behavior.hpp>
#include <nano/node/election_status.hpp>
#include <nano/node/vote_with_weight_info.hpp>

#include <atomic>
#include <chrono>
#include <memory>

namespace nano
{
class block;
class channel;
class confirmation_solicitor;
class inactive_cache_information;
Expand All @@ -24,34 +27,6 @@ class vote_info final
nano::block_hash hash;
};

class vote_with_weight_info final
{
public:
nano::account representative;
std::chrono::steady_clock::time_point time;
uint64_t timestamp;
nano::block_hash hash;
nano::uint128_t weight;
};

enum class election_behavior
{
normal,
/**
* Hinted elections:
* - shorter timespan
* - limited space inside AEC
*/
hinted,
/**
* Optimistic elections:
* - shorter timespan
* - limited space inside AEC
* - more frequent confirmation requests
*/
optimistic,
};

nano::stat::detail to_stat_detail (nano::election_behavior);

// map of vote weight per block, ordered greater first
Expand Down
22 changes: 22 additions & 0 deletions nano/node/election_behavior.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

namespace nano
{
enum class election_behavior
{
normal,
/**
* Hinted elections:
* - shorter timespan
* - limited space inside AEC
*/
hinted,
/**
* Optimistic elections:
* - shorter timespan
* - limited space inside AEC
* - more frequent confirmation requests
*/
optimistic,
};
}
39 changes: 39 additions & 0 deletions nano/node/election_status.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once

#include <nano/lib/numbers.hpp>

#include <chrono>
#include <memory>

namespace nano
{
class block;
}

namespace nano
{
/* Defines the possible states for an election to stop in */
enum class election_status_type : uint8_t
{
ongoing = 0,
active_confirmed_quorum = 1,
active_confirmation_height = 2,
inactive_confirmation_height = 3,
stopped = 5
};

/* Holds a summary of an election */
class election_status final
{
public:
std::shared_ptr<nano::block> winner;
nano::amount tally{ 0 };
nano::amount final_tally{ 0 };
std::chrono::milliseconds election_end{ std::chrono::duration_cast<std::chrono::milliseconds> (std::chrono::system_clock::now ().time_since_epoch ()) };
std::chrono::milliseconds election_duration{ std::chrono::duration_values<std::chrono::milliseconds>::zero () };
unsigned confirmation_request_count{ 0 };
unsigned block_count{ 0 };
unsigned voter_count{ 0 };
election_status_type type{ nano::election_status_type::inactive_confirmation_height };
};
}
Loading

0 comments on commit 15fe391

Please sign in to comment.