@@ -886,27 +886,15 @@ static uint64_t evmHandleCallInternal(zen::runtime::EVMInstance *Instance,
886886
887887 uint64_t CallGas = Gas;
888888 bool HasEnoughBalance = true ;
889- if (HasValueArgs && HasValue) {
890- const auto CallerBalance = Module->Host ->get_balance (CurrentMsg->recipient );
891- const intx::uint256 CallerValue =
892- intx::be::load<intx::uint256>(CallerBalance);
893- HasEnoughBalance = CallerValue >= intx::uint256 (Value);
894- }
895889
896890 if (HasValueArgs) {
897891 std::optional<bool > AccountState;
898892 uint64_t GasCost = HasValue ? zen::evm::CALL_VALUE_COST : 0 ;
899- if (HasValue && !HasEnoughBalance) {
900- GasCost -= zen::evm::CALL_GAS_STIPEND;
901- }
902893 if (CallKind == EVMC_CALL) {
903894 if (HasValue || Instance->getRevision () < EVMC_SPURIOUS_DRAGON) {
904895 AccountState = Module->Host ->account_exists (TargetAddr);
905896 if (!AccountState.value ()) {
906897 GasCost += zen::evm::ACCOUNT_CREATION_COST;
907- if (HasValue && HasEnoughBalance) {
908- GasCost -= zen::evm::CALL_GAS_STIPEND;
909- }
910898 }
911899 }
912900 }
@@ -924,11 +912,16 @@ static uint64_t evmHandleCallInternal(zen::runtime::EVMInstance *Instance,
924912 }
925913
926914 if (HasValueArgs && HasValue) {
915+ CallGas += zen::evm::CALL_GAS_STIPEND;
916+ Instance->addGas (zen::evm::CALL_GAS_STIPEND);
917+ const auto CallerBalance = Module->Host ->get_balance (CurrentMsg->recipient );
918+ const intx::uint256 CallerValue =
919+ intx::be::load<intx::uint256>(CallerBalance);
920+ HasEnoughBalance = CallerValue >= intx::uint256 (Value);
927921 if (!HasEnoughBalance) {
928922 Instance->setReturnData ({});
929923 return 0 ;
930924 }
931- CallGas += zen::evm::CALL_GAS_STIPEND;
932925 }
933926
934927 uint8_t *MemoryBase = Instance->getMemoryBase ();
@@ -972,11 +965,6 @@ static uint64_t evmHandleCallInternal(zen::runtime::EVMInstance *Instance,
972965 GasLeft = 0 ;
973966 }
974967 uint64_t GasUsed = CallGas > GasLeft ? CallGas - GasLeft : 0 ;
975- if (HasValue) {
976- GasUsed = GasUsed > zen::evm::CALL_GAS_STIPEND
977- ? GasUsed - zen::evm::CALL_GAS_STIPEND
978- : 0 ;
979- }
980968 if (GasUsed > 0 ) {
981969 Instance->chargeGas (GasUsed);
982970 }
0 commit comments