Commit 2865dd9b authored by Kelvin Fichter's avatar Kelvin Fichter

maint(ctb): cleanup and comments for SystemConfig

Minor cleanup and comment updates for the SystemConfig contract. Some
comments were missing and functions weren't entirely in the right order.
parent 615a30c1
---
'@eth-optimism/contracts-bedrock': patch
---
Minor comment updates and cleanup to the SystemConfig contract.
This diff is collapsed.
...@@ -79,13 +79,14 @@ contract SystemConfig is OwnableUpgradeable, Semver { ...@@ -79,13 +79,14 @@ contract SystemConfig is OwnableUpgradeable, Semver {
event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data); event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data);
/** /**
* @custom:semver 1.0.0 * @custom:semver 1.0.1
* *
* @param _owner Initial owner of the contract. * @param _owner Initial owner of the contract.
* @param _overhead Initial overhead value. * @param _overhead Initial overhead value.
* @param _scalar Initial scalar value. * @param _scalar Initial scalar value.
* @param _batcherHash Initial batcher hash. * @param _batcherHash Initial batcher hash.
* @param _gasLimit Initial gas limit. * @param _gasLimit Initial gas limit.
* @param _unsafeBlockSigner Initial unsafe block signer address.
*/ */
constructor( constructor(
address _owner, address _owner,
...@@ -94,18 +95,19 @@ contract SystemConfig is OwnableUpgradeable, Semver { ...@@ -94,18 +95,19 @@ contract SystemConfig is OwnableUpgradeable, Semver {
bytes32 _batcherHash, bytes32 _batcherHash,
uint64 _gasLimit, uint64 _gasLimit,
address _unsafeBlockSigner address _unsafeBlockSigner
) Semver(1, 0, 0) { ) Semver(1, 0, 1) {
initialize(_owner, _overhead, _scalar, _batcherHash, _gasLimit, _unsafeBlockSigner); initialize(_owner, _overhead, _scalar, _batcherHash, _gasLimit, _unsafeBlockSigner);
} }
/** /**
* @notice Initializer. * @notice Initializer.
* *
* @param _owner Initial owner of the contract. * @param _owner Initial owner of the contract.
* @param _overhead Initial overhead value. * @param _overhead Initial overhead value.
* @param _scalar Initial scalar value. * @param _scalar Initial scalar value.
* @param _batcherHash Initial batcher hash. * @param _batcherHash Initial batcher hash.
* @param _gasLimit Initial gas limit. * @param _gasLimit Initial gas limit.
* @param _unsafeBlockSigner Initial unsafe block signer address.
*/ */
function initialize( function initialize(
address _owner, address _owner,
...@@ -126,11 +128,14 @@ contract SystemConfig is OwnableUpgradeable, Semver { ...@@ -126,11 +128,14 @@ contract SystemConfig is OwnableUpgradeable, Semver {
} }
/** /**
* @notice High level getter for the unsafe block signer address. * @notice High level getter for the unsafe block signer address. Unsafe blocks can be
* Unsafe blocks can be propagated across the p2p network * propagated across the p2p network if they are signed by the key corresponding to
* if they are signed by the key corresponding to this address. * this address.
*
* @return Address of the unsafe block signer.
*/ */
function unsafeBlockSigner() public view returns (address) { // solhint-disable-next-line ordering
function unsafeBlockSigner() external view returns (address) {
address addr; address addr;
bytes32 slot = UNSAFE_BLOCK_SIGNER_SLOT; bytes32 slot = UNSAFE_BLOCK_SIGNER_SLOT;
assembly { assembly {
...@@ -139,12 +144,23 @@ contract SystemConfig is OwnableUpgradeable, Semver { ...@@ -139,12 +144,23 @@ contract SystemConfig is OwnableUpgradeable, Semver {
return addr; return addr;
} }
/**
* @notice Updates the unsafe block signer address.
*
* @param _unsafeBlockSigner New unsafe block signer address.
*/
function setUnsafeBlockSigner(address _unsafeBlockSigner) external onlyOwner {
_setUnsafeBlockSigner(_unsafeBlockSigner);
bytes memory data = abi.encode(_unsafeBlockSigner);
emit ConfigUpdate(VERSION, UpdateType.UNSAFE_BLOCK_SIGNER, data);
}
/** /**
* @notice Updates the batcher hash. * @notice Updates the batcher hash.
* *
* @param _batcherHash New batcher hash. * @param _batcherHash New batcher hash.
*/ */
// solhint-disable-next-line ordering
function setBatcherHash(bytes32 _batcherHash) external onlyOwner { function setBatcherHash(bytes32 _batcherHash) external onlyOwner {
batcherHash = _batcherHash; batcherHash = _batcherHash;
...@@ -166,27 +182,6 @@ contract SystemConfig is OwnableUpgradeable, Semver { ...@@ -166,27 +182,6 @@ contract SystemConfig is OwnableUpgradeable, Semver {
emit ConfigUpdate(VERSION, UpdateType.GAS_CONFIG, data); emit ConfigUpdate(VERSION, UpdateType.GAS_CONFIG, data);
} }
function setUnsafeBlockSigner(address _unsafeBlockSigner) external onlyOwner {
_setUnsafeBlockSigner(_unsafeBlockSigner);
bytes memory data = abi.encode(_unsafeBlockSigner);
emit ConfigUpdate(VERSION, UpdateType.UNSAFE_BLOCK_SIGNER, data);
}
/**
* @notice Low level setter for the unsafe block signer address.
* This function exists to deduplicate code around storing
* the unsafeBlockSigner address in storage.
*
* @param _unsafeBlockSigner New unsafeBlockSigner value
*/
function _setUnsafeBlockSigner(address _unsafeBlockSigner) internal {
bytes32 slot = UNSAFE_BLOCK_SIGNER_SLOT;
assembly {
sstore(slot, _unsafeBlockSigner)
}
}
/** /**
* @notice Updates the L2 gas limit. * @notice Updates the L2 gas limit.
* *
...@@ -199,4 +194,17 @@ contract SystemConfig is OwnableUpgradeable, Semver { ...@@ -199,4 +194,17 @@ contract SystemConfig is OwnableUpgradeable, Semver {
bytes memory data = abi.encode(_gasLimit); bytes memory data = abi.encode(_gasLimit);
emit ConfigUpdate(VERSION, UpdateType.GAS_LIMIT, data); emit ConfigUpdate(VERSION, UpdateType.GAS_LIMIT, data);
} }
/**
* @notice Low level setter for the unsafe block signer address. This function exists to
* deduplicate code around storing the unsafeBlockSigner address in storage.
*
* @param _unsafeBlockSigner New unsafeBlockSigner value.
*/
function _setUnsafeBlockSigner(address _unsafeBlockSigner) internal {
bytes32 slot = UNSAFE_BLOCK_SIGNER_SLOT;
assembly {
sstore(slot, _unsafeBlockSigner)
}
}
} }
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