提交 6144a9b9 编写于 作者: D Daniel Larimer

Segregate EOSIO.SYSTEM funds #3291

- all ram trading fees sent from user to eosio.ramfee (also implement 1% fee Fix #3182)
- all tokens received for ram sent to eosio.ram
- all proceeds from selling ram sent from eosio.ram
- all staked tokens sent to eosio.stake
- all unstaked tokens sent from eosio.stake
- fix build dependency issue with ram_tests
上级 dd0cb785
......@@ -107,24 +107,32 @@ namespace eosiosystem {
require_auth( payer );
eosio_assert( quant.amount > 0, "must purchase a positive amount" );
auto fee = quant;
fee.amount /= 200; /// .5% fee
auto quant_after_fee = quant;
quant_after_fee.amount -= fee.amount;
if( payer != N(eosio) ) {
INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {payer,N(active)},
{ payer, N(eosio), quant, std::string("buy ram") } );
{ payer, N(eosio.ram), quant_after_fee, std::string("buy ram") } );
}
if( fee.amount > 0 ) {
INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {payer,N(active)},
{ payer, N(eosio.ramfee), fee, std::string("ram fee") } );
}
int64_t bytes_out;
auto itr = _rammarket.find(S(4,RAMCORE));
_rammarket.modify( itr, 0, [&]( auto& es ) {
bytes_out = es.convert( quant, S(0,RAM) ).amount;
bytes_out = es.convert( quant_after_fee, S(0,RAM) ).amount;
});
eosio_assert( bytes_out > 0, "must reserve a positive amount" );
_gstate.total_ram_bytes_reserved += uint64_t(bytes_out);
_gstate.total_ram_stake += quant.amount;
_gstate.total_ram_stake += quant_after_fee.amount;
user_resources_table userres( _self, receiver );
auto res_itr = userres.find( receiver );
......@@ -176,7 +184,12 @@ namespace eosiosystem {
if( N(eosio) != account ) {
INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {N(eosio),N(active)},
{ N(eosio), account, asset(tokens_out), std::string("sell ram") } );
{ N(eosio.ram), account, asset(tokens_out), std::string("sell ram") } );
auto fee = tokens_out.amount / 200;
if( fee > 0 ) {
INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {N(eosio),N(active)},
{ account, N(eosio.ramfee), asset(fee), std::string("sell ram fee") } );
}
}
}
......@@ -317,7 +330,7 @@ namespace eosiosystem {
auto transfer_amount = net_balance + cpu_balance;
if ( asset(0) < transfer_amount ) {
INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {from,N(active)},
{ source_stake_from, N(eosio), asset(transfer_amount), std::string("stake bandwidth") } );
{ source_stake_from, N(eosio.stake), asset(transfer_amount), std::string("stake bandwidth") } );
}
}
......@@ -380,7 +393,7 @@ namespace eosiosystem {
// consecutive missed blocks.
INLINE_ACTION_SENDER(eosio::token, transfer)( N(eosio.token), {N(eosio),N(active)},
{ N(eosio), req->owner, req->net_amount + req->cpu_amount, std::string("unstake") } );
{ N(eosio.stake), req->owner, req->net_amount + req->cpu_amount, std::string("unstake") } );
refunds_tbl.erase( req );
}
......
Subproject commit b4b5dc9dee60489c4206af99227524b13f2eb3aa
Subproject commit 579f3a099c286a45f58ea1ffc7bf671c415be0a6
Subproject commit 70e23f7ebbdccb64f9ac11ade9fa41ba78b31b5e
Subproject commit 50dc015b2f0e25c0cd01cf520245da23c0ed446b
......@@ -27,7 +27,7 @@ target_link_libraries( unit_test eosio_chain chainbase eosio_testing eos_utiliti
target_include_directories( unit_test PUBLIC ${CMAKE_BINARY_DIR}/contracts ${CMAKE_CURRENT_BINARY_DIR}/tests/contracts )
target_include_directories( unit_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/wasm_tests )
target_include_directories( unit_test PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include )
add_dependencies(unit_test asserter test_api test_api_mem test_api_db test_api_multi_index exchange eosio.token proxy identity identity_test stltest infinite eosio.system eosio.token eosio.bios test.inline multi_index_test noop dice eosio.msig payloadless tic_tac_toe)
add_dependencies(unit_test asserter test_api test_api_mem test_api_db test_ram_limit test_api_multi_index exchange eosio.token proxy identity identity_test stltest infinite eosio.system eosio.token eosio.bios test.inline multi_index_test noop dice eosio.msig payloadless tic_tac_toe)
#Manually run unit_test for all supported runtimes
#To run unit_test with all log from blockchain displayed, put --verbose after --, i.e. unit_test -- --verbose
......
......@@ -182,7 +182,7 @@ BOOST_FIXTURE_TEST_CASE( bootseq_test, bootseq_tester ) {
try {
// Create eosio.msig and eosio.token
create_accounts({N(eosio.msig), N(eosio.token)});
create_accounts({N(eosio.msig), N(eosio.token), N(eosio.ram), N(eosio.ramfee), N(eosio.stake) });
// Set code for the following accounts:
// - eosio (code: eosio.bios) (already set by tester constructor)
......
......@@ -46,7 +46,7 @@ public:
produce_blocks( 2 );
create_accounts( { N(eosio.token) } );
create_accounts({N(eosio.msig), N(eosio.token), N(eosio.ram), N(eosio.ramfee), N(eosio.stake) });
produce_blocks( 100 );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册