You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Context and scope
When a message is delivered, an external call is made to the destinationAddress specified by the message sender where the amount of gas the call can use is specified in the message by the requiredGasLimit value. The return data from this call is not used and only the success of the call is recorded. Although a gas limit is set for the call, the external contract could force the transaction to use gas in excess of the specified limit due to an open issue with the Solidity compiler. This is possible because the TeleporterMessenger contract pays for memory expansion to accommodate the return data, but the external contract controls the size of that return data. Consider using assembly to explicitly prevent any memory from being allocated for the return data from the external call.
// Call the destination address of the message with the formatted call data.
// Only provide the required gas limit to the sub-call so that the end application
// cannot consume an arbitrary amount gas.
bytes memory payload = abi.encodeCall(
ITeleporterReceiver.receiveTeleporterMessage,
(originChainID, message.senderAddress, message.message)
);
address target = message.destinationAddress;
uint256 requiredGas = message.requiredGasLimit;
bool success;
assembly ("memory-safe") {
success := call(
requiredGas, // gas provided to the call
target, // call target
0, // zero value
add(payload, 0x20), // input data
mload(payload), // input data length
0, // output
0 // output size
)
}
// If the execution failed, store a hash of the message in state such that its
// execution can be retried again in the future with a higher gas limit (paid by whoever
// retries).Either way, the message will now be considered "delivered" since the relayer
// provided enough gas to meet the required gas limit.
if (!success) {
_storeFailedMessageExecution(originChainID, message);
return;
}
Open questions
Does call in assembly return false if the contract being call hits a revert statement?
The text was updated successfully, but these errors were encountered:
Context and scope
When a message is delivered, an external call is made to the
destinationAddress
specified by the message sender where the amount of gas the call can use is specified in the message by therequiredGasLimit
value. The return data from this call is not used and only thesuccess
of the call is recorded. Although a gas limit is set for the call, the external contract could force the transaction to use gas in excess of the specified limit due to an open issue with the Solidity compiler. This is possible because theTeleporterMessenger
contract pays for memory expansion to accommodate the return data, but the external contract controls the size of that return data. Consider using assembly to explicitly prevent any memory from being allocated for the return data from the external call.See reference here.
For instance, the change could look like:
Open questions
Does
call
in assembly return false if the contract being call hits arevert
statement?The text was updated successfully, but these errors were encountered: