Commit 0b2d0b2a authored by Michael Amadi's avatar Michael Amadi Committed by GitHub

use DeployUtils lib for deployments in deploy script (#12070)

* use DeployUtils lib for deployments in deploy script

* type safety for constructor args and use encode constructor

* add comments to helper functions

* add commentsd, deploy scripts cleanup

* fix assertion

* modify interface checker script to always expect a pseudo-constructor, modify failing interfaces

* assert contracts with no constructors to have pseudo-constructors with no input

* use pseudo-constructor encoding for contracts with no constructor defined
parent e2599c60
...@@ -208,6 +208,29 @@ for interface_file in $JSON_FILES; do ...@@ -208,6 +208,29 @@ for interface_file in $JSON_FILES; do
normalized_interface_abi=$(normalize_abi "$interface_abi") normalized_interface_abi=$(normalize_abi "$interface_abi")
normalized_contract_abi=$(normalize_abi "$contract_abi") normalized_contract_abi=$(normalize_abi "$contract_abi")
# Check if the contract ABI has no constructor but the interface is missing __constructor__
contract_has_constructor=$(echo "$normalized_contract_abi" | jq 'any(.[]; .type == "constructor")')
interface_has_default_pseudo_constructor=$(echo "$normalized_interface_abi" | jq 'any(.[]; .type == "constructor" and .inputs == [])')
# If any contract has no constructor and its corresponding interface also does not have one, flag it as a detected issue
if [ "$contract_has_constructor" = false ] && [ "$interface_has_default_pseudo_constructor" = false ]; then
if ! grep -q "^$contract_name$" "$REPORTED_INTERFACES_FILE"; then
echo "$contract_name" >> "$REPORTED_INTERFACES_FILE"
if ! is_excluded "$contract_name"; then
echo "Issue found in ABI for interface $contract_name from file $interface_file."
echo "Interface $contract_name must have a function named '__constructor__' as the corresponding contract has no constructor in its ABI."
issues_detected=true
fi
fi
continue
fi
# removes the pseudo constructor json entry from the interface files where the corresponding contract file has no constructor
# this is to ensure it is not flagged as a diff in the next step below
if [ "$contract_has_constructor" = false ] && [ "$interface_has_default_pseudo_constructor" ]; then
normalized_interface_abi=$(echo "$normalized_interface_abi" | jq 'map(select(.type != "constructor"))')
fi
# Use jq to compare the ABIs # Use jq to compare the ABIs
if ! diff_result=$(diff -u <(echo "$normalized_interface_abi" | jq 'sort') <(echo "$normalized_contract_abi" | jq 'sort')); then if ! diff_result=$(diff -u <(echo "$normalized_interface_abi" | jq 'sort') <(echo "$normalized_contract_abi" | jq 'sort')); then
if ! grep -q "^$contract_name$" "$REPORTED_INTERFACES_FILE"; then if ! grep -q "^$contract_name$" "$REPORTED_INTERFACES_FILE"; then
......
...@@ -23,6 +23,7 @@ import { LibStateDiff } from "scripts/libraries/LibStateDiff.sol"; ...@@ -23,6 +23,7 @@ import { LibStateDiff } from "scripts/libraries/LibStateDiff.sol";
import { Process } from "scripts/libraries/Process.sol"; import { Process } from "scripts/libraries/Process.sol";
import { ForgeArtifacts } from "scripts/libraries/ForgeArtifacts.sol"; import { ForgeArtifacts } from "scripts/libraries/ForgeArtifacts.sol";
import { ChainAssertions } from "scripts/deploy/ChainAssertions.sol"; import { ChainAssertions } from "scripts/deploy/ChainAssertions.sol";
import { DeployUtils } from "scripts/libraries/DeployUtils.sol";
// Contracts // Contracts
import { ProxyAdmin } from "src/universal/ProxyAdmin.sol"; import { ProxyAdmin } from "src/universal/ProxyAdmin.sol";
...@@ -41,6 +42,7 @@ import { Constants } from "src/libraries/Constants.sol"; ...@@ -41,6 +42,7 @@ import { Constants } from "src/libraries/Constants.sol";
import { Predeploys } from "src/libraries/Predeploys.sol"; import { Predeploys } from "src/libraries/Predeploys.sol";
import { Types } from "scripts/libraries/Types.sol"; import { Types } from "scripts/libraries/Types.sol";
import "src/dispute/lib/Types.sol"; import "src/dispute/lib/Types.sol";
import { LibClaim, Duration } from "src/dispute/lib/LibUDT.sol";
// Interfaces // Interfaces
import { IOptimismPortal } from "src/L1/interfaces/IOptimismPortal.sol"; import { IOptimismPortal } from "src/L1/interfaces/IOptimismPortal.sol";
...@@ -51,6 +53,7 @@ import { IL1CrossDomainMessenger } from "src/L1/interfaces/IL1CrossDomainMesseng ...@@ -51,6 +53,7 @@ import { IL1CrossDomainMessenger } from "src/L1/interfaces/IL1CrossDomainMesseng
import { IL2OutputOracle } from "src/L1/interfaces/IL2OutputOracle.sol"; import { IL2OutputOracle } from "src/L1/interfaces/IL2OutputOracle.sol";
import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol"; import { ISuperchainConfig } from "src/L1/interfaces/ISuperchainConfig.sol";
import { ISystemConfig } from "src/L1/interfaces/ISystemConfig.sol"; import { ISystemConfig } from "src/L1/interfaces/ISystemConfig.sol";
import { ISystemConfigInterop } from "src/L1/interfaces/ISystemConfigInterop.sol";
import { IDataAvailabilityChallenge } from "src/L1/interfaces/IDataAvailabilityChallenge.sol"; import { IDataAvailabilityChallenge } from "src/L1/interfaces/IDataAvailabilityChallenge.sol";
import { IL1ERC721Bridge } from "src/L1/interfaces/IL1ERC721Bridge.sol"; import { IL1ERC721Bridge } from "src/L1/interfaces/IL1ERC721Bridge.sol";
import { IL1StandardBridge } from "src/L1/interfaces/IL1StandardBridge.sol"; import { IL1StandardBridge } from "src/L1/interfaces/IL1StandardBridge.sol";
...@@ -58,6 +61,8 @@ import { IProtocolVersions, ProtocolVersion } from "src/L1/interfaces/IProtocolV ...@@ -58,6 +61,8 @@ import { IProtocolVersions, ProtocolVersion } from "src/L1/interfaces/IProtocolV
import { IBigStepper } from "src/dispute/interfaces/IBigStepper.sol"; import { IBigStepper } from "src/dispute/interfaces/IBigStepper.sol";
import { IDisputeGameFactory } from "src/dispute/interfaces/IDisputeGameFactory.sol"; import { IDisputeGameFactory } from "src/dispute/interfaces/IDisputeGameFactory.sol";
import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol"; import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol";
import { IFaultDisputeGame } from "src/dispute/interfaces/IFaultDisputeGame.sol";
import { IPermissionedDisputeGame } from "src/dispute/interfaces/IPermissionedDisputeGame.sol";
import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol"; import { IDelayedWETH } from "src/dispute/interfaces/IDelayedWETH.sol";
import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol"; import { IAnchorStateRegistry } from "src/dispute/interfaces/IAnchorStateRegistry.sol";
import { IPreimageOracle } from "src/cannon/interfaces/IPreimageOracle.sol"; import { IPreimageOracle } from "src/cannon/interfaces/IPreimageOracle.sol";
...@@ -665,7 +670,14 @@ contract Deploy is Deployer { ...@@ -665,7 +670,14 @@ contract Deploy is Deployer {
/// @notice Deploy the SuperchainConfig contract /// @notice Deploy the SuperchainConfig contract
function deploySuperchainConfig() public broadcast { function deploySuperchainConfig() public broadcast {
ISuperchainConfig superchainConfig = ISuperchainConfig(_deploy("SuperchainConfig", hex"")); ISuperchainConfig superchainConfig = ISuperchainConfig(
DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "SuperchainConfig",
_args: abi.encodeCall(ISuperchainConfig.__constructor__, ())
})
);
require(superchainConfig.guardian() == address(0)); require(superchainConfig.guardian() == address(0));
bytes32 initialized = vm.load(address(superchainConfig), bytes32(0)); bytes32 initialized = vm.load(address(superchainConfig), bytes32(0));
...@@ -674,7 +686,14 @@ contract Deploy is Deployer { ...@@ -674,7 +686,14 @@ contract Deploy is Deployer {
/// @notice Deploy the L1CrossDomainMessenger /// @notice Deploy the L1CrossDomainMessenger
function deployL1CrossDomainMessenger() public broadcast returns (address addr_) { function deployL1CrossDomainMessenger() public broadcast returns (address addr_) {
IL1CrossDomainMessenger messenger = IL1CrossDomainMessenger(_deploy("L1CrossDomainMessenger", hex"")); IL1CrossDomainMessenger messenger = IL1CrossDomainMessenger(
DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "L1CrossDomainMessenger",
_args: abi.encodeCall(IL1CrossDomainMessenger.__constructor__, ())
})
);
// Override the `L1CrossDomainMessenger` contract to the deployed implementation. This is necessary // Override the `L1CrossDomainMessenger` contract to the deployed implementation. This is necessary
// to check the `L1CrossDomainMessenger` implementation alongside dependent contracts, which // to check the `L1CrossDomainMessenger` implementation alongside dependent contracts, which
...@@ -692,7 +711,12 @@ contract Deploy is Deployer { ...@@ -692,7 +711,12 @@ contract Deploy is Deployer {
console.log("Attempting to deploy OptimismPortal with interop, this config is a noop"); console.log("Attempting to deploy OptimismPortal with interop, this config is a noop");
} }
addr_ = _deploy("OptimismPortal", hex""); addr_ = DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "OptimismPortal",
_args: abi.encodeCall(IOptimismPortal.__constructor__, ())
});
// Override the `OptimismPortal` contract to the deployed implementation. This is necessary // Override the `OptimismPortal` contract to the deployed implementation. This is necessary
// to check the `OptimismPortal` implementation alongside dependent contracts, which // to check the `OptimismPortal` implementation alongside dependent contracts, which
...@@ -710,15 +734,30 @@ contract Deploy is Deployer { ...@@ -710,15 +734,30 @@ contract Deploy is Deployer {
); );
if (cfg.useInterop()) { if (cfg.useInterop()) {
addr_ = _deploy( addr_ = DeployUtils.create2AndSave({
"OptimismPortalInterop", _save: this,
abi.encode(cfg.proofMaturityDelaySeconds(), cfg.disputeGameFinalityDelaySeconds()) _salt: _implSalt(),
); _name: "OptimismPortalInterop",
_args: DeployUtils.encodeConstructor(
abi.encodeCall(
IOptimismPortalInterop.__constructor__,
(cfg.proofMaturityDelaySeconds(), cfg.disputeGameFinalityDelaySeconds())
)
)
});
save("OptimismPortal2", addr_); save("OptimismPortal2", addr_);
} else { } else {
addr_ = _deploy( addr_ = DeployUtils.create2AndSave({
"OptimismPortal2", abi.encode(cfg.proofMaturityDelaySeconds(), cfg.disputeGameFinalityDelaySeconds()) _save: this,
); _salt: _implSalt(),
_name: "OptimismPortal2",
_args: DeployUtils.encodeConstructor(
abi.encodeCall(
IOptimismPortal2.__constructor__,
(cfg.proofMaturityDelaySeconds(), cfg.disputeGameFinalityDelaySeconds())
)
)
});
} }
// Override the `OptimismPortal2` contract to the deployed implementation. This is necessary // Override the `OptimismPortal2` contract to the deployed implementation. This is necessary
...@@ -731,7 +770,14 @@ contract Deploy is Deployer { ...@@ -731,7 +770,14 @@ contract Deploy is Deployer {
/// @notice Deploy the L2OutputOracle /// @notice Deploy the L2OutputOracle
function deployL2OutputOracle() public broadcast returns (address addr_) { function deployL2OutputOracle() public broadcast returns (address addr_) {
IL2OutputOracle oracle = IL2OutputOracle(_deploy("L2OutputOracle", hex"")); IL2OutputOracle oracle = IL2OutputOracle(
DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "L2OutputOracle",
_args: abi.encodeCall(IL2OutputOracle.__constructor__, ())
})
);
// Override the `L2OutputOracle` contract to the deployed implementation. This is necessary // Override the `L2OutputOracle` contract to the deployed implementation. This is necessary
// to check the `L2OutputOracle` implementation alongside dependent contracts, which // to check the `L2OutputOracle` implementation alongside dependent contracts, which
...@@ -750,8 +796,14 @@ contract Deploy is Deployer { ...@@ -750,8 +796,14 @@ contract Deploy is Deployer {
/// @notice Deploy the OptimismMintableERC20Factory /// @notice Deploy the OptimismMintableERC20Factory
function deployOptimismMintableERC20Factory() public broadcast returns (address addr_) { function deployOptimismMintableERC20Factory() public broadcast returns (address addr_) {
IOptimismMintableERC20Factory factory = IOptimismMintableERC20Factory factory = IOptimismMintableERC20Factory(
IOptimismMintableERC20Factory(_deploy("OptimismMintableERC20Factory", hex"")); DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "OptimismMintableERC20Factory",
_args: abi.encodeCall(IOptimismMintableERC20Factory.__constructor__, ())
})
);
// Override the `OptimismMintableERC20Factory` contract to the deployed implementation. This is necessary // Override the `OptimismMintableERC20Factory` contract to the deployed implementation. This is necessary
// to check the `OptimismMintableERC20Factory` implementation alongside dependent contracts, which // to check the `OptimismMintableERC20Factory` implementation alongside dependent contracts, which
...@@ -765,7 +817,14 @@ contract Deploy is Deployer { ...@@ -765,7 +817,14 @@ contract Deploy is Deployer {
/// @notice Deploy the DisputeGameFactory /// @notice Deploy the DisputeGameFactory
function deployDisputeGameFactory() public broadcast returns (address addr_) { function deployDisputeGameFactory() public broadcast returns (address addr_) {
IDisputeGameFactory factory = IDisputeGameFactory(_deploy("DisputeGameFactory", hex"")); IDisputeGameFactory factory = IDisputeGameFactory(
DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "DisputeGameFactory",
_args: abi.encodeCall(IDisputeGameFactory.__constructor__, ())
})
);
// Override the `DisputeGameFactory` contract to the deployed implementation. This is necessary to check the // Override the `DisputeGameFactory` contract to the deployed implementation. This is necessary to check the
// `DisputeGameFactory` implementation alongside dependent contracts, which are always proxies. // `DisputeGameFactory` implementation alongside dependent contracts, which are always proxies.
...@@ -777,7 +836,16 @@ contract Deploy is Deployer { ...@@ -777,7 +836,16 @@ contract Deploy is Deployer {
} }
function deployDelayedWETH() public broadcast returns (address addr_) { function deployDelayedWETH() public broadcast returns (address addr_) {
IDelayedWETH weth = IDelayedWETH(payable(_deploy("DelayedWETH", abi.encode(cfg.faultGameWithdrawalDelay())))); IDelayedWETH weth = IDelayedWETH(
DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "DelayedWETH",
_args: DeployUtils.encodeConstructor(
abi.encodeCall(IDelayedWETH.__constructor__, (cfg.faultGameWithdrawalDelay()))
)
})
);
// Override the `DelayedWETH` contract to the deployed implementation. This is necessary // Override the `DelayedWETH` contract to the deployed implementation. This is necessary
// to check the `DelayedWETH` implementation alongside dependent contracts, which are // to check the `DelayedWETH` implementation alongside dependent contracts, which are
...@@ -796,7 +864,14 @@ contract Deploy is Deployer { ...@@ -796,7 +864,14 @@ contract Deploy is Deployer {
/// @notice Deploy the ProtocolVersions /// @notice Deploy the ProtocolVersions
function deployProtocolVersions() public broadcast returns (address addr_) { function deployProtocolVersions() public broadcast returns (address addr_) {
IProtocolVersions versions = IProtocolVersions(_deploy("ProtocolVersions", hex"")); IProtocolVersions versions = IProtocolVersions(
DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "ProtocolVersions",
_args: abi.encodeCall(IProtocolVersions.__constructor__, ())
})
);
// Override the `ProtocolVersions` contract to the deployed implementation. This is necessary // Override the `ProtocolVersions` contract to the deployed implementation. This is necessary
// to check the `ProtocolVersions` implementation alongside dependent contracts, which // to check the `ProtocolVersions` implementation alongside dependent contracts, which
...@@ -849,8 +924,19 @@ contract Deploy is Deployer { ...@@ -849,8 +924,19 @@ contract Deploy is Deployer {
/// @notice Deploy the AnchorStateRegistry /// @notice Deploy the AnchorStateRegistry
function deployAnchorStateRegistry() public broadcast returns (address addr_) { function deployAnchorStateRegistry() public broadcast returns (address addr_) {
IAnchorStateRegistry anchorStateRegistry = IAnchorStateRegistry anchorStateRegistry = IAnchorStateRegistry(
IAnchorStateRegistry(_deploy("AnchorStateRegistry", abi.encode(mustGetAddress("DisputeGameFactoryProxy")))); DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "AnchorStateRegistry",
_args: DeployUtils.encodeConstructor(
abi.encodeCall(
IAnchorStateRegistry.__constructor__,
(IDisputeGameFactory(mustGetAddress("DisputeGameFactoryProxy")))
)
)
})
);
addr_ = address(anchorStateRegistry); addr_ = address(anchorStateRegistry);
} }
...@@ -858,10 +944,20 @@ contract Deploy is Deployer { ...@@ -858,10 +944,20 @@ contract Deploy is Deployer {
/// @notice Deploy the SystemConfig /// @notice Deploy the SystemConfig
function deploySystemConfig() public broadcast returns (address addr_) { function deploySystemConfig() public broadcast returns (address addr_) {
if (cfg.useInterop()) { if (cfg.useInterop()) {
addr_ = _deploy("SystemConfigInterop", hex""); addr_ = DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "SystemConfigInterop",
_args: abi.encodeCall(ISystemConfigInterop.__constructor__, ())
});
save("SystemConfig", addr_); save("SystemConfig", addr_);
} else { } else {
addr_ = _deploy("SystemConfig", hex""); addr_ = DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "SystemConfig",
_args: abi.encodeCall(ISystemConfig.__constructor__, ())
});
} }
// Override the `SystemConfig` contract to the deployed implementation. This is necessary // Override the `SystemConfig` contract to the deployed implementation. This is necessary
...@@ -874,7 +970,14 @@ contract Deploy is Deployer { ...@@ -874,7 +970,14 @@ contract Deploy is Deployer {
/// @notice Deploy the L1StandardBridge /// @notice Deploy the L1StandardBridge
function deployL1StandardBridge() public broadcast returns (address addr_) { function deployL1StandardBridge() public broadcast returns (address addr_) {
IL1StandardBridge bridge = IL1StandardBridge(payable(_deploy("L1StandardBridge", hex""))); IL1StandardBridge bridge = IL1StandardBridge(
DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "L1StandardBridge",
_args: abi.encodeCall(IL1StandardBridge.__constructor__, ())
})
);
// Override the `L1StandardBridge` contract to the deployed implementation. This is necessary // Override the `L1StandardBridge` contract to the deployed implementation. This is necessary
// to check the `L1StandardBridge` implementation alongside dependent contracts, which // to check the `L1StandardBridge` implementation alongside dependent contracts, which
...@@ -888,7 +991,14 @@ contract Deploy is Deployer { ...@@ -888,7 +991,14 @@ contract Deploy is Deployer {
/// @notice Deploy the L1ERC721Bridge /// @notice Deploy the L1ERC721Bridge
function deployL1ERC721Bridge() public broadcast returns (address addr_) { function deployL1ERC721Bridge() public broadcast returns (address addr_) {
IL1ERC721Bridge bridge = IL1ERC721Bridge(_deploy("L1ERC721Bridge", hex"")); IL1ERC721Bridge bridge = IL1ERC721Bridge(
DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "L1ERC721Bridge",
_args: abi.encodeCall(IL1ERC721Bridge.__constructor__, ())
})
);
// Override the `L1ERC721Bridge` contract to the deployed implementation. This is necessary // Override the `L1ERC721Bridge` contract to the deployed implementation. This is necessary
// to check the `L1ERC721Bridge` implementation alongside dependent contracts, which // to check the `L1ERC721Bridge` implementation alongside dependent contracts, which
...@@ -917,8 +1027,14 @@ contract Deploy is Deployer { ...@@ -917,8 +1027,14 @@ contract Deploy is Deployer {
/// @notice Deploy the DataAvailabilityChallenge /// @notice Deploy the DataAvailabilityChallenge
function deployDataAvailabilityChallenge() public broadcast returns (address addr_) { function deployDataAvailabilityChallenge() public broadcast returns (address addr_) {
IDataAvailabilityChallenge dac = IDataAvailabilityChallenge dac = IDataAvailabilityChallenge(
IDataAvailabilityChallenge(payable(_deploy("DataAvailabilityChallenge", hex""))); DeployUtils.create2AndSave({
_save: this,
_salt: _implSalt(),
_name: "DataAvailabilityChallenge",
_args: abi.encodeCall(IDataAvailabilityChallenge.__constructor__, ())
})
);
addr_ = address(dac); addr_ = address(dac);
} }
...@@ -1578,49 +1694,66 @@ contract Deploy is Deployer { ...@@ -1578,49 +1694,66 @@ contract Deploy is Deployer {
} }
uint32 rawGameType = GameType.unwrap(_params.gameType); uint32 rawGameType = GameType.unwrap(_params.gameType);
// Redefine _param variable to avoid stack too deep error during compilation
FaultDisputeGameParams memory _params_ = _params;
if (rawGameType != GameTypes.PERMISSIONED_CANNON.raw()) { if (rawGameType != GameTypes.PERMISSIONED_CANNON.raw()) {
_factory.setImplementation( _factory.setImplementation(
_params.gameType, _params_.gameType,
IDisputeGame( IDisputeGame(
_deploy( DeployUtils.create2AndSave({
"FaultDisputeGame", _save: this,
string.concat("FaultDisputeGame_", vm.toString(rawGameType)), _salt: _implSalt(),
abi.encode( _name: "FaultDisputeGame",
_params.gameType, _nick: string.concat("FaultDisputeGame_", vm.toString(rawGameType)),
_params.absolutePrestate, _args: DeployUtils.encodeConstructor(
_params.maxGameDepth, abi.encodeCall(
cfg.faultGameSplitDepth(), IFaultDisputeGame.__constructor__,
cfg.faultGameClockExtension(), (
_params.maxClockDuration, _params_.gameType,
_params.faultVm, _params_.absolutePrestate,
_params.weth, _params_.maxGameDepth,
IAnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")), cfg.faultGameSplitDepth(),
cfg.l2ChainID() Duration.wrap(uint64(cfg.faultGameClockExtension())),
_params_.maxClockDuration,
_params_.faultVm,
_params_.weth,
IAnchorStateRegistry(mustGetAddress("AnchorStateRegistryProxy")),
cfg.l2ChainID()
)
)
) )
) })
) )
); );
} else { } else {
_factory.setImplementation( _factory.setImplementation(
_params.gameType, _params_.gameType,
IDisputeGame( IDisputeGame(
_deploy( DeployUtils.create2AndSave({
"PermissionedDisputeGame", _save: this,
abi.encode( _salt: _implSalt(),
_params.gameType, _name: "PermissionedDisputeGame",
_params.absolutePrestate, _args: DeployUtils.encodeConstructor(
_params.maxGameDepth, abi.encodeCall(
cfg.faultGameSplitDepth(), IPermissionedDisputeGame.__constructor__,
cfg.faultGameClockExtension(), (
_params.maxClockDuration, _params_.gameType,
_params.faultVm, _params_.absolutePrestate,
_params.weth, _params_.maxGameDepth,
_params.anchorStateRegistry, cfg.faultGameSplitDepth(),
cfg.l2ChainID(), Duration.wrap(uint64(cfg.faultGameClockExtension())),
cfg.l2OutputOracleProposer(), _params_.maxClockDuration,
cfg.l2OutputOracleChallenger() _params_.faultVm,
_params_.weth,
_params_.anchorStateRegistry,
cfg.l2ChainID(),
cfg.l2OutputOracleProposer(),
cfg.l2OutputOracleChallenger()
)
)
) )
) })
) )
); );
} }
...@@ -1674,36 +1807,4 @@ contract Deploy is Deployer { ...@@ -1674,36 +1807,4 @@ contract Deploy is Deployer {
require(dac.bondSize() == daBondSize); require(dac.bondSize() == daBondSize);
require(dac.resolverRefundPercentage() == daResolverRefundPercentage); require(dac.resolverRefundPercentage() == daResolverRefundPercentage);
} }
/// @notice Deploys a contract via CREATE2.
/// @param _name The name of the contract.
/// @param _constructorParams The constructor parameters.
function _deploy(string memory _name, bytes memory _constructorParams) internal returns (address addr_) {
return _deploy(_name, _name, _constructorParams);
}
/// @notice Deploys a contract via CREATE2.
/// @param _name The name of the contract.
/// @param _nickname The nickname of the contract.
/// @param _constructorParams The constructor parameters.
function _deploy(
string memory _name,
string memory _nickname,
bytes memory _constructorParams
)
internal
returns (address addr_)
{
console.log("Deploying %s", _nickname);
bytes32 salt = _implSalt();
bytes memory initCode = abi.encodePacked(vm.getCode(_name), _constructorParams);
address preComputedAddress = vm.computeCreate2Address(salt, keccak256(initCode));
require(preComputedAddress.code.length == 0, "Deploy: contract already deployed");
assembly {
addr_ := create2(0, add(initCode, 0x20), mload(initCode), salt)
}
require(addr_ != address(0), "deployment failed");
save(_nickname, addr_);
console.log("%s deployed at %s", _nickname, addr_);
}
} }
...@@ -91,12 +91,14 @@ contract FPACOPS2 is Deploy, StdAssertions { ...@@ -91,12 +91,14 @@ contract FPACOPS2 is Deploy, StdAssertions {
function deployCannonDisputeGame() internal broadcast { function deployCannonDisputeGame() internal broadcast {
console.log("Deploying CannonFaultDisputeGame implementation"); console.log("Deploying CannonFaultDisputeGame implementation");
save( DeployUtils.create2AndSave({
"CannonFaultDisputeGame", _save: this,
address( _name: "FaultDisputeGame",
_deploy( _nick: "CannonFaultDisputeGame",
"FaultDisputeGame", _args: DeployUtils.encodeConstructor(
abi.encode( abi.encodeCall(
IFaultDisputeGame.__constructor__,
(
GameTypes.CANNON, GameTypes.CANNON,
loadMipsAbsolutePrestate(), loadMipsAbsolutePrestate(),
cfg.faultGameMaxDepth(), cfg.faultGameMaxDepth(),
...@@ -109,20 +111,22 @@ contract FPACOPS2 is Deploy, StdAssertions { ...@@ -109,20 +111,22 @@ contract FPACOPS2 is Deploy, StdAssertions {
cfg.l2ChainID() cfg.l2ChainID()
) )
) )
) ),
); _salt: _implSalt()
});
} }
/// @notice Deploys the PermissionedDisputeGame. /// @notice Deploys the PermissionedDisputeGame.
function deployPermissionedDisputeGame() internal broadcast { function deployPermissionedDisputeGame() internal broadcast {
console.log("Deploying PermissionedDisputeGame implementation"); console.log("Deploying PermissionedDisputeGame implementation");
save( DeployUtils.create2AndSave({
"PermissionedDisputeGame", _save: this,
address( _name: "PermissionedDisputeGame",
_deploy( _args: DeployUtils.encodeConstructor(
"PermissionedDisputeGame", abi.encodeCall(
abi.encode( IPermissionedDisputeGame.__constructor__,
(
GameTypes.PERMISSIONED_CANNON, GameTypes.PERMISSIONED_CANNON,
loadMipsAbsolutePrestate(), loadMipsAbsolutePrestate(),
cfg.faultGameMaxDepth(), cfg.faultGameMaxDepth(),
...@@ -137,8 +141,9 @@ contract FPACOPS2 is Deploy, StdAssertions { ...@@ -137,8 +141,9 @@ contract FPACOPS2 is Deploy, StdAssertions {
cfg.l2OutputOracleChallenger() cfg.l2OutputOracleChallenger()
) )
) )
) ),
); _salt: _implSalt()
});
} }
/// @notice Initializes the DelayedWETH proxy. /// @notice Initializes the DelayedWETH proxy.
......
...@@ -8,6 +8,7 @@ import { Artifacts } from "scripts/Artifacts.s.sol"; ...@@ -8,6 +8,7 @@ import { Artifacts } from "scripts/Artifacts.s.sol";
// Libraries // Libraries
import { LibString } from "@solady/utils/LibString.sol"; import { LibString } from "@solady/utils/LibString.sol";
import { Bytes } from "src/libraries/Bytes.sol";
// Contracts // Contracts
import { Proxy } from "src/universal/Proxy.sol"; import { Proxy } from "src/universal/Proxy.sol";
...@@ -198,6 +199,15 @@ library DeployUtils { ...@@ -198,6 +199,15 @@ library DeployUtils {
return address(uint160(uint256(keccak256(abi.encode(_sender, _identifier))))); return address(uint160(uint256(keccak256(abi.encode(_sender, _identifier)))));
} }
/// @notice Strips the first 4 bytes of `_data` and returns the remaining bytes
/// If `_data` is not greater than 4 bytes, it returns empty bytes type.
/// @param _data constructor arguments prefixed with a psuedo-constructor function signature
/// @return encodedData_ constructor arguments without the psuedo-constructor function signature prefix
function encodeConstructor(bytes memory _data) internal pure returns (bytes memory encodedData_) {
require(_data.length >= 4, "encodeConstructor takes in _data of length >= 4");
encodedData_ = Bytes.slice(_data, 4);
}
/// @notice Asserts that the given address is a valid contract address. /// @notice Asserts that the given address is a valid contract address.
/// @param _who Address to check. /// @param _who Address to check.
function assertValidContractAddress(address _who) internal view { function assertValidContractAddress(address _who) internal view {
......
...@@ -18,4 +18,6 @@ interface IL1CrossDomainMessenger is ICrossDomainMessenger { ...@@ -18,4 +18,6 @@ interface IL1CrossDomainMessenger is ICrossDomainMessenger {
function superchainConfig() external view returns (address); function superchainConfig() external view returns (address);
function systemConfig() external view returns (address); function systemConfig() external view returns (address);
function version() external view returns (string memory); function version() external view returns (string memory);
function __constructor__() external;
} }
...@@ -37,4 +37,6 @@ interface IL1ERC721Bridge is IERC721Bridge { ...@@ -37,4 +37,6 @@ interface IL1ERC721Bridge is IERC721Bridge {
function paused() external view returns (bool); function paused() external view returns (bool);
function superchainConfig() external view returns (ISuperchainConfig); function superchainConfig() external view returns (ISuperchainConfig);
function version() external view returns (string memory); function version() external view returns (string memory);
function __constructor__() external;
} }
...@@ -72,4 +72,6 @@ interface IL1StandardBridge is IStandardBridge { ...@@ -72,4 +72,6 @@ interface IL1StandardBridge is IStandardBridge {
function superchainConfig() external view returns (ISuperchainConfig); function superchainConfig() external view returns (ISuperchainConfig);
function systemConfig() external view returns (ISystemConfig); function systemConfig() external view returns (ISystemConfig);
function version() external view returns (string memory); function version() external view returns (string memory);
function __constructor__() external;
} }
...@@ -82,4 +82,6 @@ interface IOptimismPortal { ...@@ -82,4 +82,6 @@ interface IOptimismPortal {
function superchainConfig() external view returns (ISuperchainConfig); function superchainConfig() external view returns (ISuperchainConfig);
function systemConfig() external view returns (ISystemConfig); function systemConfig() external view returns (ISystemConfig);
function version() external pure returns (string memory); function version() external pure returns (string memory);
function __constructor__() external;
} }
...@@ -22,4 +22,6 @@ interface IResourceMetering { ...@@ -22,4 +22,6 @@ interface IResourceMetering {
event Initialized(uint8 version); event Initialized(uint8 version);
function params() external view returns (uint128 prevBaseFee, uint64 prevBoughtGas, uint64 prevBlockNum); // nosemgrep function params() external view returns (uint128 prevBaseFee, uint64 prevBoughtGas, uint64 prevBlockNum); // nosemgrep
function __constructor__() external;
} }
...@@ -79,4 +79,6 @@ interface ISystemConfigInterop { ...@@ -79,4 +79,6 @@ interface ISystemConfigInterop {
) )
external; external;
function version() external pure returns (string memory); function version() external pure returns (string memory);
function __constructor__() external;
} }
...@@ -3,13 +3,27 @@ pragma solidity ^0.8.0; ...@@ -3,13 +3,27 @@ pragma solidity ^0.8.0;
import { IFeeVault } from "src/universal/interfaces/IFeeVault.sol"; import { IFeeVault } from "src/universal/interfaces/IFeeVault.sol";
interface IBaseFeeVault is IFeeVault { interface IBaseFeeVault {
event Withdrawal(uint256 value, address to, address from);
event Withdrawal(uint256 value, address to, address from, IFeeVault.WithdrawalNetwork withdrawalNetwork);
receive() external payable;
function MIN_WITHDRAWAL_AMOUNT() external view returns (uint256);
function RECIPIENT() external view returns (address);
function WITHDRAWAL_NETWORK() external view returns (IFeeVault.WithdrawalNetwork);
function minWithdrawalAmount() external view returns (uint256 amount_);
function recipient() external view returns (address recipient_);
function totalProcessed() external view returns (uint256);
function withdraw() external;
function withdrawalNetwork() external view returns (IFeeVault.WithdrawalNetwork network_);
function version() external view returns (string memory); function version() external view returns (string memory);
function __constructor__( function __constructor__(
address _recipient, address _recipient,
uint256 _minWithdrawalAmount, uint256 _minWithdrawalAmount,
WithdrawalNetwork _withdrawalNetwork IFeeVault.WithdrawalNetwork _withdrawalNetwork
) )
external; external;
} }
...@@ -11,4 +11,6 @@ interface IETHLiquidity { ...@@ -11,4 +11,6 @@ interface IETHLiquidity {
function burn() external payable; function burn() external payable;
function mint(uint256 _amount) external; function mint(uint256 _amount) external;
function version() external view returns (string memory); function version() external view returns (string memory);
function __constructor__() external;
} }
...@@ -20,4 +20,6 @@ interface IGasPriceOracle { ...@@ -20,4 +20,6 @@ interface IGasPriceOracle {
function setEcotone() external; function setEcotone() external;
function setFjord() external; function setFjord() external;
function version() external view returns (string memory); function version() external view returns (string memory);
function __constructor__() external;
} }
...@@ -36,4 +36,6 @@ interface IL1Block { ...@@ -36,4 +36,6 @@ interface IL1Block {
function setL1BlockValuesEcotone() external; function setL1BlockValuesEcotone() external;
function timestamp() external view returns (uint64); function timestamp() external view returns (uint64);
function version() external pure returns (string memory); function version() external pure returns (string memory);
function __constructor__() external;
} }
...@@ -55,4 +55,6 @@ interface IL1BlockIsthmus { ...@@ -55,4 +55,6 @@ interface IL1BlockIsthmus {
function setL1BlockValuesIsthmus() external; function setL1BlockValuesIsthmus() external;
function timestamp() external view returns (uint64); function timestamp() external view returns (uint64);
function version() external pure returns (string memory); function version() external pure returns (string memory);
function __constructor__() external;
} }
...@@ -3,13 +3,27 @@ pragma solidity ^0.8.0; ...@@ -3,13 +3,27 @@ pragma solidity ^0.8.0;
import { IFeeVault } from "src/universal/interfaces/IFeeVault.sol"; import { IFeeVault } from "src/universal/interfaces/IFeeVault.sol";
interface IL1FeeVault is IFeeVault { interface IL1FeeVault {
event Withdrawal(uint256 value, address to, address from);
event Withdrawal(uint256 value, address to, address from, IFeeVault.WithdrawalNetwork withdrawalNetwork);
receive() external payable;
function MIN_WITHDRAWAL_AMOUNT() external view returns (uint256);
function RECIPIENT() external view returns (address);
function WITHDRAWAL_NETWORK() external view returns (IFeeVault.WithdrawalNetwork);
function minWithdrawalAmount() external view returns (uint256 amount_);
function recipient() external view returns (address recipient_);
function totalProcessed() external view returns (uint256);
function withdraw() external;
function withdrawalNetwork() external view returns (IFeeVault.WithdrawalNetwork network_);
function version() external view returns (string memory); function version() external view returns (string memory);
function __constructor__( function __constructor__(
address _recipient, address _recipient,
uint256 _minWithdrawalAmount, uint256 _minWithdrawalAmount,
WithdrawalNetwork _withdrawalNetwork IFeeVault.WithdrawalNetwork _withdrawalNetwork
) )
external; external;
} }
...@@ -95,4 +95,6 @@ interface IL2StandardBridgeInterop is IStandardBridge { ...@@ -95,4 +95,6 @@ interface IL2StandardBridgeInterop is IStandardBridge {
function convert(address _from, address _to, uint256 _amount) external; function convert(address _from, address _to, uint256 _amount) external;
function version() external pure returns (string memory); function version() external pure returns (string memory);
function __constructor__() external;
} }
...@@ -21,4 +21,6 @@ interface IL2ToL1MessagePasser { ...@@ -21,4 +21,6 @@ interface IL2ToL1MessagePasser {
function messageNonce() external view returns (uint256); function messageNonce() external view returns (uint256);
function sentMessages(bytes32) external view returns (bool); function sentMessages(bytes32) external view returns (bool);
function version() external view returns (string memory); function version() external view returns (string memory);
function __constructor__() external;
} }
...@@ -3,14 +3,28 @@ pragma solidity ^0.8.0; ...@@ -3,14 +3,28 @@ pragma solidity ^0.8.0;
import { IFeeVault } from "src/universal/interfaces/IFeeVault.sol"; import { IFeeVault } from "src/universal/interfaces/IFeeVault.sol";
interface ISequencerFeeVault is IFeeVault { interface ISequencerFeeVault {
event Withdrawal(uint256 value, address to, address from);
event Withdrawal(uint256 value, address to, address from, IFeeVault.WithdrawalNetwork withdrawalNetwork);
receive() external payable;
function MIN_WITHDRAWAL_AMOUNT() external view returns (uint256);
function RECIPIENT() external view returns (address);
function WITHDRAWAL_NETWORK() external view returns (IFeeVault.WithdrawalNetwork);
function minWithdrawalAmount() external view returns (uint256 amount_);
function recipient() external view returns (address recipient_);
function totalProcessed() external view returns (uint256);
function withdraw() external;
function withdrawalNetwork() external view returns (IFeeVault.WithdrawalNetwork network_);
function version() external view returns (string memory); function version() external view returns (string memory);
function l1FeeWallet() external view returns (address); function l1FeeWallet() external view returns (address);
function __constructor__( function __constructor__(
address _recipient, address _recipient,
uint256 _minWithdrawalAmount, uint256 _minWithdrawalAmount,
WithdrawalNetwork _withdrawalNetwork IFeeVault.WithdrawalNetwork _withdrawalNetwork
) )
external; external;
} }
...@@ -53,4 +53,6 @@ interface ISuperchainERC20Errors { ...@@ -53,4 +53,6 @@ interface ISuperchainERC20Errors {
/// @title ISuperchainERC20 /// @title ISuperchainERC20
/// @notice Combines Solady's ERC20 interface with the SuperchainERC20Extensions interface. /// @notice Combines Solady's ERC20 interface with the SuperchainERC20Extensions interface.
interface ISuperchainERC20 is IERC20Solady, ISuperchainERC20Extensions, ISuperchainERC20Errors { } interface ISuperchainERC20 is IERC20Solady, ISuperchainERC20Extensions, ISuperchainERC20Errors {
function __constructor__() external;
}
...@@ -30,4 +30,6 @@ interface ISuperchainWETH { ...@@ -30,4 +30,6 @@ interface ISuperchainWETH {
function transferFrom(address src, address dst, uint256 wad) external returns (bool); function transferFrom(address src, address dst, uint256 wad) external returns (bool);
function version() external view returns (string memory); function version() external view returns (string memory);
function withdraw(uint256 wad) external; function withdraw(uint256 wad) external;
function __constructor__() external;
} }
...@@ -27,4 +27,6 @@ interface IDelayedWETH is IWETH { ...@@ -27,4 +27,6 @@ interface IDelayedWETH is IWETH {
function withdraw(address _guy, uint256 _wad) external; function withdraw(address _guy, uint256 _wad) external;
function withdrawals(address _owner, address _guy) external view returns (uint256, uint256); function withdrawals(address _owner, address _guy) external view returns (uint256, uint256);
function version() external view returns (string memory); function version() external view returns (string memory);
function __constructor__(uint256 _delay) external;
} }
...@@ -10,4 +10,6 @@ interface IAddressManager is IOwnable { ...@@ -10,4 +10,6 @@ interface IAddressManager is IOwnable {
function getAddress(string memory _name) external view returns (address); function getAddress(string memory _name) external view returns (address);
function setAddress(string memory _name, address _address) external; function setAddress(string memory _name, address _address) external;
function __constructor__() external;
} }
...@@ -17,4 +17,6 @@ interface IDeployerWhitelist { ...@@ -17,4 +17,6 @@ interface IDeployerWhitelist {
function setWhitelistedDeployer(address _deployer, bool _isWhitelisted) external; function setWhitelistedDeployer(address _deployer, bool _isWhitelisted) external;
function version() external view returns (string memory); function version() external view returns (string memory);
function whitelist(address) external view returns (bool); function whitelist(address) external view returns (bool);
function __constructor__() external;
} }
...@@ -11,4 +11,6 @@ interface IL1BlockNumber is ISemver { ...@@ -11,4 +11,6 @@ interface IL1BlockNumber is ISemver {
receive() external payable; receive() external payable;
function getL1BlockNumber() external view returns (uint256); function getL1BlockNumber() external view returns (uint256);
function __constructor__() external;
} }
...@@ -8,4 +8,6 @@ import { ISemver } from "src/universal/interfaces/ISemver.sol"; ...@@ -8,4 +8,6 @@ import { ISemver } from "src/universal/interfaces/ISemver.sol";
interface ILegacyMessagePasser is ISemver { interface ILegacyMessagePasser is ISemver {
function passMessageToL1(bytes memory _message) external; function passMessageToL1(bytes memory _message) external;
function sentMessages(bytes32) external view returns (bool); function sentMessages(bytes32) external view returns (bool);
function __constructor__() external;
} }
...@@ -35,4 +35,6 @@ interface ICrossDomainMessenger { ...@@ -35,4 +35,6 @@ interface ICrossDomainMessenger {
function sendMessage(address _target, bytes memory _message, uint32 _minGasLimit) external payable; function sendMessage(address _target, bytes memory _message, uint32 _minGasLimit) external payable;
function successfulMessages(bytes32) external view returns (bool); function successfulMessages(bytes32) external view returns (bool);
function xDomainMessageSender() external view returns (address); function xDomainMessageSender() external view returns (address);
function __constructor__() external;
} }
...@@ -44,4 +44,6 @@ interface IERC721Bridge { ...@@ -44,4 +44,6 @@ interface IERC721Bridge {
function messenger() external view returns (ICrossDomainMessenger); function messenger() external view returns (ICrossDomainMessenger);
function otherBridge() external view returns (IERC721Bridge); function otherBridge() external view returns (IERC721Bridge);
function paused() external view returns (bool); function paused() external view returns (bool);
function __constructor__() external;
} }
...@@ -20,4 +20,6 @@ interface IFeeVault { ...@@ -20,4 +20,6 @@ interface IFeeVault {
function totalProcessed() external view returns (uint256); function totalProcessed() external view returns (uint256);
function withdraw() external; function withdraw() external;
function withdrawalNetwork() external view returns (WithdrawalNetwork network_); function withdrawalNetwork() external view returns (WithdrawalNetwork network_);
function __constructor__() external;
} }
...@@ -9,4 +9,6 @@ interface IOwnable { ...@@ -9,4 +9,6 @@ interface IOwnable {
function owner() external view returns (address); function owner() external view returns (address);
function renounceOwnership() external; function renounceOwnership() external;
function transferOwnership(address newOwner) external; // nosemgrep function transferOwnership(address newOwner) external; // nosemgrep
function __constructor__() external;
} }
...@@ -61,4 +61,6 @@ interface IStandardBridge { ...@@ -61,4 +61,6 @@ interface IStandardBridge {
function messenger() external view returns (ICrossDomainMessenger); function messenger() external view returns (ICrossDomainMessenger);
function otherBridge() external view returns (IStandardBridge); function otherBridge() external view returns (IStandardBridge);
function paused() external view returns (bool); function paused() external view returns (bool);
function __constructor__() external;
} }
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