Skip to content

Commit

Permalink
Remove voting requirements for rex
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed May 3, 2024
1 parent b694722 commit a8afcee
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 36 deletions.
8 changes: 0 additions & 8 deletions contracts/eosio.system/include/eosio.system/eosio.system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -891,9 +891,6 @@ namespace eosiosystem {
* @param from - owner account name,
* @param amount - amount of tokens taken out of 'from' REX fund.
*
* @pre A voting requirement must be satisfied before action can be executed.
* @pre User must vote for at least 21 producers or delegate vote to proxy before buying REX.
*
* @post User votes are updated following this action.
* @post Tokens used in purchase are added to user's voting power.
* @post Bought REX cannot be sold before 4 days counting from end of day of purchase.
Expand All @@ -910,9 +907,6 @@ namespace eosiosystem {
* @param from_net - amount of tokens to be unstaked from NET bandwidth and used for REX purchase,
* @param from_cpu - amount of tokens to be unstaked from CPU bandwidth and used for REX purchase.
*
* @pre A voting requirement must be satisfied before action can be executed.
* @pre User must vote for at least 21 producers or delegate vote to proxy before buying REX.
*
* @post User votes are updated following this action.
* @post Tokens used in purchase are added to user's voting power.
* @post Bought REX cannot be sold before 4 days counting from end of day of purchase.
Expand Down Expand Up @@ -1569,8 +1563,6 @@ namespace eosiosystem {
void runrex( uint16_t max );
void update_rex_pool();
void update_resource_limits( const name& from, const name& receiver, int64_t delta_net, int64_t delta_cpu );
void check_voting_requirement( const name& owner,
const char* error_msg = "must vote for at least 21 producers or for a proxy before buying REX" )const;
rex_order_outcome fill_rex_order( const rex_balance_table::const_iterator& bitr, const asset& rex );
asset update_rex_account( const name& owner, const asset& proceeds, const asset& unstake_quant, bool force_vote_update = false );
void channel_to_rex( const name& from, const asset& amount, bool required = false );
Expand Down
15 changes: 0 additions & 15 deletions contracts/eosio.system/src/rex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ namespace eosiosystem {

check( amount.symbol == core_symbol(), "asset must be core token" );
check( 0 < amount.amount, "must use positive amount" );
check_voting_requirement( from );
transfer_from_fund( from, amount );
const asset rex_received = add_to_rex_pool( amount );
const asset delta_rex_stake = add_to_rex_balance( from, amount, rex_received );
Expand All @@ -75,7 +74,6 @@ namespace eosiosystem {
check( from_net.symbol == core_symbol() && from_cpu.symbol == core_symbol(), "asset must be core token" );
check( (0 <= from_net.amount) && (0 <= from_cpu.amount) && (0 < from_net.amount || 0 < from_cpu.amount),
"must unstake a positive amount to buy rex" );
check_voting_requirement( owner );

{
del_bandwidth_table dbw_table( get_self(), owner.value );
Expand Down Expand Up @@ -425,19 +423,6 @@ namespace eosiosystem {
}
}

/**
* @brief Checks if account satisfies voting requirement (voting for a proxy or 21 producers)
* for buying REX
*
* @param owner - account buying or already holding REX tokens
* @err_msg - error message
*/
void system_contract::check_voting_requirement( const name& owner, const char* error_msg )const
{
auto vitr = _voters.find( owner.value );
check( vitr != _voters.end() && ( vitr->proxy || 21 <= vitr->producers.size() ), error_msg );
}

/**
* @brief Checks if CPU and Network loans are available
*
Expand Down
4 changes: 0 additions & 4 deletions contracts/eosio.system/src/voting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,6 @@ namespace eosiosystem {

vote_stake_updater( voter_name );
update_votes( voter_name, proxy, producers, true );
auto rex_itr = _rexbalance.find( voter_name.value );
if( rex_itr != _rexbalance.end() && rex_itr->rex_balance.amount > 0 ) {
check_voting_requirement( voter_name, "voter holding REX tokens must vote for at least 21 producers or for a proxy" );
}
}

void system_contract::voteupdate( const name& voter_name ) {
Expand Down
9 changes: 0 additions & 9 deletions tests/eosio.system_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4165,8 +4165,6 @@ BOOST_FIXTURE_TEST_CASE( unstake_buy_rex, eosio_system_tester, * boost::unit_tes
BOOST_REQUIRE_EQUAL( get_net_limit( alice ), init_net_limit + net_stake.get_amount() );
BOOST_REQUIRE_EQUAL( success(),
vote( alice, std::vector<account_name>(producer_names.begin(), producer_names.begin() + 20) ) );
BOOST_REQUIRE_EQUAL( wasm_assert_msg("must vote for at least 21 producers or for a proxy before buying REX"),
unstaketorex( alice, alice, net_stake, cpu_stake ) );
BOOST_REQUIRE_EQUAL( success(),
vote( alice, std::vector<account_name>(producer_names.begin(), producer_names.begin() + 21) ) );
const asset init_eosio_stake_balance = get_balance( "eosio.stake"_n );
Expand Down Expand Up @@ -5188,8 +5186,6 @@ BOOST_FIXTURE_TEST_CASE( update_rex, eosio_system_tester, * boost::unit_test::to
}
}

BOOST_REQUIRE_EQUAL( wasm_assert_msg("voter holding REX tokens must vote for at least 21 producers or for a proxy"),
vote( alice, std::vector<account_name>(producer_names.begin(), producer_names.begin() + 20) ) );
BOOST_REQUIRE_EQUAL( success(),
vote( alice, std::vector<account_name>(producer_names.begin(), producer_names.begin() + 21) ) );

Expand Down Expand Up @@ -5225,8 +5221,6 @@ BOOST_FIXTURE_TEST_CASE( update_rex, eosio_system_tester, * boost::unit_test::to
BOOST_REQUIRE_EQUAL( success(), sellrex( alice, get_rex_balance( alice ) ) );
BOOST_REQUIRE_EQUAL( 0, get_rex_balance( alice ).get_amount() );
BOOST_REQUIRE_EQUAL( success(), vote( alice, { producer_names[0], producer_names[4] } ) );
BOOST_REQUIRE_EQUAL( wasm_assert_msg("must vote for at least 21 producers or for a proxy before buying REX"),
buyrex( alice, core_sym::from_string("1.0000") ) );

} FC_LOG_AND_RETHROW()

Expand Down Expand Up @@ -5531,9 +5525,6 @@ BOOST_FIXTURE_TEST_CASE( b1_vesting, eosio_system_tester ) try {
BOOST_REQUIRE_EQUAL( wasm_assert_msg("b1 can only claim their tokens over 10 years"),
unstake( b1, b1, final_amount, final_amount ) );

BOOST_REQUIRE_EQUAL( wasm_assert_msg("must vote for at least 21 producers or for a proxy before buying REX"),
unstaketorex( b1, b1, final_amount - small_amount, final_amount - small_amount ) );

BOOST_REQUIRE_EQUAL( error("missing authority of eosio"), vote( b1, { }, "proxyaccount"_n ) );

BOOST_REQUIRE_EQUAL( success(), unstake( b1, b1, final_amount - small_amount, final_amount - small_amount ) );
Expand Down

0 comments on commit a8afcee

Please sign in to comment.