tezos-checker / checker

An in-development "robocoin" system for the Tezos blockchain
24 stars 16 forks source link

Minor reductions in gas costs and byte size #199

Closed gkaracha closed 3 years ago

gkaracha commented 3 years ago

Following @utdemir's comment I found that there are several places with unnecessary nat/int casts. Removing some of these conversions seems to lead to a rather small but consistent reduction in both size and gas costs on most entrypoints:

Sizes

                        touch: ~63491 bytes => ~63431 bytes
                      buy_kit:  ~1472 bytes =>  ~1462 bytes
                     burn_kit:  ~1872 bytes =>  ~1870 bytes
                     mint_kit:  ~2058 bytes =>  ~2054 bytes
                     sell_kit:  ~1472 bytes =>  ~1462 bytes
                  deposit_tez:  ~1269 bytes =>  ~1267 bytes
                 touch_burrow:   ~754 bytes =>   ~752 bytes
                 withdraw_tez:  ~1608 bytes =>  ~1604 bytes
                add_liquidity:  ~2131 bytes =>  ~2121 bytes
              activate_burrow:  ~1391 bytes =>  ~1389 bytes
             remove_liquidity:  ~2223 bytes =>  ~2211 bytes
            deactivate_burrow:  ~1812 bytes =>  ~1808 bytes
          set_burrow_delegate:  ~1289 bytes =>  ~1287 bytes
         mark_for_liquidation: ~19724 bytes => ~19710 bytes
     cancel_liquidation_slice: ~14149 bytes => ~14143 bytes
     touch_liquidation_slices: ~16673 bytes => ~16669 bytes
liquidation_auction_place_bid:  ~2407 bytes =>  ~2393 bytes

Gas costs

              touch: 542399 => 541949
            buy_kit:  69861 =>  69785
           burn_kit:  52644 =>  52629
           mint_kit:  53831 =>  53799
           sell_kit:  68988 =>  68912
        deposit_tez:  53472 =>  53457
       touch_burrow:  44732 =>  44715
       withdraw_tez:  58057 =>  58028
      add_liquidity:  73908 =>  73832
    activate_burrow:  54282 =>  54267
   remove_liquidity:  74180 =>  74089
  deactivate_burrow:  59614 =>  59583
set_burrow_delegate:  55157 =>  55140
gkaracha commented 3 years ago

Great, thanks the review! :+1: