Commit 2013c903 authored by Michael Amadi's avatar Michael Amadi Committed by GitHub

fix abi.encodecall semgrep check for tests (#12664)

* fix abi.encodecall semgrep for tests

* fix safe call test

* rm unneccessary abi.encodeWithSignature, fix fuzz test

* use comment for semgrep...

* use comment for semgrep...

* use pattern-not for expectRevert cases

* fixes

* fixes

* try fix ci

* fix...
parent db39e52a
......@@ -19,9 +19,11 @@ interface Vm {
library console {
address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);
function _castLogPayloadViewToPure(
function(bytes memory) internal view fnIn
) internal pure returns (function(bytes memory) internal pure fnOut) {
function _castLogPayloadViewToPure(function(bytes memory) internal view fnIn)
internal
pure
returns (function(bytes memory) internal pure fnOut)
{
assembly {
fnOut := fnIn
}
......@@ -42,30 +44,29 @@ library console {
}
function log(string memory p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string)", p0));
_sendLogPayload(abi.encodeWithSignature("log(string)", p0)); // nosemgrep: sol-style-use-abi-encodecall
}
function log(string memory p0, bool p1) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,bool)", p0, p1));
_sendLogPayload(abi.encodeWithSignature("log(string,bool)", p0, p1)); // nosemgrep: sol-style-use-abi-encodecall
}
function log(string memory p0, uint256 p1) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,uint256)", p0, p1));
_sendLogPayload(abi.encodeWithSignature("log(string,uint256)", p0, p1)); // nosemgrep: sol-style-use-abi-encodecall
}
function log(string memory p0, address p1) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,address)", p0, p1));
_sendLogPayload(abi.encodeWithSignature("log(string,address)", p0, p1)); // nosemgrep: sol-style-use-abi-encodecall
}
function log(string memory p0, string memory p1, string memory p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,string,string)", p0, p1, p2));
_sendLogPayload(abi.encodeWithSignature("log(string,string,string)", p0, p1, p2)); // nosemgrep: sol-style-use-abi-encodecall
}
}
/// @title ScriptExample
/// @notice ScriptExample is an example script. The Go forge script code tests that it can run this.
contract ScriptExample {
address internal constant VM_ADDRESS = address(uint160(uint256(keccak256("hevm cheat code"))));
Vm internal constant vm = Vm(VM_ADDRESS);
......
......@@ -74,6 +74,7 @@ library Encoding {
pure
returns (bytes memory)
{
// nosemgrep: sol-style-use-abi-encodecall
return abi.encodeWithSignature("relayMessage(address,address,bytes,uint256)", _target, _sender, _data, _nonce);
}
......@@ -97,6 +98,7 @@ library Encoding {
pure
returns (bytes memory)
{
// nosemgrep: sol-style-use-abi-encodecall
return abi.encodeWithSignature(
"relayMessage(uint256,address,address,uint256,uint256,bytes)",
_nonce,
......
......@@ -24,6 +24,7 @@ library LegacyCrossDomainUtils {
pure
returns (bytes memory)
{
// nosemgrep: sol-style-use-abi-encodecall
return abi.encodeWithSignature(
"relayMessage(address,address,bytes,uint256)", _target, _sender, _message, _messageNonce
);
......
......@@ -58,8 +58,9 @@ contract L1CrossDomainMessenger_Test is Bridge_Initializer {
// deposit transaction on the optimism portal should be called
vm.expectCall(
address(optimismPortal),
abi.encodeWithSelector(
IOptimismPortal.depositTransaction.selector,
abi.encodeCall(
IOptimismPortal.depositTransaction,
(
Predeploys.L2_CROSS_DOMAIN_MESSENGER,
0,
l1CrossDomainMessenger.baseGas(hex"ff", 100),
......@@ -68,6 +69,7 @@ contract L1CrossDomainMessenger_Test is Bridge_Initializer {
l1CrossDomainMessenger.messageNonce(), alice, recipient, 0, 100, hex"ff"
)
)
)
);
// TransactionDeposited event
......@@ -604,7 +606,7 @@ contract L1CrossDomainMessenger_Test is Bridge_Initializer {
/// @dev Tests that the superchain config is called by the messengers paused function
function test_pause_callsSuperchainConfig_succeeds() external {
vm.expectCall(address(superchainConfig), abi.encodeWithSelector(ISuperchainConfig.paused.selector));
vm.expectCall(address(superchainConfig), abi.encodeCall(ISuperchainConfig.paused, ()));
l1CrossDomainMessenger.paused();
}
......@@ -624,14 +626,15 @@ contract L1CrossDomainMessenger_Test is Bridge_Initializer {
function test_sendMessage_customGasToken_noValue_succeeds() external {
// Mock the gasPayingToken function to return a custom gas token
vm.mockCall(
address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(18))
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(18))
);
// deposit transaction on the optimism portal should be called
vm.expectCall(
address(optimismPortal),
abi.encodeWithSelector(
IOptimismPortal.depositTransaction.selector,
abi.encodeCall(
IOptimismPortal.depositTransaction,
(
Predeploys.L2_CROSS_DOMAIN_MESSENGER,
0,
l1CrossDomainMessenger.baseGas(hex"ff", 100),
......@@ -640,6 +643,7 @@ contract L1CrossDomainMessenger_Test is Bridge_Initializer {
l1CrossDomainMessenger.messageNonce(), alice, recipient, 0, 100, hex"ff"
)
)
)
);
// TransactionDeposited event
......@@ -670,7 +674,7 @@ contract L1CrossDomainMessenger_Test is Bridge_Initializer {
function test_sendMessage_customGasToken_withValue_reverts() external {
// Mock the gasPayingToken function to return a custom gas token
vm.mockCall(
address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(2))
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(2))
);
vm.expectRevert("CrossDomainMessenger: cannot send value with custom gas token");
......@@ -681,7 +685,7 @@ contract L1CrossDomainMessenger_Test is Bridge_Initializer {
function test_relayMessage_customGasToken_noValue_succeeds() external {
// Mock the gasPayingToken function to return a custom gas token
vm.mockCall(
address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(2))
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(2))
);
address target = address(0xabcd);
......@@ -721,7 +725,7 @@ contract L1CrossDomainMessenger_Test is Bridge_Initializer {
function test_relayMessage_customGasToken_withValue_reverts() external virtual {
// Mock the gasPayingToken function to return a custom gas token
vm.mockCall(
address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(2))
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(2))
);
vm.expectRevert("CrossDomainMessenger: value must be zero unless message is from a system address");
......@@ -743,7 +747,7 @@ contract L1CrossDomainMessenger_ReinitReentryTest is Bridge_Initializer {
// Common values used across functions
uint256 constant messageValue = 50;
bytes constant selector = abi.encodeWithSelector(this.reinitAndReenter.selector);
bytes selector = abi.encodeCall(this.reinitAndReenter, ());
address sender;
bytes32 hash;
address target;
......@@ -760,7 +764,7 @@ contract L1CrossDomainMessenger_ReinitReentryTest is Bridge_Initializer {
/// @dev This method will be called by the relayed message, and will attempt to reenter the relayMessage function
/// exactly once.
function reinitAndReenter() public payable {
function reinitAndReenter() external payable {
// only attempt the attack once
if (!attacked) {
attacked = true;
......
......@@ -250,7 +250,7 @@ contract L1ERC721Bridge_Test is Bridge_Initializer {
// Finalize a withdrawal.
vm.mockCall(
address(l1CrossDomainMessenger),
abi.encodeWithSelector(l1CrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(l1CrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(Predeploys.L2_ERC721_BRIDGE)
);
vm.prank(address(l1CrossDomainMessenger));
......@@ -276,7 +276,7 @@ contract L1ERC721Bridge_Test is Bridge_Initializer {
// Finalize a withdrawal.
vm.mockCall(
address(l1CrossDomainMessenger),
abi.encodeWithSelector(l1CrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(l1CrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(alice)
);
vm.prank(address(l1CrossDomainMessenger));
......@@ -290,7 +290,7 @@ contract L1ERC721Bridge_Test is Bridge_Initializer {
// Finalize a withdrawal.
vm.mockCall(
address(l1CrossDomainMessenger),
abi.encodeWithSelector(l1CrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(l1CrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(Predeploys.L2_ERC721_BRIDGE)
);
vm.prank(address(l1CrossDomainMessenger));
......@@ -306,7 +306,7 @@ contract L1ERC721Bridge_Test is Bridge_Initializer {
// Finalize a withdrawal.
vm.mockCall(
address(l1CrossDomainMessenger),
abi.encodeWithSelector(l1CrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(l1CrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(Predeploys.L2_ERC721_BRIDGE)
);
vm.prank(address(l1CrossDomainMessenger));
......@@ -325,7 +325,7 @@ contract L1ERC721Bridge_Pause_Test is Bridge_Initializer {
/// @dev Ensures that the `paused` function of the bridge contract actually calls the `paused` function of the
/// `superchainConfig`.
function test_pause_callsSuperchainConfig_succeeds() external {
vm.expectCall(address(superchainConfig), abi.encodeWithSelector(ISuperchainConfig.paused.selector));
vm.expectCall(address(superchainConfig), abi.encodeCall(ISuperchainConfig.paused, ()));
l1ERC721Bridge.paused();
}
......@@ -354,7 +354,7 @@ contract L1ERC721Bridge_Pause_TestFail is Bridge_Initializer {
vm.mockCall(
address(l1ERC721Bridge.messenger()),
abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(ICrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(address(l1ERC721Bridge.otherBridge()))
);
}
......
......@@ -68,7 +68,7 @@ contract L1StandardBridge_Pause_Test is Bridge_Initializer {
/// @dev Ensures that the `paused` function of the bridge contract actually calls the `paused` function of the
/// `superchainConfig`.
function test_pause_callsSuperchainConfig_succeeds() external {
vm.expectCall(address(superchainConfig), abi.encodeWithSelector(ISuperchainConfig.paused.selector));
vm.expectCall(address(superchainConfig), abi.encodeCall(ISuperchainConfig.paused, ()));
l1StandardBridge.paused();
}
......@@ -99,7 +99,7 @@ contract L1StandardBridge_Pause_TestFail is Bridge_Initializer {
vm.mockCall(
address(l1StandardBridge.messenger()),
abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(ICrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(address(l1StandardBridge.otherBridge()))
);
}
......@@ -173,12 +173,14 @@ contract L1StandardBridge_Receive_Test is Bridge_Initializer {
vm.expectCall(
address(l1CrossDomainMessenger),
abi.encodeWithSelector(
ICrossDomainMessenger.sendMessage.selector,
abi.encodeCall(
ICrossDomainMessenger.sendMessage,
(
address(l2StandardBridge),
abi.encodeWithSelector(StandardBridge.finalizeBridgeETH.selector, alice, alice, 100, hex""),
abi.encodeCall(StandardBridge.finalizeBridgeETH, (alice, alice, 100, hex"")),
200_000
)
)
);
vm.prank(alice, alice);
......@@ -193,7 +195,7 @@ contract L1StandardBridge_Receive_TestFail is Bridge_Initializer {
function testFuzz_receive_customGasToken_reverts(uint256 _value) external {
vm.prank(alice, alice);
vm.mockCall(
address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(18))
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(18))
);
vm.deal(alice, _value);
(bool success, bytes memory data) = address(l1StandardBridge).call{ value: _value }(hex"");
......@@ -214,51 +216,35 @@ contract PreBridgeETH is Bridge_Initializer {
uint256 version = 0; // Internal constant in the OptimismPortal: DEPOSIT_VERSION
address l1MessengerAliased = AddressAliasHelper.applyL1ToL2Alias(address(l1CrossDomainMessenger));
bytes memory message =
abi.encodeWithSelector(StandardBridge.finalizeBridgeETH.selector, alice, alice, value, hex"dead");
bytes memory message = abi.encodeCall(StandardBridge.finalizeBridgeETH, (alice, alice, value, hex"dead"));
if (isLegacy) {
vm.expectCall(
address(l1StandardBridge),
value,
abi.encodeWithSelector(l1StandardBridge.depositETH.selector, 50000, hex"dead")
address(l1StandardBridge), value, abi.encodeCall(l1StandardBridge.depositETH, (50000, hex"dead"))
);
} else {
vm.expectCall(
address(l1StandardBridge),
value,
abi.encodeWithSelector(l1StandardBridge.bridgeETH.selector, 50000, hex"dead")
address(l1StandardBridge), value, abi.encodeCall(l1StandardBridge.bridgeETH, (50000, hex"dead"))
);
}
vm.expectCall(
address(l1CrossDomainMessenger),
value,
abi.encodeWithSelector(
ICrossDomainMessenger.sendMessage.selector, address(l2StandardBridge), message, 50000
)
abi.encodeCall(ICrossDomainMessenger.sendMessage, (address(l2StandardBridge), message, 50000))
);
bytes memory innerMessage = abi.encodeWithSelector(
ICrossDomainMessenger.relayMessage.selector,
nonce,
address(l1StandardBridge),
address(l2StandardBridge),
value,
50000,
message
bytes memory innerMessage = abi.encodeCall(
ICrossDomainMessenger.relayMessage,
(nonce, address(l1StandardBridge), address(l2StandardBridge), value, 50000, message)
);
uint64 baseGas = l1CrossDomainMessenger.baseGas(message, 50000);
vm.expectCall(
address(optimismPortal),
value,
abi.encodeWithSelector(
IOptimismPortal.depositTransaction.selector,
address(l2CrossDomainMessenger),
value,
baseGas,
false,
innerMessage
abi.encodeCall(
IOptimismPortal.depositTransaction,
(address(l2CrossDomainMessenger), value, baseGas, false, innerMessage)
)
);
......@@ -311,7 +297,7 @@ contract L1StandardBridge_DepositETH_TestFail is Bridge_Initializer {
/// @dev Tests that depositing reverts with custom gas token.
function test_depositETH_customGasToken_reverts() external {
vm.mockCall(
address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(2))
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(2))
);
vm.prank(alice, alice);
vm.expectRevert("StandardBridge: cannot bridge ETH with custom gas token");
......@@ -337,7 +323,7 @@ contract L1StandardBridge_BridgeETH_TestFail is PreBridgeETH {
function test_bridgeETH_customGasToken_reverts() external {
vm.prank(alice, alice);
vm.mockCall(
address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(2))
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(2))
);
vm.expectRevert("StandardBridge: cannot bridge ETH with custom gas token");
......@@ -356,50 +342,34 @@ contract PreBridgeETHTo is Bridge_Initializer {
if (isLegacy) {
vm.expectCall(
address(l1StandardBridge),
value,
abi.encodeWithSelector(l1StandardBridge.depositETHTo.selector, bob, 60000, hex"dead")
address(l1StandardBridge), value, abi.encodeCall(l1StandardBridge.depositETHTo, (bob, 60000, hex"dead"))
);
} else {
vm.expectCall(
address(l1StandardBridge),
value,
abi.encodeWithSelector(l1StandardBridge.bridgeETHTo.selector, bob, 60000, hex"dead")
address(l1StandardBridge), value, abi.encodeCall(l1StandardBridge.bridgeETHTo, (bob, 60000, hex"dead"))
);
}
bytes memory message =
abi.encodeWithSelector(StandardBridge.finalizeBridgeETH.selector, alice, bob, value, hex"dead");
bytes memory message = abi.encodeCall(StandardBridge.finalizeBridgeETH, (alice, bob, value, hex"dead"));
// the L1 bridge should call
// L1CrossDomainMessenger.sendMessage
vm.expectCall(
address(l1CrossDomainMessenger),
abi.encodeWithSelector(
ICrossDomainMessenger.sendMessage.selector, address(l2StandardBridge), message, 60000
)
abi.encodeCall(ICrossDomainMessenger.sendMessage, (address(l2StandardBridge), message, 60000))
);
bytes memory innerMessage = abi.encodeWithSelector(
ICrossDomainMessenger.relayMessage.selector,
nonce,
address(l1StandardBridge),
address(l2StandardBridge),
value,
60000,
message
bytes memory innerMessage = abi.encodeCall(
ICrossDomainMessenger.relayMessage,
(nonce, address(l1StandardBridge), address(l2StandardBridge), value, 60000, message)
);
uint64 baseGas = l1CrossDomainMessenger.baseGas(message, 60000);
vm.expectCall(
address(optimismPortal),
abi.encodeWithSelector(
IOptimismPortal.depositTransaction.selector,
address(l2CrossDomainMessenger),
value,
baseGas,
false,
innerMessage
abi.encodeCall(
IOptimismPortal.depositTransaction,
(address(l2CrossDomainMessenger), value, baseGas, false, innerMessage)
)
);
......@@ -452,7 +422,7 @@ contract L1StandardBridge_DepositETHTo_TestFail is Bridge_Initializer {
external
{
vm.mockCall(
address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(2))
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(2))
);
vm.deal(address(this), _value);
vm.expectRevert("StandardBridge: cannot bridge ETH with custom gas token");
......@@ -484,7 +454,7 @@ contract L1StandardBridge_BridgeETHTo_TestFail is PreBridgeETHTo {
external
{
vm.mockCall(
address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(2))
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(2))
);
vm.deal(address(this), _value);
vm.expectRevert("StandardBridge: cannot bridge ETH with custom gas token");
......@@ -518,42 +488,28 @@ contract L1StandardBridge_DepositERC20_Test is Bridge_Initializer {
L1Token.approve(address(l1StandardBridge), type(uint256).max);
// The l1StandardBridge should transfer alice's tokens to itself
vm.expectCall(
address(L1Token), abi.encodeWithSelector(ERC20.transferFrom.selector, alice, address(l1StandardBridge), 100)
);
vm.expectCall(address(L1Token), abi.encodeCall(ERC20.transferFrom, (alice, address(l1StandardBridge), 100)));
bytes memory message = abi.encodeWithSelector(
StandardBridge.finalizeBridgeERC20.selector, address(L2Token), address(L1Token), alice, alice, 100, hex""
bytes memory message = abi.encodeCall(
StandardBridge.finalizeBridgeERC20, (address(L2Token), address(L1Token), alice, alice, 100, hex"")
);
// the L1 bridge should call L1CrossDomainMessenger.sendMessage
vm.expectCall(
address(l1CrossDomainMessenger),
abi.encodeWithSelector(
ICrossDomainMessenger.sendMessage.selector, address(l2StandardBridge), message, 10000
)
abi.encodeCall(ICrossDomainMessenger.sendMessage, (address(l2StandardBridge), message, 10000))
);
bytes memory innerMessage = abi.encodeWithSelector(
ICrossDomainMessenger.relayMessage.selector,
nonce,
address(l1StandardBridge),
address(l2StandardBridge),
0,
10000,
message
bytes memory innerMessage = abi.encodeCall(
ICrossDomainMessenger.relayMessage,
(nonce, address(l1StandardBridge), address(l2StandardBridge), 0, 10000, message)
);
uint64 baseGas = l1CrossDomainMessenger.baseGas(message, 10000);
vm.expectCall(
address(optimismPortal),
abi.encodeWithSelector(
IOptimismPortal.depositTransaction.selector,
address(l2CrossDomainMessenger),
0,
baseGas,
false,
innerMessage
abi.encodeCall(
IOptimismPortal.depositTransaction, (address(l2CrossDomainMessenger), 0, baseGas, false, innerMessage)
)
);
......@@ -609,18 +565,13 @@ contract L1StandardBridge_DepositERC20To_Test is Bridge_Initializer {
uint256 version = 0; // Internal constant in the OptimismPortal: DEPOSIT_VERSION
address l1MessengerAliased = AddressAliasHelper.applyL1ToL2Alias(address(l1CrossDomainMessenger));
bytes memory message = abi.encodeWithSelector(
StandardBridge.finalizeBridgeERC20.selector, address(L2Token), address(L1Token), alice, bob, 1000, hex""
bytes memory message = abi.encodeCall(
StandardBridge.finalizeBridgeERC20, (address(L2Token), address(L1Token), alice, bob, 1000, hex"")
);
bytes memory innerMessage = abi.encodeWithSelector(
ICrossDomainMessenger.relayMessage.selector,
nonce,
address(l1StandardBridge),
address(l2StandardBridge),
0,
10000,
message
bytes memory innerMessage = abi.encodeCall(
ICrossDomainMessenger.relayMessage,
(nonce, address(l1StandardBridge), address(l2StandardBridge), 0, 10000, message)
);
uint64 baseGas = l1CrossDomainMessenger.baseGas(message, 10000);
......@@ -653,26 +604,16 @@ contract L1StandardBridge_DepositERC20To_Test is Bridge_Initializer {
// the L1 bridge should call L1CrossDomainMessenger.sendMessage
vm.expectCall(
address(l1CrossDomainMessenger),
abi.encodeWithSelector(
ICrossDomainMessenger.sendMessage.selector, address(l2StandardBridge), message, 10000
)
abi.encodeCall(ICrossDomainMessenger.sendMessage, (address(l2StandardBridge), message, 10000))
);
// The L1 XDM should call OptimismPortal.depositTransaction
vm.expectCall(
address(optimismPortal),
abi.encodeWithSelector(
IOptimismPortal.depositTransaction.selector,
address(l2CrossDomainMessenger),
0,
baseGas,
false,
innerMessage
abi.encodeCall(
IOptimismPortal.depositTransaction, (address(l2CrossDomainMessenger), 0, baseGas, false, innerMessage)
)
);
vm.expectCall(
address(L1Token),
abi.encodeWithSelector(ERC20.transferFrom.selector, alice, address(l1StandardBridge), 1000)
);
vm.expectCall(address(L1Token), abi.encodeCall(ERC20.transferFrom, (alice, address(l1StandardBridge), 1000)));
vm.prank(alice);
l1StandardBridge.depositERC20To(address(L1Token), address(L2Token), bob, 1000, 10000, hex"");
......@@ -700,7 +641,7 @@ contract L1StandardBridge_FinalizeETHWithdrawal_Test is Bridge_Initializer {
vm.mockCall(
address(l1StandardBridge.messenger()),
abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(ICrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(address(l1StandardBridge.OTHER_BRIDGE()))
);
// ensure that the messenger has ETH to call with
......@@ -722,11 +663,11 @@ contract L1StandardBridge_FinalizeETHWithdrawal_TestFail is Bridge_Initializer {
external
{
vm.mockCall(
address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(2))
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(2))
);
vm.mockCall(
address(l1StandardBridge.messenger()),
abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(ICrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(address(l1StandardBridge.OTHER_BRIDGE()))
);
vm.deal(address(l1StandardBridge.messenger()), _value);
......@@ -761,11 +702,11 @@ contract L1StandardBridge_FinalizeERC20Withdrawal_Test is Bridge_Initializer {
vm.expectEmit(address(l1StandardBridge));
emit ERC20BridgeFinalized(address(L1Token), address(L2Token), alice, alice, 100, hex"");
vm.expectCall(address(L1Token), abi.encodeWithSelector(ERC20.transfer.selector, alice, 100));
vm.expectCall(address(L1Token), abi.encodeCall(ERC20.transfer, (alice, 100)));
vm.mockCall(
address(l1StandardBridge.messenger()),
abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(ICrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(address(l1StandardBridge.OTHER_BRIDGE()))
);
vm.prank(address(l1StandardBridge.messenger()));
......@@ -781,7 +722,7 @@ contract L1StandardBridge_FinalizeERC20Withdrawal_TestFail is Bridge_Initializer
function test_finalizeERC20Withdrawal_notMessenger_reverts() external {
vm.mockCall(
address(l1StandardBridge.messenger()),
abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(ICrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(address(l1StandardBridge.OTHER_BRIDGE()))
);
vm.prank(address(28));
......@@ -793,7 +734,7 @@ contract L1StandardBridge_FinalizeERC20Withdrawal_TestFail is Bridge_Initializer
function test_finalizeERC20Withdrawal_notOtherBridge_reverts() external {
vm.mockCall(
address(l1StandardBridge.messenger()),
abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(ICrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(address(address(0)))
);
vm.prank(address(l1StandardBridge.messenger()));
......@@ -808,7 +749,7 @@ contract L1StandardBridge_FinalizeBridgeETH_Test is Bridge_Initializer {
address messenger = address(l1StandardBridge.messenger());
vm.mockCall(
messenger,
abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(ICrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(address(l1StandardBridge.OTHER_BRIDGE()))
);
vm.deal(messenger, 100);
......@@ -826,13 +767,13 @@ contract L1StandardBridge_FinalizeBridgeETH_TestFail is Bridge_Initializer {
function testFuzz_finalizeBridgeETH_customGasToken_reverts(uint256 _value, bytes calldata _extraData) external {
vm.mockCall(
address(l1StandardBridge.messenger()),
abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(ICrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(address(l1StandardBridge.OTHER_BRIDGE()))
);
vm.deal(address(l1CrossDomainMessenger), _value);
vm.prank(address(l1CrossDomainMessenger));
vm.mockCall(
address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(2))
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(2))
);
vm.expectRevert("StandardBridge: cannot bridge ETH with custom gas token");
......@@ -844,7 +785,7 @@ contract L1StandardBridge_FinalizeBridgeETH_TestFail is Bridge_Initializer {
address messenger = address(l1StandardBridge.messenger());
vm.mockCall(
messenger,
abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(ICrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(address(l1StandardBridge.OTHER_BRIDGE()))
);
vm.deal(messenger, 100);
......@@ -858,7 +799,7 @@ contract L1StandardBridge_FinalizeBridgeETH_TestFail is Bridge_Initializer {
address messenger = address(l1StandardBridge.messenger());
vm.mockCall(
messenger,
abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(ICrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(address(l1StandardBridge.OTHER_BRIDGE()))
);
vm.deal(messenger, 100);
......@@ -872,7 +813,7 @@ contract L1StandardBridge_FinalizeBridgeETH_TestFail is Bridge_Initializer {
address messenger = address(l1StandardBridge.messenger());
vm.mockCall(
messenger,
abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(ICrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(address(l1StandardBridge.OTHER_BRIDGE()))
);
vm.deal(messenger, 100);
......
......@@ -422,7 +422,7 @@ contract L2OutputOracleUpgradeable_Test is L2OutputOracle_TestBase {
vm.startPrank(EIP1967Helper.getAdmin(address(proxy)));
// Reviewer note: the NextImpl() still uses reinitializer. If we want to remove that, we'll need to use a
// two step upgrade with the Storage lib.
proxy.upgradeToAndCall(address(nextImpl), abi.encodeWithSelector(NextImpl.initialize.selector, 2));
proxy.upgradeToAndCall(address(nextImpl), abi.encodeCall(NextImpl.initialize, (2)));
assertEq(proxy.implementation(), address(nextImpl));
// Verify that the NextImpl contract initialized its values according as expected
......
......@@ -201,6 +201,7 @@ contract OptimismPortal_Test is CommonTest {
}
/// @dev Tests that `depositTransaction` succeeds when msg.sender == tx.origin and non-custom gas is used.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositTransaction_senderIsOrigin_succeeds(
address _to,
uint256 _mint,
......@@ -226,6 +227,7 @@ contract OptimismPortal_Test is CommonTest {
}
/// @dev Tests that `depositTransaction` succeeds when msg.sender != tx.origin and non-custom gas is used.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositTransaction_senderNotOrigin_succeeds(
address _to,
uint256 _mint,
......@@ -308,6 +310,7 @@ contract OptimismPortal_Test is CommonTest {
}
/// @dev Tests that `depositTransaction` succeeds for an EOA.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositTransaction_eoa_succeeds(
address _to,
uint64 _gasLimit,
......@@ -352,6 +355,7 @@ contract OptimismPortal_Test is CommonTest {
}
/// @dev Tests that `depositTransaction` succeeds for a contract.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositTransaction_contract_succeeds(
address _to,
uint64 _gasLimit,
......@@ -403,7 +407,7 @@ contract OptimismPortal_Test is CommonTest {
uint256 ts = block.timestamp;
vm.mockCall(
address(optimismPortal.l2Oracle()),
abi.encodeWithSelector(IL2OutputOracle.getL2Output.selector),
abi.encodePacked(IL2OutputOracle.getL2Output.selector),
abi.encode(Types.OutputProposal(bytes32(uint256(1)), uint128(ts), uint128(startingBlockNumber)))
);
......@@ -535,7 +539,7 @@ contract OptimismPortal_Test is CommonTest {
}
function test_depositERC20Transaction_balanceOverflow_reverts() external {
vm.mockCall(address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(42), 18));
vm.mockCall(address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(42), 18));
// The balance slot
vm.store(address(optimismPortal), bytes32(uint256(61)), bytes32(type(uint256).max));
......@@ -788,7 +792,7 @@ contract OptimismPortal_FinalizeWithdrawal_Test is CommonTest {
function test_finalizeWithdrawalTransaction_provenWithdrawalHash_nonEther_targetToken_reverts() external {
vm.mockCall(
address(systemConfig),
abi.encodeWithSignature("gasPayingToken()"),
abi.encodeCall(systemConfig.gasPayingToken, ()),
abi.encode(address(_defaultTx.target), 18)
);
......@@ -832,7 +836,7 @@ contract OptimismPortal_FinalizeWithdrawal_Test is CommonTest {
// this case we just use bytes32(uint256(1)).
vm.mockCall(
address(optimismPortal.l2Oracle()),
abi.encodeWithSelector(IL2OutputOracle.getL2Output.selector),
abi.encodePacked(IL2OutputOracle.getL2Output.selector),
abi.encode(bytes32(uint256(1)), _proposedBlockNumber)
);
......@@ -858,7 +862,7 @@ contract OptimismPortal_FinalizeWithdrawal_Test is CommonTest {
// Mock a startingTimestamp change on the L2 Oracle
vm.mockCall(
address(optimismPortal.l2Oracle()),
abi.encodeWithSignature("startingTimestamp()"),
abi.encodeCall(IL2OutputOracle.startingTimestamp, ()),
abi.encode(block.timestamp + 1)
);
......@@ -887,7 +891,7 @@ contract OptimismPortal_FinalizeWithdrawal_Test is CommonTest {
// to finalize the withdrawal.
vm.mockCall(
address(optimismPortal.l2Oracle()),
abi.encodeWithSelector(IL2OutputOracle.getL2Output.selector),
abi.encodePacked(IL2OutputOracle.getL2Output.selector),
abi.encode(
Types.OutputProposal(bytes32(uint256(0)), uint128(block.timestamp), uint128(_proposedBlockNumber))
)
......@@ -918,7 +922,7 @@ contract OptimismPortal_FinalizeWithdrawal_Test is CommonTest {
// finalization period.
vm.mockCall(
address(optimismPortal.l2Oracle()),
abi.encodeWithSelector(IL2OutputOracle.getL2Output.selector),
abi.encodePacked(IL2OutputOracle.getL2Output.selector),
abi.encode(Types.OutputProposal(_outputRoot, uint128(block.timestamp + 1), uint128(_proposedBlockNumber)))
);
......@@ -954,7 +958,7 @@ contract OptimismPortal_FinalizeWithdrawal_Test is CommonTest {
uint256 recentTimestamp = block.timestamp - 1;
vm.mockCall(
address(optimismPortal.l2Oracle()),
abi.encodeWithSelector(IL2OutputOracle.getL2Output.selector),
abi.encodePacked(IL2OutputOracle.getL2Output.selector),
abi.encode(Types.OutputProposal(_outputRoot, uint128(recentTimestamp), uint128(_proposedBlockNumber)))
);
......@@ -1006,7 +1010,7 @@ contract OptimismPortal_FinalizeWithdrawal_Test is CommonTest {
vm.mockCall(
address(optimismPortal.l2Oracle()),
abi.encodeWithSelector(IL2OutputOracle.getL2Output.selector),
abi.encodePacked(IL2OutputOracle.getL2Output.selector),
abi.encode(
Types.OutputProposal(
Hashing.hashOutputRootProof(outputRootProof),
......@@ -1034,7 +1038,7 @@ contract OptimismPortal_FinalizeWithdrawal_Test is CommonTest {
// this contract's callPortalAndExpectRevert() function above.
Types.WithdrawalTransaction memory _testTx = _defaultTx;
_testTx.target = address(this);
_testTx.data = abi.encodeWithSelector(this.callPortalAndExpectRevert.selector);
_testTx.data = abi.encodeCall(this.callPortalAndExpectRevert, ());
// Get modified proof inputs.
(
......@@ -1055,7 +1059,7 @@ contract OptimismPortal_FinalizeWithdrawal_Test is CommonTest {
uint256 finalizedTimestamp = block.timestamp - l2OutputOracle.FINALIZATION_PERIOD_SECONDS() - 1;
vm.mockCall(
address(optimismPortal.l2Oracle()),
abi.encodeWithSelector(IL2OutputOracle.getL2Output.selector),
abi.encodePacked(IL2OutputOracle.getL2Output.selector),
abi.encode(Types.OutputProposal(outputRoot, uint128(finalizedTimestamp), uint128(_proposedBlockNumber)))
);
......@@ -1074,6 +1078,7 @@ contract OptimismPortal_FinalizeWithdrawal_Test is CommonTest {
}
/// @dev Tests that `finalizeWithdrawalTransaction` succeeds.
/// forge-config: ciheavy.fuzz.runs = 8192
function testDiff_finalizeWithdrawalTransaction_succeeds(
address _sender,
address _target,
......@@ -1129,7 +1134,7 @@ contract OptimismPortal_FinalizeWithdrawal_Test is CommonTest {
// Setup the Oracle to return the outputRoot
vm.mockCall(
address(l2OutputOracle),
abi.encodeWithSelector(l2OutputOracle.getL2Output.selector),
abi.encodePacked(l2OutputOracle.getL2Output.selector),
abi.encode(outputRoot, block.timestamp, 100)
);
......@@ -1176,7 +1181,7 @@ contract OptimismPortalUpgradeable_Test is CommonTest {
// The value passed to the initialize must be larger than the last value
// that initialize was called with.
IProxy(payable(address(optimismPortal))).upgradeToAndCall(
address(nextImpl), abi.encodeWithSelector(NextImpl.initialize.selector, 2)
address(nextImpl), abi.encodeCall(NextImpl.initialize, (2))
);
assertEq(IProxy(payable(address(optimismPortal))).implementation(), address(nextImpl));
......@@ -1196,6 +1201,7 @@ contract OptimismPortalResourceFuzz_Test is CommonTest {
uint256 constant MAX_GAS_LIMIT = 30_000_000;
/// @dev Test that various values of the resource metering config will not break deposits.
/// forge-config: ciheavy.fuzz.runs = 10000
function testFuzz_systemConfigDeposit_succeeds(
uint32 _maxResourceLimit,
uint8 _elasticityMultiplier,
......@@ -1249,9 +1255,7 @@ contract OptimismPortalResourceFuzz_Test is CommonTest {
systemTxMaxGas: _systemTxMaxGas,
maximumBaseFee: _maximumBaseFee
});
vm.mockCall(
address(systemConfig), abi.encodeWithSelector(systemConfig.resourceConfig.selector), abi.encode(rcfg)
);
vm.mockCall(address(systemConfig), abi.encodeCall(systemConfig.resourceConfig, ()), abi.encode(rcfg));
// Set the resource params
uint256 _prevBlockNum = block.number - _blockDiff;
......@@ -1309,7 +1313,9 @@ contract OptimismPortalWithMockERC20_Test is OptimismPortal_FinalizeWithdrawal_T
token.approve(address(optimismPortal), _mint);
// Mock the gas paying token to be the ERC20 token
vm.mockCall(address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(token), 18));
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
);
bytes memory opaqueData = abi.encodePacked(_mint, _value, _gasLimit, _isCreation, _data);
......@@ -1330,6 +1336,7 @@ contract OptimismPortalWithMockERC20_Test is OptimismPortal_FinalizeWithdrawal_T
}
/// @dev Tests that `depositERC20Transaction` succeeds when msg.sender == tx.origin.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositERC20Transaction_senderIsOrigin_succeeds(
address _to,
uint256 _mint,
......@@ -1355,6 +1362,7 @@ contract OptimismPortalWithMockERC20_Test is OptimismPortal_FinalizeWithdrawal_T
}
/// @dev Tests that `depositERC20Transaction` succeeds when msg.sender != tx.origin.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositERC20Transaction_senderNotOrigin_succeeds(
address _to,
uint256 _mint,
......@@ -1382,7 +1390,9 @@ contract OptimismPortalWithMockERC20_Test is OptimismPortal_FinalizeWithdrawal_T
/// @dev Tests that `depositERC20Transaction` reverts when not enough of the token is approved.
function test_depositERC20Transaction_notEnoughAmount_reverts() external {
// Mock the gas paying token to be the ERC20 token
vm.mockCall(address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(token), 18));
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
);
vm.expectRevert(stdError.arithmeticError);
// Deposit the token into the portal
optimismPortal.depositERC20Transaction(address(0), 1, 0, 0, false, "");
......@@ -1395,13 +1405,13 @@ contract OptimismPortalWithMockERC20_Test is OptimismPortal_FinalizeWithdrawal_T
token.approve(address(optimismPortal), 100);
// Mock the gas paying token to be the ERC20 token
vm.mockCall(address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(token), 18));
// Mock the token balance
vm.mockCall(
address(token), abi.encodeWithSelector(token.balanceOf.selector, address(optimismPortal)), abi.encode(0)
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
);
// Mock the token balance
vm.mockCall(address(token), abi.encodeCall(token.balanceOf, (address(optimismPortal))), abi.encode(0));
// Call minimumGasLimit(0) before vm.expectRevert to ensure vm.expectRevert is for depositERC20Transaction
uint64 gasLimit = optimismPortal.minimumGasLimit(0);
......@@ -1414,7 +1424,9 @@ contract OptimismPortalWithMockERC20_Test is OptimismPortal_FinalizeWithdrawal_T
/// @dev Tests that `depositERC20Transaction` reverts when creating a contract with a non-zero target.
function test_depositERC20Transaction_isCreationNotZeroTarget_reverts() external {
// Mock the gas paying token to be the ERC20 token
vm.mockCall(address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(token), 18));
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
);
// Call minimumGasLimit(0) before vm.expectRevert to ensure vm.expectRevert is for depositERC20Transaction
uint64 gasLimit = optimismPortal.minimumGasLimit(0);
......@@ -1427,7 +1439,9 @@ contract OptimismPortalWithMockERC20_Test is OptimismPortal_FinalizeWithdrawal_T
/// @dev Tests that `depositERC20Transaction` reverts when the gas limit is too low.
function test_depositERC20Transaction_gasLimitTooLow_reverts() external {
// Mock the gas paying token to be the ERC20 token
vm.mockCall(address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(token), 18));
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
);
vm.expectRevert(SmallGasLimit.selector);
// Deposit the token into the portal
......@@ -1440,7 +1454,9 @@ contract OptimismPortalWithMockERC20_Test is OptimismPortal_FinalizeWithdrawal_T
data[120_000] = 0x01;
// Mock the gas paying token to be the ERC20 token
vm.mockCall(address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(token), 18));
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
);
uint64 gasLimit = optimismPortal.minimumGasLimit(120_001);
vm.expectRevert(LargeCalldata.selector);
......@@ -1455,7 +1471,9 @@ contract OptimismPortalWithMockERC20_Test is OptimismPortal_FinalizeWithdrawal_T
token.approve(address(optimismPortal), _amount);
// Mock the gas paying token to be the ERC20 token
vm.mockCall(address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(token), 18));
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
);
// Deposit the token into the portal
optimismPortal.depositERC20Transaction(address(0), _amount, 0, optimismPortal.minimumGasLimit(0), false, "");
......@@ -1471,7 +1489,9 @@ contract OptimismPortalWithMockERC20_Test is OptimismPortal_FinalizeWithdrawal_T
token.approve(address(optimismPortal), _defaultTx.value);
// Mock the gas paying token to be the ERC20 token
vm.mockCall(address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(token), 18));
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
);
// Deposit the token into the portal
optimismPortal.depositERC20Transaction(
......@@ -1490,9 +1510,7 @@ contract OptimismPortalWithMockERC20_Test is OptimismPortal_FinalizeWithdrawal_T
vm.expectCall(_defaultTx.target, 0, _defaultTx.data);
vm.expectCall(
address(token), 0, abi.encodeWithSelector(token.transfer.selector, _defaultTx.target, _defaultTx.value)
);
vm.expectCall(address(token), 0, abi.encodeCall(token.transfer, (_defaultTx.target, _defaultTx.value)));
optimismPortal.finalizeWithdrawalTransaction(_defaultTx);
......@@ -1520,7 +1538,9 @@ contract OptimismPortalWithMockERC20_Test is OptimismPortal_FinalizeWithdrawal_T
uint64(bound(_gasLimit, optimismPortal.minimumGasLimit(uint64(_data.length)), rcfg.maxResourceLimit));
// Mock the gas paying token to be the ERC20 token
vm.mockCall(address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(token), 18));
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
);
bytes memory opaqueData = abi.encodePacked(uint256(0), _value, _gasLimit, _isCreation, _data);
......@@ -1541,6 +1561,7 @@ contract OptimismPortalWithMockERC20_Test is OptimismPortal_FinalizeWithdrawal_T
}
/// @dev Tests that `depositTransaction` succeeds when a custom gas token is used but the msg.value is zero.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositTransaction_customGasToken_noValue_senderIsOrigin_succeeds(
address _to,
uint256 _value,
......@@ -1564,6 +1585,7 @@ contract OptimismPortalWithMockERC20_Test is OptimismPortal_FinalizeWithdrawal_T
}
/// @dev Tests that `depositTransaction` succeeds when a custom gas token is used but the msg.value is zero.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositTransaction_customGasToken_noValue_senderNotOrigin_succeeds(
address _to,
uint256 _value,
......@@ -1589,7 +1611,9 @@ contract OptimismPortalWithMockERC20_Test is OptimismPortal_FinalizeWithdrawal_T
/// @dev Tests that `depositTransaction` fails when a custom gas token is used and msg.value is non-zero.
function test_depositTransaction_customGasToken_withValue_reverts() external {
// Mock the gas paying token to be the ERC20 token
vm.mockCall(address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(token), 18));
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
);
vm.expectRevert(NoValue.selector);
......
......@@ -211,6 +211,7 @@ contract OptimismPortal2_Test is CommonTest {
}
/// @dev Tests that `depositTransaction` succeeds for an EOA.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositTransaction_eoa_succeeds(
address _to,
uint64 _gasLimit,
......@@ -255,6 +256,7 @@ contract OptimismPortal2_Test is CommonTest {
}
/// @dev Tests that `depositTransaction` succeeds for a contract.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositTransaction_contract_succeeds(
address _to,
uint64 _gasLimit,
......@@ -388,7 +390,7 @@ contract OptimismPortal2_Test is CommonTest {
}
function test_depositERC20Transaction_balanceOverflow_reverts() external {
vm.mockCall(address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(42), 18));
vm.mockCall(address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(42), 18));
// The balance slot
vm.store(address(optimismPortal2), bytes32(uint256(61)), bytes32(type(uint256).max));
......@@ -892,7 +894,7 @@ contract OptimismPortal2_FinalizeWithdrawal_Test is CommonTest {
function test_finalizeWithdrawalTransaction_provenWithdrawalHash_nonEther_targetToken_reverts() external {
vm.mockCall(
address(systemConfig),
abi.encodeWithSignature("gasPayingToken()"),
abi.encodeCall(systemConfig.gasPayingToken, ()),
abi.encode(address(_defaultTx.target), 18)
);
......@@ -974,7 +976,7 @@ contract OptimismPortal2_FinalizeWithdrawal_Test is CommonTest {
vm.warp(block.timestamp + optimismPortal2.proofMaturityDelaySeconds() + 1);
// Mock a createdAt change in the dispute game.
vm.mockCall(address(game), abi.encodeWithSignature("createdAt()"), abi.encode(block.timestamp + 1));
vm.mockCall(address(game), abi.encodeCall(game.createdAt, ()), abi.encode(block.timestamp + 1));
// Attempt to finalize the withdrawal
vm.expectRevert("OptimismPortal: withdrawal timestamp less than dispute game creation timestamp");
......@@ -1120,7 +1122,7 @@ contract OptimismPortal2_FinalizeWithdrawal_Test is CommonTest {
// this contract's callPortalAndExpectRevert() function above.
Types.WithdrawalTransaction memory _testTx = _defaultTx;
_testTx.target = address(this);
_testTx.data = abi.encodeWithSelector(this.callPortalAndExpectRevert.selector);
_testTx.data = abi.encodeCall(this.callPortalAndExpectRevert, ());
// Get modified proof inputs.
(
......@@ -1161,6 +1163,7 @@ contract OptimismPortal2_FinalizeWithdrawal_Test is CommonTest {
}
/// @dev Tests that `finalizeWithdrawalTransaction` succeeds.
/// forge-config: ciheavy.fuzz.runs = 8192
function testDiff_finalizeWithdrawalTransaction_succeeds(
address _sender,
address _target,
......@@ -1420,7 +1423,7 @@ contract OptimismPortal2_Upgradeable_Test is CommonTest {
// The value passed to the initialize must be larger than the last value
// that initialize was called with.
IProxy(payable(address(optimismPortal2))).upgradeToAndCall(
address(nextImpl), abi.encodeWithSelector(NextImpl.initialize.selector, 2)
address(nextImpl), abi.encodeCall(NextImpl.initialize, (2))
);
assertEq(IProxy(payable(address(optimismPortal2))).implementation(), address(nextImpl));
......@@ -1444,6 +1447,7 @@ contract OptimismPortal2_ResourceFuzz_Test is CommonTest {
}
/// @dev Test that various values of the resource metering config will not break deposits.
/// forge-config: ciheavy.fuzz.runs = 10000
function testFuzz_systemConfigDeposit_succeeds(
uint32 _maxResourceLimit,
uint8 _elasticityMultiplier,
......@@ -1498,9 +1502,7 @@ contract OptimismPortal2_ResourceFuzz_Test is CommonTest {
systemTxMaxGas: _systemTxMaxGas,
maximumBaseFee: _maximumBaseFee
});
vm.mockCall(
address(systemConfig), abi.encodeWithSelector(systemConfig.resourceConfig.selector), abi.encode(rcfg)
);
vm.mockCall(address(systemConfig), abi.encodeCall(systemConfig.resourceConfig, ()), abi.encode(rcfg));
// Set the resource params
uint256 _prevBlockNum = block.number - _blockDiff;
......@@ -1558,7 +1560,9 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
token.approve(address(optimismPortal2), _mint);
// Mock the gas paying token to be the ERC20 token
vm.mockCall(address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(token), 18));
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
);
bytes memory opaqueData = abi.encodePacked(_mint, _value, _gasLimit, _isCreation, _data);
......@@ -1579,6 +1583,7 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
}
/// @dev Tests that `depositERC20Transaction` succeeds when msg.sender == tx.origin.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositERC20Transaction_senderIsOrigin_succeeds(
address _to,
uint256 _mint,
......@@ -1604,6 +1609,7 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
}
/// @dev Tests that `depositERC20Transaction` succeeds when msg.sender != tx.origin.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositERC20Transaction_senderNotOrigin_succeeds(
address _to,
uint256 _mint,
......@@ -1631,7 +1637,9 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
/// @dev Tests that `depositERC20Transaction` reverts when not enough of the token is approved.
function test_depositERC20Transaction_notEnoughAmount_reverts() external {
// Mock the gas paying token to be the ERC20 token
vm.mockCall(address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(token), 18));
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
);
vm.expectRevert(stdError.arithmeticError);
// Deposit the token into the portal
optimismPortal2.depositERC20Transaction(address(0), 1, 0, 0, false, "");
......@@ -1644,13 +1652,13 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
token.approve(address(optimismPortal2), 100);
// Mock the gas paying token to be the ERC20 token
vm.mockCall(address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(token), 18));
// Mock the token balance
vm.mockCall(
address(token), abi.encodeWithSelector(token.balanceOf.selector, address(optimismPortal)), abi.encode(0)
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
);
// Mock the token balance
vm.mockCall(address(token), abi.encodeCall(token.balanceOf, (address(optimismPortal))), abi.encode(0));
// Call minimumGasLimit(0) before vm.expectRevert to ensure vm.expectRevert is for depositERC20Transaction
uint64 gasLimit = optimismPortal2.minimumGasLimit(0);
......@@ -1663,7 +1671,9 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
/// @dev Tests that `depositERC20Transaction` reverts when creating a contract with a non-zero target.
function test_depositERC20Transaction_isCreationNotZeroTarget_reverts() external {
// Mock the gas paying token to be the ERC20 token
vm.mockCall(address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(token), 18));
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
);
// Call minimumGasLimit(0) before vm.expectRevert to ensure vm.expectRevert is for depositERC20Transaction
uint64 gasLimit = optimismPortal2.minimumGasLimit(0);
......@@ -1676,7 +1686,9 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
/// @dev Tests that `depositERC20Transaction` reverts when the gas limit is too low.
function test_depositERC20Transaction_gasLimitTooLow_reverts() external {
// Mock the gas paying token to be the ERC20 token
vm.mockCall(address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(token), 18));
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
);
vm.expectRevert(SmallGasLimit.selector);
// Deposit the token into the portal
......@@ -1689,7 +1701,9 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
data[120_000] = 0x01;
// Mock the gas paying token to be the ERC20 token
vm.mockCall(address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(token), 18));
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
);
uint64 gasLimit = optimismPortal2.minimumGasLimit(120_001);
vm.expectRevert(LargeCalldata.selector);
......@@ -1704,7 +1718,9 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
token.approve(address(optimismPortal2), _amount);
// Mock the gas paying token to be the ERC20 token
vm.mockCall(address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(token), 18));
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
);
// Deposit the token into the portal
optimismPortal2.depositERC20Transaction(address(0), _amount, 0, optimismPortal.minimumGasLimit(0), false, "");
......@@ -1720,7 +1736,9 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
token.approve(address(optimismPortal2), _defaultTx.value);
// Mock the gas paying token to be the ERC20 token
vm.mockCall(address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(token), 18));
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
);
// Deposit the token into the portal
optimismPortal2.depositERC20Transaction(
......@@ -1748,9 +1766,7 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
vm.expectCall(_defaultTx.target, 0, _defaultTx.data);
vm.expectCall(
address(token), 0, abi.encodeWithSelector(token.transfer.selector, _defaultTx.target, _defaultTx.value)
);
vm.expectCall(address(token), 0, abi.encodeCall(token.transfer, (_defaultTx.target, _defaultTx.value)));
optimismPortal2.finalizeWithdrawalTransaction(_defaultTx);
......@@ -1778,7 +1794,9 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
uint64(bound(_gasLimit, optimismPortal2.minimumGasLimit(uint64(_data.length)), rcfg.maxResourceLimit));
// Mock the gas paying token to be the ERC20 token
vm.mockCall(address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(token), 18));
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
);
bytes memory opaqueData = abi.encodePacked(uint256(0), _value, _gasLimit, _isCreation, _data);
......@@ -1799,6 +1817,7 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
}
/// @dev Tests that `depositTransaction` succeeds when a custom gas token is used but the msg.value is zero.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositTransaction_customGasToken_noValue_senderIsOrigin_succeeds(
address _to,
uint256 _value,
......@@ -1822,6 +1841,7 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
}
/// @dev Tests that `depositTransaction` succeeds when a custom gas token is used but the msg.value is zero.
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_depositTransaction_customGasToken_noValue_senderNotOrigin_succeeds(
address _to,
uint256 _value,
......@@ -1847,7 +1867,9 @@ contract OptimismPortal2WithMockERC20_Test is OptimismPortal2_FinalizeWithdrawal
/// @dev Tests that `depositTransaction` fails when a custom gas token is used and msg.value is non-zero.
function test_depositTransaction_customGasToken_withValue_reverts() external {
// Mock the gas paying token to be the ERC20 token
vm.mockCall(address(systemConfig), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(token), 18));
vm.mockCall(
address(systemConfig), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(token), 18)
);
vm.expectRevert(NoValue.selector);
......
......@@ -36,7 +36,7 @@ contract SuperchainConfig_Init_Test is CommonTest {
vm.startPrank(alice);
newProxy.upgradeToAndCall(
address(newImpl),
abi.encodeWithSelector(ISuperchainConfig.initialize.selector, deploy.cfg().superchainConfigGuardian(), true)
abi.encodeCall(ISuperchainConfig.initialize, (deploy.cfg().superchainConfigGuardian(), true))
);
assertTrue(ISuperchainConfig(address(newProxy)).paused());
......
......@@ -375,9 +375,9 @@ contract SystemConfig_Init_CustomGasToken is SystemConfig_Init {
vm.assume(bytes(_name).length <= 32);
vm.assume(bytes(_symbol).length <= 32);
vm.mockCall(_token, abi.encodeWithSelector(token.decimals.selector), abi.encode(18));
vm.mockCall(_token, abi.encodeWithSelector(token.name.selector), abi.encode(_name));
vm.mockCall(_token, abi.encodeWithSelector(token.symbol.selector), abi.encode(_symbol));
vm.mockCall(_token, abi.encodeCall(token.decimals, ()), abi.encode(18));
vm.mockCall(_token, abi.encodeCall(token.name, ()), abi.encode(_name));
vm.mockCall(_token, abi.encodeCall(token.symbol, ()), abi.encode(_symbol));
cleanStorageAndInit(_token);
......@@ -421,7 +421,7 @@ contract SystemConfig_Init_CustomGasToken is SystemConfig_Init {
/// @dev Tests that initialization fails if decimals are not 18.
function test_initialize_customGasToken_wrongDecimals_fails() external {
vm.mockCall(address(token), abi.encodeWithSelector(token.decimals.selector), abi.encode(8));
vm.mockCall(address(token), abi.encodeCall(token.decimals, ()), abi.encode(8));
vm.expectRevert("SystemConfig: bad decimals of gas paying token");
cleanStorageAndInit(address(token));
......@@ -432,7 +432,7 @@ contract SystemConfig_Init_CustomGasToken is SystemConfig_Init {
string memory name = new string(32);
name = string.concat(name, "a");
vm.mockCall(address(token), abi.encodeWithSelector(token.name.selector), abi.encode(name));
vm.mockCall(address(token), abi.encodeCall(token.name, ()), abi.encode(name));
vm.expectRevert("GasPayingToken: string cannot be greater than 32 bytes");
cleanStorageAndInit(address(token));
......@@ -443,7 +443,7 @@ contract SystemConfig_Init_CustomGasToken is SystemConfig_Init {
string memory symbol = new string(33);
symbol = string.concat(symbol, "a");
vm.mockCall(address(token), abi.encodeWithSelector(token.symbol.selector), abi.encode(symbol));
vm.mockCall(address(token), abi.encodeCall(token.symbol, ()), abi.encode(symbol));
vm.expectRevert("GasPayingToken: string cannot be greater than 32 bytes");
cleanStorageAndInit(address(token));
......
......@@ -41,9 +41,9 @@ contract SystemConfigInterop_Test is CommonTest {
vm.assume(bytes(_name).length <= 32);
vm.assume(bytes(_symbol).length <= 32);
vm.mockCall(_token, abi.encodeWithSelector(ERC20.decimals.selector), abi.encode(18));
vm.mockCall(_token, abi.encodeWithSelector(ERC20.name.selector), abi.encode(_name));
vm.mockCall(_token, abi.encodeWithSelector(ERC20.symbol.selector), abi.encode(_symbol));
vm.mockCall(_token, abi.encodeCall(ERC20.decimals, ()), abi.encode(18));
vm.mockCall(_token, abi.encodeCall(ERC20.name, ()), abi.encode(_name));
vm.mockCall(_token, abi.encodeCall(ERC20.symbol, ()), abi.encode(_symbol));
vm.expectCall(
address(optimismPortal),
......
......@@ -68,7 +68,7 @@ contract CrossDomainOwnableThroughPortal_Test is CommonTest {
_value: 0,
_gasLimit: 30_000,
_isCreation: false,
_data: abi.encodeWithSelector(XDomainSetter.set.selector, 1)
_data: abi.encodeCall(XDomainSetter.set, (1))
});
// Simulate the operation of the `op-node` by parsing data
......
......@@ -58,7 +58,7 @@ contract CrossDomainOwnable2_Test is Bridge_Initializer {
address target = address(setter);
uint256 value = 0;
uint256 minGasLimit = 0;
bytes memory message = abi.encodeWithSelector(XDomainSetter2.set.selector, 1);
bytes memory message = abi.encodeCall(XDomainSetter2.set, (1));
bytes32 hash = Hashing.hashCrossDomainMessage(
Encoding.encodeVersionedNonce(nonce, 1), sender, target, value, minGasLimit, message
......@@ -85,12 +85,7 @@ contract CrossDomainOwnable2_Test is Bridge_Initializer {
// the L1CrossDomainMessenger
vm.prank(AddressAliasHelper.applyL1ToL2Alias(address(l1CrossDomainMessenger)));
l2CrossDomainMessenger.relayMessage(
Encoding.encodeVersionedNonce(1, 1),
owner,
address(setter),
0,
0,
abi.encodeWithSelector(XDomainSetter2.set.selector, 2)
Encoding.encodeVersionedNonce(1, 1), owner, address(setter), 0, 0, abi.encodeCall(XDomainSetter2.set, (2))
);
assertEq(setter.value(), 2);
......
......@@ -101,7 +101,7 @@ contract CrossDomainOwnable3_Test is Bridge_Initializer {
address target = address(setter);
uint256 value = 0;
uint256 minGasLimit = 0;
bytes memory message = abi.encodeWithSelector(XDomainSetter3.set.selector, 1);
bytes memory message = abi.encodeCall(XDomainSetter3.set, (1));
bytes32 hash = Hashing.hashCrossDomainMessage(
Encoding.encodeVersionedNonce(nonce, 1), sender, target, value, minGasLimit, message
......@@ -216,12 +216,7 @@ contract CrossDomainOwnable3_Test is Bridge_Initializer {
// the L1CrossDomainMessenger
vm.prank(AddressAliasHelper.applyL1ToL2Alias(address(l1CrossDomainMessenger)));
l2CrossDomainMessenger.relayMessage(
Encoding.encodeVersionedNonce(1, 1),
bob,
address(setter),
0,
0,
abi.encodeWithSelector(XDomainSetter3.set.selector, 2)
Encoding.encodeVersionedNonce(1, 1), bob, address(setter), 0, 0, abi.encodeCall(XDomainSetter3.set, (2))
);
assertEq(setter.value(), 2);
......
......@@ -160,7 +160,7 @@ contract CrossL2InboxTest is Test {
// Ensure is not a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
data: abi.encodeCall(IL1BlockInterop.isDeposit, ()),
returnData: abi.encode(false)
});
......@@ -170,7 +170,7 @@ contract CrossL2InboxTest is Test {
// Ensure that the chain ID is in the dependency set
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(L1BlockIsInDependencySetSelector, _id.chainId),
data: abi.encodeCall(IL1BlockInterop.isInDependencySet, (_id.chainId)),
returnData: abi.encode(true)
});
......@@ -222,27 +222,27 @@ contract CrossL2InboxTest is Test {
// Ensure is not a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
data: abi.encodeCall(IL1BlockInterop.isDeposit, ()),
returnData: abi.encode(false)
});
// Ensure that id1's chain ID is in the dependency set
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(L1BlockIsInDependencySetSelector, _id1.chainId),
data: abi.encodeCall(IL1BlockInterop.isInDependencySet, (_id1.chainId)),
returnData: abi.encode(true)
});
// Ensure that id2's chain ID is in the dependency set
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(L1BlockIsInDependencySetSelector, _id2.chainId),
data: abi.encodeCall(IL1BlockInterop.isInDependencySet, (_id2.chainId)),
returnData: abi.encode(true)
});
// Set the target and message for the reentrant call
address target = address(this);
bytes memory message = abi.encodeWithSelector(this.mockReentrant.selector, _id2);
bytes memory message = abi.encodeCall(this.mockReentrant, (_id2));
// Ensure that the contract has enough balance to send with value
vm.deal(address(this), _value);
......@@ -282,7 +282,7 @@ contract CrossL2InboxTest is Test {
// Ensure it is a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
data: abi.encodeCall(IL1BlockInterop.isDeposit, ()),
returnData: abi.encode(true)
});
......@@ -312,7 +312,7 @@ contract CrossL2InboxTest is Test {
// Ensure is not a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
data: abi.encodeCall(IL1BlockInterop.isDeposit, ()),
returnData: abi.encode(false)
});
......@@ -346,7 +346,7 @@ contract CrossL2InboxTest is Test {
// Ensure is not a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
data: abi.encodeCall(IL1BlockInterop.isDeposit, ()),
returnData: abi.encode(false)
});
......@@ -375,14 +375,14 @@ contract CrossL2InboxTest is Test {
// Ensure is not a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
data: abi.encodeCall(IL1BlockInterop.isDeposit, ()),
returnData: abi.encode(false)
});
// Ensure that the chain ID is NOT in the dependency set
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(L1BlockIsInDependencySetSelector, _id.chainId),
data: abi.encodeCall(IL1BlockInterop.isInDependencySet, (_id.chainId)),
returnData: abi.encode(false)
});
......@@ -419,14 +419,14 @@ contract CrossL2InboxTest is Test {
// Ensure is not a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
data: abi.encodeCall(IL1BlockInterop.isDeposit, ()),
returnData: abi.encode(false)
});
// Ensure that the chain ID is in the dependency set
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(L1BlockIsInDependencySetSelector, _id.chainId),
data: abi.encodeCall(IL1BlockInterop.isInDependencySet, (_id.chainId)),
returnData: abi.encode(true)
});
......@@ -451,14 +451,14 @@ contract CrossL2InboxTest is Test {
// Ensure that the chain ID is in the dependency set
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(L1BlockIsInDependencySetSelector, _id.chainId),
data: abi.encodeCall(IL1BlockInterop.isInDependencySet, (_id.chainId)),
returnData: abi.encode(true)
});
// Ensure is not a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
data: abi.encodeCall(IL1BlockInterop.isDeposit, ()),
returnData: abi.encode(false)
});
......@@ -474,7 +474,7 @@ contract CrossL2InboxTest is Test {
// Ensure it is a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
data: abi.encodeCall(IL1BlockInterop.isDeposit, ()),
returnData: abi.encode(true)
});
......@@ -497,7 +497,7 @@ contract CrossL2InboxTest is Test {
// Ensure is not a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
data: abi.encodeCall(IL1BlockInterop.isDeposit, ()),
returnData: abi.encode(false)
});
......@@ -526,7 +526,7 @@ contract CrossL2InboxTest is Test {
// Ensure is not a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
data: abi.encodeCall(IL1BlockInterop.isDeposit, ()),
returnData: abi.encode(false)
});
......@@ -553,14 +553,14 @@ contract CrossL2InboxTest is Test {
// Ensure that the chain ID is NOT in the dependency set.
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(L1BlockIsInDependencySetSelector, _id.chainId),
data: abi.encodeCall(IL1BlockInterop.isInDependencySet, (_id.chainId)),
returnData: abi.encode(false)
});
// Ensure is not a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
data: abi.encodeCall(IL1BlockInterop.isDeposit, ()),
returnData: abi.encode(false)
});
......
......@@ -93,6 +93,7 @@ contract GasPriceOracleBedrock_Test is GasPriceOracle_Test {
/// @dev Tests that `setGasPrice` reverts since it was removed in bedrock.
function test_setGasPrice_doesNotExist_reverts() external {
// nosemgrep: sol-style-use-abi-encodecall
(bool success, bytes memory returndata) =
address(gasPriceOracle).call(abi.encodeWithSignature("setGasPrice(uint256)", 1));
......@@ -102,6 +103,7 @@ contract GasPriceOracleBedrock_Test is GasPriceOracle_Test {
/// @dev Tests that `setL1BaseFee` reverts since it was removed in bedrock.
function test_setL1BaseFee_doesNotExist_reverts() external {
// nosemgrep: sol-style-use-abi-encodecall
(bool success, bytes memory returndata) =
address(gasPriceOracle).call(abi.encodeWithSignature("setL1BaseFee(uint256)", 1));
......
......@@ -48,11 +48,9 @@ contract L2CrossDomainMessenger_Test is Bridge_Initializer {
Encoding.encodeCrossDomainMessage(l2CrossDomainMessenger.messageNonce(), alice, recipient, 0, 100, hex"ff");
vm.expectCall(
address(l2ToL1MessagePasser),
abi.encodeWithSelector(
IL2ToL1MessagePasser.initiateWithdrawal.selector,
address(l1CrossDomainMessenger),
l2CrossDomainMessenger.baseGas(hex"ff", 100),
xDomainCallData
abi.encodeCall(
IL2ToL1MessagePasser.initiateWithdrawal,
(address(l1CrossDomainMessenger), l2CrossDomainMessenger.baseGas(hex"ff", 100), xDomainCallData)
)
);
......@@ -230,17 +228,15 @@ contract L2CrossDomainMessenger_Test is Bridge_Initializer {
/// @dev Tests that sendMessage succeeds with a custom gas token when the call value is zero.
function test_sendMessage_customGasToken_noValue_succeeds() external {
// Mock the gasPayingToken function to return a custom gas token
vm.mockCall(address(l1Block), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(2)));
vm.mockCall(address(l1Block), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(2)));
bytes memory xDomainCallData =
Encoding.encodeCrossDomainMessage(l2CrossDomainMessenger.messageNonce(), alice, recipient, 0, 100, hex"ff");
vm.expectCall(
address(l2ToL1MessagePasser),
abi.encodeWithSelector(
IL2ToL1MessagePasser.initiateWithdrawal.selector,
address(l1CrossDomainMessenger),
l2CrossDomainMessenger.baseGas(hex"ff", 100),
xDomainCallData
abi.encodeCall(
IL2ToL1MessagePasser.initiateWithdrawal,
(address(l1CrossDomainMessenger), l2CrossDomainMessenger.baseGas(hex"ff", 100), xDomainCallData)
)
);
......@@ -272,7 +268,7 @@ contract L2CrossDomainMessenger_Test is Bridge_Initializer {
/// @dev Tests that the sendMessage reverts when call value is non-zero with custom gas token.
function test_sendMessage_customGasToken_withValue_reverts() external {
// Mock the gasPayingToken function to return a custom gas token
vm.mockCall(address(l1Block), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(2)));
vm.mockCall(address(l1Block), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(2)));
vm.expectRevert("CrossDomainMessenger: cannot send value with custom gas token");
l2CrossDomainMessenger.sendMessage{ value: 1 }(recipient, hex"ff", uint32(100));
......@@ -281,7 +277,7 @@ contract L2CrossDomainMessenger_Test is Bridge_Initializer {
/// @dev Tests that the relayMessage succeeds with a custom gas token when the call value is zero.
function test_relayMessage_customGasToken_noValue_succeeds() external {
// Mock the gasPayingToken function to return a custom gas token
vm.mockCall(address(l1Block), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(2)));
vm.mockCall(address(l1Block), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(2)));
address target = address(0xabcd);
address sender = address(l1CrossDomainMessenger);
......@@ -317,7 +313,7 @@ contract L2CrossDomainMessenger_Test is Bridge_Initializer {
/// The L1CrossDomainMessenger `sendMessage` function cannot send value with a custom gas token.
function test_relayMessage_customGasToken_withValue_reverts() external virtual {
// Mock the gasPayingToken function to return a custom gas token
vm.mockCall(address(l1Block), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(2)));
vm.mockCall(address(l1Block), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(2)));
vm.expectRevert("CrossDomainMessenger: value must be zero unless message is from a system address");
l2CrossDomainMessenger.relayMessage{ value: 1 }(
......
......@@ -240,7 +240,7 @@ contract L2ERC721Bridge_Test is Bridge_Initializer {
// Finalize a withdrawal.
vm.mockCall(
address(l2CrossDomainMessenger),
abi.encodeWithSelector(l2CrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(l2CrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(l1ERC721Bridge)
);
vm.prank(address(l2CrossDomainMessenger));
......@@ -264,7 +264,7 @@ contract L2ERC721Bridge_Test is Bridge_Initializer {
// to be compliant with the `IOptimismMintableERC721` interface.
vm.mockCall(
address(l2CrossDomainMessenger),
abi.encodeWithSelector(l2CrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(l2CrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(l1ERC721Bridge)
);
vm.prank(address(l2CrossDomainMessenger));
......@@ -287,7 +287,7 @@ contract L2ERC721Bridge_Test is Bridge_Initializer {
// Finalize a withdrawal.
vm.mockCall(
address(l2CrossDomainMessenger),
abi.encodeWithSelector(l2CrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(l2CrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(alice)
);
vm.prank(address(l2CrossDomainMessenger));
......@@ -301,7 +301,7 @@ contract L2ERC721Bridge_Test is Bridge_Initializer {
// Finalize a withdrawal.
vm.mockCall(
address(l2CrossDomainMessenger),
abi.encodeWithSelector(l2CrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(l2CrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(address(l1ERC721Bridge))
);
vm.prank(address(l2CrossDomainMessenger));
......@@ -316,7 +316,7 @@ contract L2ERC721Bridge_Test is Bridge_Initializer {
// Finalize a withdrawal.
vm.mockCall(
address(l2CrossDomainMessenger),
abi.encodeWithSelector(l2CrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(l2CrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(address(l1ERC721Bridge))
);
vm.prank(address(l2CrossDomainMessenger));
......
......@@ -139,9 +139,7 @@ contract L2GenesisTest is Test {
/// @notice Tests the genesis predeploys setup.
function _test_genesis_predeploys(string memory _path, bool _useInterop) internal {
// Set the useInterop value
vm.mockCall(
address(genesis.cfg()), abi.encodeWithSelector(genesis.cfg().useInterop.selector), abi.encode(_useInterop)
);
vm.mockCall(address(genesis.cfg()), abi.encodeCall(genesis.cfg().useInterop, ()), abi.encode(_useInterop));
// Set the predeploy proxies into state
genesis.setPredeployProxies();
......
......@@ -56,17 +56,11 @@ contract L2StandardBridge_Test is Bridge_Initializer {
assertEq(address(l2ToL1MessagePasser).balance, 0);
uint256 nonce = l2CrossDomainMessenger.messageNonce();
bytes memory message =
abi.encodeWithSelector(IStandardBridge.finalizeBridgeETH.selector, alice, alice, 100, hex"");
bytes memory message = abi.encodeCall(IStandardBridge.finalizeBridgeETH, (alice, alice, 100, hex""));
uint64 baseGas = l2CrossDomainMessenger.baseGas(message, 200_000);
bytes memory withdrawalData = abi.encodeWithSelector(
ICrossDomainMessenger.relayMessage.selector,
nonce,
address(l2StandardBridge),
address(l1StandardBridge),
100,
200_000,
message
bytes memory withdrawalData = abi.encodeCall(
ICrossDomainMessenger.relayMessage,
(nonce, address(l2StandardBridge), address(l1StandardBridge), 100, 200_000, message)
);
bytes32 withdrawalHash = Hashing.hashWithdrawal(
Types.WithdrawalTransaction({
......@@ -107,21 +101,16 @@ contract L2StandardBridge_Test is Bridge_Initializer {
vm.expectCall(
address(l2CrossDomainMessenger),
abi.encodeWithSelector(
ICrossDomainMessenger.sendMessage.selector,
address(l1StandardBridge),
message,
200_000 // StandardBridge's RECEIVE_DEFAULT_GAS_LIMIT
abi.encodeCall(
ICrossDomainMessenger.sendMessage,
(address(l1StandardBridge), message, 200_000) // StandardBridge's RECEIVE_DEFAULT_GAS_LIMIT
)
);
vm.expectCall(
Predeploys.L2_TO_L1_MESSAGE_PASSER,
abi.encodeWithSelector(
IL2ToL1MessagePasser.initiateWithdrawal.selector,
address(l1CrossDomainMessenger),
baseGas,
withdrawalData
abi.encodeCall(
IL2ToL1MessagePasser.initiateWithdrawal, (address(l1CrossDomainMessenger), baseGas, withdrawalData)
)
);
......@@ -134,7 +123,7 @@ contract L2StandardBridge_Test is Bridge_Initializer {
/// @dev Tests that the receive function reverts with custom gas token.
function testFuzz_receive_customGasToken_reverts(uint256 _value) external {
vm.prank(alice, alice);
vm.mockCall(address(l1Block), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(2)));
vm.mockCall(address(l1Block), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(2)));
vm.deal(alice, _value);
(bool success, bytes memory data) = address(l2StandardBridge).call{ value: _value }(hex"");
assertFalse(success);
......@@ -173,7 +162,9 @@ contract L2StandardBridge_Test is Bridge_Initializer {
/// @dev Tests that `withdraw` reverts with custom gas token.
function test_withdraw_customGasToken_reverts() external {
vm.mockCall(address(l1Block), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(18)));
vm.mockCall(
address(l1Block), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(18))
);
vm.expectRevert("L2StandardBridge: not supported with custom gas token");
vm.prank(alice, alice);
l2StandardBridge.withdraw(address(Predeploys.LEGACY_ERC20_ETH), 1, 1, hex"");
......@@ -181,7 +172,9 @@ contract L2StandardBridge_Test is Bridge_Initializer {
/// @dev Tests that `withdraw` reverts with custom gas token.
function test_withdrawERC20_customGasToken_reverts() external {
vm.mockCall(address(l1Block), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(18)));
vm.mockCall(
address(l1Block), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(18))
);
vm.expectRevert("L2StandardBridge: not supported with custom gas token");
vm.prank(alice, alice);
l2StandardBridge.withdraw(address(L1Token), 1, 1, hex"");
......@@ -190,7 +183,9 @@ contract L2StandardBridge_Test is Bridge_Initializer {
/// @dev Tests that `withdraw` reverts with custom gas token.
function test_withdrawERC20WithValue_customGasToken_reverts() external {
vm.deal(alice, 1 ether);
vm.mockCall(address(l1Block), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(18)));
vm.mockCall(
address(l1Block), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(18))
);
vm.expectRevert("L2StandardBridge: not supported with custom gas token");
vm.prank(alice, alice);
l2StandardBridge.withdraw{ value: 1 ether }(address(L1Token), 1, 1, hex"");
......@@ -199,7 +194,9 @@ contract L2StandardBridge_Test is Bridge_Initializer {
/// @dev Tests that `withdraw` with value reverts with custom gas token.
function test_withdraw_customGasTokenWithValue_reverts() external {
vm.deal(alice, 1 ether);
vm.mockCall(address(l1Block), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(18)));
vm.mockCall(
address(l1Block), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(18))
);
vm.expectRevert("L2StandardBridge: not supported with custom gas token");
vm.prank(alice, alice);
l2StandardBridge.withdraw{ value: 1 ether }(address(Predeploys.LEGACY_ERC20_ETH), 1, 1, hex"");
......@@ -207,7 +204,9 @@ contract L2StandardBridge_Test is Bridge_Initializer {
/// @dev Tests that `withdrawTo` reverts with custom gas token.
function test_withdrawTo_customGasToken_reverts() external {
vm.mockCall(address(l1Block), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(18)));
vm.mockCall(
address(l1Block), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(18))
);
vm.expectRevert("L2StandardBridge: not supported with custom gas token");
vm.prank(alice, alice);
l2StandardBridge.withdrawTo(address(Predeploys.LEGACY_ERC20_ETH), bob, 1, 1, hex"");
......@@ -215,7 +214,9 @@ contract L2StandardBridge_Test is Bridge_Initializer {
/// @dev Tests that `withdrawTo` reverts with custom gas token.
function test_withdrawToERC20_customGasToken_reverts() external {
vm.mockCall(address(l1Block), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(18)));
vm.mockCall(
address(l1Block), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(18))
);
vm.expectRevert("L2StandardBridge: not supported with custom gas token");
vm.prank(alice, alice);
l2StandardBridge.withdrawTo(address(L2Token), bob, 1, 1, hex"");
......@@ -224,7 +225,9 @@ contract L2StandardBridge_Test is Bridge_Initializer {
/// @dev Tests that `withdrawTo` reverts with custom gas token.
function test_withdrawToERC20WithValue_customGasToken_reverts() external {
vm.deal(alice, 1 ether);
vm.mockCall(address(l1Block), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(18)));
vm.mockCall(
address(l1Block), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(18))
);
vm.expectRevert("L2StandardBridge: not supported with custom gas token");
vm.prank(alice, alice);
l2StandardBridge.withdrawTo{ value: 1 ether }(address(L2Token), bob, 1, 1, hex"");
......@@ -233,7 +236,9 @@ contract L2StandardBridge_Test is Bridge_Initializer {
/// @dev Tests that `withdrawTo` with value reverts with custom gas token.
function test_withdrawTo_customGasTokenWithValue_reverts() external {
vm.deal(alice, 1 ether);
vm.mockCall(address(l1Block), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(18)));
vm.mockCall(
address(l1Block), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(18))
);
vm.expectRevert("L2StandardBridge: not supported with custom gas token");
vm.prank(alice, alice);
l2StandardBridge.withdrawTo{ value: 1 ether }(address(Predeploys.LEGACY_ERC20_ETH), bob, 1, 1, hex"");
......@@ -277,18 +282,12 @@ contract PreBridgeERC20 is Bridge_Initializer {
deal(_l2Token, alice, 100, true);
assertEq(ERC20(_l2Token).balanceOf(alice), 100);
uint256 nonce = l2CrossDomainMessenger.messageNonce();
bytes memory message = abi.encodeWithSelector(
IStandardBridge.finalizeBridgeERC20.selector, address(L1Token), _l2Token, alice, alice, 100, hex""
);
bytes memory message =
abi.encodeCall(IStandardBridge.finalizeBridgeERC20, (address(L1Token), _l2Token, alice, alice, 100, hex""));
uint64 baseGas = l2CrossDomainMessenger.baseGas(message, 1000);
bytes memory withdrawalData = abi.encodeWithSelector(
ICrossDomainMessenger.relayMessage.selector,
nonce,
address(l2StandardBridge),
address(l1StandardBridge),
0,
1000,
message
bytes memory withdrawalData = abi.encodeCall(
ICrossDomainMessenger.relayMessage,
(nonce, address(l2StandardBridge), address(l1StandardBridge), 0, 1000, message)
);
bytes32 withdrawalHash = Hashing.hashWithdrawal(
Types.WithdrawalTransaction({
......@@ -303,35 +302,29 @@ contract PreBridgeERC20 is Bridge_Initializer {
if (_isLegacy) {
vm.expectCall(
address(l2StandardBridge),
abi.encodeWithSelector(l2StandardBridge.withdraw.selector, _l2Token, 100, 1000, hex"")
address(l2StandardBridge), abi.encodeCall(l2StandardBridge.withdraw, (_l2Token, 100, 1000, hex""))
);
} else {
vm.expectCall(
address(l2StandardBridge),
abi.encodeWithSelector(
l2StandardBridge.bridgeERC20.selector, _l2Token, address(L1Token), 100, 1000, hex""
)
abi.encodeCall(l2StandardBridge.bridgeERC20, (_l2Token, address(L1Token), 100, 1000, hex""))
);
}
vm.expectCall(
address(l2CrossDomainMessenger),
abi.encodeWithSelector(ICrossDomainMessenger.sendMessage.selector, address(l1StandardBridge), message, 1000)
abi.encodeCall(ICrossDomainMessenger.sendMessage, (address(l1StandardBridge), message, 1000))
);
vm.expectCall(
Predeploys.L2_TO_L1_MESSAGE_PASSER,
abi.encodeWithSelector(
IL2ToL1MessagePasser.initiateWithdrawal.selector,
address(l1CrossDomainMessenger),
baseGas,
withdrawalData
abi.encodeCall(
IL2ToL1MessagePasser.initiateWithdrawal, (address(l1CrossDomainMessenger), baseGas, withdrawalData)
)
);
// The l2StandardBridge should burn the tokens
vm.expectCall(_l2Token, abi.encodeWithSelector(OptimismMintableERC20.burn.selector, alice, 100));
vm.expectCall(_l2Token, abi.encodeCall(OptimismMintableERC20.burn, (alice, 100)));
vm.expectEmit(true, true, true, true);
emit WithdrawalInitiated(address(L1Token), _l2Token, alice, alice, 100, hex"");
......@@ -415,18 +408,12 @@ contract PreBridgeERC20To is Bridge_Initializer {
deal(_l2Token, alice, 100, true);
assertEq(ERC20(L2Token).balanceOf(alice), 100);
uint256 nonce = l2CrossDomainMessenger.messageNonce();
bytes memory message = abi.encodeWithSelector(
IStandardBridge.finalizeBridgeERC20.selector, address(L1Token), _l2Token, alice, bob, 100, hex""
);
bytes memory message =
abi.encodeCall(IStandardBridge.finalizeBridgeERC20, (address(L1Token), _l2Token, alice, bob, 100, hex""));
uint64 baseGas = l2CrossDomainMessenger.baseGas(message, 1000);
bytes memory withdrawalData = abi.encodeWithSelector(
ICrossDomainMessenger.relayMessage.selector,
nonce,
address(l2StandardBridge),
address(l1StandardBridge),
0,
1000,
message
bytes memory withdrawalData = abi.encodeCall(
ICrossDomainMessenger.relayMessage,
(nonce, address(l2StandardBridge), address(l1StandardBridge), 0, 1000, message)
);
bytes32 withdrawalHash = Hashing.hashWithdrawal(
Types.WithdrawalTransaction({
......@@ -467,34 +454,29 @@ contract PreBridgeERC20To is Bridge_Initializer {
if (_isLegacy) {
vm.expectCall(
address(l2StandardBridge),
abi.encodeWithSelector(l2StandardBridge.withdrawTo.selector, _l2Token, bob, 100, 1000, hex"")
abi.encodeCall(l2StandardBridge.withdrawTo, (_l2Token, bob, 100, 1000, hex""))
);
} else {
vm.expectCall(
address(l2StandardBridge),
abi.encodeWithSelector(
l2StandardBridge.bridgeERC20To.selector, _l2Token, address(L1Token), bob, 100, 1000, hex""
)
abi.encodeCall(l2StandardBridge.bridgeERC20To, (_l2Token, address(L1Token), bob, 100, 1000, hex""))
);
}
vm.expectCall(
address(l2CrossDomainMessenger),
abi.encodeWithSelector(ICrossDomainMessenger.sendMessage.selector, address(l1StandardBridge), message, 1000)
abi.encodeCall(ICrossDomainMessenger.sendMessage, (address(l1StandardBridge), message, 1000))
);
vm.expectCall(
Predeploys.L2_TO_L1_MESSAGE_PASSER,
abi.encodeWithSelector(
IL2ToL1MessagePasser.initiateWithdrawal.selector,
address(l1CrossDomainMessenger),
baseGas,
withdrawalData
abi.encodeCall(
IL2ToL1MessagePasser.initiateWithdrawal, (address(l1CrossDomainMessenger), baseGas, withdrawalData)
)
);
// The l2StandardBridge should burn the tokens
vm.expectCall(address(L2Token), abi.encodeWithSelector(OptimismMintableERC20.burn.selector, alice, 100));
vm.expectCall(address(L2Token), abi.encodeCall(OptimismMintableERC20.burn, (alice, 100)));
vm.prank(alice, alice);
}
......@@ -524,7 +506,7 @@ contract L2StandardBridge_Bridge_Test is Bridge_Initializer {
function test_finalizeBridgeETH_sendToSelf_reverts() external {
vm.mockCall(
address(l2StandardBridge.messenger()),
abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(ICrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(address(l2StandardBridge.OTHER_BRIDGE()))
);
vm.deal(address(l2CrossDomainMessenger), 100);
......@@ -537,7 +519,7 @@ contract L2StandardBridge_Bridge_Test is Bridge_Initializer {
function test_finalizeBridgeETH_sendToMessenger_reverts() external {
vm.mockCall(
address(l2StandardBridge.messenger()),
abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(ICrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(address(l2StandardBridge.OTHER_BRIDGE()))
);
vm.deal(address(l2CrossDomainMessenger), 100);
......@@ -550,21 +532,16 @@ contract L2StandardBridge_Bridge_Test is Bridge_Initializer {
function testFuzz_bridgeETH_succeeds(uint256 _value, uint32 _minGasLimit, bytes calldata _extraData) external {
uint256 nonce = l2CrossDomainMessenger.messageNonce();
bytes memory message =
abi.encodeWithSelector(IStandardBridge.finalizeBridgeETH.selector, alice, alice, _value, _extraData);
bytes memory message = abi.encodeCall(IStandardBridge.finalizeBridgeETH, (alice, alice, _value, _extraData));
vm.expectCall(
address(l2StandardBridge),
_value,
abi.encodeWithSelector(l2StandardBridge.bridgeETH.selector, _minGasLimit, _extraData)
address(l2StandardBridge), _value, abi.encodeCall(l2StandardBridge.bridgeETH, (_minGasLimit, _extraData))
);
vm.expectCall(
address(l2CrossDomainMessenger),
_value,
abi.encodeWithSelector(
ICrossDomainMessenger.sendMessage.selector, address(l1StandardBridge), message, _minGasLimit
)
abi.encodeCall(ICrossDomainMessenger.sendMessage, (address(l1StandardBridge), message, _minGasLimit))
);
vm.expectEmit(address(l2StandardBridge));
......@@ -587,7 +564,7 @@ contract L2StandardBridge_Bridge_Test is Bridge_Initializer {
/// @dev Tests that bridging reverts with custom gas token.
function test_bridgeETH_customGasToken_reverts() external {
vm.prank(alice, alice);
vm.mockCall(address(l1Block), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(2)));
vm.mockCall(address(l1Block), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(2)));
vm.expectRevert("StandardBridge: cannot bridge ETH with custom gas token");
l2StandardBridge.bridgeETH(50000, hex"dead");
......@@ -600,19 +577,16 @@ contract L2StandardBridge_Bridge_Test is Bridge_Initializer {
vm.expectCall(
address(l2StandardBridge),
_value,
abi.encodeWithSelector(l1StandardBridge.bridgeETHTo.selector, bob, _minGasLimit, _extraData)
abi.encodeCall(l1StandardBridge.bridgeETHTo, (bob, _minGasLimit, _extraData))
);
bytes memory message =
abi.encodeWithSelector(IStandardBridge.finalizeBridgeETH.selector, alice, bob, _value, _extraData);
bytes memory message = abi.encodeCall(IStandardBridge.finalizeBridgeETH, (alice, bob, _value, _extraData));
// the L2 bridge should call
// L2CrossDomainMessenger.sendMessage
vm.expectCall(
address(l2CrossDomainMessenger),
abi.encodeWithSelector(
ICrossDomainMessenger.sendMessage.selector, address(l1StandardBridge), message, _minGasLimit
)
abi.encodeCall(ICrossDomainMessenger.sendMessage, (address(l1StandardBridge), message, _minGasLimit))
);
vm.expectEmit(address(l2StandardBridge));
......@@ -641,7 +615,7 @@ contract L2StandardBridge_Bridge_Test is Bridge_Initializer {
)
external
{
vm.mockCall(address(l1Block), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(2)));
vm.mockCall(address(l1Block), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(2)));
vm.expectRevert("StandardBridge: cannot bridge ETH with custom gas token");
vm.deal(address(this), _value);
l2StandardBridge.bridgeETHTo{ value: _value }(bob, _minGasLimit, _extraData);
......@@ -654,7 +628,7 @@ contract L2StandardBridge_FinalizeBridgeETH_Test is Bridge_Initializer {
address messenger = address(l2StandardBridge.messenger());
vm.mockCall(
messenger,
abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(ICrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(address(l2StandardBridge.OTHER_BRIDGE()))
);
vm.deal(messenger, 100);
......@@ -674,12 +648,12 @@ contract L2StandardBridge_FinalizeBridgeETH_Test is Bridge_Initializer {
address messenger = address(l2StandardBridge.messenger());
vm.mockCall(
messenger,
abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(ICrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(address(l2StandardBridge.OTHER_BRIDGE()))
);
vm.deal(address(l2CrossDomainMessenger), 1);
vm.prank(address(l2CrossDomainMessenger));
vm.mockCall(address(l1Block), abi.encodeWithSignature("gasPayingToken()"), abi.encode(address(1), uint8(2)));
vm.mockCall(address(l1Block), abi.encodeCall(systemConfig.gasPayingToken, ()), abi.encode(address(1), uint8(2)));
vm.expectRevert("StandardBridge: cannot bridge ETH with custom gas token");
l2StandardBridge.finalizeBridgeETH(alice, alice, 1, hex"");
......
......@@ -31,21 +31,17 @@ contract L2StandardBridgeInterop_Test is Bridge_Initializer {
/// @notice Mock ERC20 decimals
function _mockDecimals(address _token, uint8 _decimals) internal {
_mockAndExpect(_token, abi.encodeWithSelector(IERC20Metadata.decimals.selector), abi.encode(_decimals));
_mockAndExpect(_token, abi.encodeCall(IERC20Metadata.decimals, ()), abi.encode(_decimals));
}
/// @notice Mock ERC165 interface
function _mockInterface(address _token, bytes4 _interfaceId, bool _supported) internal {
_mockAndExpect(
_token, abi.encodeWithSelector(IERC165.supportsInterface.selector, _interfaceId), abi.encode(_supported)
);
_mockAndExpect(_token, abi.encodeCall(IERC165.supportsInterface, (_interfaceId)), abi.encode(_supported));
}
/// @notice Mock factory deployment
function _mockDeployments(address _factory, address _token, address _deployed) internal {
_mockAndExpect(
_factory, abi.encodeWithSelector(IOptimismERC20Factory.deployments.selector, _token), abi.encode(_deployed)
);
_mockAndExpect(_factory, abi.encodeCall(IOptimismERC20Factory.deployments, (_token)), abi.encode(_deployed));
}
/// @notice Assume a valid address for fuzzing
......@@ -198,12 +194,8 @@ contract L2StandardBridgeInterop_LegacyToSuper_Test is L2StandardBridgeInterop_T
emit Converted(_from, _to, _caller, _amount);
// Mock and expect the `burn` and `mint` functions
_mockAndExpect(
_from, abi.encodeWithSelector(IMintableAndBurnableERC20.burn.selector, _caller, _amount), abi.encode()
);
_mockAndExpect(
_to, abi.encodeWithSelector(IMintableAndBurnableERC20.mint.selector, _caller, _amount), abi.encode()
);
_mockAndExpect(_from, abi.encodeCall(IMintableAndBurnableERC20.burn, (_caller, _amount)), abi.encode());
_mockAndExpect(_to, abi.encodeCall(IMintableAndBurnableERC20.mint, (_caller, _amount)), abi.encode());
// Act
vm.prank(_caller);
......@@ -356,12 +348,8 @@ contract L2StandardBridgeInterop_SuperToLegacy_Test is L2StandardBridgeInterop_T
emit Converted(_from, _to, _caller, _amount);
// Mock and expect the `burn` and `mint` functions
_mockAndExpect(
_from, abi.encodeWithSelector(IMintableAndBurnableERC20.burn.selector, _caller, _amount), abi.encode()
);
_mockAndExpect(
_to, abi.encodeWithSelector(IMintableAndBurnableERC20.mint.selector, _caller, _amount), abi.encode()
);
_mockAndExpect(_from, abi.encodeCall(IMintableAndBurnableERC20.burn, (_caller, _amount)), abi.encode());
_mockAndExpect(_to, abi.encodeCall(IMintableAndBurnableERC20.mint, (_caller, _amount)), abi.encode());
// Act
vm.prank(_caller);
......
......@@ -227,7 +227,7 @@ contract L2ToL2CrossDomainMessengerTest is Test {
// Ensure the CrossL2Inbox validates this message
vm.mockCall({
callee: Predeploys.CROSS_L2_INBOX,
data: abi.encodeWithSelector(CrossL2Inbox.validateMessage.selector, id, sentMessage),
data: abi.encodeCall(CrossL2Inbox.validateMessage, (id, keccak256(sentMessage))),
returnData: ""
});
......@@ -271,7 +271,7 @@ contract L2ToL2CrossDomainMessengerTest is Test {
// Ensure the CrossL2Inbox validates this message
vm.mockCall({
callee: Predeploys.CROSS_L2_INBOX,
data: abi.encodeWithSelector(CrossL2Inbox.validateMessage.selector, id, sentMessage),
data: abi.encodeCall(CrossL2Inbox.validateMessage, (id, keccak256(sentMessage))),
returnData: ""
});
......@@ -312,7 +312,7 @@ contract L2ToL2CrossDomainMessengerTest is Test {
// Set the target and message for the reentrant call
address target = address(this);
bytes memory message = abi.encodeWithSelector(this.mockTarget.selector, _source, _sender);
bytes memory message = abi.encodeCall(this.mockTarget, (_source, _sender));
bytes32 msgHash = keccak256(abi.encode(block.chainid, _source, _nonce, _sender, target, message));
......@@ -334,7 +334,7 @@ contract L2ToL2CrossDomainMessengerTest is Test {
// Ensure the CrossL2Inbox validates this message
vm.mockCall({
callee: Predeploys.CROSS_L2_INBOX,
data: abi.encodeWithSelector(CrossL2Inbox.validateMessage.selector, id, sentMessage),
data: abi.encodeCall(CrossL2Inbox.validateMessage, (id, keccak256(sentMessage))),
returnData: ""
});
......@@ -399,7 +399,7 @@ contract L2ToL2CrossDomainMessengerTest is Test {
// Set the target and message for the reentrant call
address target = address(this);
bytes memory message = abi.encodeWithSelector(this.mockTargetReentrant.selector, _source2, _nonce, _sender2);
bytes memory message = abi.encodeCall(this.mockTargetReentrant, (_source2, _nonce, _sender2));
// Ensure the target contract is called with the correct parameters
vm.expectCall({ callee: target, msgValue: _value, data: message });
......@@ -415,7 +415,7 @@ contract L2ToL2CrossDomainMessengerTest is Test {
// Ensure the CrossL2Inbox validates this message
vm.mockCall({
callee: Predeploys.CROSS_L2_INBOX,
data: abi.encodeWithSelector(CrossL2Inbox.validateMessage.selector, id, sentMessage),
data: abi.encodeCall(CrossL2Inbox.validateMessage, (id, keccak256(sentMessage))),
returnData: ""
});
......@@ -497,7 +497,7 @@ contract L2ToL2CrossDomainMessengerTest is Test {
// Ensure the CrossL2Inbox validates this message
vm.mockCall({
callee: Predeploys.CROSS_L2_INBOX,
data: abi.encodeWithSelector(CrossL2Inbox.validateMessage.selector, id, sentMessage),
data: abi.encodeCall(CrossL2Inbox.validateMessage, (id, keccak256(sentMessage))),
returnData: ""
});
......@@ -536,7 +536,7 @@ contract L2ToL2CrossDomainMessengerTest is Test {
// Ensure the CrossL2Inbox validates this message
vm.mockCall({
callee: Predeploys.CROSS_L2_INBOX,
data: abi.encodeWithSelector(CrossL2Inbox.validateMessage.selector, id, sentMessage),
data: abi.encodeCall(CrossL2Inbox.validateMessage, (id, keccak256(sentMessage))),
returnData: ""
});
......@@ -578,7 +578,7 @@ contract L2ToL2CrossDomainMessengerTest is Test {
// Ensure the CrossL2Inbox validates this message
vm.mockCall({
callee: Predeploys.CROSS_L2_INBOX,
data: abi.encodeWithSelector(CrossL2Inbox.validateMessage.selector, id, sentMessage),
data: abi.encodeCall(CrossL2Inbox.validateMessage, (id, keccak256(sentMessage))),
returnData: ""
});
......@@ -628,7 +628,7 @@ contract L2ToL2CrossDomainMessengerTest is Test {
// Ensure the CrossL2Inbox validates this message
vm.mockCall({
callee: Predeploys.CROSS_L2_INBOX,
data: abi.encodeWithSelector(CrossL2Inbox.validateMessage.selector, id, sentMessage),
data: abi.encodeCall(CrossL2Inbox.validateMessage, (id, keccak256(sentMessage))),
returnData: ""
});
......@@ -678,7 +678,7 @@ contract L2ToL2CrossDomainMessengerTest is Test {
// Ensure the CrossL2Inbox validates this message
vm.mockCall({
callee: Predeploys.CROSS_L2_INBOX,
data: abi.encodeWithSelector(CrossL2Inbox.validateMessage.selector, id, sentMessage),
data: abi.encodeCall(CrossL2Inbox.validateMessage, (id, keccak256(sentMessage))),
returnData: ""
});
......
......@@ -63,11 +63,7 @@ contract OptimismSuperchainERC20Test is Test {
EIP1967Helper.setImplementation(_addr, _impl);
// Mock implementation address
vm.mockCall(
_impl,
abi.encodeWithSelector(IBeacon.implementation.selector),
abi.encode(address(optimismSuperchainERC20Impl))
);
vm.mockCall(_impl, abi.encodeCall(IBeacon.implementation, ()), abi.encode(address(optimismSuperchainERC20Impl)));
}
/// @notice Helper function to deploy a proxy of the OptimismSuperchainERC20 contract.
......
......@@ -96,8 +96,8 @@ contract SuperchainTokenBridgeTest is Bridge_Initializer {
abi.encodeCall(superchainTokenBridge.relayERC20, (address(superchainERC20), _sender, _to, _amount));
_mockAndExpect(
Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER,
abi.encodeWithSelector(
IL2ToL2CrossDomainMessenger.sendMessage.selector, _chainId, address(superchainTokenBridge), _message
abi.encodeCall(
IL2ToL2CrossDomainMessenger.sendMessage, (_chainId, address(superchainTokenBridge), _message)
),
abi.encode(_msgHash)
);
......@@ -150,7 +150,7 @@ contract SuperchainTokenBridgeTest is Bridge_Initializer {
// Mock the call over the `crossDomainMessageContext` function setting a wrong sender
vm.mockCall(
Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER,
abi.encodeWithSelector(IL2ToL2CrossDomainMessenger.crossDomainMessageContext.selector),
abi.encodeCall(IL2ToL2CrossDomainMessenger.crossDomainMessageContext, ()),
abi.encode(_crossDomainMessageSender, _source)
);
......@@ -169,7 +169,7 @@ contract SuperchainTokenBridgeTest is Bridge_Initializer {
// Mock the call over the `crossDomainMessageContext` function setting the same address as value
_mockAndExpect(
Predeploys.L2_TO_L2_CROSS_DOMAIN_MESSENGER,
abi.encodeWithSelector(IL2ToL2CrossDomainMessenger.crossDomainMessageContext.selector),
abi.encodeCall(IL2ToL2CrossDomainMessenger.crossDomainMessageContext, ()),
abi.encode(address(superchainTokenBridge), _source)
);
......
......@@ -322,7 +322,8 @@ contract SuperchainWETH_Test is CommonTest {
/// @notice Test that the internal mint function reverts to protect against accidentally changing the visibility.
function testFuzz_calling_internal_mint_function_reverts(address _caller, address _to, uint256 _amount) public {
// Arrange
bytes memory _calldata = abi.encodeWithSignature("_mint(address,uint256)", _to, _amount);
bytes memory _calldata = abi.encodeWithSignature("_mint(address,uint256)", _to, _amount); // nosemgrep:
// sol-style-use-abi-encodecall
vm.expectRevert(bytes(""));
// Act
......@@ -336,7 +337,8 @@ contract SuperchainWETH_Test is CommonTest {
/// @notice Test that the mint function reverts to protect against accidentally changing the visibility.
function testFuzz_calling_mint_function_reverts(address _caller, address _to, uint256 _amount) public {
// Arrange
bytes memory _calldata = abi.encodeWithSignature("mint(address,uint256)", _to, _amount);
bytes memory _calldata = abi.encodeWithSignature("mint(address,uint256)", _to, _amount); // nosemgrep:
// sol-style-use-abi-encodecall
vm.expectRevert(bytes(""));
// Act
......@@ -350,7 +352,8 @@ contract SuperchainWETH_Test is CommonTest {
/// @notice Test that the internal burn function reverts to protect against accidentally changing the visibility.
function testFuzz_calling_internal_burn_function_reverts(address _caller, address _from, uint256 _amount) public {
// Arrange
bytes memory _calldata = abi.encodeWithSignature("_burn(address,uint256)", _from, _amount);
bytes memory _calldata = abi.encodeWithSignature("_burn(address,uint256)", _from, _amount); // nosemgrep:
// sol-style-use-abi-encodecall
vm.expectRevert(bytes(""));
// Act
......@@ -364,7 +367,8 @@ contract SuperchainWETH_Test is CommonTest {
/// @notice Test that the burn function reverts to protect against accidentally changing the visibility.
function testFuzz_calling_burn_function_reverts(address _caller, address _from, uint256 _amount) public {
// Arrange
bytes memory _calldata = abi.encodeWithSignature("burn(address,uint256)", _from, _amount);
bytes memory _calldata = abi.encodeWithSignature("burn(address,uint256)", _from, _amount); // nosemgrep:
// sol-style-use-abi-encodecall
vm.expectRevert(bytes(""));
// Act
......
......@@ -10,7 +10,7 @@ import { WETH } from "src/L2/WETH.sol";
contract WETH_Test is CommonTest {
/// @dev Tests that the name function returns the correct value.
function testFuzz_name_succeeds(string memory _gasPayingTokenName) external {
vm.mockCall(address(l1Block), abi.encodeWithSignature("gasPayingTokenName()"), abi.encode(_gasPayingTokenName));
vm.mockCall(address(l1Block), abi.encodeCall(l1Block.gasPayingTokenName, ()), abi.encode(_gasPayingTokenName));
assertEq(string.concat("Wrapped ", _gasPayingTokenName), weth.name());
}
......@@ -18,7 +18,7 @@ contract WETH_Test is CommonTest {
/// @dev Tests that the symbol function returns the correct value.
function testFuzz_symbol_succeeds(string memory _gasPayingTokenSymbol) external {
vm.mockCall(
address(l1Block), abi.encodeWithSignature("gasPayingTokenSymbol()"), abi.encode(_gasPayingTokenSymbol)
address(l1Block), abi.encodeCall(l1Block.gasPayingTokenSymbol, ()), abi.encode(_gasPayingTokenSymbol)
);
assertEq(string.concat("W", _gasPayingTokenSymbol), weth.symbol());
......
......@@ -49,9 +49,7 @@ contract AnchorStateRegistry_TryUpdateAnchorState_Test is AnchorStateRegistry_In
assert(l2BlockNumber < gameProxy.l2BlockNumber());
// Mock the state that we want.
vm.mockCall(
address(gameProxy), abi.encodeWithSelector(gameProxy.status.selector), abi.encode(GameStatus.DEFENDER_WINS)
);
vm.mockCall(address(gameProxy), abi.encodeCall(gameProxy.status, ()), abi.encode(GameStatus.DEFENDER_WINS));
// Try to update the anchor state.
vm.prank(address(gameProxy));
......@@ -66,15 +64,13 @@ contract AnchorStateRegistry_TryUpdateAnchorState_Test is AnchorStateRegistry_In
/// @dev Tests that updating the anchor state fails when the game state is valid but older.
function test_tryUpdateAnchorState_validOlderState_fails() public {
// Confirm that the anchor state is newer than the game state.
vm.mockCall(address(gameProxy), abi.encodeWithSelector(gameProxy.l2BlockNumber.selector), abi.encode(0));
vm.mockCall(address(gameProxy), abi.encodeCall(gameProxy.l2BlockNumber, ()), abi.encode(0));
(Hash root, uint256 l2BlockNumber) = anchorStateRegistry.anchors(gameProxy.gameType());
assert(l2BlockNumber >= gameProxy.l2BlockNumber());
// Mock the state that we want.
vm.mockCall(address(gameProxy), abi.encodeWithSelector(gameProxy.l2BlockNumber.selector), abi.encode(0));
vm.mockCall(
address(gameProxy), abi.encodeWithSelector(gameProxy.status.selector), abi.encode(GameStatus.DEFENDER_WINS)
);
vm.mockCall(address(gameProxy), abi.encodeCall(gameProxy.l2BlockNumber, ()), abi.encode(0));
vm.mockCall(address(gameProxy), abi.encodeCall(gameProxy.status, ()), abi.encode(GameStatus.DEFENDER_WINS));
// Try to update the anchor state.
vm.prank(address(gameProxy));
......@@ -93,11 +89,7 @@ contract AnchorStateRegistry_TryUpdateAnchorState_Test is AnchorStateRegistry_In
assert(l2BlockNumber < gameProxy.l2BlockNumber());
// Mock the state that we want.
vm.mockCall(
address(gameProxy),
abi.encodeWithSelector(gameProxy.status.selector),
abi.encode(GameStatus.CHALLENGER_WINS)
);
vm.mockCall(address(gameProxy), abi.encodeCall(gameProxy.status, ()), abi.encode(GameStatus.CHALLENGER_WINS));
// Try to update the anchor state.
vm.prank(address(gameProxy));
......@@ -118,8 +110,8 @@ contract AnchorStateRegistry_TryUpdateAnchorState_Test is AnchorStateRegistry_In
// Mock the state that we want.
vm.mockCall(
address(disputeGameFactory),
abi.encodeWithSelector(
disputeGameFactory.games.selector, gameProxy.gameType(), gameProxy.rootClaim(), gameProxy.extraData()
abi.encodeCall(
disputeGameFactory.games, (gameProxy.gameType(), gameProxy.rootClaim(), gameProxy.extraData())
),
abi.encode(address(0), 0)
);
......@@ -146,8 +138,8 @@ contract AnchorStateRegistry_TryUpdateAnchorState_Test is AnchorStateRegistry_In
// Mock the state that we want.
vm.mockCall(
address(disputeGameFactory),
abi.encodeWithSelector(
disputeGameFactory.games.selector, gameProxy.gameType(), gameProxy.rootClaim(), gameProxy.extraData()
abi.encodeCall(
disputeGameFactory.games, (gameProxy.gameType(), gameProxy.rootClaim(), gameProxy.extraData())
),
abi.encode(address(0), 0)
);
......@@ -168,11 +160,7 @@ contract AnchorStateRegistry_TryUpdateAnchorState_Test is AnchorStateRegistry_In
(Hash root, uint256 l2BlockNumber) = anchorStateRegistry.anchors(gameProxy.gameType());
// Mock the state that we want.
vm.mockCall(
address(gameProxy),
abi.encodeWithSelector(gameProxy.status.selector),
abi.encode(GameStatus.CHALLENGER_WINS)
);
vm.mockCall(address(gameProxy), abi.encodeCall(gameProxy.status, ()), abi.encode(GameStatus.CHALLENGER_WINS));
// Set the anchor state.
vm.prank(superchainConfig.guardian());
......@@ -190,9 +178,7 @@ contract AnchorStateRegistry_TryUpdateAnchorState_Test is AnchorStateRegistry_In
(Hash root, uint256 l2BlockNumber) = anchorStateRegistry.anchors(gameProxy.gameType());
// Mock the state that we want.
vm.mockCall(
address(gameProxy), abi.encodeWithSelector(gameProxy.status.selector), abi.encode(GameStatus.IN_PROGRESS)
);
vm.mockCall(address(gameProxy), abi.encodeCall(gameProxy.status, ()), abi.encode(GameStatus.IN_PROGRESS));
// Set the anchor state.
vm.prank(superchainConfig.guardian());
......@@ -208,9 +194,7 @@ contract AnchorStateRegistry_TryUpdateAnchorState_Test is AnchorStateRegistry_In
/// @dev Tests that setting the anchor state succeeds.
function test_setAnchorState_succeeds() public {
// Mock the state that we want.
vm.mockCall(
address(gameProxy), abi.encodeWithSelector(gameProxy.status.selector), abi.encode(GameStatus.DEFENDER_WINS)
);
vm.mockCall(address(gameProxy), abi.encodeCall(gameProxy.status, ()), abi.encode(GameStatus.DEFENDER_WINS));
// Set the anchor state.
vm.prank(superchainConfig.guardian());
......
......@@ -6,6 +6,7 @@ import { Test } from "forge-std/Test.sol";
import { Vm } from "forge-std/Vm.sol";
import { DisputeGameFactory_Init } from "test/dispute/DisputeGameFactory.t.sol";
import { AlphabetVM } from "test/mocks/AlphabetVM.sol";
import { stdError } from "forge-std/StdError.sol";
// Scripts
import { DeployUtils } from "scripts/libraries/DeployUtils.sol";
......@@ -186,9 +187,7 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
// PreimageOracle constructor will revert if the challenge period is too large, so we need
// to mock the call to pretend this is a bugged implementation where the challenge period
// is allowed to be too large.
vm.mockCall(
address(oracle), abi.encodeWithSelector(oracle.challengePeriod.selector), abi.encode(_challengePeriod)
);
vm.mockCall(address(oracle), abi.encodeCall(IPreimageOracle.challengePeriod, ()), abi.encode(_challengePeriod));
vm.expectRevert(InvalidChallengePeriod.selector);
DeployUtils.create1({
......@@ -536,11 +535,11 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
Claim claim = _dummyClaim();
// Expect an out of bounds revert for an attack
vm.expectRevert(abi.encodeWithSignature("Panic(uint256)", 0x32));
vm.expectRevert(stdError.indexOOBError);
gameProxy.attack(_dummyClaim(), 1, claim);
// Expect an out of bounds revert for a defense
vm.expectRevert(abi.encodeWithSignature("Panic(uint256)", 0x32));
vm.expectRevert(stdError.indexOOBError);
gameProxy.defend(_dummyClaim(), 1, claim);
}
......@@ -1704,14 +1703,14 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
/// resolves in favor of the defender but the game state is not newer than the anchor state.
function test_resolve_validOlderStateSameAnchor_succeeds() public {
// Mock the game block to be older than the game state.
vm.mockCall(address(gameProxy), abi.encodeWithSelector(gameProxy.l2BlockNumber.selector), abi.encode(0));
vm.mockCall(address(gameProxy), abi.encodeCall(gameProxy.l2BlockNumber, ()), abi.encode(0));
// Confirm that the anchor state is newer than the game state.
(Hash root, uint256 l2BlockNumber) = anchorStateRegistry.anchors(gameProxy.gameType());
assert(l2BlockNumber >= gameProxy.l2BlockNumber());
// Resolve the game.
vm.mockCall(address(gameProxy), abi.encodeWithSelector(gameProxy.l2BlockNumber.selector), abi.encode(0));
vm.mockCall(address(gameProxy), abi.encodeCall(gameProxy.l2BlockNumber, ()), abi.encode(0));
vm.warp(block.timestamp + 3 days + 12 hours);
gameProxy.resolveClaim(0, 0);
assertEq(uint8(gameProxy.resolve()), uint8(GameStatus.DEFENDER_WINS));
......
......@@ -103,10 +103,7 @@ contract SafeCaller_Actor is StdUtils {
vm.expectCallMinGas(to, value, minGas, hex"");
bool success = SafeCall.call(
msg.sender,
gas,
value,
abi.encodeWithSelector(SafeCall_Succeeds_Invariants.performSafeCallMinGas.selector, to, minGas)
msg.sender, gas, value, abi.encodeCall(SafeCall_Succeeds_Invariants.performSafeCallMinGas, (to, minGas))
);
if (success && FAILS) numCalls++;
......
......@@ -34,7 +34,7 @@ contract L1ERC721BridgeKontrol is DeploymentSummaryFaultProofs, KontrolUtils {
vm.mockCall(
address(l1ERC721Bridge.messenger()),
abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(CrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(address(l1ERC721Bridge.otherBridge()))
);
......
......@@ -34,7 +34,7 @@ contract L1StandardBridgeKontrol is DeploymentSummaryFaultProofs, KontrolUtils {
vm.mockCall(
address(l1standardBridge.messenger()),
abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(CrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(address(l1standardBridge.otherBridge()))
);
......@@ -59,7 +59,7 @@ contract L1StandardBridgeKontrol is DeploymentSummaryFaultProofs, KontrolUtils {
vm.mockCall(
address(l1standardBridge.messenger()),
abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(CrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(address(l1standardBridge.otherBridge()))
);
......
......@@ -43,14 +43,14 @@ contract ResolvedDelegateProxy_Test is Test {
/// @dev Tests that the proxy properly bubbles up returndata when the delegatecall succeeds.
function testFuzz_fallback_delegateCallFoo_succeeds(uint256 x) public {
vm.expectCall(address(impl), abi.encodeWithSelector(impl.foo.selector, x));
vm.expectCall(address(impl), abi.encodeCall(impl.foo, (x)));
assertEq(proxy.foo(x), x);
}
/// @dev Tests that the proxy properly bubbles up returndata when the delegatecall reverts.
function test_fallback_delegateCallBar_reverts() public {
vm.expectRevert("SimpleImplementation: revert");
vm.expectCall(address(impl), abi.encodeWithSelector(impl.bar.selector));
vm.expectCall(address(impl), abi.encodeCall(impl.bar, ()));
proxy.bar();
}
......
......@@ -122,12 +122,12 @@ contract SafeCall_Test is Test {
for (uint64 i = 40_000; i < 100_000; i++) {
uint256 snapshot = vm.snapshot();
// 65_907 is the exact amount of gas required to make the safe call
// 65_922 is the exact amount of gas required to make the safe call
// successfully.
if (i < 65_907) {
if (i < 65_922) {
assertFalse(caller.makeSafeCall(i, 25_000));
} else {
vm.expectCallMinGas(address(caller), 0, 25_000, abi.encodeWithSelector(caller.setA.selector, 1));
vm.expectCallMinGas(address(caller), 0, 25_000, abi.encodeCall(caller.setA, (1)));
assertTrue(caller.makeSafeCall(i, 25_000));
}
......@@ -142,12 +142,12 @@ contract SafeCall_Test is Test {
for (uint64 i = 15_200_000; i < 15_300_000; i++) {
uint256 snapshot = vm.snapshot();
// 15_278_606 is the exact amount of gas required to make the safe call
// 15_278_621 is the exact amount of gas required to make the safe call
// successfully.
if (i < 15_278_606) {
if (i < 15_278_621) {
assertFalse(caller.makeSafeCall(i, 15_000_000));
} else {
vm.expectCallMinGas(address(caller), 0, 15_000_000, abi.encodeWithSelector(caller.setA.selector, 1));
vm.expectCallMinGas(address(caller), 0, 15_000_000, abi.encodeCall(caller.setA, (1)));
assertTrue(caller.makeSafeCall(i, 15_000_000));
}
......@@ -160,11 +160,11 @@ contract SimpleSafeCaller {
uint256 public a;
function makeSafeCall(uint64 gas, uint64 minGas) external returns (bool) {
return SafeCall.call(address(this), gas, 0, abi.encodeWithSelector(this.makeSafeCallMinGas.selector, minGas));
return SafeCall.call(address(this), gas, 0, abi.encodeCall(this.makeSafeCallMinGas, (minGas)));
}
function makeSafeCallMinGas(uint64 minGas) external returns (bool) {
return SafeCall.callWithMinGas(address(this), minGas, 0, abi.encodeWithSelector(this.setA.selector, 1));
return SafeCall.callWithMinGas(address(this), minGas, 0, abi.encodeCall(this.setA, (1)));
}
function setA(uint256 _a) external {
......
......@@ -41,7 +41,7 @@ contract TransactorTest is Transactor_Initializer {
/// @notice Tests CALL, should do a call to target
function test_call_succeeds() external {
// Initialize call data
bytes memory data = abi.encodeWithSelector(callRecorded.record.selector);
bytes memory data = abi.encodeCall(CallRecorder.record, ());
// Run CALL
vm.prank(alice);
vm.expectCall(address(callRecorded), 200_000 wei, data);
......@@ -51,7 +51,7 @@ contract TransactorTest is Transactor_Initializer {
/// @notice It should revert if called by non-owner
function test_call_unauthorized_reverts() external {
// Initialize call data
bytes memory data = abi.encodeWithSelector(callRecorded.record.selector);
bytes memory data = abi.encodeCall(CallRecorder.record, ());
// Run CALL
vm.prank(bob);
vm.expectRevert("UNAUTHORIZED");
......@@ -61,7 +61,7 @@ contract TransactorTest is Transactor_Initializer {
/// @notice Deletate call succeeds.
function test_delegateCall_succeeds() external {
// Initialize call data
bytes memory data = abi.encodeWithSelector(reverter.doRevert.selector);
bytes memory data = abi.encodeCall(Reverter.doRevert, ());
// Run CALL
vm.prank(alice);
vm.expectCall(address(reverter), data);
......@@ -71,7 +71,7 @@ contract TransactorTest is Transactor_Initializer {
/// @notice It should revert if called by non-owner
function test_delegateCall_unauthorized_reverts() external {
// Initialize call data
bytes memory data = abi.encodeWithSelector(reverter.doRevert.selector);
bytes memory data = abi.encodeCall(Reverter.doRevert, ());
// Run CALL
vm.prank(bob);
vm.expectRevert("UNAUTHORIZED");
......
......@@ -353,7 +353,7 @@ contract Drippie_Test is Test {
// Add in an action
cfg.actions[0] = Drippie.DripAction({
target: payable(address(simpleStorage)),
data: abi.encodeWithSelector(SimpleStorage.set.selector, key, value),
data: abi.encodeCall(SimpleStorage.set, (key, value)),
value: 0
});
......@@ -365,7 +365,7 @@ contract Drippie_Test is Test {
vm.prank(drippie.owner());
drippie.status(dripName, Drippie.DripStatus.ACTIVE);
vm.expectCall(address(simpleStorage), 0, abi.encodeWithSelector(SimpleStorage.set.selector, key, value));
vm.expectCall(address(simpleStorage), 0, abi.encodeCall(SimpleStorage.set, (key, value)));
vm.expectEmit(address(drippie));
emit DripExecuted(dripName, dripName, address(this), block.timestamp);
......@@ -383,7 +383,7 @@ contract Drippie_Test is Test {
bytes32 valueOne = bytes32(uint256(3));
actions[0] = Drippie.DripAction({
target: payable(address(simpleStorage)),
data: abi.encodeWithSelector(simpleStorage.set.selector, keyOne, valueOne),
data: abi.encodeCall(SimpleStorage.set, (keyOne, valueOne)),
value: 0
});
......@@ -391,7 +391,7 @@ contract Drippie_Test is Test {
bytes32 valueTwo = bytes32(uint256(5));
actions[1] = Drippie.DripAction({
target: payable(address(simpleStorage)),
data: abi.encodeWithSelector(simpleStorage.set.selector, keyTwo, valueTwo),
data: abi.encodeCall(SimpleStorage.set, (keyTwo, valueTwo)),
value: 0
});
......@@ -407,9 +407,9 @@ contract Drippie_Test is Test {
vm.expectCall(drippie.dripConfigCheckAddress(dripName), drippie.dripConfigCheckParams(dripName));
vm.expectCall(address(simpleStorage), 0, abi.encodeWithSelector(SimpleStorage.set.selector, keyOne, valueOne));
vm.expectCall(address(simpleStorage), 0, abi.encodeCall(SimpleStorage.set, (keyOne, valueOne)));
vm.expectCall(address(simpleStorage), 0, abi.encodeWithSelector(SimpleStorage.set.selector, keyTwo, valueTwo));
vm.expectCall(address(simpleStorage), 0, abi.encodeCall(SimpleStorage.set, (keyTwo, valueTwo)));
vm.expectEmit(address(drippie));
emit DripExecuted(dripName, dripName, address(this), block.timestamp);
......
......@@ -130,9 +130,7 @@ contract Optimist_Initializer is Test {
/// @notice Mocks the allowlistAttestor to always return true for a given address.
function _mockAllowlistTrueFor(address _claimer) internal {
vm.mockCall(
address(optimistAllowlist),
abi.encodeWithSelector(OptimistAllowlist.isAllowedToMint.selector, _claimer),
abi.encode(true)
address(optimistAllowlist), abi.encodeCall(OptimistAllowlist.isAllowedToMint, (_claimer)), abi.encode(true)
);
assertTrue(optimist.isOnAllowList(_claimer));
......@@ -210,7 +208,7 @@ contract OptimistTest is Optimist_Initializer {
assertTrue(optimistAllowlist.isAllowedToMint(bob));
// Check that the OptimistAllowlist is checked
bytes memory data = abi.encodeWithSelector(optimistAllowlist.isAllowedToMint.selector, bob);
bytes memory data = abi.encodeCall(OptimistAllowlist.isAllowedToMint, (bob));
vm.expectCall(address(optimistAllowlist), data);
// mint an NFT and expect mint transfer event to be emitted
......@@ -236,7 +234,7 @@ contract OptimistTest is Optimist_Initializer {
assertTrue(optimistAllowlist.isAllowedToMint(bob));
// Check that the OptimistAllowlist is checked
bytes memory data = abi.encodeWithSelector(optimistAllowlist.isAllowedToMint.selector, bob);
bytes memory data = abi.encodeCall(OptimistAllowlist.isAllowedToMint, (bob));
vm.expectCall(address(optimistAllowlist), data);
// mint an NFT and expect mint transfer event to be emitted
......@@ -262,7 +260,7 @@ contract OptimistTest is Optimist_Initializer {
assertTrue(optimistAllowlist.isAllowedToMint(bob));
// Check that the OptimistAllowlist is checked
bytes memory data = abi.encodeWithSelector(optimistAllowlist.isAllowedToMint.selector, bob);
bytes memory data = abi.encodeCall(OptimistAllowlist.isAllowedToMint, (bob));
vm.expectCall(address(optimistAllowlist), data);
// mint an NFT and expect mint transfer event to be emitted
......@@ -293,7 +291,7 @@ contract OptimistTest is Optimist_Initializer {
assertTrue(optimistAllowlist.isAllowedToMint(bob));
// Check that the OptimistAllowlist is checked
bytes memory data = abi.encodeWithSelector(optimistAllowlist.isAllowedToMint.selector, bob);
bytes memory data = abi.encodeCall(OptimistAllowlist.isAllowedToMint, (bob));
vm.expectCall(address(optimistAllowlist), data);
// mint an NFT and expect mint transfer event to be emitted
......@@ -350,11 +348,9 @@ contract OptimistTest is Optimist_Initializer {
function test_baseURI_returnsCorrectBaseURI_succeeds() external {
_attestBaseURI(base_uri);
bytes memory data = abi.encodeWithSelector(
attestationStation.attestations.selector,
carol_baseURIAttestor,
address(optimist),
optimist.BASE_URI_ATTESTATION_KEY()
bytes memory data = abi.encodeCall(
attestationStation.attestations,
(carol_baseURIAttestor, address(optimist), optimist.BASE_URI_ATTESTATION_KEY())
);
vm.expectCall(address(attestationStation), data);
vm.prank(carol_baseURIAttestor);
......@@ -527,14 +523,14 @@ contract OptimistTest is Optimist_Initializer {
// First call is to claim the invite, receiving the attestation
calls[0] = IMulticall3.Call3({
target: address(optimistInviter),
callData: abi.encodeWithSelector(optimistInviter.claimInvite.selector, bob, claimableInvite, signature),
callData: abi.encodeCall(OptimistInviter.claimInvite, (bob, claimableInvite, signature)),
allowFailure: false
});
// Second call is to mint the Optimist NFT
calls[1] = IMulticall3.Call3({
target: address(optimist),
callData: abi.encodeWithSelector(optimist.mint.selector, bob),
callData: abi.encodeCall(Optimist.mint, (bob)),
allowFailure: false
});
......
......@@ -260,7 +260,7 @@ library SafeTestLib {
instance,
address(instance.safe),
0,
abi.encodeWithSelector(ModuleManager.enableModule.selector, module),
abi.encodeCall(ModuleManager.enableModule, (module)),
Enum.Operation.Call,
0,
0,
......@@ -289,7 +289,7 @@ library SafeTestLib {
instance,
address(instance.safe),
0,
abi.encodeWithSelector(ModuleManager.disableModule.selector, prevModule, module),
abi.encodeCall(ModuleManager.disableModule, (prevModule, module)),
Enum.Operation.Call,
0,
0,
......@@ -308,7 +308,7 @@ library SafeTestLib {
instance,
address(instance.safe),
0,
abi.encodeWithSelector(GuardManager.setGuard.selector, guard),
abi.encodeCall(GuardManager.setGuard, (guard)),
Enum.Operation.Call,
0,
0,
......@@ -326,7 +326,7 @@ library SafeTestLib {
instance: instance,
to: signMessageLib,
value: 0,
data: abi.encodeWithSelector(SignMessageLib.signMessage.selector, data),
data: abi.encodeCall(SignMessageLib.signMessage, (data)),
operation: Enum.Operation.DelegateCall,
safeTxGas: 0,
baseGas: 0,
......@@ -350,21 +350,13 @@ library SafeTestLib {
/// @dev Adds a new owner to the safe
function changeThreshold(SafeInstance memory instance, uint256 threshold) internal {
execTransaction(
instance,
address(instance.safe),
0,
abi.encodeWithSelector(OwnerManager.changeThreshold.selector, threshold)
);
execTransaction(instance, address(instance.safe), 0, abi.encodeCall(OwnerManager.changeThreshold, (threshold)));
}
/// @dev Adds a new owner to the safe
function addOwnerWithThreshold(SafeInstance memory instance, address owner, uint256 threshold) internal {
execTransaction(
instance,
address(instance.safe),
0,
abi.encodeWithSelector(OwnerManager.addOwnerWithThreshold.selector, owner, threshold)
instance, address(instance.safe), 0, abi.encodeCall(OwnerManager.addOwnerWithThreshold, (owner, threshold))
);
}
......@@ -373,10 +365,7 @@ library SafeTestLib {
function removeOwner(SafeInstance memory instance, address prevOwner, address owner, uint256 threshold) internal {
prevOwner = prevOwner > address(0) ? prevOwner : SafeTestLib.getPrevOwner(instance, owner);
execTransaction(
instance,
address(instance.safe),
0,
abi.encodeWithSelector(OwnerManager.removeOwner.selector, prevOwner, owner, threshold)
instance, address(instance.safe), 0, abi.encodeCall(OwnerManager.removeOwner, (prevOwner, owner, threshold))
);
}
......@@ -385,10 +374,7 @@ library SafeTestLib {
function swapOwner(SafeInstance memory instance, address prevOwner, address oldOwner, address newOwner) internal {
prevOwner = prevOwner > address(0) ? prevOwner : SafeTestLib.getPrevOwner(instance, oldOwner);
execTransaction(
instance,
address(instance.safe),
0,
abi.encodeWithSelector(OwnerManager.swapOwner.selector, prevOwner, oldOwner, newOwner)
instance, address(instance.safe), 0, abi.encodeCall(OwnerManager.swapOwner, (prevOwner, oldOwner, newOwner))
);
}
......@@ -537,8 +523,9 @@ contract SafeTestTools {
bytes memory initData = advancedParams.initData.length > 0
? advancedParams.initData
: abi.encodeWithSelector(
GnosisSafe.setup.selector,
: abi.encodeCall(
GnosisSafe.setup,
(
owners,
threshold,
advancedParams.setupModulesCall_to,
......@@ -547,6 +534,7 @@ contract SafeTestTools {
advancedParams.refundToken,
advancedParams.refundAmount,
advancedParams.refundReceiver
)
);
DeployedSafe safe0 = DeployedSafe(
......
......@@ -100,7 +100,7 @@ contract DeputyGuardianModule_Pause_TestFail is DeputyGuardianModule_TestInit {
function test_pause_targetReverts_reverts() external {
vm.mockCallRevert(
address(superchainConfig),
abi.encodeWithSelector(superchainConfig.pause.selector),
abi.encodePacked(superchainConfig.pause.selector),
"SuperchainConfig: pause() reverted"
);
......@@ -150,7 +150,7 @@ contract DeputyGuardianModule_Unpause_TestFail is DeputyGuardianModule_Unpause_T
function test_unpause_targetReverts_reverts() external {
vm.mockCallRevert(
address(superchainConfig),
abi.encodeWithSelector(superchainConfig.unpause.selector),
abi.encodePacked(superchainConfig.unpause.selector),
"SuperchainConfig: unpause reverted"
);
......@@ -170,9 +170,7 @@ contract DeputyGuardianModule_SetAnchorState_TestFail is DeputyGuardianModule_Te
function test_setAnchorState_targetReverts_reverts() external {
IAnchorStateRegistry asr = IAnchorStateRegistry(makeAddr("asr"));
vm.mockCallRevert(
address(asr),
abi.encodeWithSelector(asr.setAnchorState.selector),
"AnchorStateRegistry: setAnchorState reverted"
address(asr), abi.encodePacked(asr.setAnchorState.selector), "AnchorStateRegistry: setAnchorState reverted"
);
vm.prank(address(deputyGuardian));
vm.expectRevert(
......@@ -186,9 +184,7 @@ contract DeputyGuardianModule_SetAnchorState_Test is DeputyGuardianModule_TestIn
function test_setAnchorState_succeeds() external {
IAnchorStateRegistry asr = IAnchorStateRegistry(makeAddr("asr"));
vm.mockCall(
address(asr),
abi.encodeWithSelector(IAnchorStateRegistry.setAnchorState.selector, IFaultDisputeGame(address(0))),
""
address(asr), abi.encodeCall(IAnchorStateRegistry.setAnchorState, (IFaultDisputeGame(address(0)))), ""
);
vm.expectEmit(address(safeInstance.safe));
emit ExecutionFromModuleSuccess(address(deputyGuardianModule));
......@@ -228,7 +224,7 @@ contract DeputyGuardianModule_BlacklistDisputeGame_TestFail is DeputyGuardianMod
function test_blacklistDisputeGame_targetReverts_reverts() external {
vm.mockCallRevert(
address(optimismPortal2),
abi.encodeWithSelector(optimismPortal2.blacklistDisputeGame.selector),
abi.encodePacked(optimismPortal2.blacklistDisputeGame.selector),
"OptimismPortal2: blacklistDisputeGame reverted"
);
......@@ -271,7 +267,7 @@ contract DeputyGuardianModule_setRespectedGameType_TestFail is DeputyGuardianMod
function test_setRespectedGameType_targetReverts_reverts() external {
vm.mockCallRevert(
address(optimismPortal2),
abi.encodeWithSelector(optimismPortal2.setRespectedGameType.selector),
abi.encodePacked(optimismPortal2.setRespectedGameType.selector),
"OptimismPortal2: setRespectedGameType reverted"
);
......
......@@ -110,7 +110,7 @@ contract LivenessGuard_CheckTx_Test is LivenessGuard_TestInit {
vm.expectEmit(address(livenessGuard));
emit OwnerRecorded(signers[i]);
}
vm.expectCall(address(safeInstance.safe), abi.encodeWithSignature("nonce()"));
vm.expectCall(address(safeInstance.safe), abi.encodeCall(safeInstance.safe.nonce, ()));
vm.expectCall(address(safeInstance.safe), abi.encodeCall(OwnerManager.getThreshold, ()));
safeInstance.execTransaction({ to: address(1111), value: 0, data: hex"abba" });
for (uint256 i; i < safeInstance.threshold; i++) {
......@@ -228,6 +228,7 @@ contract LivenessGuard_FuzzOwnerManagement_Test is StdCheats, StdUtils, Liveness
mapping(address => uint256) privateKeys;
/// @dev Tests that the guard correctly manages the lastLive mapping when owners are added, removed, or swapped
/// forge-config: ciheavy.fuzz.runs = 8192
function testFuzz_OwnerManagement_works(
uint256 initialOwners,
uint256 threshold,
......
......@@ -75,6 +75,7 @@ contract SafeSigners_Test is Test, SafeTestTools {
contractSigs++;
address addr = SafeTestLib.decodeSmartContractWalletAsAddress(pks[i]);
r = bytes32(uint256(uint160(addr)));
// nosemgrep: sol-style-use-abi-encodecall
vm.mockCall(
addr, abi.encodeWithSignature("isValidSignature(bytes,bytes)"), abi.encode(EIP1271_MAGIC_VALUE)
);
......
......@@ -187,7 +187,7 @@ contract GasBenchMark_L1StandardBridge_Finalize is Bridge_Initializer {
deal(address(L1Token), address(l1StandardBridge), 100, true);
vm.mockCall(
address(l1StandardBridge.messenger()),
abi.encodeWithSelector(ICrossDomainMessenger.xDomainMessageSender.selector),
abi.encodeCall(ICrossDomainMessenger.xDomainMessageSender, ()),
abi.encode(address(l1StandardBridge.OTHER_BRIDGE()))
);
vm.startPrank(address(l1StandardBridge.messenger()));
......@@ -302,7 +302,7 @@ contract GasBenchMark_L1BlockInterop_DepositsComplete is GasBenchMark_L1BlockInt
function test_depositsComplete_benchmark() external {
SafeCall.call({
_target: address(l1BlockInterop),
_calldata: abi.encodeWithSelector(l1BlockInterop.depositsComplete.selector)
_calldata: abi.encodeCall(IL1BlockInterop.depositsComplete, ())
});
}
}
......@@ -317,7 +317,7 @@ contract GasBenchMark_L1BlockInterop_DepositsComplete_Warm is GasBenchMark_L1Blo
function test_depositsComplete_benchmark() external {
SafeCall.call({
_target: address(l1BlockInterop),
_calldata: abi.encodeWithSelector(l1BlockInterop.depositsComplete.selector)
_calldata: abi.encodeCall(l1BlockInterop.depositsComplete, ())
});
}
}
......@@ -99,7 +99,7 @@ contract ExternalRelay is Test {
/// @notice Helper function to get the callData for an `externalCallWithMinGas
function getCallData() public pure returns (bytes memory) {
return abi.encodeWithSelector(ExternalRelay.externalCallWithMinGas.selector);
return abi.encodeCall(ExternalRelay.externalCallWithMinGas, ());
}
/// @notice Helper function to set the fuzzed sender
......
......@@ -42,7 +42,7 @@ contract OptimismMintableTokenFactory_Test is Bridge_Initializer {
vm.startPrank(EIP1967Helper.getAdmin(address(proxy)));
// Reviewer note: the NextImpl() still uses reinitializer. If we want to remove that, we'll need to use a
// two step upgrade with the Storage lib.
proxy.upgradeToAndCall(address(nextImpl), abi.encodeWithSelector(NextImpl.initialize.selector, 2));
proxy.upgradeToAndCall(address(nextImpl), abi.encodeCall(NextImpl.initialize, (2)));
assertEq(proxy.implementation(), address(nextImpl));
// Verify that the NextImpl contract initialized its values according as expected
......
......@@ -160,7 +160,7 @@ contract Proxy_Test is Test {
vm.expectEmit(true, true, true, true);
emit Upgraded(address(simpleStorage));
vm.prank(alice);
proxy.upgradeToAndCall(address(simpleStorage), abi.encodeWithSelector(simpleStorage.set.selector, 1, 1));
proxy.upgradeToAndCall(address(simpleStorage), abi.encodeCall(SimpleStorage.set, (1, 1)));
// The call should have impacted the state
uint256 result = SimpleStorage(address(proxy)).get(1);
......@@ -193,7 +193,7 @@ contract Proxy_Test is Test {
// The attempt to `upgradeToAndCall`
// should revert when it is not called by the owner.
vm.expectRevert(bytes(""));
proxy.upgradeToAndCall(address(simpleStorage), abi.encodeWithSelector(simpleStorage.set.selector, 1, 1));
proxy.upgradeToAndCall(address(simpleStorage), abi.encodeCall(simpleStorage.set, (1, 1)));
}
function test_upgradeToAndCall_isPayable_succeeds() external {
......@@ -202,9 +202,7 @@ contract Proxy_Test is Test {
// Set the implementation and call and send
// value.
vm.prank(alice);
proxy.upgradeToAndCall{ value: 1 ether }(
address(simpleStorage), abi.encodeWithSelector(simpleStorage.set.selector, 1, 1)
);
proxy.upgradeToAndCall{ value: 1 ether }(address(simpleStorage), abi.encodeCall(simpleStorage.set, (1, 1)));
// The implementation address should be correct
vm.prank(alice);
......@@ -265,7 +263,8 @@ contract Proxy_Test is Test {
(bool success, bytes memory returndata) = address(proxy).call(hex"");
assertEq(success, false);
bytes memory err = abi.encodeWithSignature("Error(string)", "Proxy: implementation not initialized");
bytes memory err = abi.encodeWithSignature("Error(string)", "Proxy: implementation not initialized"); // nosemgrep:
// sol-style-use-abi-encodecall
assertEq(returndata, err);
}
......
......@@ -248,7 +248,7 @@ contract ProxyAdmin_Test is Test {
function upgradeAndCall(address payable _proxy) internal {
vm.prank(alice);
admin.upgradeAndCall(_proxy, address(implementation), abi.encodeWithSelector(SimpleStorage.set.selector, 1, 1));
admin.upgradeAndCall(_proxy, address(implementation), abi.encodeCall(SimpleStorage.set, (1, 1)));
address impl = admin.getProxyImplementation(_proxy);
assertEq(impl, address(implementation));
......
......@@ -54,7 +54,8 @@ rules:
version\(\) public pure virtual returns \(string memory\)
\{\s+return
"(?P<VERSION2>[0-9]+\.[0-9]+\.[0-9]+(?:-[a-zA-Z0-9.]+)?)";
- pattern-regex: /// @custom:semver (?P<VERSION1>[a-zA-Z0-9.+-]+)\s+function
- pattern-regex:
/// @custom:semver (?P<VERSION1>[a-zA-Z0-9.+-]+)\s+function
version\(\) public pure override returns \(string memory\)
\{\s+return string\.concat\(super\.version\(\),
"(?P<VERSION2>[a-zA-Z0-9.+-]+)"\);
......@@ -152,11 +153,14 @@ rules:
severity: ERROR
message: Use abi.encodeCall instead of abi.encodeWithSelector
patterns:
- pattern-either:
- pattern: |
abi.encodeWithSelector(...);
- pattern: |
abi.encodeWithSignature(...);
- pattern-not: vm.expectRevert(abi.encodeWithSelector(...));
paths:
exclude:
- packages/contracts-bedrock/test
- packages/contracts-bedrock/src/L1/OPContractsManager.sol
- packages/contracts-bedrock/src/L1/OPContractsManagerInterop.sol
- packages/contracts-bedrock/src/legacy/L1ChugSplashProxy.sol
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment