Commit 304884d7 authored by Mark Tyneway's avatar Mark Tyneway

contracts-bedrock: more polish

parent e0c5cb1c
......@@ -206,28 +206,11 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
// Intentionally empty.
}
// TODO: I don't like having so many return args but I also don't like
// wrapping them into a struct
/**
* @notice
*/
function resourceConfig() public view override returns (SystemConfig.ResourceConfig memory) {
(
uint32 maxResourceLimit,
uint8 elasticityMultiplier,
uint8 baseFeeMaxChangeDenominator,
uint32 minimumBaseFee,
uint32 systemTxMaxGas,
uint128 maximumBaseFee
) = SYSTEM_CONFIG.resourceConfig();
SystemConfig.ResourceConfig memory config = SystemConfig.ResourceConfig({
maxResourceLimit: maxResourceLimit,
elasticityMultiplier: elasticityMultiplier,
baseFeeMaxChangeDenominator: baseFeeMaxChangeDenominator,
minimumBaseFee: minimumBaseFee,
systemTxMaxGas: systemTxMaxGas,
maximumBaseFee: maximumBaseFee
});
return config;
return SYSTEM_CONFIG.resourceConfig();
}
/**
......
......@@ -82,7 +82,10 @@ contract SystemConfig is OwnableUpgradeable, Semver {
*/
uint64 public gasLimit;
ResourceConfig public resourceConfig;
/**
* @notice
*/
ResourceConfig internal _resourceConfig;
/**
* @notice Emitted when configuration is updated
......@@ -141,7 +144,7 @@ contract SystemConfig is OwnableUpgradeable, Semver {
bytes32 _batcherHash,
uint64 _gasLimit,
address _unsafeBlockSigner,
ResourceConfig memory _resourceConfig
ResourceConfig memory _config
) public initializer {
__Ownable_init();
transferOwnership(_owner);
......@@ -150,7 +153,7 @@ contract SystemConfig is OwnableUpgradeable, Semver {
batcherHash = _batcherHash;
gasLimit = _gasLimit;
_setUnsafeBlockSigner(_unsafeBlockSigner);
_setResourceConfig(_resourceConfig);
_setResourceConfig(_config);
require(_gasLimit >= minimumGasLimit(), "SystemConfig: gas limit too low");
}
......@@ -235,6 +238,10 @@ contract SystemConfig is OwnableUpgradeable, Semver {
}
}
function resourceConfig() external view returns (ResourceConfig memory) {
return _resourceConfig;
}
function setResourceConfig(ResourceConfig memory _config) external onlyOwner {
_setResourceConfig(_config);
......@@ -247,10 +254,10 @@ contract SystemConfig is OwnableUpgradeable, Semver {
require(_config.baseFeeMaxChangeDenominator > 0);
require(_config.maxResourceLimit + _config.systemTxMaxGas <= gasLimit);
resourceConfig = _config;
_resourceConfig = _config;
}
function minimumGasLimit() public view returns (uint256) {
return resourceConfig.maxResourceLimit + resourceConfig.systemTxMaxGas;
return _resourceConfig.maxResourceLimit + _resourceConfig.systemTxMaxGas;
}
}
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