@@ -1073,6 +1073,8 @@ namespace golos { namespace chain {
10731073 GOLOS_ASSERT (fc::raw::pack_size (trx) <= (get_dynamic_global_properties ().maximum_block_size - 256 ),
10741074 golos::protocol::tx_too_long, " Transaction data is too long. Maximum transaction size ${max} bytes" ,
10751075 (" max" ,get_dynamic_global_properties ().maximum_block_size - 256 ));
1076+ GOLOS_ASSERT (!is_transit_enabled (), golos::transit_enabled_exception,
1077+ " Migrating to CyberWay disabled transaction accepting to prevent user actions lost." );
10761078 with_weak_write_lock ([&]() {
10771079 detail::with_producing (*this , [&]() {
10781080 _push_transaction (trx, skip);
@@ -1162,7 +1164,9 @@ namespace golos { namespace chain {
11621164
11631165 uint64_t postponed_tx_count = 0 ;
11641166 // pop pending state (reset to head block state)
1165- for (const signed_transaction &tx : _pending_tx) {
1167+ if (is_transit_enabled ()) {
1168+ wlog (" Migrating to CyberWay disables generating blocks with transactions." );
1169+ } else for (const signed_transaction &tx : _pending_tx) {
11661170 // Only include transactions that have not expired yet for currently generating block,
11671171 // this should clear problem transactions and allow block production to continue
11681172
@@ -1475,6 +1479,58 @@ namespace golos { namespace chain {
14751479 }
14761480 }
14771481
1482+ bool database::is_transit_enabled () const {
1483+ return
1484+ has_hardfork (STEEMIT_HARDFORK_0_21__1348 ) &&
1485+ get_dynamic_global_properties ().transit_block_num != std::numeric_limits<uint32_t >::max ();
1486+ }
1487+
1488+ void database::process_transit_to_cyberway (const signed_block& b, uint32_t skip) {
1489+ if (!has_hardfork (STEEMIT_HARDFORK_0_21__1348 )) {
1490+ return ;
1491+ }
1492+
1493+ const auto & gpo = get_dynamic_global_properties ();
1494+
1495+ if (!is_transit_enabled ()) {
1496+ vector<account_name_type> transit_witnesses;
1497+ transit_witnesses.reserve (STEEMIT_MAX_WITNESSES );
1498+
1499+ uint32_t i;
1500+ const auto & wso = get_witness_schedule_object ();
1501+ for (i = 0 ; i < wso.num_scheduled_witnesses ; ++i) {
1502+ auto & witness = get_witness (wso.current_shuffled_witnesses [i]);
1503+ if (witness.schedule != witness_object::top19) {
1504+ // skip
1505+ } else if (witness.transit_to_cyberway_vote != STEEMIT_GENESIS_TIME ) {
1506+ transit_witnesses.push_back (witness.owner );
1507+ }
1508+ }
1509+
1510+ if (transit_witnesses.size () >= STEEMIT_TRANSIT_REQUIRED_WITNESSES ) {
1511+ modify (gpo, [&](auto & o) {
1512+ i = 0 ;
1513+ o.transit_block_num = b.block_num ();
1514+ for (auto owner: transit_witnesses) {
1515+ o.transit_witnesses [i++] = owner;
1516+ }
1517+ });
1518+ } else {
1519+ return ;
1520+ }
1521+ }
1522+
1523+ if (is_transit_enabled ()) {
1524+ if (skip & skip_block_log) {
1525+ set_revision (gpo.head_block_number );
1526+ }
1527+
1528+ if (gpo.transit_block_num == gpo.last_irreversible_block_num ) {
1529+ STEEMIT_TRY_NOTIFY (transit_to_cyberway, b.block_num (), skip);
1530+ }
1531+ }
1532+ }
1533+
14781534 void database::update_witness_schedule4 () {
14791535 vector<account_name_type> active_witnesses;
14801536 active_witnesses.reserve (STEEMIT_MAX_WITNESSES );
@@ -3057,6 +3113,7 @@ namespace golos { namespace chain {
30573113 _my->_evaluator_registry .register_evaluator <delegate_vesting_shares_evaluator>();
30583114 _my->_evaluator_registry .register_evaluator <delegate_vesting_shares_with_interest_evaluator>();
30593115 _my->_evaluator_registry .register_evaluator <reject_vesting_shares_delegation_evaluator>();
3116+ _my->_evaluator_registry .register_evaluator <transit_to_cyberway_evaluator>();
30603117 _my->_evaluator_registry .register_evaluator <proposal_create_evaluator>();
30613118 _my->_evaluator_registry .register_evaluator <proposal_update_evaluator>();
30623119 _my->_evaluator_registry .register_evaluator <proposal_delete_evaluator>();
@@ -3589,6 +3646,11 @@ namespace golos { namespace chain {
35893646 );
35903647 }
35913648
3649+ if (is_transit_enabled ()) {
3650+ FC_ASSERT (next_block.transactions .empty (),
3651+ " Migrating to CyberWay disabled accepting blocks with transactions." );
3652+ }
3653+
35923654 for (const auto &trx : next_block.transactions ) {
35933655 /* We do not need to push the undo state for each transaction
35943656 * because they either all apply and are valid or the
@@ -3610,33 +3672,43 @@ namespace golos { namespace chain {
36103672 update_last_irreversible_block (skip);
36113673
36123674 create_block_summary (next_block);
3613- clear_expired_proposals ();
3614- clear_expired_transactions ();
3615- clear_expired_orders ();
3616- clear_expired_delegations ();
3675+
3676+ if (is_transit_enabled ()) {
3677+ wlog (" Migrating to Cyberway disables the processes to prevent lost of account balances" );
3678+ } else {
3679+ clear_expired_proposals ();
3680+ clear_expired_transactions ();
3681+ clear_expired_orders ();
3682+ clear_expired_delegations ();
3683+ }
3684+
36173685 update_witness_schedule ();
36183686
3619- update_median_feed ();
3620- update_virtual_supply ();
3687+ if (!is_transit_enabled ()) {
3688+ update_median_feed ();
3689+ update_virtual_supply ();
36213690
3622- clear_null_account_balance ();
3623- process_funds ();
3624- process_conversions ();
3625- process_comment_cashout ();
3626- process_vesting_withdrawals ();
3627- process_savings_withdraws ();
3628- pay_liquidity_reward ();
3629- update_virtual_supply ();
3691+ clear_null_account_balance ();
3692+ process_funds ();
3693+ process_conversions ();
3694+ process_comment_cashout ();
3695+ process_vesting_withdrawals ();
3696+ process_savings_withdraws ();
3697+ pay_liquidity_reward ();
3698+ update_virtual_supply ();
36303699
3631- account_recovery_processing ();
3632- expire_escrow_ratification ();
3633- process_decline_voting_rights ();
3700+ account_recovery_processing ();
3701+ expire_escrow_ratification ();
3702+ process_decline_voting_rights ();
3703+ }
36343704
36353705 process_hardforks ();
36363706
36373707 // notify observers that the block has been applied
36383708 notify_applied_block (next_block);
36393709
3710+ process_transit_to_cyberway (next_block, skip);
3711+
36403712 notify_changed_objects ();
36413713
36423714 } FC_CAPTURE_LOG_AND_RETHROW ((next_block.block_num ()))
@@ -3903,9 +3975,7 @@ namespace golos { namespace chain {
39033975 modify (witness_missed, [&](witness_object &w) {
39043976 w.total_missed ++;
39053977 if (has_hardfork (STEEMIT_HARDFORK_0_14__278 )) {
3906- if (head_block_num () -
3907- w.last_confirmed_block_num >
3908- STEEMIT_BLOCKS_PER_DAY ) {
3978+ if (head_block_num () - w.last_confirmed_block_num > STEEMIT_BLOCKS_PER_DAY ) {
39093979 w.signing_key = public_key_type ();
39103980 push_virtual_operation (shutdown_witness_operation (w.owner ));
39113981 }
@@ -4076,10 +4146,18 @@ namespace golos { namespace chain {
40764146 b->last_confirmed_block_num ;
40774147 });
40784148
4079- uint32_t new_last_irreversible_block_num = wit_objs[offset]->last_confirmed_block_num ;
4149+ uint32_t new_last_irreversible_block_num = std::min (
4150+ uint32_t (wit_objs[offset]->last_confirmed_block_num ),
4151+ _fixed_irreversible_block_num);
4152+
4153+ if (new_last_irreversible_block_num > dpo.last_irreversible_block_num ) {
4154+ if (is_transit_enabled () &&
4155+ dpo.transit_block_num > dpo.last_irreversible_block_num &&
4156+ dpo.transit_block_num <= new_last_irreversible_block_num
4157+ ) {
4158+ new_last_irreversible_block_num = dpo.transit_block_num ;
4159+ }
40804160
4081- if (new_last_irreversible_block_num >
4082- dpo.last_irreversible_block_num ) {
40834161 modify (dpo, [&](dynamic_global_property_object &_dpo) {
40844162 _dpo.last_irreversible_block_num = new_last_irreversible_block_num;
40854163 });
0 commit comments