Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Nov 20, 2023
1 parent b23315e commit a67628a
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 57 deletions.
18 changes: 9 additions & 9 deletions nano/core_test/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2629,6 +2629,15 @@ TEST (node, DISABLED_vote_by_hash_epoch_block_republish)

TEST (node, epoch_conflict_confirm)
{
// Print easily visible separator
for (int i = 0; i < 10; ++i)
{
std::cout << "==" << std::endl;
}
std::cout << std::endl;
std::cout << std::endl;
std::cout << std::endl;

nano::test::system system;
nano::node_config node_config (system.get_available_port (), system.logging);
node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled;
Expand Down Expand Up @@ -2684,15 +2693,6 @@ TEST (node, epoch_conflict_confirm)
.work (*system.work.generate (open->hash ()))
.build_shared ();

// Print easily visible separator
for (int i = 0; i < 10; ++i)
{
std::cout << "==" << std::endl;
}
std::cout << std::endl;
std::cout << std::endl;
std::cout << std::endl;

std::cout << "send: " << send->hash ().to_string () << " root: " << send->root ().to_string () << std::endl;
std::cout << "open: " << open->hash ().to_string () << " root: " << open->root ().to_string () << std::endl;
std::cout << "change: " << change->hash ().to_string () << " root: " << change->root ().to_string () << std::endl;
Expand Down
2 changes: 2 additions & 0 deletions nano/node/confirmation_height_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ void nano::confirmation_height_processor::unpause ()

void nano::confirmation_height_processor::add (std::shared_ptr<nano::block> const & block_a)
{
std::cout << "confirmation_height_processor::add hash: " << block_a->hash ().to_string () << std::endl;

{
nano::lock_guard<nano::mutex> lk (mutex);
awaiting_processing.get<tag_sequence> ().emplace_back (block_a);
Expand Down
6 changes: 3 additions & 3 deletions nano/node/election.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ void nano::election::send_confirm_req (nano::confirmation_solicitor & solicitor_
{
if (confirm_req_time () < (std::chrono::steady_clock::now () - last_req))
{
std::cout
<< "node: " << node.network.port << " "
<< "send_confirm_req for: " << status.winner->hash ().to_string () << " id: " << (void *)this << std::endl;
// std::cout
// << "node: " << node.network.port << " "
// << "send_confirm_req for: " << status.winner->hash ().to_string () << " id: " << (void *)this << std::endl;

nano::lock_guard<nano::mutex> guard{ mutex };
if (!solicitor_a.add (*this))
Expand Down
88 changes: 44 additions & 44 deletions nano/node/request_aggregator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ void nano::request_aggregator::add (std::shared_ptr<nano::transport::channel> co
auto const endpoint (nano::transport::map_endpoint_to_v6 (channel_a->get_endpoint ()));
nano::unique_lock<nano::mutex> lock{ mutex };

for (auto const & [hash, root] : hashes_roots_a)
{
std::cout
<< "request aggregator request #1 for: " << hash.to_string () << std::endl;
}
// for (auto const & [hash, root] : hashes_roots_a)
// {
// std::cout
// << "request aggregator request #1 for: " << hash.to_string () << std::endl;
// }

// Protecting from ever-increasing memory usage when request are consumed slower than generated
// Reject request if the oldest request has not yet been processed after its deadline + a modest margin
Expand Down Expand Up @@ -88,11 +88,11 @@ void nano::request_aggregator::add (std::shared_ptr<nano::transport::channel> co
});
if (requests.size () == 1)
{
for (auto const & [hash, root] : hashes_roots_a)
{
std::cout
<< "request aggregator request #5 for: " << hash.to_string () << std::endl;
}
// for (auto const & [hash, root] : hashes_roots_a)
// {
// std::cout
// << "request aggregator request #5 for: " << hash.to_string () << std::endl;
// }

lock.unlock ();
condition.notify_all ();
Expand All @@ -113,7 +113,7 @@ void nano::request_aggregator::run ()
{
if (!requests.empty ())
{
std::cout << "request aggregator loop" << std::endl;
// std::cout << "request aggregator loop" << std::endl;

auto & requests_by_deadline (requests.get<tag_deadline> ());
auto front (requests_by_deadline.begin ());
Expand Down Expand Up @@ -235,20 +235,20 @@ std::pair<std::vector<std::shared_ptr<nano::block>>, std::vector<std::shared_ptr
std::unordered_set<nano::block_hash> cached_hashes;
for (auto const & [hash, root] : requests_a)
{
std::cout << "aggregate: " << hash.to_string () << " root: " << root.to_string () << std::endl;
// std::cout << "aggregate: " << hash.to_string () << " root: " << root.to_string () << std::endl;

// 0. Hashes already sent
if (cached_hashes.count (hash) > 0)
{
std::cout << "aggregate drop: " << hash.to_string () << std::endl;
// std::cout << "aggregate drop: " << hash.to_string () << std::endl;
continue;
}

// 1. Votes in cache
auto find_votes (local_votes.votes (root, hash));
if (!find_votes.empty ())
{
std::cout << "aggregate already cached: " << hash.to_string () << std::endl;
// std::cout << "aggregate already cached: " << hash.to_string () << std::endl;
for (auto & found_vote : find_votes)
{
cached_votes.push_back (found_vote);
Expand All @@ -268,14 +268,14 @@ std::pair<std::vector<std::shared_ptr<nano::block>>, std::vector<std::shared_ptr
auto final_vote_hashes (ledger.store.final_vote.get (transaction, root));
if (!final_vote_hashes.empty ())
{
std::cout << "aggregate final vote: " << hash.to_string ()
<< " final_vote_hashes.size (): " << final_vote_hashes.size ()
<< std::endl;
// std::cout << "aggregate final vote: " << hash.to_string ()
// << " final_vote_hashes.size (): " << final_vote_hashes.size ()
// << std::endl;

for (auto const & final_vote_hash : final_vote_hashes)
{
std::cout << "aggregate final vote hash: " << final_vote_hash.to_string () << std::endl;
}
// for (auto const & final_vote_hash : final_vote_hashes)
// {
// std::cout << "aggregate final vote hash: " << final_vote_hash.to_string () << std::endl;
// }

generate_final_vote = true;
block = ledger.store.block.get (transaction, final_vote_hashes[0]);
Expand All @@ -291,15 +291,15 @@ std::pair<std::vector<std::shared_ptr<nano::block>>, std::vector<std::shared_ptr
// 3. Election winner by hash
if (block == nullptr)
{
std::cout << "aggregate election winner: " << hash.to_string () << std::endl;
// std::cout << "aggregate election winner: " << hash.to_string () << std::endl;

block = active.winner (hash);
}

// 4. Ledger by hash
if (block == nullptr)
{
std::cout << "aggregate ledger by hash: " << hash.to_string () << std::endl;
// std::cout << "aggregate ledger by hash: " << hash.to_string () << std::endl;

block = ledger.store.block.get (transaction, hash);
// Confirmation status. Generate final votes for confirmed
Expand All @@ -314,7 +314,7 @@ std::pair<std::vector<std::shared_ptr<nano::block>>, std::vector<std::shared_ptr
// 5. Ledger by root
if (block == nullptr && !root.is_zero ())
{
std::cout << "aggregate ledger by root: " << hash.to_string () << std::endl;
// std::cout << "aggregate ledger by root: " << hash.to_string () << std::endl;

// Search for block root
auto successor (ledger.store.block.successor (transaction, root.as_block_hash ()));
Expand Down Expand Up @@ -371,16 +371,16 @@ std::pair<std::vector<std::shared_ptr<nano::block>>, std::vector<std::shared_ptr
}
}

for (auto const & block : to_generate)
{
std::cout
<< "aggregate to_generate #temp: " << block->hash ().to_string () << std::endl;
}
for (auto const & block : to_generate_final)
{
std::cout
<< "aggregate to_generate_final #temp: " << block->hash ().to_string () << std::endl;
}
// for (auto const & block : to_generate)
// {
// std::cout
// << "aggregate to_generate #temp: " << block->hash ().to_string () << std::endl;
// }
// for (auto const & block : to_generate_final)
// {
// std::cout
// << "aggregate to_generate_final #temp: " << block->hash ().to_string () << std::endl;
// }

// Let the node know about the alternative block
if (block->hash () != hash)
Expand Down Expand Up @@ -408,16 +408,16 @@ std::pair<std::vector<std::shared_ptr<nano::block>>, std::vector<std::shared_ptr
stats.add (nano::stat::type::requests, nano::stat::detail::requests_cached_hashes, stat::dir::in, cached_hashes.size ());
stats.add (nano::stat::type::requests, nano::stat::detail::requests_cached_votes, stat::dir::in, cached_votes.size ());

for (auto const & block : to_generate)
{
std::cout
<< "aggregate to_generate: " << block->hash ().to_string () << std::endl;
}
for (auto const & block : to_generate_final)
{
std::cout
<< "aggregate to_generate_final: " << block->hash ().to_string () << std::endl;
}
// for (auto const & block : to_generate)
// {
// std::cout
// << "aggregate to_generate: " << block->hash ().to_string () << std::endl;
// }
// for (auto const & block : to_generate_final)
// {
// std::cout
// << "aggregate to_generate_final: " << block->hash ().to_string () << std::endl;
// }

return std::make_pair (to_generate, to_generate_final);
}
Expand Down
7 changes: 7 additions & 0 deletions nano/node/voting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <nano/node/wallet.hpp>
#include <nano/secure/ledger.hpp>
#include <nano/store/component.hpp>
#include <nano/lib/stacktrace.hpp>

#include <chrono>

Expand Down Expand Up @@ -232,6 +233,12 @@ void nano::vote_generator::stop ()

void nano::vote_generator::add (const root & root, const block_hash & hash)
{
std::cout << "vote_generator::add"
<< " root: " << root.to_string ()
<< " hash: " << hash.to_string ()
<< " stacktrace: " << nano::generate_stacktrace ()
<< std::endl;

vote_generation_queue.add (std::make_pair (root, hash));
}

Expand Down
2 changes: 1 addition & 1 deletion nano/store/lmdb/final_vote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bool nano::store::lmdb::final_vote::put (store::write_transaction const & transa
}
else
{
std::cout << "put final vote for root: " << root.to_string ()
std::cout << "final vote store root: " << root.to_string ()
<< " hash: " << hash.to_string ()
<< std::endl;

Expand Down

0 comments on commit a67628a

Please sign in to comment.