Commit d8cb523d authored by smartcontracts's avatar smartcontracts Committed by GitHub

fix(ct): correct input and return argument formatting (#12131)

Standardizes the input and return argument formatting everywhere.
parent c6d3adf6
......@@ -19,9 +19,25 @@ tests/
.semgrep_logs/
op-chain-ops/script/testdata
op-chain-ops/script/testdata/scripts/ScriptExample.s.sol
packages/*/node_modules
packages/*/test
# Autogenerated solidity library
# TODO: Define these exclusions inside of the semgrep rules once those rules
# are all defined locally in the repository instead of the semgrep app.
# Contracts: autogenerated solidity library
packages/contracts-bedrock/scripts/libraries/Solarray.sol
# Contracts: vendor interfaces
packages/contracts-bedrock/scripts/interfaces/IGnosisSafe.sol
packages/contracts-bedrock/src/EAS/
# Contracts: deliberate exclusions
packages/contracts-bedrock/src/universal/WETH98.sol
packages/contracts-bedrock/src/universal/interfaces/IWETH.sol
packages/contracts-bedrock/src/L2/SuperchainWETH.sol
packages/contracts-bedrock/src/L2/interfaces/ISuperchainWETH.sol
packages/contracts-bedrock/src/governance/GovernanceToken.sol
packages/contracts-bedrock/src/governance/interfaces/IGovernanceToken.sol
......@@ -49,8 +49,8 @@ contract DeployAuthSystemInput is CommonBase {
contract DeployAuthSystemOutput is CommonBase {
Safe internal _safe;
function set(bytes4 sel, address _address) public {
if (sel == this.safe.selector) _safe = Safe(payable(_address));
function set(bytes4 _sel, address _address) public {
if (_sel == this.safe.selector) _safe = Safe(payable(_address));
else revert("DeployAuthSystemOutput: unknown selector");
}
......
......@@ -64,41 +64,41 @@ contract DeployImplementationsInput is BaseDeployIO {
string internal _standardVersionsToml;
function set(bytes4 sel, uint256 _value) public {
function set(bytes4 _sel, uint256 _value) public {
require(_value != 0, "DeployImplementationsInput: cannot set zero value");
if (sel == this.withdrawalDelaySeconds.selector) {
if (_sel == this.withdrawalDelaySeconds.selector) {
_withdrawalDelaySeconds = _value;
} else if (sel == this.minProposalSizeBytes.selector) {
} else if (_sel == this.minProposalSizeBytes.selector) {
_minProposalSizeBytes = _value;
} else if (sel == this.challengePeriodSeconds.selector) {
} else if (_sel == this.challengePeriodSeconds.selector) {
require(_value <= type(uint64).max, "DeployImplementationsInput: challengePeriodSeconds too large");
_challengePeriodSeconds = _value;
} else if (sel == this.proofMaturityDelaySeconds.selector) {
} else if (_sel == this.proofMaturityDelaySeconds.selector) {
_proofMaturityDelaySeconds = _value;
} else if (sel == this.disputeGameFinalityDelaySeconds.selector) {
} else if (_sel == this.disputeGameFinalityDelaySeconds.selector) {
_disputeGameFinalityDelaySeconds = _value;
} else {
revert("DeployImplementationsInput: unknown selector");
}
}
function set(bytes4 sel, string memory _value) public {
function set(bytes4 _sel, string memory _value) public {
require(!LibString.eq(_value, ""), "DeployImplementationsInput: cannot set empty string");
if (sel == this.release.selector) _release = _value;
else if (sel == this.standardVersionsToml.selector) _standardVersionsToml = _value;
if (_sel == this.release.selector) _release = _value;
else if (_sel == this.standardVersionsToml.selector) _standardVersionsToml = _value;
else revert("DeployImplementationsInput: unknown selector");
}
function set(bytes4 sel, address _addr) public {
function set(bytes4 _sel, address _addr) public {
require(_addr != address(0), "DeployImplementationsInput: cannot set zero address");
if (sel == this.superchainConfigProxy.selector) _superchainConfigProxy = SuperchainConfig(_addr);
else if (sel == this.protocolVersionsProxy.selector) _protocolVersionsProxy = ProtocolVersions(_addr);
if (_sel == this.superchainConfigProxy.selector) _superchainConfigProxy = SuperchainConfig(_addr);
else if (_sel == this.protocolVersionsProxy.selector) _protocolVersionsProxy = ProtocolVersions(_addr);
else revert("DeployImplementationsInput: unknown selector");
}
function set(bytes4 sel, bytes32 _value) public {
if (sel == this.salt.selector) _salt = _value;
function set(bytes4 _sel, bytes32 _value) public {
if (_sel == this.salt.selector) _salt = _value;
else revert("DeployImplementationsInput: unknown selector");
}
......@@ -179,22 +179,22 @@ contract DeployImplementationsOutput is BaseDeployIO {
OptimismMintableERC20Factory internal _optimismMintableERC20FactoryImpl;
DisputeGameFactory internal _disputeGameFactoryImpl;
function set(bytes4 sel, address _addr) public {
function set(bytes4 _sel, address _addr) public {
require(_addr != address(0), "DeployImplementationsOutput: cannot set zero address");
// forgefmt: disable-start
if (sel == this.opcmProxy.selector) _opcmProxy = OPContractsManager(payable(_addr));
else if (sel == this.opcmImpl.selector) _opcmImpl = OPContractsManager(payable(_addr));
else if (sel == this.optimismPortalImpl.selector) _optimismPortalImpl = OptimismPortal2(payable(_addr));
else if (sel == this.delayedWETHImpl.selector) _delayedWETHImpl = DelayedWETH(payable(_addr));
else if (sel == this.preimageOracleSingleton.selector) _preimageOracleSingleton = PreimageOracle(_addr);
else if (sel == this.mipsSingleton.selector) _mipsSingleton = MIPS(_addr);
else if (sel == this.systemConfigImpl.selector) _systemConfigImpl = SystemConfig(_addr);
else if (sel == this.l1CrossDomainMessengerImpl.selector) _l1CrossDomainMessengerImpl = L1CrossDomainMessenger(_addr);
else if (sel == this.l1ERC721BridgeImpl.selector) _l1ERC721BridgeImpl = L1ERC721Bridge(_addr);
else if (sel == this.l1StandardBridgeImpl.selector) _l1StandardBridgeImpl = L1StandardBridge(payable(_addr));
else if (sel == this.optimismMintableERC20FactoryImpl.selector) _optimismMintableERC20FactoryImpl = OptimismMintableERC20Factory(_addr);
else if (sel == this.disputeGameFactoryImpl.selector) _disputeGameFactoryImpl = DisputeGameFactory(_addr);
if (_sel == this.opcmProxy.selector) _opcmProxy = OPContractsManager(payable(_addr));
else if (_sel == this.opcmImpl.selector) _opcmImpl = OPContractsManager(payable(_addr));
else if (_sel == this.optimismPortalImpl.selector) _optimismPortalImpl = OptimismPortal2(payable(_addr));
else if (_sel == this.delayedWETHImpl.selector) _delayedWETHImpl = DelayedWETH(payable(_addr));
else if (_sel == this.preimageOracleSingleton.selector) _preimageOracleSingleton = PreimageOracle(_addr);
else if (_sel == this.mipsSingleton.selector) _mipsSingleton = MIPS(_addr);
else if (_sel == this.systemConfigImpl.selector) _systemConfigImpl = SystemConfig(_addr);
else if (_sel == this.l1CrossDomainMessengerImpl.selector) _l1CrossDomainMessengerImpl = L1CrossDomainMessenger(_addr);
else if (_sel == this.l1ERC721BridgeImpl.selector) _l1ERC721BridgeImpl = L1ERC721Bridge(_addr);
else if (_sel == this.l1StandardBridgeImpl.selector) _l1StandardBridgeImpl = L1StandardBridge(payable(_addr));
else if (_sel == this.optimismMintableERC20FactoryImpl.selector) _optimismMintableERC20FactoryImpl = OptimismMintableERC20Factory(_addr);
else if (_sel == this.disputeGameFactoryImpl.selector) _disputeGameFactoryImpl = DisputeGameFactory(_addr);
else revert("DeployImplementationsOutput: unknown selector");
// forgefmt: disable-end
}
......
......@@ -164,24 +164,24 @@ contract DeployOPChainOutput is BaseDeployIO {
DelayedWETH internal _delayedWETHPermissionedGameProxy;
DelayedWETH internal _delayedWETHPermissionlessGameProxy;
function set(bytes4 sel, address _addr) public {
function set(bytes4 _sel, address _addr) public {
require(_addr != address(0), "DeployOPChainOutput: cannot set zero address");
// forgefmt: disable-start
if (sel == this.opChainProxyAdmin.selector) _opChainProxyAdmin = ProxyAdmin(_addr) ;
else if (sel == this.addressManager.selector) _addressManager = AddressManager(_addr) ;
else if (sel == this.l1ERC721BridgeProxy.selector) _l1ERC721BridgeProxy = L1ERC721Bridge(_addr) ;
else if (sel == this.systemConfigProxy.selector) _systemConfigProxy = SystemConfig(_addr) ;
else if (sel == this.optimismMintableERC20FactoryProxy.selector) _optimismMintableERC20FactoryProxy = OptimismMintableERC20Factory(_addr) ;
else if (sel == this.l1StandardBridgeProxy.selector) _l1StandardBridgeProxy = L1StandardBridge(payable(_addr)) ;
else if (sel == this.l1CrossDomainMessengerProxy.selector) _l1CrossDomainMessengerProxy = L1CrossDomainMessenger(_addr) ;
else if (sel == this.optimismPortalProxy.selector) _optimismPortalProxy = OptimismPortal2(payable(_addr)) ;
else if (sel == this.disputeGameFactoryProxy.selector) _disputeGameFactoryProxy = DisputeGameFactory(_addr) ;
else if (sel == this.anchorStateRegistryProxy.selector) _anchorStateRegistryProxy = AnchorStateRegistry(_addr) ;
else if (sel == this.anchorStateRegistryImpl.selector) _anchorStateRegistryImpl = AnchorStateRegistry(_addr) ;
else if (sel == this.faultDisputeGame.selector) _faultDisputeGame = FaultDisputeGame(_addr) ;
else if (sel == this.permissionedDisputeGame.selector) _permissionedDisputeGame = PermissionedDisputeGame(_addr) ;
else if (sel == this.delayedWETHPermissionedGameProxy.selector) _delayedWETHPermissionedGameProxy = DelayedWETH(payable(_addr)) ;
else if (sel == this.delayedWETHPermissionlessGameProxy.selector) _delayedWETHPermissionlessGameProxy = DelayedWETH(payable(_addr)) ;
if (_sel == this.opChainProxyAdmin.selector) _opChainProxyAdmin = ProxyAdmin(_addr) ;
else if (_sel == this.addressManager.selector) _addressManager = AddressManager(_addr) ;
else if (_sel == this.l1ERC721BridgeProxy.selector) _l1ERC721BridgeProxy = L1ERC721Bridge(_addr) ;
else if (_sel == this.systemConfigProxy.selector) _systemConfigProxy = SystemConfig(_addr) ;
else if (_sel == this.optimismMintableERC20FactoryProxy.selector) _optimismMintableERC20FactoryProxy = OptimismMintableERC20Factory(_addr) ;
else if (_sel == this.l1StandardBridgeProxy.selector) _l1StandardBridgeProxy = L1StandardBridge(payable(_addr)) ;
else if (_sel == this.l1CrossDomainMessengerProxy.selector) _l1CrossDomainMessengerProxy = L1CrossDomainMessenger(_addr) ;
else if (_sel == this.optimismPortalProxy.selector) _optimismPortalProxy = OptimismPortal2(payable(_addr)) ;
else if (_sel == this.disputeGameFactoryProxy.selector) _disputeGameFactoryProxy = DisputeGameFactory(_addr) ;
else if (_sel == this.anchorStateRegistryProxy.selector) _anchorStateRegistryProxy = AnchorStateRegistry(_addr) ;
else if (_sel == this.anchorStateRegistryImpl.selector) _anchorStateRegistryImpl = AnchorStateRegistry(_addr) ;
else if (_sel == this.faultDisputeGame.selector) _faultDisputeGame = FaultDisputeGame(_addr) ;
else if (_sel == this.permissionedDisputeGame.selector) _permissionedDisputeGame = PermissionedDisputeGame(_addr) ;
else if (_sel == this.delayedWETHPermissionedGameProxy.selector) _delayedWETHPermissionedGameProxy = DelayedWETH(payable(_addr)) ;
else if (_sel == this.delayedWETHPermissionlessGameProxy.selector) _delayedWETHPermissionlessGameProxy = DelayedWETH(payable(_addr)) ;
else revert("DeployOPChainOutput: unknown selector");
// forgefmt: disable-end
}
......
......@@ -164,13 +164,13 @@ contract DeploySuperchainOutput is BaseDeployIO {
// This method lets each field be set individually. The selector of an output's getter method
// is used to determine which field to set.
function set(bytes4 sel, address _address) public {
function set(bytes4 _sel, address _address) public {
require(_address != address(0), "DeploySuperchainOutput: cannot set zero address");
if (sel == this.superchainProxyAdmin.selector) _superchainProxyAdmin = ProxyAdmin(_address);
else if (sel == this.superchainConfigImpl.selector) _superchainConfigImpl = SuperchainConfig(_address);
else if (sel == this.superchainConfigProxy.selector) _superchainConfigProxy = SuperchainConfig(_address);
else if (sel == this.protocolVersionsImpl.selector) _protocolVersionsImpl = ProtocolVersions(_address);
else if (sel == this.protocolVersionsProxy.selector) _protocolVersionsProxy = ProtocolVersions(_address);
if (_sel == this.superchainProxyAdmin.selector) _superchainProxyAdmin = ProxyAdmin(_address);
else if (_sel == this.superchainConfigImpl.selector) _superchainConfigImpl = SuperchainConfig(_address);
else if (_sel == this.superchainConfigProxy.selector) _superchainConfigProxy = SuperchainConfig(_address);
else if (_sel == this.protocolVersionsImpl.selector) _protocolVersionsImpl = ProtocolVersions(_address);
else if (_sel == this.protocolVersionsProxy.selector) _protocolVersionsProxy = ProtocolVersions(_address);
else revert("DeploySuperchainOutput: unknown selector");
}
......
......@@ -16,7 +16,7 @@ temp_dir=$(mktemp -d)
trap 'rm -rf "$temp_dir"' EXIT
# Exit early if semver-lock.json has not changed.
if ! git diff origin/develop...HEAD --name-only | grep -q "$SEMVER_LOCK"; then
if ! { git diff origin/develop...HEAD --name-only; git diff --name-only; git diff --cached --name-only; } | grep -q "$SEMVER_LOCK"; then
echo "No changes detected in semver-lock.json"
exit 0
fi
......@@ -71,9 +71,12 @@ for contract in $changed_contracts; do
has_errors=true
fi
# TODO: Use an existing semver comparison function since this will only
# check if the version has changed at all and not that the version has
# increased properly.
# Check if the version changed.
if [ "$old_version" = "$new_version" ]; then
echo "❌ Error: src/$contract has changes in semver-lock.json but no version change"
echo "❌ Error: $contract has changes in semver-lock.json but no version change"
echo " Old version: $old_version"
echo " New version: $new_version"
has_errors=true
......
......@@ -281,11 +281,11 @@ contract Deploy is Deployer {
/// @notice Deploy a new OP Chain using an existing SuperchainConfig and ProtocolVersions
/// @param _superchainConfigProxy Address of the existing SuperchainConfig proxy
/// @param _protocolVersionsProxy Address of the existing ProtocolVersions proxy
/// @param includeDump Whether to include a state dump after deployment
/// @param _includeDump Whether to include a state dump after deployment
function runWithSuperchain(
address payable _superchainConfigProxy,
address payable _protocolVersionsProxy,
bool includeDump
bool _includeDump
)
public
{
......@@ -306,7 +306,7 @@ contract Deploy is Deployer {
_run(false);
if (includeDump) {
if (_includeDump) {
vm.dumpState(Config.stateDumpPath(""));
}
}
......
......@@ -94,8 +94,8 @@ contract DeployConfig is Script {
function read(string memory _path) public {
console.log("DeployConfig: reading file %s", _path);
try vm.readFile(_path) returns (string memory data) {
_json = data;
try vm.readFile(_path) returns (string memory data_) {
_json = data_;
} catch {
require(false, string.concat("Cannot find deploy config file at ", _path));
}
......@@ -191,14 +191,14 @@ contract DeployConfig is Script {
}
function l1StartingBlockTag() public returns (bytes32) {
try vm.parseJsonBytes32(_json, "$.l1StartingBlockTag") returns (bytes32 tag) {
return tag;
try vm.parseJsonBytes32(_json, "$.l1StartingBlockTag") returns (bytes32 tag_) {
return tag_;
} catch {
try vm.parseJsonString(_json, "$.l1StartingBlockTag") returns (string memory tag) {
return _getBlockByTag(tag);
try vm.parseJsonString(_json, "$.l1StartingBlockTag") returns (string memory tag_) {
return _getBlockByTag(tag_);
} catch {
try vm.parseJsonUint(_json, "$.l1StartingBlockTag") returns (uint256 tag) {
return _getBlockByTag(vm.toString(tag));
try vm.parseJsonUint(_json, "$.l1StartingBlockTag") returns (uint256 tag_) {
return _getBlockByTag(vm.toString(tag_));
} catch { }
}
}
......@@ -266,32 +266,48 @@ contract DeployConfig is Script {
return abi.decode(res, (bytes32));
}
function _readOr(string memory json, string memory key, bool defaultValue) internal view returns (bool) {
return vm.keyExistsJson(json, key) ? json.readBool(key) : defaultValue;
function _readOr(string memory _jsonInp, string memory _key, bool _defaultValue) internal view returns (bool) {
return vm.keyExistsJson(_jsonInp, _key) ? _jsonInp.readBool(_key) : _defaultValue;
}
function _readOr(string memory json, string memory key, uint256 defaultValue) internal view returns (uint256) {
return (vm.keyExistsJson(json, key) && !_isNull(json, key)) ? json.readUint(key) : defaultValue;
function _readOr(
string memory _jsonInp,
string memory _key,
uint256 _defaultValue
)
internal
view
returns (uint256)
{
return (vm.keyExistsJson(_jsonInp, _key) && !_isNull(_json, _key)) ? _jsonInp.readUint(_key) : _defaultValue;
}
function _readOr(string memory json, string memory key, address defaultValue) internal view returns (address) {
return vm.keyExistsJson(json, key) ? json.readAddress(key) : defaultValue;
function _readOr(
string memory _jsonInp,
string memory _key,
address _defaultValue
)
internal
view
returns (address)
{
return vm.keyExistsJson(_jsonInp, _key) ? _jsonInp.readAddress(_key) : _defaultValue;
}
function _isNull(string memory json, string memory key) internal pure returns (bool) {
string memory value = json.readString(key);
function _isNull(string memory _jsonInp, string memory _key) internal pure returns (bool) {
string memory value = _jsonInp.readString(_key);
return (keccak256(bytes(value)) == keccak256(bytes("null")));
}
function _readOr(
string memory json,
string memory key,
string memory defaultValue
string memory _jsonInp,
string memory _key,
string memory _defaultValue
)
internal
view
returns (string memory)
{
return vm.keyExists(json, key) ? json.readString(key) : defaultValue;
return vm.keyExists(_jsonInp, _key) ? _jsonInp.readString(_key) : _defaultValue;
}
}
......@@ -65,45 +65,45 @@ library Config {
/// @notice Returns the path on the local filesystem where the deployment artifact is
/// written to disk after doing a deployment.
function deploymentOutfile() internal view returns (string memory _env) {
_env = vm.envOr(
function deploymentOutfile() internal view returns (string memory env_) {
env_ = vm.envOr(
"DEPLOYMENT_OUTFILE",
string.concat(vm.projectRoot(), "/deployments/", vm.toString(block.chainid), "-deploy.json")
);
}
/// @notice Returns the path on the local filesystem where the deploy config is
function deployConfigPath() internal view returns (string memory _env) {
function deployConfigPath() internal view returns (string memory env_) {
if (vm.isContext(VmSafe.ForgeContext.TestGroup)) {
_env = string.concat(vm.projectRoot(), "/deploy-config/hardhat.json");
env_ = string.concat(vm.projectRoot(), "/deploy-config/hardhat.json");
} else {
_env = vm.envOr("DEPLOY_CONFIG_PATH", string(""));
require(bytes(_env).length > 0, "Config: must set DEPLOY_CONFIG_PATH to filesystem path of deploy config");
env_ = vm.envOr("DEPLOY_CONFIG_PATH", string(""));
require(bytes(env_).length > 0, "Config: must set DEPLOY_CONFIG_PATH to filesystem path of deploy config");
}
}
/// @notice Returns the chainid from the EVM context or the value of the CHAIN_ID env var as
/// an override.
function chainID() internal view returns (uint256 _env) {
_env = vm.envOr("CHAIN_ID", block.chainid);
function chainID() internal view returns (uint256 env_) {
env_ = vm.envOr("CHAIN_ID", block.chainid);
}
/// @notice Returns the value of the env var CONTRACT_ADDRESSES_PATH which is a JSON key/value
/// pair of contract names and their addresses. Each key/value pair is passed to `save`
/// which then backs the `getAddress` function.
function contractAddressesPath() internal view returns (string memory _env) {
_env = vm.envOr("CONTRACT_ADDRESSES_PATH", string(""));
function contractAddressesPath() internal view returns (string memory env_) {
env_ = vm.envOr("CONTRACT_ADDRESSES_PATH", string(""));
}
/// @notice The CREATE2 salt to be used when deploying the implementations.
function implSalt() internal view returns (string memory _env) {
_env = vm.envOr("IMPL_SALT", string("ethers phoenix"));
function implSalt() internal view returns (string memory env_) {
env_ = vm.envOr("IMPL_SALT", string("ethers phoenix"));
}
/// @notice Returns the path that the state dump file should be written to or read from
/// on the local filesystem.
function stateDumpPath(string memory _suffix) internal view returns (string memory _env) {
_env = vm.envOr(
function stateDumpPath(string memory _suffix) internal view returns (string memory env_) {
env_ = vm.envOr(
"STATE_DUMP_PATH",
string.concat(vm.projectRoot(), "/state-dump-", vm.toString(block.chainid), _suffix, ".json")
);
......@@ -112,13 +112,13 @@ library Config {
/// @notice Returns the name of the file that the forge deployment artifact is written to on the local
/// filesystem. By default, it is the name of the deploy script with the suffix `-latest.json`.
/// This was useful for creating hardhat deploy style artifacts and will be removed in a future release.
function deployFile(string memory _sig) internal view returns (string memory _env) {
_env = vm.envOr("DEPLOY_FILE", string.concat(_sig, "-latest.json"));
function deployFile(string memory _sig) internal view returns (string memory env_) {
env_ = vm.envOr("DEPLOY_FILE", string.concat(_sig, "-latest.json"));
}
/// @notice Returns the private key that is used to configure drippie.
function drippieOwnerPrivateKey() internal view returns (uint256 _env) {
_env = vm.envUint("DRIPPIE_OWNER_PRIVATE_KEY");
function drippieOwnerPrivateKey() internal view returns (uint256 env_) {
env_ = vm.envUint("DRIPPIE_OWNER_PRIVATE_KEY");
}
/// @notice Returns the OutputMode for genesis allocs generation.
......@@ -139,8 +139,8 @@ library Config {
}
/// @notice Returns true if multithreaded Cannon is used for the deployment.
function useMultithreadedCannon() internal view returns (bool _enabled) {
_enabled = vm.envOr("USE_MT_CANNON", false);
function useMultithreadedCannon() internal view returns (bool enabled_) {
enabled_ = vm.envOr("USE_MT_CANNON", false);
}
/// @notice Returns the latest fork to use for genesis allocs generation.
......
......@@ -268,13 +268,13 @@ library ForgeArtifacts {
/// @notice Returns the function ABIs of all L1 contracts.
function getContractFunctionAbis(
string memory path,
string[] memory pathExcludes
string memory _path,
string[] memory _pathExcludes
)
internal
returns (Abi[] memory abis_)
{
string[] memory contractNames = getContractNames(path, pathExcludes);
string[] memory contractNames = getContractNames(_path, _pathExcludes);
abis_ = new Abi[](contractNames.length);
for (uint256 i; i < contractNames.length; i++) {
......
......@@ -40,8 +40,8 @@ contract PeripheryDeployConfig is Script {
constructor(string memory _path) {
console.log("PeripheryDeployConfig: reading file %s", _path);
try vm.readFile(_path) returns (string memory data) {
_json = data;
try vm.readFile(_path) returns (string memory data_) {
_json = data_;
} catch {
console.log("Warning: unable to read config. Do not deploy unless you are not using config.");
return;
......
......@@ -66,8 +66,8 @@ contract DrippieConfig is Script {
constructor(string memory _path) {
// Load the configuration file.
console.log("DrippieConfig: reading file %s", _path);
try vm.readFile(_path) returns (string memory data) {
_json = data;
try vm.readFile(_path) returns (string memory data_) {
_json = data_;
} catch {
console.log("WARNING: unable to read config, do not deploy unless you are not using config");
return;
......
......@@ -103,14 +103,14 @@ contract ManageDrippie is Script {
/// @notice Generates the data for a Gelato task that would trigger a drip.
/// @param _drippie The drippie contract.
/// @param _name The name of the drip.
/// @return _taskData Gelato task data.
/// @return taskData_ Gelato task data.
function _makeGelatoDripTaskData(
Drippie _drippie,
string memory _name
)
internal
view
returns (GelatoTaskData memory _taskData)
returns (GelatoTaskData memory taskData_)
{
// Get the drip interval.
uint256 dripInterval = _drippie.getDripInterval(_name);
......@@ -131,7 +131,7 @@ contract ManageDrippie is Script {
args[1] = abi.encode(uint128(GelatoDataTypes.TriggerType.TIME), abi.encode(uint128(0), interval));
// Create the task data.
_taskData = GelatoTaskData({
taskData_ = GelatoTaskData({
taskCreator: msg.sender,
execAddress: address(_drippie),
execData: abi.encodeCall(Drippie.drip, (_name)),
......@@ -158,7 +158,7 @@ contract ManageDrippie is Script {
/// @param _gelato The gelato contract.
/// @param _drippie The drippie contract.
/// @param _name The name of the drip being triggered.
/// @return _active True if the task is active, false otherwise.
/// @return active_ True if the task is active, false otherwise.
function _isGelatoDripTaskActive(
IGelato _gelato,
Drippie _drippie,
......@@ -166,7 +166,7 @@ contract ManageDrippie is Script {
)
internal
view
returns (bool _active)
returns (bool active_)
{
GelatoTaskData memory taskData = _makeGelatoDripTaskData({ _drippie: _drippie, _name: _name });
bytes32 taskId = GelatoTaskId.getTaskId({
......@@ -181,7 +181,7 @@ contract ManageDrippie is Script {
bytes32[] memory taskIds = _gelato.getTaskIdsByUser(taskData.taskCreator);
for (uint256 i = 0; i < taskIds.length; i++) {
if (taskIds[i] == taskId) {
_active = true;
active_ = true;
}
}
}
......
......@@ -8,16 +8,16 @@
"sourceCodeHash": "0x9ec99e63a991691e8756a663edf2ccfbe9b91161c134e24f38298da61ecd66dd"
},
"src/L1/DataAvailabilityChallenge.sol": {
"initCodeHash": "0xcc96cf2e4d841adb7ecb9dd84abeb0893dd62d913c0d47ab5b66a893c6e47e88",
"sourceCodeHash": "0xce01773740f4d50ac77f868343d654f6ca24f85d2770eb7e4043e98f609b1c15"
"initCodeHash": "0xbd00d6568abab3e7fc211c40d682862242f25493010a4a097bd1f3b45c8c87c3",
"sourceCodeHash": "0x58b587034a67b4bb718abbaded8ac23b082c0971105874bcc42c23f051c67f6e"
},
"src/L1/DelayedVetoable.sol": {
"initCodeHash": "0xd504ab0568719a0fb960ebe73d0437645f5c4bd8f6619219858209ef002516dd",
"sourceCodeHash": "0x60af558156543d639a0a92e983ad0f045aac1f9ac4c3adaa1d4d97b37175e03a"
"initCodeHash": "0x9fe8ade6f6332262ff1f3539ac0bf57660edbad3cf4c4cb230c2ddac18aa0a3f",
"sourceCodeHash": "0x30e83a535ef27b2e900c831c4e1a4ec2750195350011c4fdacda1da9db2d167b"
},
"src/L1/L1CrossDomainMessenger.sol": {
"initCodeHash": "0x48db42620b9f16e0dec2355f4076314f82fd0f60ef04c10cdbc266eac9472515",
"sourceCodeHash": "0xb77342e6b55b835e9597f7a1c4a2d52ddd56f5cfb7cd38da0bcc488c79a9011e"
"initCodeHash": "0x2e9cb3ceb5e55341b311f0666ef7655df4fafae75afdfbcd701cd9c9b2b017d5",
"sourceCodeHash": "0x848ec3774be17bcc8ba65a23d08e35e979b3f39f9d2ac8a810188f945c69c9ea"
},
"src/L1/L1ERC721Bridge.sol": {
"initCodeHash": "0xfb8b3c51e1790a0b951eaba05ed7368309fbfc7ddc558b4ce1de29da087fb4bd",
......@@ -32,8 +32,8 @@
"sourceCodeHash": "0xde4df0f9633dc0cdb1c9f634003ea5b0f7c5c1aebc407bc1b2f44c0ecf938649"
},
"src/L1/OPContractsManager.sol": {
"initCodeHash": "0x7903f225091334a1910470bb1b5c111f13f6f2572faf03e0c74ad625e4c0d6f5",
"sourceCodeHash": "0x3a25b0ac70b1d434773c86f46b1f2a995722e33d3273762fd5abbb541bffa7db"
"initCodeHash": "0x08be0367ee031ee292b74aa9b6fc86c5d65cbbdadd455bb8120748eec79cf2d8",
"sourceCodeHash": "0x84fd2b583ddf44e900c58861ddda103f7bea793d71fb845f76ed28afd1e757bc"
},
"src/L1/OptimismPortal.sol": {
"initCodeHash": "0xbe2c0c81b3459014f287d8c89cdc0d27dde5d1f44e5d024fa1e4773ddc47c190",
......@@ -112,20 +112,20 @@
"sourceCodeHash": "0xd08a2e6514dbd44e16aa312a1b27b2841a9eab5622cbd05a39c30f543fad673c"
},
"src/L2/L2ToL2CrossDomainMessenger.sol": {
"initCodeHash": "0x3e4337542234c732a55e60fc20dcb1ad639ff2fb378e3f29e94b4059df9a637b",
"sourceCodeHash": "0x4b806cc85cead74c8df34ab08f4b6c6a95a1a387a335ec8a7cb2de4ea4e1cf41"
"initCodeHash": "0x2ec4cdf62baf9dfb2c4c211d8b914f3dd1e0c0133c15c739ff81c5a2504d4359",
"sourceCodeHash": "0x54dfffed789dafe11b7f7bb16dfb29988713a19da5209452119c5d6539e48c48"
},
"src/L2/OptimismSuperchainERC20.sol": {
"initCodeHash": "0x4fd71b5352b78d51d39625b6defa77a75be53067b32f3cba86bd17a46917adf9",
"sourceCodeHash": "0xad3934ea533544b3c130c80be26201354af85f9166cb2ce54d96e5e383ebb5c1"
"initCodeHash": "0x192bb3abd2a103832172d913f548e36bcf6f2c0220cd224a83f8420e2e86b4ec",
"sourceCodeHash": "0x09d3367612dee674e3708da1c70eebbd0c6835fbcbba339780e678338bdfd3ca"
},
"src/L2/OptimismSuperchainERC20Beacon.sol": {
"initCodeHash": "0x99ce8095b23c124850d866cbc144fee6cee05dbc6bb5d83acadfe00b90cf42c7",
"sourceCodeHash": "0x5e58b7c867fafa49fe39d68d83875425e9cf94f05f2835bdcdaa08fc8bc6b68e"
},
"src/L2/OptimismSuperchainERC20Factory.sol": {
"initCodeHash": "0x98011045722178751e4a1112892f7d9a11bc1f5e42ac18205b6d30a1f1476d24",
"sourceCodeHash": "0x9e72b2a77d82fcf3963734232ba9faff9d63962594a032041c2561f0a9f1b0b5"
"initCodeHash": "0x524bc58927ca60ba2fbc4b036ad00c5055758d5c5b2ebb3d75cb9b996175f2cb",
"sourceCodeHash": "0x155a4b22ff8e266560d1fae72e1db7fc164afd84b8a81afb74c69414e0d5438e"
},
"src/L2/SequencerFeeVault.sol": {
"initCodeHash": "0x2e6551705e493bacba8cffe22e564d5c401ae5bb02577a5424e0d32784e13e74",
......@@ -144,8 +144,8 @@
"sourceCodeHash": "0xba4674e1846afbbc708877332a38dfabd4b8d1e48ce07d8ebf0a45c9f27f16b0"
},
"src/cannon/MIPS2.sol": {
"initCodeHash": "0x67fb4107e25561ffcb3a9b6653f695e125773408d626a92036ea4b0814797021",
"sourceCodeHash": "0x5f4851e04dc9369552c94fb23aee8e8ca4ea9a9602917f0abb3b5f1347460bd5"
"initCodeHash": "0xbb8c2370460e66274210d16ae527a29cb432bb646ebdccc0db0b21e53a4e428c",
"sourceCodeHash": "0x50ed780b621521047ed36ffb260032f2e5ec287f3e1ab3d742c7de45febb280d"
},
"src/cannon/PreimageOracle.sol": {
"initCodeHash": "0x801e52f9c8439fcf7089575fa93272dfb874641dbfc7d82f36d979c987271c0b",
......@@ -200,8 +200,8 @@
"sourceCodeHash": "0xde1a289c1cb0bf92138daf8f3db7457be2f84bedaa111b536f646dd6e121718c"
},
"src/safe/LivenessGuard.sol": {
"initCodeHash": "0xfd74ff89e7b689b38ab97515d64429ffaf6c0cd1ea6488c6a4743a0665419c85",
"sourceCodeHash": "0xa40ea6472d9c7e124791489c0899822d6f6b19b16e583d3b437674c615e4bac3"
"initCodeHash": "0x9ac0b039b1591f7c00cf11cb758d118c9b42e6e08250b619d6b6fd605a43d5ee",
"sourceCodeHash": "0xc1a968b0c6fbc4d82c2821c917b273feaaa224d258886b394416e84ee250d026"
},
"src/safe/LivenessModule.sol": {
"initCodeHash": "0xcfccdd9e423c95a0ddc6e09ccb6333d5fc8429ed2b8fc872f1290d392ae13aad",
......@@ -224,7 +224,7 @@
"sourceCodeHash": "0x1c4bc4727f08d80e8364561b49397ee57bb485072cb004b7a430559cbfa019a6"
},
"src/universal/StorageSetter.sol": {
"initCodeHash": "0x00b8b883597e67e5c3548e7ba4139ed720893c0acb217dd170bec520cefdfab5",
"sourceCodeHash": "0xf63aff9c38f4c5e9cdbd1f910bc002e16008a592d26c0dcc67929e0024638edd"
"initCodeHash": "0x21b3059e9b13b330f76d02b61f61dcfa3abf3517a0b56afa0895c4b8291740bf",
"sourceCodeHash": "0xc1ea12a87e3a7ef9c950f0a41a4e35b60d4d9c4c816ff671dbfca663861c16f4"
}
}
\ No newline at end of file
......@@ -44,12 +44,12 @@
"inputs": [
{
"internalType": "uint256",
"name": "challengedBlockNumber",
"name": "_challengedBlockNumber",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "challengedCommitment",
"name": "_challengedCommitment",
"type": "bytes"
}
],
......@@ -95,12 +95,12 @@
"inputs": [
{
"internalType": "uint256",
"name": "challengedBlockNumber",
"name": "_challengedBlockNumber",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "challengedCommitment",
"name": "_challengedCommitment",
"type": "bytes"
}
],
......@@ -141,12 +141,12 @@
"inputs": [
{
"internalType": "uint256",
"name": "challengedBlockNumber",
"name": "_challengedBlockNumber",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "challengedCommitment",
"name": "_challengedCommitment",
"type": "bytes"
}
],
......@@ -218,17 +218,17 @@
"inputs": [
{
"internalType": "uint256",
"name": "challengedBlockNumber",
"name": "_challengedBlockNumber",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "challengedCommitment",
"name": "_challengedCommitment",
"type": "bytes"
},
{
"internalType": "bytes",
"name": "resolveData",
"name": "_resolveData",
"type": "bytes"
}
],
......@@ -306,12 +306,12 @@
"inputs": [
{
"internalType": "uint256",
"name": "challengedBlockNumber",
"name": "_challengedBlockNumber",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "challengedCommitment",
"name": "_challengedCommitment",
"type": "bytes"
}
],
......@@ -324,7 +324,7 @@
"inputs": [
{
"internalType": "bytes",
"name": "commitment",
"name": "_commitment",
"type": "bytes"
}
],
......
......@@ -3,22 +3,22 @@
"inputs": [
{
"internalType": "address",
"name": "vetoer_",
"name": "_vetoer",
"type": "address"
},
{
"internalType": "address",
"name": "initiator_",
"name": "_initiator",
"type": "address"
},
{
"internalType": "address",
"name": "target_",
"name": "_target",
"type": "address"
},
{
"internalType": "uint256",
"name": "operatingDelay_",
"name": "_operatingDelay",
"type": "uint256"
}
],
......@@ -59,7 +59,7 @@
"inputs": [
{
"internalType": "bytes32",
"name": "callHash",
"name": "_callHash",
"type": "bytes32"
}
],
......
......@@ -5,7 +5,7 @@
"outputs": [
{
"internalType": "address",
"name": "_sender",
"name": "sender_",
"type": "address"
}
],
......@@ -18,7 +18,7 @@
"outputs": [
{
"internalType": "uint256",
"name": "_source",
"name": "source_",
"type": "uint256"
}
],
......
......@@ -32,57 +32,57 @@
"inputs": [
{
"internalType": "address",
"name": "to",
"name": "_to",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"name": "_value",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "data",
"name": "_data",
"type": "bytes"
},
{
"internalType": "enum Enum.Operation",
"name": "operation",
"name": "_operation",
"type": "uint8"
},
{
"internalType": "uint256",
"name": "safeTxGas",
"name": "_safeTxGas",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "baseGas",
"name": "_baseGas",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "gasPrice",
"name": "_gasPrice",
"type": "uint256"
},
{
"internalType": "address",
"name": "gasToken",
"name": "_gasToken",
"type": "address"
},
{
"internalType": "address payable",
"name": "refundReceiver",
"name": "_refundReceiver",
"type": "address"
},
{
"internalType": "bytes",
"name": "signatures",
"name": "_signatures",
"type": "bytes"
},
{
"internalType": "address",
"name": "msgSender",
"name": "_msgSender",
"type": "address"
}
],
......
......@@ -26,7 +26,7 @@
"outputs": [
{
"internalType": "address",
"name": "_superchainERC20",
"name": "superchainERC20_",
"type": "address"
}
],
......
......@@ -127,7 +127,7 @@
}
],
"internalType": "struct StorageSetter.Slot[]",
"name": "slots",
"name": "_slots",
"type": "tuple[]"
}
],
......
......@@ -94,8 +94,8 @@ contract DataAvailabilityChallenge is OwnableUpgradeable, ISemver {
event BalanceChanged(address account, uint256 balance);
/// @notice Semantic version.
/// @custom:semver 1.0.1-beta.1
string public constant version = "1.0.1-beta.1";
/// @custom:semver 1.0.1-beta.2
string public constant version = "1.0.1-beta.2";
/// @notice The fixed cost of resolving a challenge.
/// @dev The value is estimated by measuring the cost of resolving with `bytes(0)`
......@@ -210,48 +210,48 @@ contract DataAvailabilityChallenge is OwnableUpgradeable, ISemver {
}
/// @notice Checks if the current block is within the challenge window for a given challenged block number.
/// @param challengedBlockNumber The block number at which the commitment was made.
/// @param _challengedBlockNumber The block number at which the commitment was made.
/// @return True if the current block is within the challenge window, false otherwise.
function _isInChallengeWindow(uint256 challengedBlockNumber) internal view returns (bool) {
return (block.number >= challengedBlockNumber && block.number <= challengedBlockNumber + challengeWindow);
function _isInChallengeWindow(uint256 _challengedBlockNumber) internal view returns (bool) {
return (block.number >= _challengedBlockNumber && block.number <= _challengedBlockNumber + challengeWindow);
}
/// @notice Checks if the current block is within the resolve window for a given challenge start block number.
/// @param challengeStartBlockNumber The block number at which the challenge was initiated.
/// @param _challengeStartBlockNumber The block number at which the challenge was initiated.
/// @return True if the current block is within the resolve window, false otherwise.
function _isInResolveWindow(uint256 challengeStartBlockNumber) internal view returns (bool) {
return block.number <= challengeStartBlockNumber + resolveWindow;
function _isInResolveWindow(uint256 _challengeStartBlockNumber) internal view returns (bool) {
return block.number <= _challengeStartBlockNumber + resolveWindow;
}
/// @notice Returns a challenge for the given block number and commitment.
/// @dev Unlike with a public `challenges` mapping, we can return a Challenge struct instead of tuple.
/// @param challengedBlockNumber The block number at which the commitment was made.
/// @param challengedCommitment The commitment that is being challenged.
/// @param _challengedBlockNumber The block number at which the commitment was made.
/// @param _challengedCommitment The commitment that is being challenged.
/// @return The challenge struct.
function getChallenge(
uint256 challengedBlockNumber,
bytes calldata challengedCommitment
uint256 _challengedBlockNumber,
bytes calldata _challengedCommitment
)
public
view
returns (Challenge memory)
{
return challenges[challengedBlockNumber][challengedCommitment];
return challenges[_challengedBlockNumber][_challengedCommitment];
}
/// @notice Returns the status of a challenge for a given challenged block number and challenged commitment.
/// @param challengedBlockNumber The block number at which the commitment was made.
/// @param challengedCommitment The commitment that is being challenged.
/// @param _challengedBlockNumber The block number at which the commitment was made.
/// @param _challengedCommitment The commitment that is being challenged.
/// @return The status of the challenge.
function getChallengeStatus(
uint256 challengedBlockNumber,
bytes calldata challengedCommitment
uint256 _challengedBlockNumber,
bytes calldata _challengedCommitment
)
public
view
returns (ChallengeStatus)
{
Challenge memory _challenge = challenges[challengedBlockNumber][challengedCommitment];
Challenge memory _challenge = challenges[_challengedBlockNumber][_challengedCommitment];
// if the address is 0, the challenge is uninitialized
if (_challenge.challenger == address(0)) return ChallengeStatus.Uninitialized;
......@@ -267,22 +267,22 @@ contract DataAvailabilityChallenge is OwnableUpgradeable, ISemver {
/// @notice Extract the commitment type from a given commitment.
/// @dev The commitment type is located in the first byte of the commitment.
/// @param commitment The commitment from which to extract the commitment type.
/// @param _commitment The commitment from which to extract the commitment type.
/// @return The commitment type of the given commitment.
function _getCommitmentType(bytes calldata commitment) internal pure returns (uint8) {
return uint8(bytes1(commitment));
function _getCommitmentType(bytes calldata _commitment) internal pure returns (uint8) {
return uint8(bytes1(_commitment));
}
/// @notice Validate that a given commitment has a known type and the expected length for this type.
/// @dev The type of a commitment is stored in its first byte.
/// The function reverts with `UnknownCommitmentType` if the type is not known and
/// with `InvalidCommitmentLength` if the commitment has an unexpected length.
/// @param commitment The commitment for which to check the type.
function validateCommitment(bytes calldata commitment) public pure {
uint8 commitmentType = _getCommitmentType(commitment);
/// @param _commitment The commitment for which to check the type.
function validateCommitment(bytes calldata _commitment) public pure {
uint8 commitmentType = _getCommitmentType(_commitment);
if (commitmentType == uint8(CommitmentType.Keccak256)) {
if (commitment.length != 33) {
revert InvalidCommitmentLength(uint8(CommitmentType.Keccak256), 33, commitment.length);
if (_commitment.length != 33) {
revert InvalidCommitmentLength(uint8(CommitmentType.Keccak256), 33, _commitment.length);
}
return;
}
......@@ -295,11 +295,11 @@ contract DataAvailabilityChallenge is OwnableUpgradeable, ISemver {
/// since the contract cannot access the block number of the commitment.
/// The function reverts if the commitment type (first byte) is unknown,
/// if the caller does not have a bond or if the challenge already exists.
/// @param challengedBlockNumber The block number at which the commitment was made.
/// @param challengedCommitment The commitment that is being challenged.
function challenge(uint256 challengedBlockNumber, bytes calldata challengedCommitment) external payable {
/// @param _challengedBlockNumber The block number at which the commitment was made.
/// @param _challengedCommitment The commitment that is being challenged.
function challenge(uint256 _challengedBlockNumber, bytes calldata _challengedCommitment) external payable {
// require the commitment type to be known
validateCommitment(challengedCommitment);
validateCommitment(_challengedCommitment);
// deposit value sent with the transaction as bond
deposit();
......@@ -310,12 +310,12 @@ contract DataAvailabilityChallenge is OwnableUpgradeable, ISemver {
}
// require the challenge status to be uninitialized
if (getChallengeStatus(challengedBlockNumber, challengedCommitment) != ChallengeStatus.Uninitialized) {
if (getChallengeStatus(_challengedBlockNumber, _challengedCommitment) != ChallengeStatus.Uninitialized) {
revert ChallengeExists();
}
// require the current block to be in the challenge window
if (!_isInChallengeWindow(challengedBlockNumber)) {
if (!_isInChallengeWindow(_challengedBlockNumber)) {
revert ChallengeWindowNotOpen();
}
......@@ -323,11 +323,11 @@ contract DataAvailabilityChallenge is OwnableUpgradeable, ISemver {
balances[msg.sender] -= bondSize;
// store the challenger's address, bond size, and start block of the challenge
challenges[challengedBlockNumber][challengedCommitment] =
challenges[_challengedBlockNumber][_challengedCommitment] =
Challenge({ challenger: msg.sender, lockedBond: bondSize, startBlock: block.number, resolvedBlock: 0 });
// emit an event to notify that the challenge status is now active
emit ChallengeStatusChanged(challengedBlockNumber, challengedCommitment, ChallengeStatus.Active);
emit ChallengeStatusChanged(_challengedBlockNumber, _challengedCommitment, ChallengeStatus.Active);
}
/// @notice Resolve a challenge by providing the data corresponding to the challenged commitment.
......@@ -335,45 +335,45 @@ contract DataAvailabilityChallenge is OwnableUpgradeable, ISemver {
/// challenged commitment.
/// It reverts if the commitment type is unknown, if the data doesn't match the commitment,
/// if the challenge is not active or if the resolve window is not open.
/// @param challengedBlockNumber The block number at which the commitment was made.
/// @param challengedCommitment The challenged commitment that is being resolved.
/// @param resolveData The pre-image data corresponding to the challenged commitment.
/// @param _challengedBlockNumber The block number at which the commitment was made.
/// @param _challengedCommitment The challenged commitment that is being resolved.
/// @param _resolveData The pre-image data corresponding to the challenged commitment.
function resolve(
uint256 challengedBlockNumber,
bytes calldata challengedCommitment,
bytes calldata resolveData
uint256 _challengedBlockNumber,
bytes calldata _challengedCommitment,
bytes calldata _resolveData
)
external
{
// require the commitment type to be known
validateCommitment(challengedCommitment);
validateCommitment(_challengedCommitment);
// require the challenge to be active (started, not resolved, and resolve window still open)
if (getChallengeStatus(challengedBlockNumber, challengedCommitment) != ChallengeStatus.Active) {
if (getChallengeStatus(_challengedBlockNumber, _challengedCommitment) != ChallengeStatus.Active) {
revert ChallengeNotActive();
}
// compute the commitment corresponding to the given resolveData
uint8 commitmentType = _getCommitmentType(challengedCommitment);
uint8 commitmentType = _getCommitmentType(_challengedCommitment);
bytes memory computedCommitment;
if (commitmentType == uint8(CommitmentType.Keccak256)) {
computedCommitment = computeCommitmentKeccak256(resolveData);
computedCommitment = computeCommitmentKeccak256(_resolveData);
}
// require the provided input data to correspond to the challenged commitment
if (keccak256(computedCommitment) != keccak256(challengedCommitment)) {
revert InvalidInputData(computedCommitment, challengedCommitment);
if (keccak256(computedCommitment) != keccak256(_challengedCommitment)) {
revert InvalidInputData(computedCommitment, _challengedCommitment);
}
// store the block number at which the challenge was resolved
Challenge storage activeChallenge = challenges[challengedBlockNumber][challengedCommitment];
Challenge storage activeChallenge = challenges[_challengedBlockNumber][_challengedCommitment];
activeChallenge.resolvedBlock = block.number;
// emit an event to notify that the challenge status is now resolved
emit ChallengeStatusChanged(challengedBlockNumber, challengedCommitment, ChallengeStatus.Resolved);
emit ChallengeStatusChanged(_challengedBlockNumber, _challengedCommitment, ChallengeStatus.Resolved);
// distribute the bond among challenger, resolver and address(0)
_distributeBond(activeChallenge, resolveData.length, msg.sender);
_distributeBond(activeChallenge, _resolveData.length, msg.sender);
}
/// @notice Distribute the bond of a resolved challenge among the resolver, challenger and address(0).
......@@ -385,16 +385,22 @@ contract DataAvailabilityChallenge is OwnableUpgradeable, ISemver {
/// pre-image.
/// The real resolution cost might vary, because calldata is priced differently for zero and non-zero bytes.
/// Computing the exact cost adds too much gas overhead to be worth the tradeoff.
/// @param resolvedChallenge The resolved challenge in storage.
/// @param preImageLength The size of the pre-image used to resolve the challenge.
/// @param resolver The address of the resolver.
function _distributeBond(Challenge storage resolvedChallenge, uint256 preImageLength, address resolver) internal {
uint256 lockedBond = resolvedChallenge.lockedBond;
address challenger = resolvedChallenge.challenger;
/// @param _resolvedChallenge The resolved challenge in storage.
/// @param _preImageLength The size of the pre-image used to resolve the challenge.
/// @param _resolver The address of the resolver.
function _distributeBond(
Challenge storage _resolvedChallenge,
uint256 _preImageLength,
address _resolver
)
internal
{
uint256 lockedBond = _resolvedChallenge.lockedBond;
address challenger = _resolvedChallenge.challenger;
// approximate the cost of resolving a challenge with the provided pre-image size
uint256 resolutionCost = (
fixedResolutionCost + preImageLength * variableResolutionCost / variableResolutionCostPrecision
fixedResolutionCost + _preImageLength * variableResolutionCost / variableResolutionCostPrecision
) * block.basefee;
// refund bond exceeding the resolution cost to the challenger
......@@ -410,31 +416,31 @@ contract DataAvailabilityChallenge is OwnableUpgradeable, ISemver {
resolverRefund = lockedBond;
}
if (resolverRefund > 0) {
balances[resolver] += resolverRefund;
balances[_resolver] += resolverRefund;
lockedBond -= resolverRefund;
emit BalanceChanged(resolver, balances[resolver]);
emit BalanceChanged(_resolver, balances[_resolver]);
}
// burn the remaining bond
if (lockedBond > 0) {
payable(address(0)).transfer(lockedBond);
}
resolvedChallenge.lockedBond = 0;
_resolvedChallenge.lockedBond = 0;
}
/// @notice Unlock the bond associated wth an expired challenge.
/// @dev The function reverts if the challenge is not expired.
/// If the expiration is successful, the challenger's bond is unlocked.
/// @param challengedBlockNumber The block number at which the commitment was made.
/// @param challengedCommitment The commitment that is being challenged.
function unlockBond(uint256 challengedBlockNumber, bytes calldata challengedCommitment) external {
/// @param _challengedBlockNumber The block number at which the commitment was made.
/// @param _challengedCommitment The commitment that is being challenged.
function unlockBond(uint256 _challengedBlockNumber, bytes calldata _challengedCommitment) external {
// require the challenge to be active (started, not resolved, and in the resolve window)
if (getChallengeStatus(challengedBlockNumber, challengedCommitment) != ChallengeStatus.Expired) {
if (getChallengeStatus(_challengedBlockNumber, _challengedCommitment) != ChallengeStatus.Expired) {
revert ChallengeNotExpired();
}
// Unlock the bond associated with the challenge
Challenge storage expiredChallenge = challenges[challengedBlockNumber][challengedCommitment];
Challenge storage expiredChallenge = challenges[_challengedBlockNumber][_challengedCommitment];
balances[expiredChallenge.challenger] += expiredChallenge.lockedBond;
expiredChallenge.lockedBond = 0;
......@@ -444,8 +450,8 @@ contract DataAvailabilityChallenge is OwnableUpgradeable, ISemver {
}
/// @notice Compute the expected commitment for a given blob of data.
/// @param data The blob of data to compute a commitment for.
/// @param _data The blob of data to compute a commitment for.
/// @return The commitment for the given blob of data.
function computeCommitmentKeccak256(bytes memory data) pure returns (bytes memory) {
return bytes.concat(bytes1(uint8(CommitmentType.Keccak256)), keccak256(data));
function computeCommitmentKeccak256(bytes memory _data) pure returns (bytes memory) {
return bytes.concat(bytes1(uint8(CommitmentType.Keccak256)), keccak256(_data));
}
......@@ -69,21 +69,21 @@ contract DelayedVetoable is ISemver {
}
/// @notice Semantic version.
/// @custom:semver 1.0.1-beta.1
string public constant version = "1.0.1-beta.1";
/// @custom:semver 1.0.1-beta.2
string public constant version = "1.0.1-beta.2";
/// @notice Sets the target admin during contract deployment.
/// @param vetoer_ Address of the vetoer.
/// @param initiator_ Address of the initiator.
/// @param target_ Address of the target.
/// @param operatingDelay_ Time to delay when the system is operational.
constructor(address vetoer_, address initiator_, address target_, uint256 operatingDelay_) {
/// @param _vetoer Address of the vetoer.
/// @param _initiator Address of the initiator.
/// @param _target Address of the target.
/// @param _operatingDelay Time to delay when the system is operational.
constructor(address _vetoer, address _initiator, address _target, uint256 _operatingDelay) {
// Note that the _delay value is not set here. Having an initial delay of 0 is helpful
// during the deployment of a new system.
VETOER = vetoer_;
INITIATOR = initiator_;
TARGET = target_;
OPERATING_DELAY = operatingDelay_;
VETOER = _vetoer;
INITIATOR = _initiator;
TARGET = _target;
OPERATING_DELAY = _operatingDelay;
}
/// @notice Gets the initiator
......@@ -111,10 +111,10 @@ contract DelayedVetoable is ISemver {
}
/// @notice Gets entries in the _queuedAt mapping.
/// @param callHash The hash of the call data.
/// @param _callHash The hash of the call data.
/// @return queuedAt_ The time the callHash was recorded.
function queuedAt(bytes32 callHash) external readOrHandle returns (uint256 queuedAt_) {
queuedAt_ = _queuedAt[callHash];
function queuedAt(bytes32 _callHash) external readOrHandle returns (uint256 queuedAt_) {
queuedAt_ = _queuedAt[_callHash];
}
/// @notice Used for all calls that pass data to the contract.
......@@ -176,9 +176,9 @@ contract DelayedVetoable is ISemver {
}
/// @notice Forwards the call to the target and halts the call frame.
function _forwardAndHalt(bytes32 callHash) internal {
function _forwardAndHalt(bytes32 _callHash) internal {
// Forward the call
emit Forwarded(callHash, msg.data);
emit Forwarded(_callHash, msg.data);
(bool success, bytes memory returndata) = TARGET.call(msg.data);
if (success == true) {
assembly {
......
......@@ -30,8 +30,8 @@ contract L1CrossDomainMessenger is CrossDomainMessenger, ISemver {
ISystemConfig public systemConfig;
/// @notice Semantic version.
/// @custom:semver 2.4.1-beta.1
string public constant version = "2.4.1-beta.1";
/// @custom:semver 2.4.1-beta.2
string public constant version = "2.4.1-beta.2";
/// @notice Constructs the L1CrossDomainMessenger contract.
constructor() CrossDomainMessenger() {
......@@ -61,8 +61,8 @@ contract L1CrossDomainMessenger is CrossDomainMessenger, ISemver {
}
/// @inheritdoc CrossDomainMessenger
function gasPayingToken() internal view override returns (address _addr, uint8 _decimals) {
(_addr, _decimals) = systemConfig.gasPayingToken();
function gasPayingToken() internal view override returns (address addr_, uint8 decimals_) {
(addr_, decimals_) = systemConfig.gasPayingToken();
}
/// @notice Getter function for the OptimismPortal contract on this chain.
......
......@@ -124,8 +124,8 @@ contract OPContractsManager is ISemver, Initializable {
// -------- Constants and Variables --------
/// @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 Represents the interface version so consumers know how to decode the DeployOutput struct
/// that's emitted in the `Deployed` event. Whenever that struct changes, a new version should be used.
......@@ -432,7 +432,7 @@ contract OPContractsManager is ISemver, Initializable {
/// @notice Helper method for encoding the SystemConfig initializer data.
function encodeSystemConfigInitializer(
bytes4 selector,
bytes4 _selector,
DeployInput memory _input,
DeployOutput memory _output
)
......@@ -442,10 +442,10 @@ contract OPContractsManager is ISemver, Initializable {
returns (bytes memory)
{
(ResourceMetering.ResourceConfig memory referenceResourceConfig, SystemConfig.Addresses memory opChainAddrs) =
defaultSystemConfigParams(selector, _input, _output);
defaultSystemConfigParams(_selector, _input, _output);
return abi.encodeWithSelector(
selector,
_selector,
_input.roles.systemConfigOwner,
_input.basefeeScalar,
_input.blobBasefeeScalar,
......
......@@ -20,7 +20,7 @@ contract OPContractsManagerInterop is OPContractsManager {
// The `SystemConfigInterop` contract has an extra `address _dependencyManager` argument
// that we must account for.
function encodeSystemConfigInitializer(
bytes4 selector,
bytes4 _selector,
DeployInput memory _input,
DeployOutput memory _output
)
......@@ -31,7 +31,7 @@ contract OPContractsManagerInterop is OPContractsManager {
returns (bytes memory)
{
(ResourceMetering.ResourceConfig memory referenceResourceConfig, SystemConfig.Addresses memory opChainAddrs) =
defaultSystemConfigParams(selector, _input, _output);
defaultSystemConfigParams(_selector, _input, _output);
// TODO For now we assume that the dependency manager is the same as the proxy admin owner.
// This is currently undefined since it's not part of the standard config, so we may need
......@@ -41,7 +41,7 @@ contract OPContractsManagerInterop is OPContractsManager {
address dependencyManager = address(_input.roles.opChainProxyAdminOwner);
return abi.encodeWithSelector(
selector,
_selector,
_input.roles.systemConfigOwner,
_input.basefeeScalar,
_input.blobBasefeeScalar,
......
......@@ -44,20 +44,20 @@ interface IDataAvailabilityChallenge {
function balances(address) external view returns (uint256);
function bondSize() external view returns (uint256);
function challenge(uint256 challengedBlockNumber, bytes memory challengedCommitment) external payable;
function challenge(uint256 _challengedBlockNumber, bytes memory _challengedCommitment) external payable;
function challengeWindow() external view returns (uint256);
function deposit() external payable;
function fixedResolutionCost() external view returns (uint256);
function getChallenge(
uint256 challengedBlockNumber,
bytes memory challengedCommitment
uint256 _challengedBlockNumber,
bytes memory _challengedCommitment
)
external
view
returns (Challenge memory);
function getChallengeStatus(
uint256 challengedBlockNumber,
bytes memory challengedCommitment
uint256 _challengedBlockNumber,
bytes memory _challengedCommitment
)
external
view
......@@ -73,18 +73,18 @@ interface IDataAvailabilityChallenge {
function owner() external view returns (address);
function renounceOwnership() external;
function resolve(
uint256 challengedBlockNumber,
bytes memory challengedCommitment,
bytes memory resolveData
uint256 _challengedBlockNumber,
bytes memory _challengedCommitment,
bytes memory _resolveData
)
external;
function resolveWindow() external view returns (uint256);
function resolverRefundPercentage() external view returns (uint256);
function setBondSize(uint256 _bondSize) external;
function setResolverRefundPercentage(uint256 _resolverRefundPercentage) external;
function transferOwnership(address newOwner) external;
function unlockBond(uint256 challengedBlockNumber, bytes memory challengedCommitment) external;
function validateCommitment(bytes memory commitment) external pure;
function transferOwnership(address newOwner) external; // nosemgrep
function unlockBond(uint256 _challengedBlockNumber, bytes memory _challengedCommitment) external;
function validateCommitment(bytes memory _commitment) external pure;
function variableResolutionCost() external view returns (uint256);
function variableResolutionCostPrecision() external view returns (uint256);
function version() external view returns (string memory);
......
......@@ -14,10 +14,10 @@ interface IDelayedVetoable {
function delay() external returns (uint256 delay_);
function initiator() external returns (address initiator_);
function queuedAt(bytes32 callHash) external returns (uint256 queuedAt_);
function queuedAt(bytes32 _callHash) external returns (uint256 queuedAt_);
function target() external returns (address target_);
function version() external view returns (string memory);
function vetoer() external returns (address vetoer_);
function __constructor__(address vetoer_, address initiator_, address target_, uint256 operatingDelay_) external;
function __constructor__(address _vetoer, address _initiator, address _target, uint256 _operatingDelay) external;
}
......@@ -65,7 +65,7 @@ interface IOptimismPortal {
function l2Oracle() external view returns (IL2OutputOracle);
function l2Sender() external view returns (address);
function minimumGasLimit(uint64 _byteCount) external pure returns (uint64);
function params() external view returns (uint128 prevBaseFee, uint64 prevBoughtGas, uint64 prevBlockNum);
function params() external view returns (uint128 prevBaseFee, uint64 prevBoughtGas, uint64 prevBlockNum); // nosemgrep
function paused() external view returns (bool paused_);
function proveWithdrawalTransaction(
Types.WithdrawalTransaction memory _tx,
......@@ -77,7 +77,7 @@ interface IOptimismPortal {
function provenWithdrawals(bytes32)
external
view
returns (bytes32 outputRoot, uint128 timestamp, uint128 l2OutputIndex);
returns (bytes32 outputRoot, uint128 timestamp, uint128 l2OutputIndex); // nosemgrep
function setGasPayingToken(address _token, uint8 _decimals, bytes32 _name, bytes32 _symbol) external;
function superchainConfig() external view returns (ISuperchainConfig);
function systemConfig() external view returns (ISystemConfig);
......
......@@ -88,7 +88,7 @@ interface IOptimismPortal2 {
function l2Sender() external view returns (address);
function minimumGasLimit(uint64 _byteCount) external pure returns (uint64);
function numProofSubmitters(bytes32 _withdrawalHash) external view returns (uint256);
function params() external view returns (uint128 prevBaseFee, uint64 prevBoughtGas, uint64 prevBlockNum);
function params() external view returns (uint128 prevBaseFee, uint64 prevBoughtGas, uint64 prevBlockNum); // nosemgrep
function paused() external view returns (bool);
function proofMaturityDelaySeconds() external view returns (uint256);
function proofSubmitters(bytes32, uint256) external view returns (address);
......@@ -105,7 +105,7 @@ interface IOptimismPortal2 {
)
external
view
returns (IDisputeGame disputeGameProxy, uint64 timestamp);
returns (IDisputeGame disputeGameProxy, uint64 timestamp); // nosemgrep
function respectedGameType() external view returns (GameType);
function respectedGameTypeUpdatedAt() external view returns (uint64);
function setGasPayingToken(address _token, uint8 _decimals, bytes32 _name, bytes32 _symbol) external;
......
......@@ -89,7 +89,7 @@ interface IOptimismPortalInterop {
function l2Sender() external view returns (address);
function minimumGasLimit(uint64 _byteCount) external pure returns (uint64);
function numProofSubmitters(bytes32 _withdrawalHash) external view returns (uint256);
function params() external view returns (uint128 prevBaseFee, uint64 prevBoughtGas, uint64 prevBlockNum);
function params() external view returns (uint128 prevBaseFee, uint64 prevBoughtGas, uint64 prevBlockNum); // nosemgrep
function paused() external view returns (bool);
function proofMaturityDelaySeconds() external view returns (uint256);
function proofSubmitters(bytes32, uint256) external view returns (address);
......@@ -106,7 +106,7 @@ interface IOptimismPortalInterop {
)
external
view
returns (IDisputeGame disputeGameProxy, uint64 timestamp);
returns (IDisputeGame disputeGameProxy, uint64 timestamp); // nosemgrep
function respectedGameType() external view returns (GameType);
function respectedGameTypeUpdatedAt() external view returns (uint64);
function setConfig(ConfigType _type, bytes memory _value) external;
......
......@@ -23,7 +23,7 @@ interface IProtocolVersions {
function required() external view returns (ProtocolVersion out_);
function setRecommended(ProtocolVersion _recommended) external;
function setRequired(ProtocolVersion _required) external;
function transferOwnership(address newOwner) external;
function transferOwnership(address newOwner) external; // nosemgrep
function version() external view returns (string memory);
function __constructor__() external;
......
......@@ -21,5 +21,5 @@ interface IResourceMetering {
event Initialized(uint8 version);
function params() external view returns (uint128 prevBaseFee, uint64 prevBoughtGas, uint64 prevBlockNum);
function params() external view returns (uint128 prevBaseFee, uint64 prevBoughtGas, uint64 prevBlockNum); // nosemgrep
}
......@@ -75,7 +75,7 @@ interface ISystemConfig {
function setGasLimit(uint64 _gasLimit) external;
function setUnsafeBlockSigner(address _unsafeBlockSigner) external;
function startBlock() external view returns (uint256 startBlock_);
function transferOwnership(address newOwner) external;
function transferOwnership(address newOwner) external; // nosemgrep
function unsafeBlockSigner() external view returns (address addr_);
function version() external pure returns (string memory);
......
......@@ -59,7 +59,7 @@ interface ISystemConfigInterop {
function setGasLimit(uint64 _gasLimit) external;
function setUnsafeBlockSigner(address _unsafeBlockSigner) external;
function startBlock() external view returns (uint256 startBlock_);
function transferOwnership(address newOwner) external;
function transferOwnership(address newOwner) external; // nosemgrep
function unsafeBlockSigner() external view returns (address addr_);
function addDependency(uint256 _chainId) external;
......
......@@ -57,8 +57,8 @@ contract L2ToL2CrossDomainMessenger is IL2ToL2CrossDomainMessenger, ISemver, Tra
uint16 public constant messageVersion = uint16(0);
/// @notice Semantic version.
/// @custom:semver 1.0.0-beta.4
string public constant version = "1.0.0-beta.4";
/// @custom:semver 1.0.0-beta.5
string public constant version = "1.0.0-beta.5";
/// @notice Mapping of message hashes to boolean receipt values. Note that a message will only be present in this
/// mapping if it has successfully been relayed on this chain, and can therefore not be relayed again.
......@@ -78,18 +78,18 @@ contract L2ToL2CrossDomainMessenger is IL2ToL2CrossDomainMessenger, ISemver, Tra
event FailedRelayedMessage(bytes32 indexed messageHash);
/// @notice Retrieves the sender of the current cross domain message. If not entered, reverts.
/// @return _sender Address of the sender of the current cross domain message.
function crossDomainMessageSender() external view onlyEntered returns (address _sender) {
/// @return sender_ Address of the sender of the current cross domain message.
function crossDomainMessageSender() external view onlyEntered returns (address sender_) {
assembly {
_sender := tload(CROSS_DOMAIN_MESSAGE_SENDER_SLOT)
sender_ := tload(CROSS_DOMAIN_MESSAGE_SENDER_SLOT)
}
}
/// @notice Retrieves the source of the current cross domain message. If not entered, reverts.
/// @return _source Chain ID of the source of the current cross domain message.
function crossDomainMessageSource() external view onlyEntered returns (uint256 _source) {
/// @return source_ Chain ID of the source of the current cross domain message.
function crossDomainMessageSource() external view onlyEntered returns (uint256 source_) {
assembly {
_source := tload(CROSS_DOMAIN_MESSAGE_SOURCE_SLOT)
source_ := tload(CROSS_DOMAIN_MESSAGE_SOURCE_SLOT)
}
}
......
......@@ -50,9 +50,9 @@ contract OptimismSuperchainERC20 is
}
/// @notice Returns the storage for the OptimismSuperchainERC20Metadata.
function _getStorage() private pure returns (OptimismSuperchainERC20Metadata storage _storage) {
function _getStorage() private pure returns (OptimismSuperchainERC20Metadata storage storage_) {
assembly {
_storage.slot := OPTIMISM_SUPERCHAIN_ERC20_METADATA_SLOT
storage_.slot := OPTIMISM_SUPERCHAIN_ERC20_METADATA_SLOT
}
}
......@@ -63,8 +63,8 @@ contract OptimismSuperchainERC20 is
}
/// @notice Semantic version.
/// @custom:semver 1.0.0-beta.2
string public constant version = "1.0.0-beta.2";
/// @custom:semver 1.0.0-beta.3
string public constant version = "1.0.0-beta.3";
/// @notice Constructs the OptimismSuperchainERC20 contract.
constructor() {
......
......@@ -27,15 +27,15 @@ contract OptimismSuperchainERC20Factory is IOptimismERC20Factory, ISemver {
);
/// @notice Semantic version.
/// @custom:semver 1.0.0-beta.1
string public constant version = "1.0.0-beta.1";
/// @custom:semver 1.0.0-beta.2
string public constant version = "1.0.0-beta.2";
/// @notice Deploys a OptimismSuperchainERC20 Beacon Proxy using CREATE3.
/// @param _remoteToken Address of the remote token.
/// @param _name Name of the OptimismSuperchainERC20.
/// @param _symbol Symbol of the OptimismSuperchainERC20.
/// @param _decimals Decimals of the OptimismSuperchainERC20.
/// @return _superchainERC20 Address of the OptimismSuperchainERC20 deployment.
/// @return superchainERC20_ Address of the OptimismSuperchainERC20 deployment.
function deploy(
address _remoteToken,
string memory _name,
......@@ -43,7 +43,7 @@ contract OptimismSuperchainERC20Factory is IOptimismERC20Factory, ISemver {
uint8 _decimals
)
external
returns (address _superchainERC20)
returns (address superchainERC20_)
{
bytes memory initCallData =
abi.encodeCall(OptimismSuperchainERC20.initialize, (_remoteToken, _name, _symbol, _decimals));
......@@ -53,10 +53,10 @@ contract OptimismSuperchainERC20Factory is IOptimismERC20Factory, ISemver {
);
bytes32 salt = keccak256(abi.encode(_remoteToken, _name, _symbol, _decimals));
_superchainERC20 = CREATE3.deploy({ salt: salt, creationCode: creationCode, value: 0 });
superchainERC20_ = CREATE3.deploy({ salt: salt, creationCode: creationCode, value: 0 });
deployments[_superchainERC20] = _remoteToken;
deployments[superchainERC20_] = _remoteToken;
emit OptimismSuperchainERC20Created(_superchainERC20, _remoteToken, msg.sender);
emit OptimismSuperchainERC20Created(superchainERC20_, _remoteToken, msg.sender);
}
}
......@@ -18,24 +18,24 @@ interface ICrossL2Inbox {
function interopStart() external view returns (uint256 interopStart_);
/// @notice Returns the origin address of the Identifier.
/// @return _origin The origin address of the Identifier.
function origin() external view returns (address _origin);
/// @return origin_ The origin address of the Identifier.
function origin() external view returns (address origin_);
/// @notice Returns the block number of the Identifier.
/// @return _blockNumber The block number of the Identifier.
function blockNumber() external view returns (uint256 _blockNumber);
/// @return blockNumber_ The block number of the Identifier.
function blockNumber() external view returns (uint256 blockNumber_);
/// @notice Returns the log index of the Identifier.
/// @return _logIndex The log index of the Identifier.
function logIndex() external view returns (uint256 _logIndex);
/// @return logIndex_ The log index of the Identifier.
function logIndex() external view returns (uint256 logIndex_);
/// @notice Returns the timestamp of the Identifier.
/// @return _timestamp The timestamp of the Identifier.
function timestamp() external view returns (uint256 _timestamp);
/// @return timestamp_ The timestamp of the Identifier.
function timestamp() external view returns (uint256 timestamp_);
/// @notice Returns the chain ID of the Identifier.
/// @return _chainId The chain ID of the Identifier.
function chainId() external view returns (uint256 _chainId);
/// @return chainId_ The chain ID of the Identifier.
function chainId() external view returns (uint256 chainId_);
/// @notice Executes a cross chain message on the destination chain.
/// @param _id An Identifier pointing to the initiating message.
......
......@@ -18,12 +18,12 @@ interface IL2ToL2CrossDomainMessenger {
function messageNonce() external view returns (uint256);
/// @notice Retrieves the sender of the current cross domain message.
/// @return _sender Address of the sender of the current cross domain message.
function crossDomainMessageSender() external view returns (address _sender);
/// @return sender_ Address of the sender of the current cross domain message.
function crossDomainMessageSender() external view returns (address sender_);
/// @notice Retrieves the source of the current cross domain message.
/// @return _source Chain ID of the source of the current cross domain message.
function crossDomainMessageSource() external view returns (uint256 _source);
/// @return source_ Chain ID of the source of the current cross domain message.
function crossDomainMessageSource() external view returns (uint256 source_);
/// @notice Sends a message to some target address on a destination chain. Note that if the call
/// always reverts, then the message will be unrelayable, and any ETH sent will be
......
......@@ -7,6 +7,6 @@ pragma solidity ^0.8.0;
interface IOptimismERC20Factory {
/// @notice Checks if a ERC20 token is deployed by the factory.
/// @param _localToken The address of the ERC20 token to check the deployment.
/// @return _remoteToken The address of the remote token if it is deployed or `address(0)` if not.
function deployments(address _localToken) external view returns (address _remoteToken);
/// @return remoteToken_ The address of the remote token if it is deployed or `address(0)` if not.
function deployments(address _localToken) external view returns (address remoteToken_);
}
......@@ -57,8 +57,8 @@ contract MIPS2 is ISemver {
}
/// @notice The semantic version of the MIPS2 contract.
/// @custom:semver 1.0.0-beta.11
string public constant version = "1.0.0-beta.11";
/// @custom:semver 1.0.0-beta.12
string public constant version = "1.0.0-beta.12";
/// @notice The preimage oracle contract.
IPreimageOracle internal immutable ORACLE;
......@@ -595,11 +595,11 @@ contract MIPS2 is ISemver {
)
internal
view
returns (uint32 v0, uint32 v1)
returns (uint32 v0_, uint32 v1_)
{
bool memUpdated;
uint32 memAddr;
(v0, v1, _state.preimageOffset, _state.memRoot, memUpdated, memAddr) = sys.handleSysRead(_args);
(v0_, v1_, _state.preimageOffset, _state.memRoot, memUpdated, memAddr) = sys.handleSysRead(_args);
if (memUpdated) {
handleMemoryUpdate(_state, memAddr);
}
......@@ -717,7 +717,7 @@ contract MIPS2 is ISemver {
)
internal
pure
returns (bool _changedDirections)
returns (bool changedDirections_)
{
// pop thread from the current stack and push to the other stack
if (_state.traverseRight) {
......@@ -732,7 +732,7 @@ contract MIPS2 is ISemver {
bytes32 current = _state.traverseRight ? _state.rightThreadStack : _state.leftThreadStack;
if (current == EMPTY_THREAD_ROOT) {
_state.traverseRight = !_state.traverseRight;
_changedDirections = true;
changedDirections_ = true;
}
_state.stepsSinceLastContextSwitch = 0;
}
......@@ -768,10 +768,10 @@ contract MIPS2 is ISemver {
return inactiveStack == EMPTY_THREAD_ROOT && currentStackIsAlmostEmpty;
}
function computeThreadRoot(bytes32 _currentRoot, ThreadState memory _thread) internal pure returns (bytes32 _out) {
function computeThreadRoot(bytes32 _currentRoot, ThreadState memory _thread) internal pure returns (bytes32 out_) {
// w_i = hash(w_0 ++ hash(thread))
bytes32 threadRoot = outputThreadState(_thread);
_out = keccak256(abi.encodePacked(_currentRoot, threadRoot));
out_ = keccak256(abi.encodePacked(_currentRoot, threadRoot));
}
function outputThreadState(ThreadState memory _thread) internal pure returns (bytes32 out_) {
......
......@@ -11,8 +11,8 @@ library MIPSState {
uint32 hi;
}
function assertExitedIsValid(uint32 exited) internal pure {
if (exited > 1) {
function assertExitedIsValid(uint32 _exited) internal pure {
if (_exited > 1) {
revert InvalidExitedValue();
}
}
......
......@@ -18,7 +18,7 @@ interface IAnchorStateRegistry {
event Initialized(uint8 version);
function anchors(GameType) external view returns (Hash root, uint256 l2BlockNumber);
function anchors(GameType) external view returns (Hash root, uint256 l2BlockNumber); // nosemgrep
function disputeGameFactory() external view returns (IDisputeGameFactory);
function initialize(
StartingAnchorRoot[] memory _startingAnchorRoots,
......
......@@ -21,7 +21,7 @@ interface IDelayedWETH is IWETH {
function initialize(address _owner, ISuperchainConfig _config) external;
function owner() external view returns (address);
function recover(uint256 _wad) external;
function transferOwnership(address newOwner) external;
function transferOwnership(address newOwner) external; // nosemgrep
function renounceOwnership() external;
function unlock(address _guy, uint256 _wad) external;
function withdraw(address _guy, uint256 _wad) external;
......
......@@ -67,7 +67,7 @@ interface IDisputeGameFactory {
function renounceOwnership() external;
function setImplementation(GameType _gameType, IDisputeGame _impl) external;
function setInitBond(GameType _gameType, uint256 _initBond) external;
function transferOwnership(address newOwner) external;
function transferOwnership(address newOwner) external; // nosemgrep
function version() external view returns (string memory);
function __constructor__() external;
......
......@@ -72,7 +72,7 @@ interface IFaultDisputeGame is IDisputeGame {
function claimCredit(address _recipient) external;
function claimData(uint256)
external
view
view // nosemgrep
returns (
uint32 parentIndex,
address counteredBy,
......@@ -100,12 +100,12 @@ interface IFaultDisputeGame is IDisputeGame {
function resolutionCheckpoints(uint256)
external
view
returns (bool initialCheckpointComplete, uint32 subgameIndex, Position leftmostPosition, address counteredBy);
returns (bool initialCheckpointComplete, uint32 subgameIndex, Position leftmostPosition, address counteredBy); // nosemgrep
function resolveClaim(uint256 _claimIndex, uint256 _numToResolve) external;
function resolvedSubgames(uint256) external view returns (bool);
function splitDepth() external view returns (uint256 splitDepth_);
function startingBlockNumber() external view returns (uint256 startingBlockNumber_);
function startingOutputRoot() external view returns (Hash root, uint256 l2BlockNumber);
function startingOutputRoot() external view returns (Hash root, uint256 l2BlockNumber); // nosemgrep
function startingRootHash() external view returns (Hash startingRootHash_);
function step(uint256 _claimIndex, bool _isAttack, bytes memory _stateData, bytes memory _proof) external;
function subgames(uint256, uint256) external view returns (uint256);
......
......@@ -73,7 +73,7 @@ interface IPermissionedDisputeGame is IDisputeGame {
function claimCredit(address _recipient) external;
function claimData(uint256)
external
view
view // nosemgrep
returns (
uint32 parentIndex,
address counteredBy,
......@@ -101,12 +101,12 @@ interface IPermissionedDisputeGame is IDisputeGame {
function resolutionCheckpoints(uint256)
external
view
returns (bool initialCheckpointComplete, uint32 subgameIndex, Position leftmostPosition, address counteredBy);
returns (bool initialCheckpointComplete, uint32 subgameIndex, Position leftmostPosition, address counteredBy); // nosemgrep
function resolveClaim(uint256 _claimIndex, uint256 _numToResolve) external;
function resolvedSubgames(uint256) external view returns (bool);
function splitDepth() external view returns (uint256 splitDepth_);
function startingBlockNumber() external view returns (uint256 startingBlockNumber_);
function startingOutputRoot() external view returns (Hash root, uint256 l2BlockNumber);
function startingOutputRoot() external view returns (Hash root, uint256 l2BlockNumber); // nosemgrep
function startingRootHash() external view returns (Hash startingRootHash_);
function step(uint256 _claimIndex, bool _isAttack, bytes memory _stateData, bytes memory _proof) external;
function subgames(uint256, uint256) external view returns (uint256);
......
......@@ -14,7 +14,7 @@ interface IMintManager {
function mintPermittedAfter() external view returns (uint256);
function owner() external view returns (address);
function renounceOwnership() external;
function transferOwnership(address newOwner) external;
function transferOwnership(address newOwner) external; // nosemgrep
function upgrade(address _newMintManager) external;
function __constructor__(address _upgrader, address _governanceToken) external;
......
......@@ -135,25 +135,25 @@ library Encoding {
}
/// @notice Returns an appropriately encoded call to L1Block.setL1BlockValuesEcotone
/// @param baseFeeScalar L1 base fee Scalar
/// @param blobBaseFeeScalar L1 blob base fee Scalar
/// @param sequenceNumber Number of L2 blocks since epoch start.
/// @param timestamp L1 timestamp.
/// @param number L1 blocknumber.
/// @param baseFee L1 base fee.
/// @param blobBaseFee L1 blob base fee.
/// @param hash L1 blockhash.
/// @param batcherHash Versioned hash to authenticate batcher by.
/// @param _baseFeeScalar L1 base fee Scalar
/// @param _blobBaseFeeScalar L1 blob base fee Scalar
/// @param _sequenceNumber Number of L2 blocks since epoch start.
/// @param _timestamp L1 timestamp.
/// @param _number L1 blocknumber.
/// @param _baseFee L1 base fee.
/// @param _blobBaseFee L1 blob base fee.
/// @param _hash L1 blockhash.
/// @param _batcherHash Versioned hash to authenticate batcher by.
function encodeSetL1BlockValuesEcotone(
uint32 baseFeeScalar,
uint32 blobBaseFeeScalar,
uint64 sequenceNumber,
uint64 timestamp,
uint64 number,
uint256 baseFee,
uint256 blobBaseFee,
bytes32 hash,
bytes32 batcherHash
uint32 _baseFeeScalar,
uint32 _blobBaseFeeScalar,
uint64 _sequenceNumber,
uint64 _timestamp,
uint64 _number,
uint256 _baseFee,
uint256 _blobBaseFee,
bytes32 _hash,
bytes32 _batcherHash
)
internal
pure
......@@ -162,15 +162,15 @@ library Encoding {
bytes4 functionSignature = bytes4(keccak256("setL1BlockValuesEcotone()"));
return abi.encodePacked(
functionSignature,
baseFeeScalar,
blobBaseFeeScalar,
sequenceNumber,
timestamp,
number,
baseFee,
blobBaseFee,
hash,
batcherHash
_baseFeeScalar,
_blobBaseFeeScalar,
_sequenceNumber,
_timestamp,
_number,
_baseFee,
_blobBaseFee,
_hash,
_batcherHash
);
}
......
......@@ -25,8 +25,8 @@ contract LivenessGuard is ISemver, BaseGuard {
event OwnerRecorded(address owner);
/// @notice Semantic version.
/// @custom:semver 1.0.1-beta.1
string public constant version = "1.0.1-beta.1";
/// @custom:semver 1.0.1-beta.2
string public constant version = "1.0.1-beta.2";
/// @notice The safe account for which this contract will be the guard.
Safe internal immutable SAFE;
......@@ -66,21 +66,21 @@ contract LivenessGuard is ISemver, BaseGuard {
/// @notice Records the most recent time which any owner has signed a transaction.
/// @dev Called by the Safe contract before execution of a transaction.
function checkTransaction(
address to,
uint256 value,
bytes memory data,
Enum.Operation operation,
uint256 safeTxGas,
uint256 baseGas,
uint256 gasPrice,
address gasToken,
address payable refundReceiver,
bytes memory signatures,
address msgSender
address _to,
uint256 _value,
bytes memory _data,
Enum.Operation _operation,
uint256 _safeTxGas,
uint256 _baseGas,
uint256 _gasPrice,
address _gasToken,
address payable _refundReceiver,
bytes memory _signatures,
address _msgSender
)
external
{
msgSender; // silence unused variable warning
_msgSender; // silence unused variable warning
_requireOnlySafe();
// Cache the set of owners prior to execution.
......@@ -93,21 +93,21 @@ contract LivenessGuard is ISemver, BaseGuard {
// This call will reenter to the Safe which is calling it. This is OK because it is only reading the
// nonce, and using the getTransactionHash() method.
bytes32 txHash = SAFE.getTransactionHash({
to: to,
value: value,
data: data,
operation: operation,
safeTxGas: safeTxGas,
baseGas: baseGas,
gasPrice: gasPrice,
gasToken: gasToken,
refundReceiver: refundReceiver,
to: _to,
value: _value,
data: _data,
operation: _operation,
safeTxGas: _safeTxGas,
baseGas: _baseGas,
gasPrice: _gasPrice,
gasToken: _gasToken,
refundReceiver: _refundReceiver,
_nonce: SAFE.nonce() - 1
});
uint256 threshold = SAFE.getThreshold();
address[] memory signers =
SafeSigners.getNSigners({ dataHash: txHash, signatures: signatures, requiredSignatures: threshold });
SafeSigners.getNSigners({ _dataHash: txHash, _signatures: _signatures, _requiredSignatures: threshold });
for (uint256 i = 0; i < signers.length; i++) {
lastLive[signers[i]] = block.timestamp;
......
......@@ -8,31 +8,31 @@ library SafeSigners {
/// @dev Make sure to perform a bounds check for @param pos, to avoid out of bounds access on @param signatures
/// The signature format is a compact form of {bytes32 r}{bytes32 s}{uint8 v}
/// Compact means uint8 is not padded to 32 bytes.
/// @param pos Which signature to read.
/// @param _pos Which signature to read.
/// A prior bounds check of this parameter should be performed, to avoid out of bounds access.
/// @param signatures Concatenated {r, s, v} signatures.
/// @return v Recovery ID or Safe signature type.
/// @return r Output value r of the signature.
/// @return s Output value s of the signature.
/// @param _signatures Concatenated {r, s, v} signatures.
/// @return v_ Recovery ID or Safe signature type.
/// @return r_ Output value r of the signature.
/// @return s_ Output value s of the signature.
function signatureSplit(
bytes memory signatures,
uint256 pos
bytes memory _signatures,
uint256 _pos
)
internal
pure
returns (uint8 v, bytes32 r, bytes32 s)
returns (uint8 v_, bytes32 r_, bytes32 s_)
{
assembly {
let signaturePos := mul(0x41, pos)
r := mload(add(signatures, add(signaturePos, 0x20)))
s := mload(add(signatures, add(signaturePos, 0x40)))
let signaturePos := mul(0x41, _pos)
r_ := mload(add(_signatures, add(signaturePos, 0x20)))
s_ := mload(add(_signatures, add(signaturePos, 0x40)))
/**
* Here we are loading the last 32 bytes, including 31 bytes
* of 's'. There is no 'mload8' to do this.
* 'byte' is not working due to the Solidity parser, so lets
* use the second best option, 'and'
*/
v := and(mload(add(signatures, add(signaturePos, 0x41))), 0xff)
v_ := and(mload(add(_signatures, add(signaturePos, 0x41))), 0xff)
}
}
......@@ -43,23 +43,23 @@ library SafeSigners {
/// the signatures.
/// This method therefore simply extracts the addresses from the signatures.
function getNSigners(
bytes32 dataHash,
bytes memory signatures,
uint256 requiredSignatures
bytes32 _dataHash,
bytes memory _signatures,
uint256 _requiredSignatures
)
internal
pure
returns (address[] memory _owners)
returns (address[] memory owners_)
{
_owners = new address[](requiredSignatures);
owners_ = new address[](_requiredSignatures);
address currentOwner;
uint8 v;
bytes32 r;
bytes32 s;
uint256 i;
for (i = 0; i < requiredSignatures; i++) {
(v, r, s) = signatureSplit(signatures, i);
for (i = 0; i < _requiredSignatures; i++) {
(v, r, s) = signatureSplit(_signatures, i);
if (v == 0) {
// If v is 0 then it is a contract signature
// When handling contract signatures the address of the contract is encoded into r
......@@ -73,13 +73,13 @@ library SafeSigners {
// To support eth_sign and similar we adjust v and hash the messageHash with the Ethereum message prefix
// before applying ecrecover
currentOwner =
ecrecover(keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", dataHash)), v - 4, r, s);
ecrecover(keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", _dataHash)), v - 4, r, s);
} else {
// Default is the ecrecover flow with the provided data hash
// Use ecrecover with the messageHash for EOA signatures
currentOwner = ecrecover(dataHash, v, r, s);
currentOwner = ecrecover(_dataHash, v, r, s);
}
_owners[i] = currentOwner;
owners_[i] = currentOwner;
}
}
}
......@@ -16,8 +16,8 @@ contract StorageSetter is ISemver {
}
/// @notice Semantic version.
/// @custom:semver 1.2.1-beta.1
string public constant version = "1.2.1-beta.1";
/// @custom:semver 1.2.1-beta.2
string public constant version = "1.2.1-beta.2";
/// @notice Stores a bytes32 `_value` at `_slot`. Any storage slots that
/// are packed should be set through this interface.
......@@ -26,10 +26,10 @@ contract StorageSetter is ISemver {
}
/// @notice Stores a bytes32 value at each key in `_slots`.
function setBytes32(Slot[] calldata slots) public {
uint256 length = slots.length;
function setBytes32(Slot[] calldata _slots) public {
uint256 length = _slots.length;
for (uint256 i; i < length; i++) {
Storage.setBytes32(slots[i].key, slots[i].value);
Storage.setBytes32(_slots[i].key, _slots[i].value);
}
}
......
......@@ -8,5 +8,5 @@ interface IOwnable {
function owner() external view returns (address);
function renounceOwnership() external;
function transferOwnership(address newOwner) external; // nosemgrep: sol-style-input-arg-fmt.
function transferOwnership(address newOwner) external; // nosemgrep
}
......@@ -29,10 +29,10 @@ contract DelayedVetoable_Init is Test {
delayedVetoable = IDelayedVetoable(
address(
new DelayedVetoable({
initiator_: initiator,
vetoer_: vetoer,
target_: address(target),
operatingDelay_: operatingDelay
_initiator: initiator,
_vetoer: vetoer,
_target: address(target),
_operatingDelay: operatingDelay
})
)
);
......
......@@ -71,17 +71,17 @@ contract LivenessGuard_CheckTx_TestFails is LivenessGuard_TestInit {
function test_checkTransaction_callerIsNotSafe_revert() external {
vm.expectRevert("LivenessGuard: only Safe can call this function");
livenessGuard.checkTransaction({
to: address(0),
value: 0,
data: hex"00",
operation: Enum.Operation.Call,
safeTxGas: 0,
baseGas: 0,
gasPrice: 0,
gasToken: address(0),
refundReceiver: payable(address(0)),
signatures: hex"00",
msgSender: address(0)
_to: address(0),
_value: 0,
_data: hex"00",
_operation: Enum.Operation.Call,
_safeTxGas: 0,
_baseGas: 0,
_gasPrice: 0,
_gasToken: address(0),
_refundReceiver: payable(address(0)),
_signatures: hex"00",
_msgSender: address(0)
});
}
}
......
......@@ -98,7 +98,7 @@ contract SafeSigners_Test is Test, SafeTestTools {
// Recover the signatures using the _getNSigners() method.
address[] memory gotSigners =
SafeSigners.getNSigners({ dataHash: digest, signatures: signatures, requiredSignatures: numSigs });
SafeSigners.getNSigners({ _dataHash: digest, _signatures: signatures, _requiredSignatures: numSigs });
// Compare the list of recovered signers to the expected signers.
assertEq(gotSigners.length, numSigs);
......
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