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
......
...@@ -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