Skip to content

Commit

Permalink
introduce change for issue #609
Browse files Browse the repository at this point in the history
Test for new behavior was uncommented. Old test for voting only had to be corrected in one place
(which only shows that it is pretty bad).
  • Loading branch information
ABW committed Nov 24, 2023
1 parent b60f8db commit 2fcf722
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
6 changes: 5 additions & 1 deletion libraries/chain/hive_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1796,7 +1796,11 @@ void hf20_vote_evaluator( const vote_operation& o, database& _db )
int16_t abs_weight = abs( o.weight );
uint128_t used_mana = 0;

if( dgpo.downvote_pool_percent && o.weight < 0 )
if( _db.has_hardfork( HIVE_HARDFORK_1_28_STABLE_VOTE ) )
{
used_mana = ( uint128_t( voter.get_effective_vesting_shares().value ) * abs_weight * 60 * 60 * 24 ) / HIVE_100_PERCENT;
}
else if( dgpo.downvote_pool_percent && o.weight < 0 )
{
if( _db.has_hardfork( HIVE_HARDFORK_0_22__3485 ) )
{
Expand Down
4 changes: 2 additions & 2 deletions libraries/chain/include/hive/chain/global_property_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ namespace hive { namespace chain {

/**
* The number of votes regenerated per day. Any user voting slower than this rate will be
* "wasting" voting power through spillover; any user voting faster than this rate will have
* their votes reduced.
* "wasting" voting power through spillover; any user voting faster than this rate will
* eventually exhaust their voting mana (since HF28, previously their vote was reduced).
*/
uint32_t vote_power_reserve_rate = HIVE_INITIAL_VOTE_POWER_RATE;

Expand Down
2 changes: 2 additions & 0 deletions libraries/protocol/hardfork.d/1_28.hf
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ long next_hf_time();
#define HIVE_HARDFORK_1_28_NO_VOTE_LIMIT (HIVE_HARDFORK_1_28)
// fix way of detecting "no-op" [cancel] power down operation
#define HIVE_HARDFORK_1_28_FIX_CANCEL_POWER_DOWN (HIVE_HARDFORK_1_28)
// use max mana instead of current when determining strength of vote (issue #609)
#define HIVE_HARDFORK_1_28_STABLE_VOTE (HIVE_HARDFORK_1_28)

#endif
4 changes: 2 additions & 2 deletions tests/unit/tests/hf28_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ BOOST_AUTO_TEST_CASE( vote_stabilization )
ilog( "${i}: downvote with ${p} BP of full power", ( i )( "p", last_power * HIVE_100_PERCENT / full_power ) );
}
generate_block();
/*

BOOST_TEST_MESSAGE( "Testing consecutive single block votes and downvotes after HF28" );

inject_hardfork( HIVE_BLOCKCHAIN_VERSION.minor_v() );
Expand Down Expand Up @@ -1022,7 +1022,7 @@ BOOST_AUTO_TEST_CASE( vote_stabilization )
++i;
HIVE_REQUIRE_ASSERT( vote_reply( i, -HIVE_100_PERCENT, "anticarol", anticarol_post_key ),
"voter.voting_manabar.current_mana + voter.downvote_manabar.current_mana > fc::uint128_to_int64( used_mana )" );
*/

validate_database();
}
FC_LOG_AND_RETHROW()
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/tests/operation_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ BOOST_AUTO_TEST_CASE( vote_apply )
BOOST_REQUIRE( itr->get_rshares() == ( old_mana - _alice.voting_manabar.current_mana ) - HIVE_VOTE_DUST_THRESHOLD );
validate_database();

BOOST_TEST_MESSAGE( "--- Test reduced power for quick voting" );
BOOST_TEST_MESSAGE( "--- Test reduced power for quick voting" ); // no such feature (anymore) - even more true after HF28

generate_blocks( db->head_block_time() + HIVE_MIN_VOTE_INTERVAL_SEC );

Expand Down Expand Up @@ -923,7 +923,7 @@ BOOST_AUTO_TEST_CASE( vote_apply )
old_manabar.last_update_time = _alice.voting_manabar.last_update_time;
old_manabar.regenerate_mana( params, db->head_block_time() );
old_downvote_manabar.regenerate_mana( params, db->head_block_time() );
alice_weight = old_manabar.current_mana * 60 * 60 * 24;
alice_weight = params.max_mana * 60 * 60 * 24;
max_vote_denom = db->get_dynamic_global_properties().vote_power_reserve_rate * HIVE_VOTING_MANA_REGENERATION_SECONDS;
alice_weight = ( alice_weight + max_vote_denom - 1 ) / max_vote_denom;

Expand Down

0 comments on commit 2fcf722

Please sign in to comment.