Skip to content

Commit

Permalink
2% inflation to voters (double previous)
Browse files Browse the repository at this point in the history
  • Loading branch information
porkchop committed Aug 5, 2022
1 parent 187880c commit deb8c3e
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 47 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## Pending (wax-1.7.0-X.Y.Z)
## Pending (wax-2.1.12-X.Y.Z)

BREAKING CHANGES:

Expand All @@ -10,6 +10,19 @@ IMPROVEMENTS:

BUG FIXES:

## wax-2.10.12-3.0.0

BREAKING CHANGES:

FEATURES:

IMPROVEMENTS:
- voters reward bumped to 2%
- producers sorted by location
- genesis tokens no longer submitted on claimgbmprod nor claimgbmvote. GBM is over and these actions are equivament to claimrewards and voterclaim, respectively

BUG FIXES:

## wax-1.7.0-2.1.1

BREAKING CHANGES:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ After build:
Run interactive tests:
1. Start the interactive shell: `make dev-docker-start`
1. Run all the tests: `make test`
1. Run a single test: `make compile && ./build/tests/unit_test --log_level=all --run_test=eosio_wps_tests/committee_reg_edit_rmv`
1. Run a single test: `make compile && ./build/tests/unit_test --log_level=all --run_test=eosio_system_tests/producer_pay_as_gbm`

### License
[MIT](https://github.com/worldwide-asset-exchange/wax-eos-contracts/blob/master/LICENSE)
Expand Down
19 changes: 8 additions & 11 deletions contracts/eosio.system/src/producer_pay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ namespace eosiosystem {
const auto unstake_time = std::min(current_time_point(), gbm_final_time);
const int64_t delta_time_usec = (gbm_final_time - unstake_time).count();
auto new_tokens = static_cast<int64_t>( (continuous_rate * double(token_supply.amount) * double(usecs_since_last_fill)) / double(useconds_per_year) );
// needs to be 1/2 Savings, 1/5 Voters, GBM receives a linearly deflating share over three years
auto to_voters = new_tokens / 5;
auto to_per_block_pay = to_voters;
// needs to be 2/5 Savings, 2/5 Voters, 1/5 producers, GBM receives a linearly deflating share over three years, which has already expired as of July 1 2022
auto to_per_block_pay = new_tokens / 5;
auto to_voters = 2 * to_per_block_pay;
auto to_savings = new_tokens - (to_voters + to_per_block_pay);
auto to_gbm = to_voters * 2 * (delta_time_usec / double(useconds_in_gbm_period));
new_tokens += to_gbm;
auto to_gbm = to_voters * (delta_time_usec / double(useconds_in_gbm_period));
new_tokens += to_gbm; // always 0 as of July 1, 2022

{
token::issue_action issue_act{ token_account, { {get_self(), active_permission} } };
Expand All @@ -101,6 +101,7 @@ namespace eosiosystem {
}
}

// as_gbm is deprecated and maintained only for backwards compatibility with existing actions
void system_contract::claim_producer_rewards( const name owner, bool as_gbm ) {
require_auth( owner );

Expand Down Expand Up @@ -161,12 +162,8 @@ namespace eosiosystem {
});

if( producer_per_block_pay > 0 ) {
if(as_gbm){
send_genesis_token( bpay_account, owner, asset(producer_per_block_pay, core_symbol()));
}else {
token::transfer_action transfer_act{ token_account, { {bpay_account, active_permission}, {owner, active_permission} } };
transfer_act.send( bpay_account, owner, asset(producer_per_block_pay, core_symbol()), "producer block pay" );
}
token::transfer_action transfer_act{ token_account, { {bpay_account, active_permission}, {owner, active_permission} } };
transfer_act.send( bpay_account, owner, asset(producer_per_block_pay, core_symbol()), "producer block pay" );
}
}

Expand Down
5 changes: 2 additions & 3 deletions contracts/eosio.system/src/voting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,8 @@ namespace eosiosystem {
}

void system_contract::claimgbmvote(const name owner) {
int64_t reward = collect_voter_reward(owner);

send_genesis_token( voters_account, owner, asset(reward, core_symbol()));
// gbm is expired, this action does a regular voterclaim now
voterclaim(owner);
}

int64_t system_contract::collect_voter_reward(const name owner) {
Expand Down
5 changes: 2 additions & 3 deletions deploy-system-contract.bash
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ then
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 # handle exits from shell or function but don't exit interactive shell
fi

production_url=https://chain.wax.io
production_url=https://wax.greymass.com

chain_url=$production_url

Expand All @@ -40,8 +40,7 @@ $EOSC vault create --import --vault-file $TEMP_VAULT_FILE
make clean # if this fails, do `sudo make clean`
rm $DEPLOYMENT_FILE
make dev-docker-all
$CLEOS set contract eosio ./build/contracts/eosio.system/ -x 604800 -s -d --json > $DEPLOYMENT_FILE
$EOSC multisig cancel $PROPOSER_ACCOUNT $PROPOSAL_NAME $PROPOSER_ACCOUNT --vault-file $TEMP_VAULT_FILE || echo "Proposal did not already exist - excellent"
$EOSC system setcontract eosio ./build/contracts/eosio.system/eosio.system.wasm ./build/contracts/eosio.system/eosio.system.abi --write-transaction $DEPLOYMENT_FILE --skip-sign --expiration 604800
$EOSC multisig propose $PROPOSER_ACCOUNT $PROPOSAL_NAME $DEPLOYMENT_FILE --request admin.wax --with-subaccounts --vault-file $TEMP_VAULT_FILE
echo "use this command to review the multisig proposal: '$EOSC multisig review $PROPOSER_ACCOUNT $PROPOSAL_NAME'"
echo "use this command to execute the multisig proposal: '$EOSC multisig exec $PROPOSER_ACCOUNT $PROPOSAL_NAME $PROPOSER_ACCOUNT' (You will probably need to create a vault for your proposer account 'eosc vault create --import')"
Expand Down
48 changes: 20 additions & 28 deletions tests/eosio.system_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1579,7 +1579,7 @@ BOOST_FIXTURE_TEST_CASE(voter_pay, eosio_system_tester, * boost::unit_test::tole
BOOST_REQUIRE_EQUAL(0, voters_bucket); // all tokens were already distributed

BOOST_REQUIRE_EQUAL(add_gbm(new_tokens), supply.get_amount() - initial_supply.get_amount());
BOOST_REQUIRE_EQUAL(int64_t(new_tokens / 5), balance.get_amount() - initial_balance.get_amount());
BOOST_REQUIRE_EQUAL(int64_t(new_tokens / 5) * 2, balance.get_amount() - initial_balance.get_amount());
}

{
Expand Down Expand Up @@ -1630,7 +1630,7 @@ BOOST_FIXTURE_TEST_CASE(voter_pay, eosio_system_tester, * boost::unit_test::tole
BOOST_REQUIRE_EQUAL(0, voters_bucket); // all tokens were already distributed

BOOST_REQUIRE_EQUAL(add_gbm(new_tokens), supply.get_amount() - initial_supply.get_amount());
BOOST_REQUIRE_EQUAL(int64_t(new_tokens / 5), balance.get_amount() - initial_balance.get_amount());
BOOST_REQUIRE_EQUAL(int64_t(new_tokens / 5) * 2, balance.get_amount() - initial_balance.get_amount());
}

// Voting less than 16 producers should award no rewards
Expand Down Expand Up @@ -1714,8 +1714,8 @@ BOOST_FIXTURE_TEST_CASE(multiple_voters, eosio_system_tester, * boost::unit_test
asset balance2 = get_balance(N(voter2)) - initial_balance2;
asset supply = get_token_supply();

uint64_t voters_inflation = (mid_term_supply.get_amount() - initial_supply.get_amount()) / 5
+ (supply.get_amount() - mid_term_supply.get_amount()) / 5;
uint64_t voters_inflation = 2 * (mid_term_supply.get_amount() - initial_supply.get_amount()) / 5
+ 2 * (supply.get_amount() - mid_term_supply.get_amount()) / 5;

// Both voters should get almost the same reward (the difference is caused by the 0.5 seconds between claims).
BOOST_REQUIRE(5 > balance1.get_amount() - balance2.get_amount());
Expand Down Expand Up @@ -1778,7 +1778,7 @@ BOOST_FIXTURE_TEST_CASE(multiple_voters, eosio_system_tester, * boost::unit_test
asset balance1 = get_balance(N(voter1));
asset balance2 = get_balance(N(voter2));

BOOST_REQUIRE(2000 > (balance1.get_amount() - initial_balance1.get_amount()) / 2 - (balance2.get_amount() - initial_balance2.get_amount()));
BOOST_REQUIRE(4000 > (balance1.get_amount() - initial_balance1.get_amount()) / 2 - (balance2.get_amount() - initial_balance2.get_amount()));
}

// Updating votes.
Expand All @@ -1805,8 +1805,8 @@ BOOST_FIXTURE_TEST_CASE(multiple_voters, eosio_system_tester, * boost::unit_test
asset balance1 = get_balance(N(voter1));
asset balance2 = get_balance(N(voter2));

// Check out if the 2000 extra grains is fine.
BOOST_REQUIRE(balance1.get_amount() - initial_balance1.get_amount() > balance2.get_amount() - initial_balance2.get_amount() + 2000);
// Check out if the 4000 extra grains is fine.
BOOST_REQUIRE(balance1.get_amount() - initial_balance1.get_amount() > balance2.get_amount() - initial_balance2.get_amount() + 4000);
}

// Claiming after unstaking
Expand Down Expand Up @@ -1920,7 +1920,7 @@ BOOST_FIXTURE_TEST_CASE(voter_gbm_pay, eosio_system_tester, * boost::unit_test::
BOOST_REQUIRE_EQUAL(0, voters_bucket); // all tokens were already distributed

BOOST_REQUIRE_EQUAL(add_gbm(new_tokens), supply.get_amount() - initial_supply.get_amount());
BOOST_REQUIRE_EQUAL(int64_t(new_tokens / 5), genesis_balance.get_amount() - initial_genesis_balance.get_amount());
BOOST_REQUIRE_EQUAL(0, genesis_balance.get_amount() - initial_genesis_balance.get_amount());
}

{
Expand Down Expand Up @@ -1971,7 +1971,7 @@ BOOST_FIXTURE_TEST_CASE(voter_gbm_pay, eosio_system_tester, * boost::unit_test::
BOOST_REQUIRE_EQUAL(0, voters_bucket); // all tokens were already distributed

BOOST_REQUIRE_EQUAL(add_gbm(new_tokens), supply.get_amount() - initial_supply.get_amount());
BOOST_REQUIRE_EQUAL(int64_t(new_tokens / 5), genesis_balance.get_amount() - initial_genesis_balance.get_amount());
BOOST_REQUIRE_EQUAL(0, genesis_balance.get_amount() - initial_genesis_balance.get_amount());
}

// Voting less than 16 producers should award no rewards
Expand All @@ -1990,7 +1990,7 @@ BOOST_FIXTURE_TEST_CASE(voter_gbm_pay, eosio_system_tester, * boost::unit_test::
const asset supply = get_token_supply();
const asset genesis_balance = get_genesis_balance(N(producvotera));

BOOST_REQUIRE((supply.get_amount() - initial_supply.get_amount()) / 5 >= genesis_balance.get_amount() - initial_genesis_balance.get_amount());
BOOST_REQUIRE(0 == genesis_balance.get_amount() - initial_genesis_balance.get_amount());

produce_block(fc::hours(24));
// There should be no more rewards available
Expand Down Expand Up @@ -2146,7 +2146,7 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t
BOOST_REQUIRE_EQUAL(0, initial_pervote_bucket);

BOOST_REQUIRE_EQUAL(add_gbm(new_tokens), supply.get_amount() - initial_supply.get_amount());
BOOST_REQUIRE_EQUAL(int64_t(new_tokens - (new_tokens / 5) * 2), savings - initial_savings);
BOOST_REQUIRE_EQUAL(int64_t(new_tokens - (new_tokens / 5) * 3), savings - initial_savings);
BOOST_REQUIRE_EQUAL(int64_t(new_tokens / 5), balance.get_amount() - initial_balance.get_amount());

int64_t from_perblock_bucket = int64_t( initial_supply.get_amount() * double(secs_between_fills) * (continuous_rate / 5.) / secs_per_year ) ;
Expand Down Expand Up @@ -2219,7 +2219,7 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t

BOOST_REQUIRE_EQUAL(add_gbm(int64_t( ( double(initial_supply.get_amount()) * double(usecs_between_fills) * continuous_rate / usecs_per_year ) )),
supply.get_amount() - initial_supply.get_amount());
BOOST_REQUIRE(5 > ((supply.get_amount() - initial_supply.get_amount()) - ((supply.get_amount() - initial_supply.get_amount()) / 5) * 2) -
BOOST_REQUIRE(5 > ((supply.get_amount() - initial_supply.get_amount()) - ((supply.get_amount() - initial_supply.get_amount()) / 5) * 3) -
add_gbm(savings - initial_savings));

int64_t to_producer = int64_t( (double(initial_supply.get_amount()) * double(usecs_between_fills) * continuous_rate) / usecs_per_year ) / 5;
Expand Down Expand Up @@ -2261,7 +2261,7 @@ BOOST_FIXTURE_TEST_CASE(producer_pay, eosio_system_tester, * boost::unit_test::t
// Amount issued per year is very close to the 6% inflation target. Small difference (500 tokens out of 50'000'000 issued)
// is due to compounding every 8 hours in this test as opposed to theoretical continuous compounding
BOOST_REQUIRE(500 * 10000 > int64_t(double(initial_supply.get_amount()) * double(0.06)) - (supply.get_amount() - initial_supply.get_amount()));
BOOST_REQUIRE(500 * 10000 > int64_t(double(initial_supply.get_amount()) * double(0.03)) - (savings - initial_savings));
BOOST_REQUIRE(500 * 10000 > int64_t(double(initial_supply.get_amount()) * double(0.02)) - (savings - initial_savings));
}

} FC_LOG_AND_RETHROW()
Expand Down Expand Up @@ -2333,13 +2333,8 @@ BOOST_FIXTURE_TEST_CASE(producer_pay_as_gbm, eosio_system_tester, * boost::unit_
BOOST_REQUIRE_EQUAL(0, initial_perblock_bucket);

BOOST_REQUIRE_EQUAL(add_gbm(new_tokens), supply.get_amount() - initial_supply.get_amount());
BOOST_REQUIRE_EQUAL(int64_t(new_tokens - (new_tokens / 5) * 2), savings - initial_savings);
BOOST_REQUIRE_EQUAL(new_tokens / 5, genesis_balance.get_amount() - initial_genesis_balance.get_amount());

int64_t from_perblock_bucket = int64_t( initial_supply.get_amount() * double(secs_between_fills) * (continuous_rate/ 5.) / secs_per_year ) ;


BOOST_REQUIRE_EQUAL(from_perblock_bucket, genesis_balance.get_amount() - initial_genesis_balance.get_amount());
BOOST_REQUIRE_EQUAL(int64_t(new_tokens - (new_tokens / 5) * 3), savings - initial_savings);
BOOST_REQUIRE_EQUAL(0, genesis_balance.get_amount() - initial_genesis_balance.get_amount());
}

{
Expand Down Expand Up @@ -2395,13 +2390,10 @@ BOOST_FIXTURE_TEST_CASE(producer_pay_as_gbm, eosio_system_tester, * boost::unit_

BOOST_REQUIRE_EQUAL(add_gbm(int64_t( ( double(initial_supply.get_amount()) * double(usecs_between_fills) * continuous_rate / usecs_per_year )) ),
supply.get_amount() - initial_supply.get_amount());
BOOST_REQUIRE(5 > ((supply.get_amount() - initial_supply.get_amount()) - ((supply.get_amount() - initial_supply.get_amount()) / 5) * 2) -
BOOST_REQUIRE(5 > ((supply.get_amount() - initial_supply.get_amount()) - ((supply.get_amount() - initial_supply.get_amount()) / 5) * 3) -
add_gbm(savings - initial_savings));

int64_t to_producer = int64_t( (double(initial_supply.get_amount()) * double(usecs_between_fills) * continuous_rate) / usecs_per_year ) / 5;
int64_t to_perblock_bucket = to_producer;

BOOST_REQUIRE_EQUAL(to_perblock_bucket, genesis_balance.get_amount() - initial_genesis_balance.get_amount());
BOOST_REQUIRE_EQUAL(0, genesis_balance.get_amount() - initial_genesis_balance.get_amount());
}

// defproducerb tries to claim rewards but he's not on the list
Expand Down Expand Up @@ -2430,7 +2422,7 @@ BOOST_FIXTURE_TEST_CASE(producer_pay_as_gbm, eosio_system_tester, * boost::unit_
// Amount issued per year is very close to the 6% inflation target. Small difference (500 tokens out of 50'000'000 issued)
// is due to compounding every 8 hours in this test as opposed to theoretical continuous compounding
BOOST_REQUIRE(500 * 10000 > int64_t(double(initial_supply.get_amount()) * double(0.06)) - (supply.get_amount() - initial_supply.get_amount()));
BOOST_REQUIRE(500 * 10000 > int64_t(double(initial_supply.get_amount()) * double(0.03)) - (savings - initial_savings));
BOOST_REQUIRE(500 * 10000 > int64_t(double(initial_supply.get_amount()) * double(0.02)) - (savings - initial_savings));
}

} FC_LOG_AND_RETHROW()
Expand Down Expand Up @@ -2577,7 +2569,7 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni
const double expected_supply_growth = initial_supply.get_amount() * double(usecs_between_fills) * cont_rate / usecs_per_year;
BOOST_REQUIRE_EQUAL( add_gbm(int64_t(expected_supply_growth)), supply.get_amount() - initial_supply.get_amount() );

BOOST_REQUIRE_EQUAL( int64_t(expected_supply_growth) - (int64_t(expected_supply_growth)/5 * 2), savings - initial_savings );
BOOST_REQUIRE_EQUAL( int64_t(expected_supply_growth) - (int64_t(expected_supply_growth)/5 * 3), savings - initial_savings );

const int64_t expected_perblock_bucket = int64_t( double(initial_supply.get_amount()) * double(usecs_between_fills) * (cont_rate / 5.) / usecs_per_year );
const int64_t expected_pervote_bucket = 0;
Expand Down Expand Up @@ -2648,7 +2640,7 @@ BOOST_FIXTURE_TEST_CASE(multiple_producer_pay, eosio_system_tester, * boost::uni

const double expected_supply_growth = initial_supply.get_amount() * double(usecs_between_fills) * cont_rate / usecs_per_year;
BOOST_REQUIRE_EQUAL( add_gbm(int64_t(expected_supply_growth)), supply.get_amount() - initial_supply.get_amount() );
BOOST_REQUIRE_EQUAL( int64_t(expected_supply_growth) - (int64_t(expected_supply_growth) / 5 * 2), savings - initial_savings );
BOOST_REQUIRE_EQUAL( int64_t(expected_supply_growth) - (int64_t(expected_supply_growth) / 5 * 3), savings - initial_savings );

const int64_t expected_perblock_bucket = int64_t( double(initial_supply.get_amount()) * double(usecs_between_fills) * (cont_rate/ 5.) / usecs_per_year )
+ initial_perblock_bucket;
Expand Down

0 comments on commit deb8c3e

Please sign in to comment.