Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: dependency set refactor #170

Merged
merged 4 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions packages/contracts-bedrock/interfaces/L1/ISuperchainConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,27 @@ interface ISuperchainConfig is IDependencySet {
event Initialized(uint8 version);
event Paused(string identifier);
event Unpaused();
event ChainAdded(uint256 indexed chainId, address indexed systemConfig, address indexed portal);
event DependencyAdded(uint256 indexed chainId, address indexed systemConfig, address indexed portal);

error Unauthorized();
error ChainAlreadyHasDependencies();
error ChainAlreadyAdded();
error DependencySetTooLarge();
error InvalidChainID();
error DependencyAlreadyAdded();

function GUARDIAN_SLOT() external view returns (bytes32);
function PAUSED_SLOT() external view returns (bytes32);
function UPGRADER_SLOT() external view returns (bytes32);
function DEPENDENCY_MANAGER_SLOT() external view returns (bytes32);
function SHARED_LOCKBOX() external view returns (ISharedLockbox);
function guardian() external view returns (address guardian_);
function systemConfigs(uint256) external view returns (address);
function upgrader() external view returns (address upgrader_);
function initialize(address _guardian, address _upgrader, bool _paused) external;
function dependencyManager() external view returns (address dependencyManager_);
function initialize(address _guardian, address _dependencyManager, bool _paused) external;
function pause(string memory _identifier) external;
function paused() external view returns (bool paused_);
function unpause() external;
function version() external view returns (string memory);
function addChain(uint256 _chainId, address _systemConfig) external;
function addDependency(uint256 _chainId, address _systemConfig) external;
function dependencySet() external view returns (uint256[] memory);
function dependencySetSize() external view returns (uint8);

function __constructor__(address _sharedLockbox) external;
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ interface ISystemConfigInterop {
function transferOwnership(address newOwner) external; // nosemgrep
function unsafeBlockSigner() external view returns (address addr_);

function addDependency(uint256 _chainId) external;
function removeDependency(uint256 _chainId) external;
function dependencyCounter() external view returns (uint256);
function initialize(
address _owner,
uint32 _basefeeScalar,
Expand All @@ -69,7 +66,6 @@ interface ISystemConfigInterop {
)
external;
function version() external pure returns (string memory);
function SUPERCHAIN_CONFIG() external view returns (address);

function __constructor__(address _superchainConfig) external;
function __constructor__() external;
}
3 changes: 0 additions & 3 deletions packages/contracts-bedrock/interfaces/L2/ICrossL2Inbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ interface ICrossL2Inbox {
/// @notice Thrown when trying to execute a cross chain message with an invalid Identifier timestamp.
error InvalidTimestamp();

/// @notice Thrown when trying to execute a cross chain message with an invalid Identifier chain ID.
error InvalidChainId();

/// @notice Thrown when trying to execute a cross chain message and the target call fails.
error TargetCallFailed();

Expand Down
12 changes: 1 addition & 11 deletions packages/contracts-bedrock/interfaces/L2/IL1BlockInterop.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,13 @@
pragma solidity ^0.8.0;

enum ConfigType {
SET_GAS_PAYING_TOKEN,
ADD_DEPENDENCY,
REMOVE_DEPENDENCY
SET_GAS_PAYING_TOKEN
}

interface IL1BlockInterop {
error AlreadyDependency();
error CantRemovedDependency();
error DependencySetSizeTooLarge();
error NotCrossL2Inbox();
error NotDependency();
error NotDepositor();

event DependencyAdded(uint256 indexed chainId);
event DependencyRemoved(uint256 indexed chainId);
event GasPayingTokenSet(address indexed token, uint8 indexed decimals, bytes32 name, bytes32 symbol);

function DEPOSITOR_ACCOUNT() external pure returns (address addr_);
Expand All @@ -25,15 +17,13 @@ interface IL1BlockInterop {
function batcherHash() external view returns (bytes32);
function blobBaseFee() external view returns (uint256);
function blobBaseFeeScalar() external view returns (uint32);
function dependencySetSize() external view returns (uint8);
function depositsComplete() external;
function gasPayingToken() external view returns (address addr_, uint8 decimals_);
function gasPayingTokenName() external view returns (string memory name_);
function gasPayingTokenSymbol() external view returns (string memory symbol_);
function hash() external view returns (bytes32);
function isCustomGasToken() external view returns (bool);
function isDeposit() external view returns (bool isDeposit_);
function isInDependencySet(uint256 _chainId) external view returns (bool);
function l1FeeOverhead() external view returns (uint256);
function l1FeeScalar() external view returns (uint256);
function number() external view returns (uint64);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ interface IL2ToL2CrossDomainMessenger {
/// @notice Thrown when a call to the target contract during message relay fails.
error TargetCallFailed();

/// @notice Thrown when attempting to use a chain ID that is not in the dependency set.
error InvalidChainId();

/// @notice Emitted whenever a message is sent to a destination
/// @param destination Chain ID of the destination chain.
/// @param target Target contract or wallet address.
Expand Down
5 changes: 0 additions & 5 deletions packages/contracts-bedrock/scripts/deploy/ChainAssertions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,13 @@ library ChainAssertions {
/// @notice Asserts that the SystemConfigInterop is setup correctly
function checkSystemConfigInterop(
Types.ContractSet memory _contracts,
Types.ContractSet memory _proxies,
DeployConfig _cfg,
bool _isProxy
)
internal
view
{
ISystemConfigInterop config = ISystemConfigInterop(_contracts.SystemConfig);
ISuperchainConfig superchainConfig = ISuperchainConfig(_proxies.SuperchainConfig);

console.log(
"Running chain assertions on the SystemConfigInterop %s at %s",
Expand All @@ -161,9 +159,6 @@ library ChainAssertions {
);

checkSystemConfig(_contracts, _cfg, _isProxy);

require(config.dependencyCounter() == 0, "CHECK-SCFGI-10");
require(config.SUPERCHAIN_CONFIG() == address(superchainConfig), "CHECK-SCFGI-20");
}

/// @notice Asserts that the L1CrossDomainMessenger is setup correctly
Expand Down
8 changes: 1 addition & 7 deletions packages/contracts-bedrock/scripts/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -394,13 +394,7 @@ contract Deploy is Deployer {
_oracle: IPreimageOracle(address(dio.preimageOracleSingleton()))
});
if (_isInterop) {
Types.ContractSet memory proxies = _proxies();
ChainAssertions.checkSystemConfigInterop({
_contracts: contracts,
_proxies: proxies,
_cfg: cfg,
_isProxy: false
});
ChainAssertions.checkSystemConfigInterop({ _contracts: contracts, _cfg: cfg, _isProxy: false });
} else {
ChainAssertions.checkSystemConfig({ _contracts: contracts, _cfg: cfg, _isProxy: false });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -990,14 +990,11 @@ contract DeployImplementationsInterop is DeployImplementations {
if (existingImplementation != address(0)) {
impl = ISystemConfigInterop(existingImplementation);
} else {
address superchainConfig = address(_dii.superchainConfigProxy());
vm.broadcast(msg.sender);
impl = ISystemConfigInterop(
DeployUtils.create1({
_name: "SystemConfigInterop",
_args: DeployUtils.encodeConstructor(
abi.encodeCall(ISystemConfigInterop.__constructor__, (superchainConfig))
)
_args: DeployUtils.encodeConstructor(abi.encodeCall(ISystemConfigInterop.__constructor__, ()))
})
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ contract DeploySuperchain is Script {
ISuperchainConfig superchainConfigProxy;
{
address guardian = _dsi.guardian();
address upgrader = _dsi.superchainProxyAdminOwner();
address dependencyManager = _dsi.superchainProxyAdminOwner();
bool paused = _dsi.paused();

vm.startBroadcast(msg.sender);
Expand All @@ -497,7 +497,7 @@ contract DeploySuperchain is Script {
superchainProxyAdmin.upgradeAndCall(
payable(address(superchainConfigProxy)),
address(_dso.superchainConfigImpl()),
abi.encodeCall(ISuperchainConfig.initialize, (guardian, upgrader, paused))
abi.encodeCall(ISuperchainConfig.initialize, (guardian, dependencyManager, paused))
);
vm.stopBroadcast();
}
Expand Down
23 changes: 12 additions & 11 deletions packages/contracts-bedrock/scripts/deploy/ManageDependencies.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,18 @@ contract ManageDependenciesInput is BaseDeployIO {
}

contract ManageDependencies is Script {
// TODO: Fix dependency management since SystemConfig does not handle them anymore
0xDiscotech marked this conversation as resolved.
Show resolved Hide resolved
function run(ManageDependenciesInput _input) public {
bool remove = _input.remove();
uint256 chainId = _input.chainId();
ISystemConfigInterop systemConfig = _input.systemConfig();

// Call the appropriate function based on the remove flag
vm.broadcast(msg.sender);
if (remove) {
systemConfig.removeDependency(chainId);
} else {
systemConfig.addDependency(chainId);
}
// bool remove = _input.remove();
// uint256 chainId = _input.chainId();
// ISystemConfigInterop systemConfig = _input.systemConfig();

// // Call the appropriate function based on the remove flag
// vm.broadcast(msg.sender);
// if (remove) {
// systemConfig.removeDependency(chainId);
// } else {
// systemConfig.addDependency(chainId);
// }
}
}
2 changes: 1 addition & 1 deletion packages/contracts-bedrock/snapshots/.gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GasBenchMark_L1BlockInterop_DepositsComplete:test_depositsComplete_benchmark() (gas: 7589)
GasBenchMark_L1BlockInterop_DepositsComplete_Warm:test_depositsComplete_benchmark() (gas: 5589)
GasBenchMark_L1BlockInterop_SetValuesInterop:test_setL1BlockValuesInterop_benchmark() (gas: 175722)
GasBenchMark_L1BlockInterop_SetValuesInterop:test_setL1BlockValuesInterop_benchmark() (gas: 175700)
GasBenchMark_L1BlockInterop_SetValuesInterop_Warm:test_setL1BlockValuesInterop_benchmark() (gas: 5144)
GasBenchMark_L1Block_SetValuesEcotone:test_setL1BlockValuesEcotone_benchmark() (gas: 158553)
GasBenchMark_L1Block_SetValuesEcotone_Warm:test_setL1BlockValuesEcotone_benchmark() (gas: 7619)
Expand Down
5 changes: 0 additions & 5 deletions packages/contracts-bedrock/snapshots/abi/CrossL2Inbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,6 @@
"name": "InteropStartAlreadySet",
"type": "error"
},
{
"inputs": [],
"name": "InvalidChainId",
"type": "error"
},
{
"inputs": [],
"name": "InvalidTimestamp",
Expand Down
78 changes: 0 additions & 78 deletions packages/contracts-bedrock/snapshots/abi/L1BlockInterop.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,6 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "dependencySetSize",
"outputs": [
{
"internalType": "uint8",
"name": "",
"type": "uint8"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "depositsComplete",
Expand Down Expand Up @@ -180,25 +167,6 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_chainId",
"type": "uint256"
}
],
"name": "isInDependencySet",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "l1FeeOverhead",
Expand Down Expand Up @@ -385,32 +353,6 @@
"stateMutability": "pure",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "chainId",
"type": "uint256"
}
],
"name": "DependencyAdded",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "chainId",
"type": "uint256"
}
],
"name": "DependencyRemoved",
"type": "event"
},
{
"anonymous": false,
"inputs": [
Expand Down Expand Up @@ -442,31 +384,11 @@
"name": "GasPayingTokenSet",
"type": "event"
},
{
"inputs": [],
"name": "AlreadyDependency",
"type": "error"
},
{
"inputs": [],
"name": "CantRemovedDependency",
"type": "error"
},
{
"inputs": [],
"name": "DependencySetSizeTooLarge",
"type": "error"
},
{
"inputs": [],
"name": "NotCrossL2Inbox",
"type": "error"
},
{
"inputs": [],
"name": "NotDependency",
"type": "error"
},
{
"inputs": [],
"name": "NotDepositor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,6 @@
"name": "IdOriginNotL2ToL2CrossDomainMessenger",
"type": "error"
},
{
"inputs": [],
"name": "InvalidChainId",
"type": "error"
},
{
"inputs": [],
"name": "MessageAlreadyRelayed",
Expand Down
Loading