Skip to content

Commit

Permalink
renaming functions
Browse files Browse the repository at this point in the history
  • Loading branch information
derpy-duck committed Oct 12, 2023
1 parent 4620276 commit b9c28d5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 5 additions & 7 deletions ethereum/contracts/relayer/libraries/Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,22 @@ import "../../interfaces/relayer/TypedUnits.sol";

error NotAnEvmAddress(bytes32);

uint256 constant GAS_LIMIT_EXTERNAL_CALL = 100_000;

function pay(address payable receiver, LocalNative amount) returns (bool success) {
uint256 amount_ = LocalNative.unwrap(amount);
if (amount_ != 0)
// TODO: we currently ignore the return data. Some users of this function might want to bubble up the return value though.
// Specifying a higher limit than 63/64 of the remaining gas caps it at that amount without throwing an exception.
(success,) = returnLengthBoundedCallWithValue(receiver, new bytes(0), gasleft(), amount_, 0);
(success,) = returnLengthBoundedCall(receiver, new bytes(0), gasleft(), amount_, 0);
else
success = true;
}

function payWithBoundedGas(address payable receiver, LocalNative amount, uint256 gasBound) returns (bool success) {
function pay(address payable receiver, LocalNative amount, uint256 gasBound) returns (bool success) {
uint256 amount_ = LocalNative.unwrap(amount);
if (amount_ != 0)
// TODO: we currently ignore the return data. Some users of this function might want to bubble up the return value though.
// Specifying a higher limit than 63/64 of the remaining gas caps it at that amount without throwing an exception.
(success,) = returnLengthBoundedCallWithValue(receiver, new bytes(0), gasBound, amount_, 0);
(success,) = returnLengthBoundedCall(receiver, new bytes(0), gasBound, amount_, 0);
else
success = true;
}
Expand Down Expand Up @@ -68,7 +66,7 @@ function returnLengthBoundedCall(
uint256 gasLimit,
uint256 dataLengthBound
) returns (bool success, bytes memory returnedData) {
return returnLengthBoundedCallWithValue(payable(callee), callData, gasLimit, 0, dataLengthBound);
return returnLengthBoundedCall(payable(callee), callData, gasLimit, 0, dataLengthBound);
}

/**
Expand All @@ -77,7 +75,7 @@ function returnLengthBoundedCall(
*
* @param returnedData Buffer of returned data truncated to the first `dataLengthBound` bytes.
*/
function returnLengthBoundedCallWithValue(
function returnLengthBoundedCall(
address payable callee,
bytes memory callData,
uint256 gasLimit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
import {IWormholeReceiver} from "../../interfaces/relayer/IWormholeReceiver.sol";
import {IDeliveryProvider} from "../../interfaces/relayer/IDeliveryProviderTyped.sol";

import {pay, payWithBoundedGas, min, toWormholeFormat, fromWormholeFormat, returnLengthBoundedCall, returnLengthBoundedCallWithValue, GAS_LIMIT_EXTERNAL_CALL} from "../../relayer/libraries/Utils.sol";
import {pay, pay, min, toWormholeFormat, fromWormholeFormat, returnLengthBoundedCall, returnLengthBoundedCall} from "../../relayer/libraries/Utils.sol";
import {
DeliveryInstruction,
DeliveryOverride,
Expand All @@ -45,6 +45,8 @@ import "../../relayer/libraries/ExecutionParameters.sol";

uint256 constant QUOTE_LENGTH_BYTES = 32;

uint256 constant GAS_LIMIT_EXTERNAL_CALL = 100_000;

abstract contract WormholeRelayerDelivery is WormholeRelayerBase, IWormholeRelayerDelivery {
using WormholeRelayerSerde for *;
using BytesParsing for bytes;
Expand Down Expand Up @@ -328,7 +330,7 @@ abstract contract WormholeRelayerDelivery is WormholeRelayerBase, IWormholeRelay
// Calls the `receiveWormholeMessages` endpoint on the contract `evmInstruction.targetAddress`
// (with the gas limit and value specified in instruction, and `encodedVMs` as the input)
// If it reverts, returns the first 132 bytes of the revert message
(success, results.additionalStatusInfo) = returnLengthBoundedCallWithValue(
(success, results.additionalStatusInfo) = returnLengthBoundedCall(
deliveryTarget,
callData,
gasLimit.unwrap(),
Expand Down Expand Up @@ -452,7 +454,7 @@ abstract contract WormholeRelayerDelivery is WormholeRelayerBase, IWormholeRelay
) private returns (RefundStatus) {
// User requested refund on this chain
if (refundChain == getChainId()) {
return payWithBoundedGas(payable(fromWormholeFormat(refundAddress)), refundAmount, GAS_LIMIT_EXTERNAL_CALL)
return pay(payable(fromWormholeFormat(refundAddress)), refundAmount, GAS_LIMIT_EXTERNAL_CALL)
? RefundStatus.REFUND_SENT
: RefundStatus.REFUND_FAIL;
}
Expand Down

0 comments on commit b9c28d5

Please sign in to comment.