@@ -74,41 +74,30 @@ failed_pre:
7474fn call_gas_extra(inst=0xf1 u8, value u256, warm u1, exists u1) -> (gas_extra=2600 u64, stipend u64)
7575;; PRE: inst in {0xf1,0xf2,0xf4,0xf5]
7676{
77-   var gas_transfer u16
78-   var gas_new_account u16
7977  var gas_access u16
78+   var notWarm, notExists u1
79+   ;; inversions
80+   notWarm = 1 - warm
81+   notExists = 1 - exists
82+   ;; calculate gas access cost
83+   gas_access = (warm * G_WARMACCESS) + (notWarm * G_COLDACCOUNTACCESS)
8084  ;;
81-   if inst == 0xf1 goto call_only
82-   if inst == 0xf2 goto call_other
83-   if inst == 0xf4 goto call_no_transfer
84-   if inst == 0xfa goto call_no_transfer
85-   fail
86- call_only:
8785  if value == 0 goto call_no_transfer
88-   if exists == 1 goto call_other
86+   if inst == EVM_INST_CALL goto call
87+   if inst == EVM_INST_CALLCODE goto callcode
88+   goto call_no_transfer
89+ call:
8990  stipend = G_CALLSTIPEND
90-   gas_transfer = G_CALLVALUE
91-   gas_new_account = G_NEWACCOUNT
92-   goto call
93- call_other:
94-   if value == 0 goto call_no_transfer
91+   gas_extra = gas_access + G_CALLVALUE + (notExists * G_NEWACCOUNT)
92+   return
93+ callcode:
9594  stipend = G_CALLSTIPEND
96-   gas_transfer = G_CALLVALUE
97-   gas_new_account = 0
98-   goto call
95+   gas_extra = gas_access + G_CALLVALUE
96+   return
9997call_no_transfer:
100-   stipend = 0
101-   gas_transfer = 0
102-   gas_new_account = 0
103- call:
104-   ;; check for warm access
105-   if warm == 0 goto call_cold
106-   gas_access = G_WARMACCESS
107-   goto call_cont
108- call_cold:
109-   gas_access = G_COLDACCOUNTACCESS
110- call_cont:
111-   gas_extra = gas_access + gas_transfer + gas_new_account
98+   ;; staticcall / delegatecall
99+   stipend=0
100+   gas_extra = gas_access
112101  return
113102}
114103
0 commit comments