Commit a0eee5cc authored by Disco's avatar Disco Committed by GitHub

chore: solidity isthmus to interop (#12132)

* chore: rename isthmus to interop on solidity files

* chore: rename test file

* chore: update contracts versions (#66)
parent 3210a8c6
GasBenchMark_L1BlockIsthmus_DepositsComplete:test_depositsComplete_benchmark() (gas: 7567)
GasBenchMark_L1BlockIsthmus_DepositsComplete_Warm:test_depositsComplete_benchmark() (gas: 5567)
GasBenchMark_L1BlockIsthmus_SetValuesIsthmus:test_setL1BlockValuesIsthmus_benchmark() (gas: 175657)
GasBenchMark_L1BlockIsthmus_SetValuesIsthmus_Warm:test_setL1BlockValuesIsthmus_benchmark() (gas: 5121)
GasBenchMark_L1BlockInterop_DepositsComplete:test_depositsComplete_benchmark() (gas: 7567)
GasBenchMark_L1BlockInterop_DepositsComplete_Warm:test_depositsComplete_benchmark() (gas: 5567)
GasBenchMark_L1BlockInterop_SetValuesInterop:test_setL1BlockValuesInterop_benchmark() (gas: 175677)
GasBenchMark_L1BlockInterop_SetValuesInterop_Warm:test_setL1BlockValuesInterop_benchmark() (gas: 5099)
GasBenchMark_L1Block_SetValuesEcotone:test_setL1BlockValuesEcotone_benchmark() (gas: 158531)
GasBenchMark_L1Block_SetValuesEcotone_Warm:test_setL1BlockValuesEcotone_benchmark() (gas: 7597)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369242)
......
......@@ -384,7 +384,7 @@ contract L2Genesis is Deployer {
/// @notice This predeploy is following the safety invariant #1.
function setL1Block() public {
if (cfg.useInterop()) {
string memory cname = "L1BlockIsthmus";
string memory cname = "L1BlockInterop";
address impl = Predeploys.predeployToCodeNamespace(Predeploys.L1_BLOCK_ATTRIBUTES);
console.log("Setting %s implementation at: %s", cname, impl);
vm.etch(impl, vm.getDeployedCode(string.concat(cname, ".sol:", cname)));
......
......@@ -44,8 +44,8 @@
"sourceCodeHash": "0x3fb97859f66c078573753b6ba5ec370449ab03b8eca9e7779fce8db5bb23b7c0"
},
"src/L1/OptimismPortalInterop.sol": {
"initCodeHash": "0x1c8372865dbf38225de4d843ca696a17f0d9e3cacf13c10a3d065ba19bdca05e",
"sourceCodeHash": "0xe6a7794799915f408cb57c73af266670de8a3f02408d3dbc2c97db25d3e42635"
"initCodeHash": "0xfeaa67ccd652bda9103fea507e4357b2bd4e93210b03ff85eb357d7145f1606c",
"sourceCodeHash": "0x6401b81f04093863557ef46192f56793daa0d412618065383ab353b2ed2929d8"
},
"src/L1/ProtocolVersions.sol": {
"initCodeHash": "0x8f033874dd8b36615b2209d553660dcff1ff91ca2bad3ca1de7b441dbfba4842",
......@@ -60,16 +60,16 @@
"sourceCodeHash": "0x06a50ac992175fdb434b13e8461893e83862c23ce399e697e6e8109728ad1a3d"
},
"src/L1/SystemConfigInterop.sol": {
"initCodeHash": "0x1f500e310170769ffc747e08ad1d5b0de4b0f58534001bc4d4d563ec058bb331",
"sourceCodeHash": "0xcb6008cb49a06f87eb5b6cb4651e5e4aafe0b1f33000eccd165226c04f6b63c6"
"initCodeHash": "0x7515e5ed1266412a8c2d27d99aba6266fda2fc9068c20f0b7e6b555ee5073c91",
"sourceCodeHash": "0x441d1e3e8e987f829f55996b5b6c850da8c59ad48f09cf7e0a69a1fa559d42a2"
},
"src/L2/BaseFeeVault.sol": {
"initCodeHash": "0x3bfcd57e25ad54b66c374f63e24e33a6cf107044aa8f5f69ef21202c380b5c5b",
"sourceCodeHash": "0x2dc2284cf7c68e743da50e4113e96ffeab435de2390aeba2eab2f1e8ca411ce9"
},
"src/L2/CrossL2Inbox.sol": {
"initCodeHash": "0x0ee27866b4bf864a0b68ab25ea9559d7f2722b0396d02f2e8e089c6a1a5a6a93",
"sourceCodeHash": "0xe6f453049035e0d77e4d7a92904b448bc17e04dd3d99e738b9af20e20986ce64"
"initCodeHash": "0x66b052adce7e9194d054952d67d08b53964120067600358243ec86c85b90877b",
"sourceCodeHash": "0x38e6127ec6be99eb8c38c2c9d6e82761b33dde446bba250dc2c1b84983449e4e"
},
"src/L2/ETHLiquidity.sol": {
"initCodeHash": "0x713c18f95a6a746d0703f475f3ae10c106c9b9ecb64d881a2e61b8969b581371",
......@@ -83,9 +83,9 @@
"initCodeHash": "0xd12353c5bf71c6765cc9292eecf262f216e67f117f4ba6287796a5207dbca00f",
"sourceCodeHash": "0xfe3a9585d9bfca8428e12759cab68a3114374e5c37371cfe08bb1976a9a5a041"
},
"src/L2/L1BlockIsthmus.sol": {
"initCodeHash": "0xb7a7a113056e4ac44824350b79fed5ea423e880223edcf1220e8f8b3172f50c5",
"sourceCodeHash": "0x6be7e7402c4dfc10e1407e070712a3f9f352db45f8a8ab296e8f6bc56a341f47"
"src/L2/L1BlockInterop.sol": {
"initCodeHash": "0x77b3b2151fe14ea36a640469115a5e4de27f7654a9606a9d0701522c6a4ad887",
"sourceCodeHash": "0x7417677643e1df1ae1782513b94c7821097b9529d3f8626c3bcb8b3a9ae0d180"
},
"src/L2/L1FeeVault.sol": {
"initCodeHash": "0x3bfcd57e25ad54b66c374f63e24e33a6cf107044aa8f5f69ef21202c380b5c5b",
......
......@@ -354,7 +354,7 @@
},
{
"inputs": [],
"name": "setL1BlockValuesIsthmus",
"name": "setL1BlockValuesInterop",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
......
......@@ -3,7 +3,7 @@ pragma solidity 0.8.15;
// Contracts
import { OptimismPortal2 } from "src/L1/OptimismPortal2.sol";
import { L1BlockIsthmus, ConfigType } from "src/L2/L1BlockIsthmus.sol";
import { L1BlockInterop, ConfigType } from "src/L2/L1BlockInterop.sol";
// Libraries
import { Predeploys } from "src/libraries/Predeploys.sol";
......@@ -23,9 +23,9 @@ contract OptimismPortalInterop is OptimismPortal2 {
OptimismPortal2(_proofMaturityDelaySeconds, _disputeGameFinalityDelaySeconds)
{ }
/// @custom:semver +interop
/// @custom:semver +interop-beta.1
function version() public pure override returns (string memory) {
return string.concat(super.version(), "+interop");
return string.concat(super.version(), "+interop-beta.1");
}
/// @notice Sets static configuration options for the L2 system.
......@@ -48,7 +48,7 @@ contract OptimismPortalInterop is OptimismPortal2 {
uint256(0), // value
uint64(SYSTEM_DEPOSIT_GAS_LIMIT), // gasLimit
false, // isCreation,
abi.encodeCall(L1BlockIsthmus.setConfig, (_type, _value))
abi.encodeCall(L1BlockInterop.setConfig, (_type, _value))
)
);
}
......
......@@ -5,7 +5,7 @@ pragma solidity 0.8.15;
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { IOptimismPortalInterop as IOptimismPortal } from "src/L1/interfaces/IOptimismPortalInterop.sol";
import { SystemConfig } from "src/L1/SystemConfig.sol";
import { ConfigType } from "src/L2/L1BlockIsthmus.sol";
import { ConfigType } from "src/L2/L1BlockInterop.sol";
// Libraries
import { Constants } from "src/libraries/Constants.sol";
......@@ -68,9 +68,9 @@ contract SystemConfigInterop is SystemConfig {
Storage.setAddress(DEPENDENCY_MANAGER_SLOT, _dependencyManager);
}
/// @custom:semver +interop
/// @custom:semver +interop-beta.1
function version() public pure override returns (string memory) {
return string.concat(super.version(), "+interop");
return string.concat(super.version(), "+interop-beta.1");
}
/// @notice Internal setter for the gas paying token address, includes validation.
......
......@@ -7,7 +7,7 @@ import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol";
import { IDisputeGameFactory } from "src/dispute/interfaces/IDisputeGameFactory.sol";
import { ISystemConfig } from "src/L1/interfaces/ISystemConfig.sol";
import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol";
import { ConfigType } from "src/L2/L1BlockIsthmus.sol";
import { ConfigType } from "src/L2/L1BlockInterop.sol";
interface IOptimismPortalInterop {
error AlreadyFinalized();
......
......@@ -7,7 +7,7 @@ import { ISemver } from "src/universal/interfaces/ISemver.sol";
import { ICrossL2Inbox } from "src/L2/interfaces/ICrossL2Inbox.sol";
import { SafeCall } from "src/libraries/SafeCall.sol";
import { IDependencySet } from "src/L2/interfaces/IDependencySet.sol";
import { IL1BlockIsthmus } from "src/L2/interfaces/IL1BlockIsthmus.sol";
import { IL1BlockInterop } from "src/L2/interfaces/IL1BlockInterop.sol";
/// @notice Thrown when the caller is not DEPOSITOR_ACCOUNT when calling `setInteropStart()`
error NotDepositor();
......@@ -65,8 +65,8 @@ contract CrossL2Inbox is ICrossL2Inbox, ISemver, TransientReentrancyAware {
address internal constant DEPOSITOR_ACCOUNT = 0xDeaDDEaDDeAdDeAdDEAdDEaddeAddEAdDEAd0001;
/// @notice Semantic version.
/// @custom:semver 1.0.0-beta.7
string public constant version = "1.0.0-beta.7";
/// @custom:semver 1.0.0-beta.8
string public constant version = "1.0.0-beta.8";
/// @notice Emitted when a cross chain message is being executed.
/// @param msgHash Hash of message payload being executed.
......@@ -140,7 +140,7 @@ contract CrossL2Inbox is ICrossL2Inbox, ISemver, TransientReentrancyAware {
reentrantAware
{
// We need to know if this is being called on a depositTx
if (IL1BlockIsthmus(Predeploys.L1_BLOCK_ATTRIBUTES).isDeposit()) revert NoExecutingDeposits();
if (IL1BlockInterop(Predeploys.L1_BLOCK_ATTRIBUTES).isDeposit()) revert NoExecutingDeposits();
// Check the Identifier.
_checkIdentifier(_id);
......@@ -165,7 +165,7 @@ contract CrossL2Inbox is ICrossL2Inbox, ISemver, TransientReentrancyAware {
/// @param _msgHash Hash of the message payload to call target with.
function validateMessage(Identifier calldata _id, bytes32 _msgHash) external {
// We need to know if this is being called on a depositTx
if (IL1BlockIsthmus(Predeploys.L1_BLOCK_ATTRIBUTES).isDeposit()) revert NoExecutingDeposits();
if (IL1BlockInterop(Predeploys.L1_BLOCK_ATTRIBUTES).isDeposit()) revert NoExecutingDeposits();
// Check the Identifier.
_checkIdentifier(_id);
......
......@@ -11,7 +11,7 @@ import { StaticConfig } from "src/libraries/StaticConfig.sol";
import { Predeploys } from "src/libraries/Predeploys.sol";
import "src/libraries/L1BlockErrors.sol";
/// @notice Enum representing different types of configurations that can be set on L1BlockIsthmus.
/// @notice Enum representing different types of configurations that can be set on L1BlockInterop.
/// @custom:value SET_GAS_PAYING_TOKEN Represents the config type for setting the gas paying token.
/// @custom:value ADD_DEPENDENCY Represents the config type for adding a chain to the interop dependency set.
/// @custom:value REMOVE_DEPENDENCY Represents the config type for removing a chain from the interop dependency set.
......@@ -23,9 +23,9 @@ enum ConfigType {
/// @custom:proxied true
/// @custom:predeploy 0x4200000000000000000000000000000000000015
/// @title L1BlockIsthmus
/// @notice Isthmus extenstions of L1Block.
contract L1BlockIsthmus is L1Block {
/// @title L1BlockInterop
/// @notice Interop extenstions of L1Block.
contract L1BlockInterop is L1Block {
using EnumerableSet for EnumerableSet.UintSet;
/// @notice Event emitted when a new dependency is added to the interop dependency set.
......@@ -42,9 +42,9 @@ contract L1BlockIsthmus is L1Block {
/// keccak256(abi.encode(uint256(keccak256("l1Block.identifier.isDeposit")) - 1)) & ~bytes32(uint256(0xff))
uint256 internal constant IS_DEPOSIT_SLOT = 0x921bd3a089295c6e5540e8fba8195448d253efd6f2e3e495b499b627dc36a300;
/// @custom:semver +isthmus
/// @custom:semver +interop
function version() public pure override returns (string memory) {
return string.concat(super.version(), "+isthmus");
return string.concat(super.version(), "+interop");
}
/// @notice Returns whether the call was triggered from a a deposit or not.
......@@ -70,10 +70,10 @@ contract L1BlockIsthmus is L1Block {
return uint8(dependencySet.length());
}
/// @notice Updates the `isDeposit` flag and sets the L1 block values for an Isthmus upgraded chain.
/// @notice Updates the `isDeposit` flag and sets the L1 block values for an Interop upgraded chain.
/// It updates the L1 block values through the `setL1BlockValuesEcotone` function.
/// It forwards the calldata to the internally-used `setL1BlockValuesEcotone` function.
function setL1BlockValuesIsthmus() external {
function setL1BlockValuesInterop() external {
// Set the isDeposit flag to true.
assembly {
sstore(IS_DEPOSIT_SLOT, 1)
......
......@@ -7,7 +7,7 @@ enum ConfigType {
REMOVE_DEPENDENCY
}
interface IL1BlockIsthmus {
interface IL1BlockInterop {
error AlreadyDependency();
error CantRemovedDependency();
error DependencySetSizeTooLarge();
......@@ -52,7 +52,7 @@ interface IL1BlockIsthmus {
)
external;
function setL1BlockValuesEcotone() external;
function setL1BlockValuesIsthmus() external;
function setL1BlockValuesInterop() external;
function timestamp() external view returns (uint64);
function version() external pure returns (string memory);
......
......@@ -184,7 +184,7 @@ library Encoding {
/// @param _blobBaseFee L1 blob base fee.
/// @param _hash L1 blockhash.
/// @param _batcherHash Versioned hash to authenticate batcher by.
function encodeSetL1BlockValuesIsthmus(
function encodeSetL1BlockValuesInterop(
uint32 _baseFeeScalar,
uint32 _blobBaseFeeScalar,
uint64 _sequenceNumber,
......@@ -199,7 +199,7 @@ library Encoding {
pure
returns (bytes memory)
{
bytes4 functionSignature = bytes4(keccak256("setL1BlockValuesIsthmus()"));
bytes4 functionSignature = bytes4(keccak256("setL1BlockValuesInterop()"));
return abi.encodePacked(
functionSignature,
_baseFeeScalar,
......
......@@ -10,7 +10,7 @@ import { Bridge_Initializer } from "test/setup/Bridge_Initializer.sol";
// Libraries
import { Types } from "src/libraries/Types.sol";
import { SafeCall } from "src/libraries/SafeCall.sol";
import { L1BlockIsthmus } from "src/L2/L1BlockIsthmus.sol";
import { L1BlockInterop } from "src/L2/L1BlockInterop.sol";
import { Encoding } from "src/libraries/Encoding.sol";
// Interfaces
......@@ -254,13 +254,13 @@ contract GasBenchMark_L1Block_SetValuesEcotone_Warm is GasBenchMark_L1Block {
}
}
contract GasBenchMark_L1BlockIsthmus is GasBenchMark_L1Block {
L1BlockIsthmus l1BlockIsthmus;
contract GasBenchMark_L1BlockInterop is GasBenchMark_L1Block {
L1BlockInterop l1BlockInterop;
function setUp() public virtual override {
super.setUp();
l1BlockIsthmus = new L1BlockIsthmus();
setValuesCalldata = Encoding.encodeSetL1BlockValuesIsthmus(
l1BlockInterop = new L1BlockInterop();
setValuesCalldata = Encoding.encodeSetL1BlockValuesInterop(
type(uint32).max,
type(uint32).max,
type(uint64).max,
......@@ -274,42 +274,42 @@ contract GasBenchMark_L1BlockIsthmus is GasBenchMark_L1Block {
}
}
contract GasBenchMark_L1BlockIsthmus_SetValuesIsthmus is GasBenchMark_L1BlockIsthmus {
function test_setL1BlockValuesIsthmus_benchmark() external {
SafeCall.call({ _target: address(l1BlockIsthmus), _calldata: setValuesCalldata });
contract GasBenchMark_L1BlockInterop_SetValuesInterop is GasBenchMark_L1BlockInterop {
function test_setL1BlockValuesInterop_benchmark() external {
SafeCall.call({ _target: address(l1BlockInterop), _calldata: setValuesCalldata });
}
}
contract GasBenchMark_L1BlockIsthmus_SetValuesIsthmus_Warm is GasBenchMark_L1BlockIsthmus {
contract GasBenchMark_L1BlockInterop_SetValuesInterop_Warm is GasBenchMark_L1BlockInterop {
function setUp() public virtual override {
SafeCall.call({ _target: address(l1BlockIsthmus), _calldata: setValuesCalldata });
SafeCall.call({ _target: address(l1BlockInterop), _calldata: setValuesCalldata });
}
function test_setL1BlockValuesIsthmus_benchmark() external {
SafeCall.call({ _target: address(l1BlockIsthmus), _calldata: setValuesCalldata });
function test_setL1BlockValuesInterop_benchmark() external {
SafeCall.call({ _target: address(l1BlockInterop), _calldata: setValuesCalldata });
}
}
contract GasBenchMark_L1BlockIsthmus_DepositsComplete is GasBenchMark_L1BlockIsthmus {
contract GasBenchMark_L1BlockInterop_DepositsComplete is GasBenchMark_L1BlockInterop {
function test_depositsComplete_benchmark() external {
SafeCall.call({
_target: address(l1BlockIsthmus),
_calldata: abi.encodeWithSelector(l1BlockIsthmus.depositsComplete.selector)
_target: address(l1BlockInterop),
_calldata: abi.encodeWithSelector(l1BlockInterop.depositsComplete.selector)
});
}
}
contract GasBenchMark_L1BlockIsthmus_DepositsComplete_Warm is GasBenchMark_L1BlockIsthmus {
contract GasBenchMark_L1BlockInterop_DepositsComplete_Warm is GasBenchMark_L1BlockInterop {
function setUp() public virtual override {
super.setUp();
// Set the isDeposit flag to true so then we can benchmark when it is reset.
SafeCall.call({ _target: address(l1BlockIsthmus), _calldata: setValuesCalldata });
SafeCall.call({ _target: address(l1BlockInterop), _calldata: setValuesCalldata });
}
function test_depositsComplete_benchmark() external {
SafeCall.call({
_target: address(l1BlockIsthmus),
_calldata: abi.encodeWithSelector(l1BlockIsthmus.depositsComplete.selector)
_target: address(l1BlockInterop),
_calldata: abi.encodeWithSelector(l1BlockInterop.depositsComplete.selector)
});
}
}
......@@ -12,7 +12,7 @@ import "src/libraries/PortalErrors.sol";
// Target contract dependencies
import "src/libraries/PortalErrors.sol";
import { OptimismPortalInterop } from "src/L1/OptimismPortalInterop.sol";
import { L1BlockIsthmus, ConfigType } from "src/L2/L1BlockIsthmus.sol";
import { L1BlockInterop, ConfigType } from "src/L2/L1BlockInterop.sol";
// Interfaces
import { IOptimismPortalInterop } from "src/L1/interfaces/IOptimismPortalInterop.sol";
......@@ -35,7 +35,7 @@ contract OptimismPortalInterop_Test is CommonTest {
_mint: 0,
_gasLimit: 200_000,
_isCreation: false,
_data: abi.encodeCall(L1BlockIsthmus.setConfig, (ConfigType.SET_GAS_PAYING_TOKEN, _value))
_data: abi.encodeCall(L1BlockInterop.setConfig, (ConfigType.SET_GAS_PAYING_TOKEN, _value))
});
vm.prank(address(_optimismPortalInterop().systemConfig()));
......@@ -58,7 +58,7 @@ contract OptimismPortalInterop_Test is CommonTest {
_mint: 0,
_gasLimit: 200_000,
_isCreation: false,
_data: abi.encodeCall(L1BlockIsthmus.setConfig, (ConfigType.ADD_DEPENDENCY, _value))
_data: abi.encodeCall(L1BlockInterop.setConfig, (ConfigType.ADD_DEPENDENCY, _value))
});
vm.prank(address(_optimismPortalInterop().systemConfig()));
......@@ -81,7 +81,7 @@ contract OptimismPortalInterop_Test is CommonTest {
_mint: 0,
_gasLimit: 200_000,
_isCreation: false,
_data: abi.encodeCall(L1BlockIsthmus.setConfig, (ConfigType.REMOVE_DEPENDENCY, _value))
_data: abi.encodeCall(L1BlockInterop.setConfig, (ConfigType.REMOVE_DEPENDENCY, _value))
});
vm.prank(address(_optimismPortalInterop().systemConfig()));
......
......@@ -6,7 +6,7 @@ import { CommonTest } from "test/setup/CommonTest.sol";
// Contracts
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { ConfigType } from "src/L2/L1BlockIsthmus.sol";
import { ConfigType } from "src/L2/L1BlockInterop.sol";
// Libraries
import { Constants } from "src/libraries/Constants.sol";
......
......@@ -19,7 +19,7 @@ import {
NotDepositor,
InteropStartAlreadySet
} from "src/L2/CrossL2Inbox.sol";
import { IL1BlockIsthmus } from "src/L2/interfaces/IL1BlockIsthmus.sol";
import { IL1BlockInterop } from "src/L2/interfaces/IL1BlockInterop.sol";
import { ICrossL2Inbox } from "src/L2/interfaces/ICrossL2Inbox.sol";
/// @title CrossL2InboxWithModifiableTransientStorage
......@@ -160,7 +160,7 @@ contract CrossL2InboxTest is Test {
// Ensure is not a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockIsthmus.isDeposit.selector),
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
returnData: abi.encode(false)
});
......@@ -222,7 +222,7 @@ contract CrossL2InboxTest is Test {
// Ensure is not a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockIsthmus.isDeposit.selector),
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
returnData: abi.encode(false)
});
......@@ -282,7 +282,7 @@ contract CrossL2InboxTest is Test {
// Ensure it is a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockIsthmus.isDeposit.selector),
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
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(IL1BlockIsthmus.isDeposit.selector),
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
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(IL1BlockIsthmus.isDeposit.selector),
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
returnData: abi.encode(false)
});
......@@ -375,7 +375,7 @@ contract CrossL2InboxTest is Test {
// Ensure is not a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockIsthmus.isDeposit.selector),
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
returnData: abi.encode(false)
});
......@@ -419,7 +419,7 @@ contract CrossL2InboxTest is Test {
// Ensure is not a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockIsthmus.isDeposit.selector),
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
returnData: abi.encode(false)
});
......@@ -464,7 +464,7 @@ contract CrossL2InboxTest is Test {
// Ensure is not a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockIsthmus.isDeposit.selector),
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
returnData: abi.encode(false)
});
......@@ -485,7 +485,7 @@ contract CrossL2InboxTest is Test {
// Ensure it is a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockIsthmus.isDeposit.selector),
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
returnData: abi.encode(true)
});
......@@ -508,7 +508,7 @@ contract CrossL2InboxTest is Test {
// Ensure is not a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockIsthmus.isDeposit.selector),
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
returnData: abi.encode(false)
});
......@@ -537,7 +537,7 @@ contract CrossL2InboxTest is Test {
// Ensure is not a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockIsthmus.isDeposit.selector),
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
returnData: abi.encode(false)
});
......@@ -571,7 +571,7 @@ contract CrossL2InboxTest is Test {
// Ensure is not a deposit transaction
vm.mockCall({
callee: Predeploys.L1_BLOCK_ATTRIBUTES,
data: abi.encodeWithSelector(IL1BlockIsthmus.isDeposit.selector),
data: abi.encodeWithSelector(IL1BlockInterop.isDeposit.selector),
returnData: abi.encode(false)
});
......
......@@ -8,17 +8,17 @@ import { CommonTest } from "test/setup/CommonTest.sol";
import { StaticConfig } from "src/libraries/StaticConfig.sol";
// Target contract dependencies
import { L1BlockIsthmus, ConfigType } from "src/L2/L1BlockIsthmus.sol";
import { L1BlockInterop, ConfigType } from "src/L2/L1BlockInterop.sol";
import { Predeploys } from "src/libraries/Predeploys.sol";
import "src/libraries/L1BlockErrors.sol";
contract L1BlockIsthmusTest is CommonTest {
contract L1BlockInteropTest is CommonTest {
event GasPayingTokenSet(address indexed token, uint8 indexed decimals, bytes32 name, bytes32 symbol);
event DependencyAdded(uint256 indexed chainId);
event DependencyRemoved(uint256 indexed chainId);
modifier prankDepositor() {
vm.startPrank(_l1BlockIsthmus().DEPOSITOR_ACCOUNT());
vm.startPrank(_l1BlockInterop().DEPOSITOR_ACCOUNT());
_;
vm.stopPrank();
}
......@@ -34,14 +34,14 @@ contract L1BlockIsthmusTest is CommonTest {
function testFuzz_isInDependencySet_succeeds(uint256 _chainId) public prankDepositor {
vm.assume(_chainId != block.chainid);
_l1BlockIsthmus().setConfig(ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(_chainId));
_l1BlockInterop().setConfig(ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(_chainId));
assertTrue(_l1BlockIsthmus().isInDependencySet(_chainId));
assertTrue(_l1BlockInterop().isInDependencySet(_chainId));
}
/// @dev Tests that `isInDependencySet` returns true when the chain's chain ID is passed as the input.
function test_isInDependencySet_chainChainId_succeeds() public view {
assertTrue(_l1BlockIsthmus().isInDependencySet(block.chainid));
assertTrue(_l1BlockInterop().isInDependencySet(block.chainid));
}
/// @dev Tests that `isInDependencySet` reverts when the input chain ID is not in the dependency set
......@@ -50,16 +50,16 @@ contract L1BlockIsthmusTest is CommonTest {
vm.assume(_chainId != block.chainid);
// Check that the chain ID is not in the dependency set
assertFalse(_l1BlockIsthmus().isInDependencySet(_chainId));
assertFalse(_l1BlockInterop().isInDependencySet(_chainId));
}
/// @dev Tests that `isInDependencySet` returns false when the dependency set is empty.
function testFuzz_isInDependencySet_dependencySetEmpty_succeeds(uint256 _chainId) public view {
vm.assume(_chainId != block.chainid);
assertEq(_l1BlockIsthmus().dependencySetSize(), 0);
assertEq(_l1BlockInterop().dependencySetSize(), 0);
assertFalse(_l1BlockIsthmus().isInDependencySet(_chainId));
assertFalse(_l1BlockInterop().isInDependencySet(_chainId));
}
/// @dev Tests that the dependency set size is correct when adding an arbitrary number of chain IDs.
......@@ -70,16 +70,16 @@ contract L1BlockIsthmusTest is CommonTest {
for (uint256 i = 0; i < _dependencySetSize; i++) {
if (i == block.chainid) continue;
_l1BlockIsthmus().setConfig(ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(i));
_l1BlockInterop().setConfig(ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(i));
uniqueCount++;
}
assertEq(_l1BlockIsthmus().dependencySetSize(), uniqueCount);
assertEq(_l1BlockInterop().dependencySetSize(), uniqueCount);
}
/// @dev Tests that the dependency set size is correct when the dependency set is empty.
function test_dependencySetSize_dependencySetEmpty_succeeds() public view {
assertEq(_l1BlockIsthmus().dependencySetSize(), 0);
assertEq(_l1BlockInterop().dependencySetSize(), 0);
}
/// @dev Tests that the config for setting the gas paying token succeeds.
......@@ -97,7 +97,7 @@ contract L1BlockIsthmusTest is CommonTest {
vm.expectEmit(address(l1Block));
emit GasPayingTokenSet({ token: _token, decimals: _decimals, name: _name, symbol: _symbol });
_l1BlockIsthmus().setConfig(
_l1BlockInterop().setConfig(
ConfigType.SET_GAS_PAYING_TOKEN,
StaticConfig.encodeSetGasPayingToken({ _token: _token, _decimals: _decimals, _name: _name, _symbol: _symbol })
);
......@@ -115,7 +115,7 @@ contract L1BlockIsthmusTest is CommonTest {
vm.assume(_token != address(vm));
vm.expectRevert(NotDepositor.selector);
_l1BlockIsthmus().setConfig(
_l1BlockInterop().setConfig(
ConfigType.SET_GAS_PAYING_TOKEN,
StaticConfig.encodeSetGasPayingToken({ _token: _token, _decimals: _decimals, _name: _name, _symbol: _symbol })
);
......@@ -128,41 +128,41 @@ contract L1BlockIsthmusTest is CommonTest {
vm.expectEmit(address(l1Block));
emit DependencyAdded(_chainId);
_l1BlockIsthmus().setConfig(ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(_chainId));
_l1BlockInterop().setConfig(ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(_chainId));
}
/// @dev Tests that adding a dependency reverts if it's the chain's chain id
function test_setConfig_addDependency_chainChainId_reverts() public prankDepositor {
vm.expectRevert(AlreadyDependency.selector);
_l1BlockIsthmus().setConfig(ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(block.chainid));
_l1BlockInterop().setConfig(ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(block.chainid));
}
/// @dev Tests that adding a dependency already in the set reverts
function test_setConfig_addDependency_alreadyDependency_reverts(uint256 _chainId) public prankDepositor {
vm.assume(_chainId != block.chainid);
_l1BlockIsthmus().setConfig(ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(_chainId));
_l1BlockInterop().setConfig(ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(_chainId));
vm.expectRevert(AlreadyDependency.selector);
_l1BlockIsthmus().setConfig(ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(_chainId));
_l1BlockInterop().setConfig(ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(_chainId));
}
/// @dev Tests that setting the add dependency config as not the depositor reverts.
function testFuzz_setConfig_addDependency_notDepositor_reverts(uint256 _chainId) public {
vm.expectRevert(NotDepositor.selector);
_l1BlockIsthmus().setConfig(ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(_chainId));
_l1BlockInterop().setConfig(ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(_chainId));
}
/// @dev Tests that setting the add dependency config when the dependency set size is too large reverts.
function test_setConfig_addDependency_dependencySetSizeTooLarge_reverts() public prankDepositor {
for (uint256 i = 0; i < type(uint8).max; i++) {
_l1BlockIsthmus().setConfig(ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(i));
_l1BlockInterop().setConfig(ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(i));
}
assertEq(_l1BlockIsthmus().dependencySetSize(), type(uint8).max);
assertEq(_l1BlockInterop().dependencySetSize(), type(uint8).max);
vm.expectRevert(DependencySetSizeTooLarge.selector);
_l1BlockIsthmus().setConfig(ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(1));
_l1BlockInterop().setConfig(ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(1));
}
/// @dev Tests that the config for removing a dependency can be set.
......@@ -170,24 +170,24 @@ contract L1BlockIsthmusTest is CommonTest {
vm.assume(_chainId != block.chainid);
// Add the chain ID to the dependency set before removing it
_l1BlockIsthmus().setConfig(ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(_chainId));
_l1BlockInterop().setConfig(ConfigType.ADD_DEPENDENCY, StaticConfig.encodeAddDependency(_chainId));
vm.expectEmit(address(l1Block));
emit DependencyRemoved(_chainId);
_l1BlockIsthmus().setConfig(ConfigType.REMOVE_DEPENDENCY, StaticConfig.encodeRemoveDependency(_chainId));
_l1BlockInterop().setConfig(ConfigType.REMOVE_DEPENDENCY, StaticConfig.encodeRemoveDependency(_chainId));
}
/// @dev Tests that setting the remove dependency config as not the depositor reverts.
function testFuzz_setConfig_removeDependency_notDepositor_reverts(uint256 _chainId) public {
vm.expectRevert(NotDepositor.selector);
_l1BlockIsthmus().setConfig(ConfigType.REMOVE_DEPENDENCY, StaticConfig.encodeRemoveDependency(_chainId));
_l1BlockInterop().setConfig(ConfigType.REMOVE_DEPENDENCY, StaticConfig.encodeRemoveDependency(_chainId));
}
/// @dev Tests that setting the remove dependency config for the chain's chain ID reverts.
function test_setConfig_removeDependency_chainChainId_reverts() public prankDepositor {
vm.expectRevert(CantRemovedDependency.selector);
_l1BlockIsthmus().setConfig(ConfigType.REMOVE_DEPENDENCY, StaticConfig.encodeRemoveDependency(block.chainid));
_l1BlockInterop().setConfig(ConfigType.REMOVE_DEPENDENCY, StaticConfig.encodeRemoveDependency(block.chainid));
}
/// @dev Tests that setting the remove dependency config for a chain ID that is not in the dependency set reverts.
......@@ -195,50 +195,50 @@ contract L1BlockIsthmusTest is CommonTest {
vm.assume(_chainId != block.chainid);
vm.expectRevert(NotDependency.selector);
_l1BlockIsthmus().setConfig(ConfigType.REMOVE_DEPENDENCY, StaticConfig.encodeRemoveDependency(_chainId));
_l1BlockInterop().setConfig(ConfigType.REMOVE_DEPENDENCY, StaticConfig.encodeRemoveDependency(_chainId));
}
/// @dev Returns the L1BlockIsthmus instance.
function _l1BlockIsthmus() internal view returns (L1BlockIsthmus) {
return L1BlockIsthmus(address(l1Block));
/// @dev Returns the L1BlockInterop instance.
function _l1BlockInterop() internal view returns (L1BlockInterop) {
return L1BlockInterop(address(l1Block));
}
}
contract L1BlockIsthmusIsDeposit_Test is L1BlockIsthmusTest {
contract L1BlockInteropIsDeposit_Test is L1BlockInteropTest {
/// @dev Tests that `isDeposit` reverts if the caller is not the cross L2 inbox.
function test_isDeposit_notCrossL2Inbox_reverts(address _caller) external {
vm.assume(_caller != Predeploys.CROSS_L2_INBOX);
vm.expectRevert(NotCrossL2Inbox.selector);
_l1BlockIsthmus().isDeposit();
_l1BlockInterop().isDeposit();
}
/// @dev Tests that `isDeposit` always returns the correct value.
function test_isDeposit_succeeds() external {
// Assert is false if the value is not updated
vm.prank(Predeploys.CROSS_L2_INBOX);
assertEq(_l1BlockIsthmus().isDeposit(), false);
assertEq(_l1BlockInterop().isDeposit(), false);
/// @dev Assuming that `setL1BlockValuesIsthmus` will set the proper value. That function is tested as well
vm.prank(_l1BlockIsthmus().DEPOSITOR_ACCOUNT());
_l1BlockIsthmus().setL1BlockValuesIsthmus();
/// @dev Assuming that `setL1BlockValuesInterop` will set the proper value. That function is tested as well
vm.prank(_l1BlockInterop().DEPOSITOR_ACCOUNT());
_l1BlockInterop().setL1BlockValuesInterop();
// Assert is true if the value is updated
vm.prank(Predeploys.CROSS_L2_INBOX);
assertEq(_l1BlockIsthmus().isDeposit(), true);
assertEq(_l1BlockInterop().isDeposit(), true);
}
}
contract L1BlockIsthmusSetL1BlockValuesIsthmus_Test is L1BlockIsthmusTest {
/// @dev Tests that `setL1BlockValuesIsthmus` reverts if sender address is not the depositor
function test_setL1BlockValuesIsthmus_notDepositor_reverts(address _caller) external {
vm.assume(_caller != _l1BlockIsthmus().DEPOSITOR_ACCOUNT());
contract L1BlockInteropSetL1BlockValuesInterop_Test is L1BlockInteropTest {
/// @dev Tests that `setL1BlockValuesInterop` reverts if sender address is not the depositor
function test_setL1BlockValuesInterop_notDepositor_reverts(address _caller) external {
vm.assume(_caller != _l1BlockInterop().DEPOSITOR_ACCOUNT());
vm.prank(_caller);
vm.expectRevert(NotDepositor.selector);
_l1BlockIsthmus().setL1BlockValuesIsthmus();
_l1BlockInterop().setL1BlockValuesInterop();
}
/// @dev Tests that `setL1BlockValuesIsthmus` succeeds if sender address is the depositor
function test_setL1BlockValuesIsthmus_succeeds(
/// @dev Tests that `setL1BlockValuesInterop` succeeds if sender address is the depositor
function test_setL1BlockValuesInterop_succeeds(
uint32 baseFeeScalar,
uint32 blobBaseFeeScalar,
uint64 sequenceNumber,
......@@ -251,62 +251,62 @@ contract L1BlockIsthmusSetL1BlockValuesIsthmus_Test is L1BlockIsthmusTest {
)
external
{
// Ensure the `isDepositTransaction` flag is false before calling `setL1BlockValuesIsthmus`
// Ensure the `isDepositTransaction` flag is false before calling `setL1BlockValuesInterop`
vm.prank(Predeploys.CROSS_L2_INBOX);
assertEq(_l1BlockIsthmus().isDeposit(), false);
assertEq(_l1BlockInterop().isDeposit(), false);
bytes memory setValuesEcotoneCalldata = abi.encodePacked(
baseFeeScalar, blobBaseFeeScalar, sequenceNumber, timestamp, number, baseFee, blobBaseFee, hash, batcherHash
);
vm.prank(_l1BlockIsthmus().DEPOSITOR_ACCOUNT());
vm.prank(_l1BlockInterop().DEPOSITOR_ACCOUNT());
(bool success,) = address(l1Block).call(
abi.encodePacked(L1BlockIsthmus.setL1BlockValuesIsthmus.selector, setValuesEcotoneCalldata)
abi.encodePacked(L1BlockInterop.setL1BlockValuesInterop.selector, setValuesEcotoneCalldata)
);
assertTrue(success, "function call failed");
// Assert that the `isDepositTransaction` flag was properly set to true
vm.prank(Predeploys.CROSS_L2_INBOX);
assertEq(_l1BlockIsthmus().isDeposit(), true);
assertEq(_l1BlockInterop().isDeposit(), true);
// Assert `setL1BlockValuesEcotone` was properly called, forwarding the calldata to it
assertEq(_l1BlockIsthmus().baseFeeScalar(), baseFeeScalar, "base fee scalar not properly set");
assertEq(_l1BlockIsthmus().blobBaseFeeScalar(), blobBaseFeeScalar, "blob base fee scalar not properly set");
assertEq(_l1BlockIsthmus().sequenceNumber(), sequenceNumber, "sequence number not properly set");
assertEq(_l1BlockIsthmus().timestamp(), timestamp, "timestamp not properly set");
assertEq(_l1BlockIsthmus().number(), number, "number not properly set");
assertEq(_l1BlockIsthmus().basefee(), baseFee, "base fee not properly set");
assertEq(_l1BlockIsthmus().blobBaseFee(), blobBaseFee, "blob base fee not properly set");
assertEq(_l1BlockIsthmus().hash(), hash, "hash not properly set");
assertEq(_l1BlockIsthmus().batcherHash(), batcherHash, "batcher hash not properly set");
assertEq(_l1BlockInterop().baseFeeScalar(), baseFeeScalar, "base fee scalar not properly set");
assertEq(_l1BlockInterop().blobBaseFeeScalar(), blobBaseFeeScalar, "blob base fee scalar not properly set");
assertEq(_l1BlockInterop().sequenceNumber(), sequenceNumber, "sequence number not properly set");
assertEq(_l1BlockInterop().timestamp(), timestamp, "timestamp not properly set");
assertEq(_l1BlockInterop().number(), number, "number not properly set");
assertEq(_l1BlockInterop().basefee(), baseFee, "base fee not properly set");
assertEq(_l1BlockInterop().blobBaseFee(), blobBaseFee, "blob base fee not properly set");
assertEq(_l1BlockInterop().hash(), hash, "hash not properly set");
assertEq(_l1BlockInterop().batcherHash(), batcherHash, "batcher hash not properly set");
}
}
contract L1BlockDepositsComplete_Test is L1BlockIsthmusTest {
contract L1BlockDepositsComplete_Test is L1BlockInteropTest {
// @dev Tests that `depositsComplete` reverts if the caller is not the depositor.
function test_deposits_is_depositor_reverts(address _caller) external {
vm.assume(_caller != _l1BlockIsthmus().DEPOSITOR_ACCOUNT());
vm.assume(_caller != _l1BlockInterop().DEPOSITOR_ACCOUNT());
vm.expectRevert(NotDepositor.selector);
_l1BlockIsthmus().depositsComplete();
_l1BlockInterop().depositsComplete();
}
// @dev Tests that `depositsComplete` succeeds if the caller is the depositor.
function test_depositsComplete_succeeds() external {
// Set the `isDeposit` flag to true
vm.prank(_l1BlockIsthmus().DEPOSITOR_ACCOUNT());
_l1BlockIsthmus().setL1BlockValuesIsthmus();
vm.prank(_l1BlockInterop().DEPOSITOR_ACCOUNT());
_l1BlockInterop().setL1BlockValuesInterop();
// Assert that the `isDeposit` flag was properly set to true
vm.prank(Predeploys.CROSS_L2_INBOX);
assertTrue(_l1BlockIsthmus().isDeposit());
assertTrue(_l1BlockInterop().isDeposit());
// Call `depositsComplete`
vm.prank(_l1BlockIsthmus().DEPOSITOR_ACCOUNT());
_l1BlockIsthmus().depositsComplete();
vm.prank(_l1BlockInterop().DEPOSITOR_ACCOUNT());
_l1BlockInterop().depositsComplete();
// Assert that the `isDeposit` flag was properly set to false
/// @dev Assuming that `isDeposit()` wil return the proper value. That function is tested as well
vm.prank(Predeploys.CROSS_L2_INBOX);
assertEq(_l1BlockIsthmus().isDeposit(), false);
assertEq(_l1BlockInterop().isDeposit(), false);
}
}
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