Commit 8a3074ab authored by smartcontracts's avatar smartcontracts Committed by GitHub

fix(ctb): minor L1 semver/init cleanup (#2998)

Minor L1 contract semver/initialization cleanup after spotting an
inconsistency with ResourceMetering.
parent 2bea4f96
---
'@eth-optimism/contracts-bedrock': patch
---
Minor cleanups to initialization and semver for L1 contracts
This diff is collapsed.
...@@ -254,13 +254,13 @@ RLPWriter_Test:test_writeUint_smallint3() (gas: 7372) ...@@ -254,13 +254,13 @@ RLPWriter_Test:test_writeUint_smallint3() (gas: 7372)
RLPWriter_Test:test_writeUint_smallint4() (gas: 7351) RLPWriter_Test:test_writeUint_smallint4() (gas: 7351)
RLPWriter_Test:test_writeUint_zero() (gas: 7798) RLPWriter_Test:test_writeUint_zero() (gas: 7798)
ResourceMetering_Test:test_initialResourceParams() (gas: 8964) ResourceMetering_Test:test_initialResourceParams() (gas: 8964)
ResourceMetering_Test:test_updateNoGasDelta() (gas: 2008269) ResourceMetering_Test:test_updateNoGasDelta() (gas: 2008317)
ResourceMetering_Test:test_updateOneEmptyBlock() (gas: 18123) ResourceMetering_Test:test_updateOneEmptyBlock() (gas: 18171)
ResourceMetering_Test:test_updateParamsNoChange() (gas: 13860) ResourceMetering_Test:test_updateParamsNoChange() (gas: 13956)
ResourceMetering_Test:test_updateTenEmptyBlocks() (gas: 20523) ResourceMetering_Test:test_updateTenEmptyBlocks() (gas: 20571)
ResourceMetering_Test:test_updateTwoEmptyBlocks() (gas: 20546) ResourceMetering_Test:test_updateTwoEmptyBlocks() (gas: 20594)
ResourceMetering_Test:test_useMaxSucceeds() (gas: 8017023) ResourceMetering_Test:test_useMaxSucceeds() (gas: 8017119)
ResourceMetering_Test:test_useMoreThanMaxReverts() (gas: 16002) ResourceMetering_Test:test_useMoreThanMaxReverts() (gas: 16047)
Semver_Test:test_behindProxy() (gas: 504908) Semver_Test:test_behindProxy() (gas: 504908)
Semver_Test:test_major() (gas: 5406) Semver_Test:test_major() (gas: 5406)
Semver_Test:test_minor() (gas: 5430) Semver_Test:test_minor() (gas: 5430)
......
...@@ -86,6 +86,8 @@ contract L1StandardBridge is StandardBridge, Semver { ...@@ -86,6 +86,8 @@ contract L1StandardBridge is StandardBridge, Semver {
); );
/** /**
* @custom:semver 0.0.1
*
* @param _messenger Address of the L1CrossDomainMessenger. * @param _messenger Address of the L1CrossDomainMessenger.
*/ */
constructor(address payable _messenger) Semver(0, 0, 1) { constructor(address payable _messenger) Semver(0, 0, 1) {
......
...@@ -99,12 +99,11 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver { ...@@ -99,12 +99,11 @@ contract OptimismPortal is Initializable, ResourceMetering, Semver {
constructor(L2OutputOracle _l2Oracle, uint256 _finalizationPeriodSeconds) Semver(0, 0, 1) { constructor(L2OutputOracle _l2Oracle, uint256 _finalizationPeriodSeconds) Semver(0, 0, 1) {
L2_ORACLE = _l2Oracle; L2_ORACLE = _l2Oracle;
FINALIZATION_PERIOD_SECONDS = _finalizationPeriodSeconds; FINALIZATION_PERIOD_SECONDS = _finalizationPeriodSeconds;
initialize(); initialize();
} }
/** /**
* @notice Intializes mutable variables. * @notice Initializer;
*/ */
function initialize() public initializer { function initialize() public initializer {
l2Sender = DEFAULT_L2_SENDER; l2Sender = DEFAULT_L2_SENDER;
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity 0.8.10; pragma solidity 0.8.10;
import { Initializable } from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; import { Math } from "@openzeppelin/contracts/utils/math/Math.sol";
import { SignedMath } from "@openzeppelin/contracts/utils/math/SignedMath.sol"; import { SignedMath } from "@openzeppelin/contracts/utils/math/SignedMath.sol";
import { FixedPointMathLib } from "@rari-capital/solmate/src/utils/FixedPointMathLib.sol"; import { FixedPointMathLib } from "@rari-capital/solmate/src/utils/FixedPointMathLib.sol";
...@@ -11,7 +12,7 @@ import { Burn } from "../libraries/Burn.sol"; ...@@ -11,7 +12,7 @@ import { Burn } from "../libraries/Burn.sol";
* @notice ResourceMetering implements an EIP-1559 style resource metering system where pricing * @notice ResourceMetering implements an EIP-1559 style resource metering system where pricing
* updates automatically based on current demand. * updates automatically based on current demand.
*/ */
contract ResourceMetering { abstract contract ResourceMetering is Initializable {
/** /**
* @notice Represents the various parameters that control the way in which resources are * @notice Represents the various parameters that control the way in which resources are
* metered. Corresponds to the EIP-1559 resource metering system. * metered. Corresponds to the EIP-1559 resource metering system.
...@@ -62,19 +63,11 @@ contract ResourceMetering { ...@@ -62,19 +63,11 @@ contract ResourceMetering {
*/ */
uint256[49] private __gap; uint256[49] private __gap;
/**
* @notice Set the initial values. In order to enable this contract to be used in an upgradable
* context, the constructor calls a separate init function.
*/
constructor() {
__ResourceMetering_init();
}
/** /**
* @notice Sets initial resource parameter values. This function must either be called by the * @notice Sets initial resource parameter values. This function must either be called by the
* initializer function of an upgradeable child contract. * initializer function of an upgradeable child contract.
*/ */
function __ResourceMetering_init() internal { function __ResourceMetering_init() internal onlyInitializing {
params = ResourceParams({ params = ResourceParams({
prevBaseFee: INITIAL_BASE_FEE, prevBaseFee: INITIAL_BASE_FEE,
prevBoughtGas: 0, prevBoughtGas: 0,
......
...@@ -7,6 +7,10 @@ import { Proxy } from "../universal/Proxy.sol"; ...@@ -7,6 +7,10 @@ import { Proxy } from "../universal/Proxy.sol";
contract MeterUser is ResourceMetering { contract MeterUser is ResourceMetering {
constructor() { constructor() {
initialize();
}
function initialize() public initializer {
__ResourceMetering_init(); __ResourceMetering_init();
} }
......
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