|
4 | 4 | */
|
5 | 5 |
|
6 | 6 | #include <eosio/chain/chain_controller.hpp>
|
7 |
| -#include <eosio/chain/contracts/staked_balance_objects.hpp> |
8 | 7 |
|
9 | 8 | #include <eosio/chain/block_summary_object.hpp>
|
10 | 9 | #include <eosio/chain/global_property_object.hpp>
|
|
16 | 15 | #include <eosio/chain/permission_link_object.hpp>
|
17 | 16 | #include <eosio/chain/authority_checker.hpp>
|
18 | 17 | #include <eosio/chain/contracts/chain_initializer.hpp>
|
19 |
| -#include <eosio/chain/contracts/producer_objects.hpp> |
20 | 18 | #include <eosio/chain/scope_sequence_object.hpp>
|
21 | 19 | #include <eosio/chain/merkle.hpp>
|
22 | 20 |
|
@@ -918,28 +916,8 @@ void chain_controller::create_block_summary(const signed_block& next_block) {
|
918 | 916 | * block_signing_key is null.
|
919 | 917 | */
|
920 | 918 | producer_schedule_type chain_controller::_calculate_producer_schedule()const {
|
| 919 | + producer_schedule_type schedule = get_global_properties().new_active_producers; |
921 | 920 |
|
922 |
| - return get_global_properties().active_producers; |
923 |
| - |
924 |
| - //const auto& producers_by_vote = _db.get_index<contracts::producer_votes_multi_index,contracts::by_votes>(); |
925 |
| - //auto itr = producers_by_vote.begin(); |
926 |
| - // FC_ASSERT( itr != producers_by_vote.end() ); |
927 |
| - |
928 |
| - producer_schedule_type schedule; |
929 |
| - uint32_t count = 0; |
930 |
| - wdump((schedule.producers)); |
931 |
| - /* |
932 |
| - while( itr != producers_by_vote.end() && count < schedule.producers.size() ) { |
933 |
| - ilog( "." ); |
934 |
| - schedule.producers[count].producer_name = itr->owner_name; |
935 |
| - schedule.producers[count].block_signing_key = get_producer(itr->owner_name).signing_key; |
936 |
| - ++itr; |
937 |
| - if( schedule.producers[count].block_signing_key != public_key_type() ) { |
938 |
| - ++count; |
939 |
| - } |
940 |
| - } |
941 |
| - */ |
942 |
| - ilog( "." ); |
943 | 921 | const auto& hps = _head_producer_schedule();
|
944 | 922 | schedule.version = hps.version;
|
945 | 923 | if( hps != schedule )
|
@@ -1087,6 +1065,7 @@ void chain_controller::_initialize_chain(contracts::chain_initializer& starter)
|
1087 | 1065 | const auto& gp = _db.create<global_property_object>([&starter](global_property_object& p) {
|
1088 | 1066 | p.configuration = starter.get_chain_start_configuration();
|
1089 | 1067 | p.active_producers = starter.get_chain_start_producers();
|
| 1068 | + p.new_active_producers = starter.get_chain_start_producers(); |
1090 | 1069 | wdump((starter.get_chain_start_producers()));
|
1091 | 1070 | });
|
1092 | 1071 |
|
@@ -1590,38 +1569,33 @@ void chain_controller::update_usage( transaction_metadata& meta, uint32_t act_us
|
1590 | 1569 |
|
1591 | 1570 | auto head_time = head_block_time();
|
1592 | 1571 | for( const auto& authaccnt : authorizing_accounts ) {
|
| 1572 | + |
1593 | 1573 | const auto& buo = _db.get<bandwidth_usage_object,by_owner>( authaccnt.first );
|
1594 | 1574 | _db.modify( buo, [&]( auto& bu ){
|
1595 | 1575 | bu.bytes.add_usage( trx_size, head_time );
|
1596 | 1576 | bu.acts.add_usage( act_usage, head_time );
|
1597 | 1577 | });
|
1598 |
| - const auto& sbo = _db.get<contracts::staked_balance_object, contracts::by_owner_name>(authaccnt.first); |
1599 |
| - // TODO enable this after fixing divide by 0 with virtual_net_bandwidth and total_staked_tokens |
1600 |
| - /// note: buo.bytes.value is in ubytes and virtual_net_bandwidth is in bytes, so |
1601 |
| - // we convert to fixed int uin128_t with 60 bits of precision, divide by rate limiting precision |
1602 |
| - // then divide by virtual max_block_size which gives us % of virtual max block size in fixed width |
1603 | 1578 |
|
1604 | 1579 | uint128_t used_ubytes = buo.bytes.value;
|
1605 | 1580 | uint128_t used_uacts = buo.acts.value;
|
1606 | 1581 | uint128_t virtual_max_ubytes = dgpo.virtual_net_bandwidth * config::rate_limiting_precision;
|
1607 | 1582 | uint128_t virtual_max_uacts = dgpo.virtual_act_bandwidth * config::rate_limiting_precision;
|
1608 |
| - uint64_t user_stake = sbo.staked_balance; |
1609 | 1583 |
|
1610 | 1584 | if( !(_skip_flags & genesis_setup) ) {
|
1611 |
| - FC_ASSERT( (used_ubytes * dgpo.total_staked_tokens) <= (user_stake * virtual_max_ubytes), "authorizing account '${n}' has insufficient net bandwidth for this transaction", |
| 1585 | + FC_ASSERT( (used_ubytes * dgpo.total_net_weight) <= (buo.net_weight * virtual_max_ubytes), "authorizing account '${n}' has insufficient net bandwidth for this transaction", |
1612 | 1586 | ("n",name(authaccnt.first))
|
1613 | 1587 | ("used_bytes",double(used_ubytes)/1000000.)
|
1614 |
| - ("user_stake",user_stake) |
| 1588 | + ("user_net_weight",buo.net_weight) |
1615 | 1589 | ("virtual_max_bytes", double(virtual_max_ubytes)/1000000. )
|
1616 |
| - ("total_staked_tokens", dgpo.total_staked_tokens) |
| 1590 | + ("total_net_weight", dgpo.total_net_weight) |
1617 | 1591 | );
|
1618 |
| - FC_ASSERT( (used_uacts * dgpo.total_staked_tokens) <= (user_stake * virtual_max_uacts), "authorizing account '${n}' has insufficient compute bandwidth for this transaction", |
| 1592 | + FC_ASSERT( (used_uacts * dgpo.total_cpu_weight) <= (buo.cpu_weight* virtual_max_uacts), "authorizing account '${n}' has insufficient compute bandwidth for this transaction", |
1619 | 1593 | ("n",name(authaccnt.first))
|
1620 | 1594 | ("used_acts",double(used_uacts)/1000000.)
|
1621 |
| - ("user_stake",user_stake) |
| 1595 | + ("user_cpu_weight",buo.cpu_weight) |
1622 | 1596 | ("virtual_max_uacts", double(virtual_max_uacts)/1000000. )
|
1623 |
| - ("total_staked_tokens", dgpo.total_staked_tokens) |
1624 |
| - ); |
| 1597 | + ("total_cpu_tokens", dgpo.total_cpu_weight) |
| 1598 | + ); |
1625 | 1599 | }
|
1626 | 1600 |
|
1627 | 1601 | // for any transaction not sent by code, update the affirmative last time a given permission was used
|
|
0 commit comments