diff --git a/contracts/eosio.system/delegate_bandwidth.cpp b/contracts/eosio.system/delegate_bandwidth.cpp index 181f3ca3b0326389412bcb1febe18deb24f8ba54..c6600dce4240b9946b669f7e6b8bec11625599b3 100644 --- a/contracts/eosio.system/delegate_bandwidth.cpp +++ b/contracts/eosio.system/delegate_bandwidth.cpp @@ -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 ); } diff --git a/externals/binaryen b/externals/binaryen index b4b5dc9dee60489c4206af99227524b13f2eb3aa..579f3a099c286a45f58ea1ffc7bf671c415be0a6 160000 --- a/externals/binaryen +++ b/externals/binaryen @@ -1 +1 @@ -Subproject commit b4b5dc9dee60489c4206af99227524b13f2eb3aa +Subproject commit 579f3a099c286a45f58ea1ffc7bf671c415be0a6 diff --git a/libraries/appbase b/libraries/appbase index 70e23f7ebbdccb64f9ac11ade9fa41ba78b31b5e..50dc015b2f0e25c0cd01cf520245da23c0ed446b 160000 --- a/libraries/appbase +++ b/libraries/appbase @@ -1 +1 @@ -Subproject commit 70e23f7ebbdccb64f9ac11ade9fa41ba78b31b5e +Subproject commit 50dc015b2f0e25c0cd01cf520245da23c0ed446b diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index f82f48562084249a7f87b709192eb4d7ea37fea4..7eccb70e200581b7cdc54edd4130f41ee4cd24de 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -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 diff --git a/unittests/bootseq_tests.cpp b/unittests/bootseq_tests.cpp index 786c641468bbe1a0be53e06faa4aa56c5579b542..b2b9ea6c4884a0a571cb17c8ca4c73d034185096 100644 --- a/unittests/bootseq_tests.cpp +++ b/unittests/bootseq_tests.cpp @@ -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) diff --git a/unittests/eosio_system_tester.hpp b/unittests/eosio_system_tester.hpp index 673af4a6f111f3b52eafa9dfc4b73d80683284d1..e17548042bfbfb5cd705328180bc4c26eb8da413 100644 --- a/unittests/eosio_system_tester.hpp +++ b/unittests/eosio_system_tester.hpp @@ -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 );