Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/tasks/MultisigTask.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ abstract contract MultisigTask is Test, Script, StateOverrideManager, TaskManage
using AccountAccessParser for VmSafe.AccountAccess;
using StdStyle for string;

/// @notice Maximum gas limit for transactions (14M gas to leave margin below Fusaka EIP-7825 cap of 16,777,216)
uint256 internal constant MAX_GAS_LIMIT = 14_000_000;
Comment thread
mds1 marked this conversation as resolved.
Outdated

/// @notice AddressesRegistry contract
AddressRegistry public addrRegistry;

Expand Down Expand Up @@ -519,6 +522,30 @@ abstract contract MultisigTask is Test, Script, StateOverrideManager, TaskManage

(bool success, bytes memory returnData) = multisig.call{gas: gas}(callData);

// Check that the transaction did not exceed the maximum gas limit.
// We must check gas consumed BEFORE refunds, because the EVM requires enough gas upfront,
// therefore we check gasTotalUsed + gasRefunded
// Note: gasRefunded is int64, but should always be >= 0 in practice, unsure why this is
// an int64 in forge.
VmSafe.Gas memory gasInfo = vm.lastCallGas();
require(gasInfo.gasRefunded >= 0, "MultisigTask: negative gas refund is invalid");
uint256 gasRefunded = uint256(uint64(gasInfo.gasRefunded));
uint256 gasConsumedBeforeRefund = uint256(gasInfo.gasTotalUsed) + gasRefunded;
require(
gasConsumedBeforeRefund <= MAX_GAS_LIMIT,
string.concat(
"MultisigTask: transaction exceeds 14M gas limit (consumed before refund: ",
vm.toString(gasConsumedBeforeRefund),
", refunded: ",
vm.toString(gasRefunded),
", final used: ",
vm.toString(gasInfo.gasTotalUsed),
", limit: ",
vm.toString(MAX_GAS_LIMIT),
"). Fusaka EIP-7825 cap is 16,777,216 gas."
)
);

if (!success) {
MultisigTaskPrinter.printErrorExecutingMultisigTransaction(returnData);
revert("MultisigTask: execute failed");
Expand Down