Skip to content

Commit

Permalink
Merge branch 'develop' into container-infos-5
Browse files Browse the repository at this point in the history
# Conflicts:
#	nano/node/bootstrap_ascending/service.cpp
  • Loading branch information
pwojcikdev committed Oct 2, 2024
2 parents f897eea + 2a155b7 commit 15e91e2
Show file tree
Hide file tree
Showing 85 changed files with 1,312 additions and 1,410 deletions.
60 changes: 30 additions & 30 deletions nano/core_test/active_elections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,15 @@ TEST (inactive_votes_cache, existing_vote)
auto send = builder.send ()
.previous (latest)
.destination (key.pub)
.balance (nano::dev::constants.genesis_amount - 100 * nano::Gxrb_ratio)
.balance (nano::dev::constants.genesis_amount - 100 * nano::Knano_ratio)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*system.work.generate (latest))
.build ();
auto open = builder.state ()
.account (key.pub)
.previous (0)
.representative (key.pub)
.balance (100 * nano::Gxrb_ratio)
.balance (100 * nano::Knano_ratio)
.link (send->hash ())
.sign (key.prv, key.pub)
.work (*system.work.generate (key.pub))
Expand Down Expand Up @@ -388,15 +388,15 @@ TEST (inactive_votes_cache, multiple_votes)
auto send1 = builder.send ()
.previous (nano::dev::genesis->hash ())
.destination (key1.pub)
.balance (nano::dev::constants.genesis_amount - 100 * nano::Gxrb_ratio)
.balance (nano::dev::constants.genesis_amount - 100 * nano::Knano_ratio)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*system.work.generate (nano::dev::genesis->hash ()))
.build ();

auto send2 = builder.send ()
.previous (send1->hash ())
.destination (key1.pub)
.balance (100 * nano::Gxrb_ratio)
.balance (100 * nano::Knano_ratio)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*system.work.generate (send1->hash ()))
.build ();
Expand All @@ -405,7 +405,7 @@ TEST (inactive_votes_cache, multiple_votes)
.account (key1.pub)
.previous (0)
.representative (key1.pub)
.balance (100 * nano::Gxrb_ratio)
.balance (100 * nano::Knano_ratio)
.link (send1->hash ())
.sign (key1.prv, key1.pub)
.work (*system.work.generate (key1.pub))
Expand Down Expand Up @@ -442,7 +442,7 @@ TEST (inactive_votes_cache, election_start)
nano::send_block_builder send_block_builder;
nano::state_block_builder state_block_builder;
// Enough weight to trigger election hinting but not enough to confirm block on its own
auto amount = ((node.online_reps.trended () / 100) * node.config.hinted_scheduler.hinting_threshold_percent) / 2 + 1000 * nano::Gxrb_ratio;
auto amount = ((node.online_reps.trended () / 100) * node.config.hinted_scheduler.hinting_threshold_percent) / 2 + 1000 * nano::Knano_ratio;
auto send1 = send_block_builder.make_block ()
.previous (latest)
.destination (key1.pub)
Expand Down Expand Up @@ -544,24 +544,24 @@ TEST (active_elections, vote_replays)
nano::keypair key;
nano::state_block_builder builder;

// send Gxrb_ratio raw from genesis to key
// send Knano_ratio raw from genesis to key
auto send1 = builder.make_block ()
.account (nano::dev::genesis_key.pub)
.previous (nano::dev::genesis->hash ())
.representative (nano::dev::genesis_key.pub)
.balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio)
.balance (nano::dev::constants.genesis_amount - nano::Knano_ratio)
.link (key.pub)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*system.work.generate (nano::dev::genesis->hash ()))
.build ();
ASSERT_NE (nullptr, send1);

// create open block for key receing Gxrb_ratio raw
// create open block for key receing Knano_ratio raw
auto open1 = builder.make_block ()
.account (key.pub)
.previous (0)
.representative (key.pub)
.balance (nano::Gxrb_ratio)
.balance (nano::Knano_ratio)
.link (send1->hash ())
.sign (key.prv, key.pub)
.work (*system.work.generate (key.pub))
Expand Down Expand Up @@ -589,14 +589,14 @@ TEST (active_elections, vote_replays)
ASSERT_EQ (nano::vote_code::replay, node.vote_router.vote (vote_open1).at (open1->hash ()));
ASSERT_TIMELY (5s, node.active.empty ());
ASSERT_EQ (nano::vote_code::replay, node.vote_router.vote (vote_open1).at (open1->hash ()));
ASSERT_EQ (nano::Gxrb_ratio, node.ledger.weight (key.pub));
ASSERT_EQ (nano::Knano_ratio, node.ledger.weight (key.pub));

// send 1 raw to key to key
auto send2 = builder.make_block ()
.account (key.pub)
.previous (open1->hash ())
.representative (key.pub)
.balance (nano::Gxrb_ratio - 1)
.balance (nano::Knano_ratio - 1)
.link (key.pub)
.sign (key.prv, key.pub)
.work (*system.work.generate (open1->hash ()))
Expand Down Expand Up @@ -649,22 +649,22 @@ TEST (active_elections, dropped_cleanup)
nano::vectorstream stream (block_bytes);
chain[0]->serialize (stream);
}
ASSERT_FALSE (node.network.publish_filter.apply (block_bytes.data (), block_bytes.size ()));
ASSERT_TRUE (node.network.publish_filter.apply (block_bytes.data (), block_bytes.size ()));
ASSERT_FALSE (node.network.filter.apply (block_bytes.data (), block_bytes.size ()));
ASSERT_TRUE (node.network.filter.apply (block_bytes.data (), block_bytes.size ()));

auto election = nano::test::start_election (system, node, hash);
ASSERT_NE (nullptr, election);

// Not yet removed
ASSERT_TRUE (node.network.publish_filter.apply (block_bytes.data (), block_bytes.size ()));
ASSERT_TRUE (node.network.filter.apply (block_bytes.data (), block_bytes.size ()));
ASSERT_TRUE (node.vote_router.active (hash));

// Now simulate dropping the election
ASSERT_FALSE (election->confirmed ());
node.active.erase (*chain[0]);

// The filter must have been cleared
ASSERT_FALSE (node.network.publish_filter.apply (block_bytes.data (), block_bytes.size ()));
ASSERT_FALSE (node.network.filter.apply (block_bytes.data (), block_bytes.size ()));

// An election was recently dropped
ASSERT_EQ (1, node.stats.count (nano::stat::type::active_elections_dropped, nano::stat::detail::manual));
Expand All @@ -673,7 +673,7 @@ TEST (active_elections, dropped_cleanup)
ASSERT_FALSE (node.vote_router.active (hash));

// Repeat test for a confirmed election
ASSERT_TRUE (node.network.publish_filter.apply (block_bytes.data (), block_bytes.size ()));
ASSERT_TRUE (node.network.filter.apply (block_bytes.data (), block_bytes.size ()));

election = nano::test::start_election (system, node, hash);
ASSERT_NE (nullptr, election);
Expand All @@ -682,7 +682,7 @@ TEST (active_elections, dropped_cleanup)
node.active.erase (*chain[0]);

// The filter should not have been cleared
ASSERT_TRUE (node.network.publish_filter.apply (block_bytes.data (), block_bytes.size ()));
ASSERT_TRUE (node.network.filter.apply (block_bytes.data (), block_bytes.size ()));

// Not dropped
ASSERT_EQ (1, node.stats.count (nano::stat::type::active_elections_dropped, nano::stat::detail::manual));
Expand All @@ -706,7 +706,7 @@ TEST (active_elections, republish_winner)
.account (nano::dev::genesis_key.pub)
.previous (nano::dev::genesis->hash ())
.representative (nano::dev::genesis_key.pub)
.balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio)
.balance (nano::dev::constants.genesis_amount - nano::Knano_ratio)
.link (key.pub)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*system.work.generate (nano::dev::genesis->hash ()))
Expand Down Expand Up @@ -739,7 +739,7 @@ TEST (active_elections, republish_winner)
.account (nano::dev::genesis_key.pub)
.previous (nano::dev::genesis->hash ())
.representative (nano::dev::genesis_key.pub)
.balance (nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio)
.balance (nano::dev::constants.genesis_amount - 2 * nano::Knano_ratio)
.link (key.pub)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*system.work.generate (nano::dev::genesis->hash ()))
Expand Down Expand Up @@ -772,7 +772,7 @@ TEST (active_elections, fork_filter_cleanup)
.previous (latest_hash)
.account (nano::dev::genesis_key.pub)
.representative (nano::dev::genesis_key.pub)
.balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio)
.balance (nano::dev::constants.genesis_amount - nano::Knano_ratio)
.link (key.pub)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*system.work.generate (latest_hash))
Expand Down Expand Up @@ -825,7 +825,7 @@ TEST (active_elections, fork_filter_cleanup)
ASSERT_TIMELY_EQ (5s, node1.ledger.block_count (), 2);

// Block is erased from the duplicate filter
ASSERT_TIMELY (5s, node1.network.publish_filter.apply (send_block_bytes.data (), send_block_bytes.size ()));
ASSERT_TIMELY (5s, node1.network.filter.apply (send_block_bytes.data (), send_block_bytes.size ()));
}

/*
Expand Down Expand Up @@ -889,7 +889,7 @@ TEST (active_elections, fork_replacement_tally)
.account (nano::dev::genesis_key.pub)
.previous (latest)
.representative (nano::dev::genesis_key.pub)
.balance (balance - 2 * nano::Gxrb_ratio)
.balance (balance - 2 * nano::Knano_ratio)
.link (key.pub)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*system.work.generate (latest))
Expand All @@ -902,7 +902,7 @@ TEST (active_elections, fork_replacement_tally)
.account (nano::dev::genesis_key.pub)
.previous (latest)
.representative (nano::dev::genesis_key.pub)
.balance (balance - nano::Gxrb_ratio - i)
.balance (balance - nano::Knano_ratio - i)
.link (key.pub)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*system.work.generate (latest))
Expand Down Expand Up @@ -960,7 +960,7 @@ TEST (active_elections, fork_replacement_tally)
// Process correct block
node_config.peering_port = system.get_available_port ();
auto & node2 (*system.add_node (node_config));
node1.network.publish_filter.clear ();
node1.network.filter.clear ();
node2.network.flood_block (send_last);
ASSERT_TIMELY (3s, node1.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::in) > 0);

Expand All @@ -974,7 +974,7 @@ TEST (active_elections, fork_replacement_tally)
node1.vote_processor.vote (vote, std::make_shared<nano::transport::inproc::channel> (node1, node1));
// ensure vote arrives before the block
ASSERT_TIMELY_EQ (5s, 1, node1.vote_cache.find (send_last->hash ()).size ());
node1.network.publish_filter.clear ();
node1.network.filter.clear ();
node2.network.flood_block (send_last);
ASSERT_TIMELY (5s, node1.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::in) > 1);

Expand Down Expand Up @@ -1304,7 +1304,7 @@ TEST (active_elections, vacancy)
.previous (nano::dev::genesis->hash ())
.representative (nano::dev::genesis_key.pub)
.link (nano::dev::genesis_key.pub)
.balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio)
.balance (nano::dev::constants.genesis_amount - nano::Knano_ratio)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*system.work.generate (nano::dev::genesis->hash ()))
.build ();
Expand Down Expand Up @@ -1339,7 +1339,7 @@ TEST (active_elections, limit_vote_hinted_elections)

// Setup representatives
// Enough weight to trigger election hinting but not enough to confirm block on its own
const auto amount = ((node.online_reps.trended () / 100) * node.config.hinted_scheduler.hinting_threshold_percent) + 1000 * nano::Gxrb_ratio;
const auto amount = ((node.online_reps.trended () / 100) * node.config.hinted_scheduler.hinting_threshold_percent) + 1000 * nano::Knano_ratio;
nano::keypair rep1 = nano::test::setup_rep (system, node, amount / 2);
nano::keypair rep2 = nano::test::setup_rep (system, node, amount / 2);

Expand Down Expand Up @@ -1408,7 +1408,7 @@ TEST (active_elections, bound_election_winners)

{
// Prevent cementing of confirmed blocks
auto guard = node.ledger.tx_begin_write ({}, nano::store::writer::testing);
auto guard = node.ledger.tx_begin_write (nano::store::writer::testing);

// Ensure that when the number of election winners reaches the limit, AEC vacancy reflects that
ASSERT_TRUE (node.active.vacancy (nano::election_behavior::priority) > 0);
Expand Down Expand Up @@ -1464,7 +1464,7 @@ TEST (active_elections, broadcast_block_on_activation)
.account (nano::dev::genesis_key.pub)
.previous (nano::dev::genesis->hash ())
.representative (nano::dev::genesis_key.pub)
.balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio)
.balance (nano::dev::constants.genesis_amount - nano::Knano_ratio)
.link (nano::dev::genesis_key.pub)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*system.work.generate (nano::dev::genesis->hash ()))
Expand Down
2 changes: 1 addition & 1 deletion nano/core_test/backlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ TEST (backlog, election_activation)
.account (nano::dev::genesis_key.pub)
.previous (nano::dev::genesis->hash ())
.representative (nano::dev::genesis_key.pub)
.balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio)
.balance (nano::dev::constants.genesis_amount - nano::Knano_ratio)
.link (key.pub)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*node.work_generate_blocking (nano::dev::genesis->hash ()))
Expand Down
14 changes: 7 additions & 7 deletions nano/core_test/block_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ TEST (mdb_block_store, sideband_height)
.send ()
.previous (nano::dev::genesis->hash ())
.destination (nano::dev::genesis_key.pub)
.balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio)
.balance (nano::dev::constants.genesis_amount - nano::Knano_ratio)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*pool.generate (nano::dev::genesis->hash ()))
.build ();
Expand All @@ -1035,7 +1035,7 @@ TEST (mdb_block_store, sideband_height)
.account (nano::dev::genesis_key.pub)
.previous (change->hash ())
.representative (0)
.balance (nano::dev::constants.genesis_amount - nano::Gxrb_ratio)
.balance (nano::dev::constants.genesis_amount - nano::Knano_ratio)
.link (key1.pub)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*pool.generate (change->hash ()))
Expand All @@ -1046,7 +1046,7 @@ TEST (mdb_block_store, sideband_height)
.account (nano::dev::genesis_key.pub)
.previous (state_send1->hash ())
.representative (0)
.balance (nano::dev::constants.genesis_amount - 2 * nano::Gxrb_ratio)
.balance (nano::dev::constants.genesis_amount - 2 * nano::Knano_ratio)
.link (key2.pub)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*pool.generate (state_send1->hash ()))
Expand All @@ -1057,7 +1057,7 @@ TEST (mdb_block_store, sideband_height)
.account (nano::dev::genesis_key.pub)
.previous (state_send2->hash ())
.representative (0)
.balance (nano::dev::constants.genesis_amount - 3 * nano::Gxrb_ratio)
.balance (nano::dev::constants.genesis_amount - 3 * nano::Knano_ratio)
.link (key3.pub)
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*pool.generate (state_send2->hash ()))
Expand All @@ -1068,7 +1068,7 @@ TEST (mdb_block_store, sideband_height)
.account (key1.pub)
.previous (0)
.representative (0)
.balance (nano::Gxrb_ratio)
.balance (nano::Knano_ratio)
.link (state_send1->hash ())
.sign (key1.prv, key1.pub)
.work (*pool.generate (key1.pub))
Expand All @@ -1079,7 +1079,7 @@ TEST (mdb_block_store, sideband_height)
.account (key1.pub)
.previous (state_open->hash ())
.representative (0)
.balance (nano::Gxrb_ratio)
.balance (nano::Knano_ratio)
.link (ledger.epoch_link (nano::epoch::epoch_1))
.sign (nano::dev::genesis_key.prv, nano::dev::genesis_key.pub)
.work (*pool.generate (state_open->hash ()))
Expand All @@ -1103,7 +1103,7 @@ TEST (mdb_block_store, sideband_height)
.account (key2.pub)
.previous (epoch_open->hash ())
.representative (0)
.balance (nano::Gxrb_ratio)
.balance (nano::Knano_ratio)
.link (state_send2->hash ())
.sign (key2.prv, key2.pub)
.work (*pool.generate (epoch_open->hash ()))
Expand Down
Loading

0 comments on commit 15e91e2

Please sign in to comment.