cadawg cross-posted this post in OCD 6 years ago


What is SoftFork 0.22.2? A dive into the code

in Programming & Dev6 years ago (edited)

SoftFork 0.22.2 confused me as much as it probably did the rest of you, I slept through the fork and so I was very confused, let's take a look into the code:

/* If the time of the current block is more than the target SoftFork time */

if ( fc::time_point_sec( STEEM_PROTECTION_HARDFORK_TIME ) <= head_block_time() )
   {

Based on the kind of operation, block it if it's from a STEEMIT, Inc owned account and:

      switch( op.which() )
      {

It's a witness vote or proxy

         case operation::tag<account_witness_proxy_operation>::value:
            if ( hardforkprotect::get_steemit_accounts().count( op.get< account_witness_proxy_operation >().account ) )
               FC_THROW_EXCEPTION(transaction_exception, "Error when pushing TX:\nReason: TX has been rejected.");
            break;
         case operation::tag<account_witness_vote_operation>::value:
            if ( hardforkprotect::get_steemit_accounts().count( op.get< account_witness_vote_operation >().account ) )
               FC_THROW_EXCEPTION(transaction_exception, "Error when pushing TX:\nReason: TX has been rejected.");
            break;
         case 

It's a proposal vote

operation::tag<update_proposal_votes_operation>::value:
            if ( hardforkprotect::get_steemit_accounts().count( op.get< update_proposal_votes_operation >().voter ) )
               FC_THROW_EXCEPTION(transaction_exception, "Error when pushing TX:\nReason: TX has been rejected.");
            break;

It's a post vote

         case operation::tag<vote_operation>::value:
            if ( hardforkprotect::get_steemit_accounts().count( op.get< vote_operation >().voter ) )
               FC_THROW_EXCEPTION(transaction_exception, "Error when pushing TX:\nReason: TX has been rejected.");
            break;

It's a powerdown (you can powerdown to other accounts)

         case operation::tag<withdraw_vesting_operation>::value:
            if ( hardforkprotect::get_steemit_accounts().count( op.get< withdraw_vesting_operation >().account ) )
               FC_THROW_EXCEPTION(transaction_exception, "Error when pushing TX:\nReason: TX has been rejected.");
            break;

Trying to set powerdown route (account to powerdown to)

         case operation::tag<set_withdraw_vesting_route_operation>::value:
            if ( hardforkprotect::get_steemit_accounts().count( op.get< set_withdraw_vesting_route_operation >().from_account ) )
               FC_THROW_EXCEPTION(transaction_exception, "Error when pushing TX:\nReason: TX has been rejected.");
            break;

Trying to do a plain-old transfer

         case operation::tag<transfer_operation>::value:
            if ( hardforkprotect::get_steemit_accounts().count( op.get< transfer_operation >().from ) )
               FC_THROW_EXCEPTION(transaction_exception, "Error when pushing TX:\nReason: TX has been rejected.");
            break;

Trying to make a market order

         case operation::tag<limit_order_create_operation>::value:
            if ( hardforkprotect::get_steemit_accounts().count( op.get< limit_order_create_operation >().owner ) )
               FC_THROW_EXCEPTION(transaction_exception, "Error when pushing TX:\nReason: TX has been rejected.");
            break;
         case operation::tag<limit_order_create2_operation>::value:
            if ( hardforkprotect::get_steemit_accounts().count( op.get< limit_order_create2_operation >().owner ) )
               FC_THROW_EXCEPTION(transaction_exception, "Error when pushing TX:\nReason: TX has been rejected.");
            break;

Powering up

         case operation::tag<transfer_to_vesting_operation>::value:
            if ( hardforkprotect::get_steemit_accounts().count( op.get< transfer_to_vesting_operation >().from ) )
               FC_THROW_EXCEPTION(transaction_exception, "Error when pushing TX:\nReason: TX has been rejected.");
            break;

Sending to savings

         case operation::tag<transfer_to_savings_operation>::value:
            if ( hardforkprotect::get_steemit_accounts().count( op.get< transfer_to_savings_operation >().from ) )
               FC_THROW_EXCEPTION(transaction_exception, "Error when pushing TX:\nReason: TX has been rejected.");
            break;

Using inbuilt escrow function of the chain to make a transfer

         case operation::tag<escrow_transfer_operation>::value:
            if ( hardforkprotect::get_steemit_accounts().count( op.get< escrow_transfer_operation >().from ) )
               FC_THROW_EXCEPTION(transaction_exception, "Error when pushing TX:\nReason: TX has been rejected.");
            break;

For any other transaction, allow (so long as all the other requirements are ok)

         default:
            break;
      }
   }

Hope this helps you to understand,
~ @CADawg