@@ -548,7 +548,7 @@ const instr_info* op_jumpi(const instr_info* instr, execution_state& state) noex
548
548
549
549
const instr_info* op_pc (const instr_info* instr, execution_state& state) noexcept
550
550
{
551
- state.stack .push (instr->arg .p . number );
551
+ state.stack .push (instr->arg .number );
552
552
return ++instr;
553
553
}
554
554
@@ -560,7 +560,7 @@ const instr_info* op_msize(const instr_info* instr, execution_state& state) noex
560
560
561
561
const instr_info* op_gas (const instr_info* instr, execution_state& state) noexcept
562
562
{
563
- const auto correction = state.current_block_cost - instr->arg .p . number ;
563
+ const auto correction = state.current_block_cost - instr->arg .number ;
564
564
const auto gas = static_cast <uint64_t >(state.gas_left + correction);
565
565
state.stack .push (gas);
566
566
return ++instr;
@@ -793,6 +793,7 @@ const instr_info* op_revert(const instr_info*, execution_state& state) noexcept
793
793
return state.exit (EVMC_REVERT);
794
794
}
795
795
796
+ template <evmc_call_kind kind>
796
797
const instr_info* op_call (const instr_info* instr, execution_state& state) noexcept
797
798
{
798
799
const auto arg = instr->arg ;
@@ -820,26 +821,29 @@ const instr_info* op_call(const instr_info* instr, execution_state& state) noexc
820
821
821
822
822
823
auto msg = evmc_message{};
823
- msg.kind = arg. p . call_kind ;
824
+ msg.kind = kind ;
824
825
msg.flags = state.msg ->flags ;
825
826
msg.value = intx::be::store<evmc::uint256be>(value);
826
827
827
- auto correction = state.current_block_cost - arg.p . number ;
828
+ auto correction = state.current_block_cost - arg.number ;
828
829
auto gas_left = state.gas_left + correction;
829
830
830
831
auto cost = 0 ;
831
832
auto has_value = value != 0 ;
833
+
832
834
if (has_value)
833
- {
834
- if (arg.p .call_kind == EVMC_CALL && state.msg ->flags & EVMC_STATIC)
835
- return state.exit (EVMC_STATIC_MODE_VIOLATION);
836
835
cost += 9000 ;
837
- }
838
836
839
- if (arg. p . call_kind == EVMC_CALL && (has_value || state. rev < EVMC_SPURIOUS_DRAGON) )
837
+ if constexpr (kind == EVMC_CALL)
840
838
{
841
- if (!state.host .account_exists (dst))
842
- cost += 25000 ;
839
+ if (has_value && state.msg ->flags & EVMC_STATIC)
840
+ return state.exit (EVMC_STATIC_MODE_VIOLATION);
841
+
842
+ if (has_value || state.rev < EVMC_SPURIOUS_DRAGON)
843
+ {
844
+ if (!state.host .account_exists (dst))
845
+ cost += 25000 ;
846
+ }
843
847
}
844
848
845
849
if ((gas_left -= cost) < 0 )
@@ -938,7 +942,7 @@ const instr_info* op_delegatecall(const instr_info* instr, execution_state& stat
938
942
auto msg = evmc_message{};
939
943
msg.kind = EVMC_DELEGATECALL;
940
944
941
- auto correction = state.current_block_cost - arg.p . number ;
945
+ auto correction = state.current_block_cost - arg.number ;
942
946
auto gas_left = state.gas_left + correction;
943
947
944
948
// TEST: Gas saturation for big gas values.
@@ -1013,7 +1017,7 @@ const instr_info* op_staticcall(const instr_info* instr, execution_state& state)
1013
1017
1014
1018
msg.depth = state.msg ->depth + 1 ;
1015
1019
1016
- auto correction = state.current_block_cost - arg.p . number ;
1020
+ auto correction = state.current_block_cost - arg.number ;
1017
1021
auto gas_left = state.gas_left + correction;
1018
1022
1019
1023
msg.gas = std::numeric_limits<int64_t >::max ();
@@ -1077,7 +1081,7 @@ const instr_info* op_create(const instr_info* instr, execution_state& state) noe
1077
1081
1078
1082
auto msg = evmc_message{};
1079
1083
1080
- auto correction = state.current_block_cost - arg.p . number ;
1084
+ auto correction = state.current_block_cost - arg.number ;
1081
1085
msg.gas = state.gas_left + correction;
1082
1086
if (state.rev >= EVMC_TANGERINE_WHISTLE)
1083
1087
msg.gas = msg.gas - msg.gas / 64 ;
@@ -1143,7 +1147,7 @@ const instr_info* op_create2(const instr_info* instr, execution_state& state) no
1143
1147
1144
1148
auto msg = evmc_message{};
1145
1149
1146
- auto correction = state.current_block_cost - arg.p . number ;
1150
+ auto correction = state.current_block_cost - arg.number ;
1147
1151
auto gas = state.gas_left + correction;
1148
1152
msg.gas = gas - gas / 64 ;
1149
1153
@@ -1200,7 +1204,7 @@ const instr_info* op_selfdestruct(const instr_info*, execution_state& state) noe
1200
1204
1201
1205
const instr_info* opx_beginblock (const instr_info* instr, execution_state& state) noexcept
1202
1206
{
1203
- auto & block = state.analysis ->blocks [static_cast <size_t >(instr->arg .p . number )];
1207
+ auto & block = state.analysis ->blocks [static_cast <size_t >(instr->arg .number )];
1204
1208
1205
1209
if ((state.gas_left -= block.gas_cost ) < 0 )
1206
1210
return state.exit (EVMC_OUT_OF_GAS);
@@ -1324,8 +1328,8 @@ constexpr exec_fn_table create_op_table_frontier() noexcept
1324
1328
table[OP_LOG4] = op_log<OP_LOG4>;
1325
1329
1326
1330
table[OP_CREATE] = op_create;
1327
- table[OP_CALL] = op_call;
1328
- table[OP_CALLCODE] = op_call;
1331
+ table[OP_CALL] = op_call<EVMC_CALL> ;
1332
+ table[OP_CALLCODE] = op_call<EVMC_CALLCODE> ;
1329
1333
table[OP_RETURN] = op_return;
1330
1334
table[OP_INVALID] = op_invalid;
1331
1335
table[OP_SELFDESTRUCT] = op_selfdestruct;
0 commit comments