Commit b903b980 authored by Andreas Bigger's avatar Andreas Bigger

Updates all L1 bedrock contracts to use the triple slash natspec

standard.
parent 8f626d83
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -142,7 +142,7 @@ L1StandardBridge_FinalizeERC20Withdrawal_Test:test_finalizeERC20Withdrawal_succe ...@@ -142,7 +142,7 @@ L1StandardBridge_FinalizeERC20Withdrawal_Test:test_finalizeERC20Withdrawal_succe
L1StandardBridge_FinalizeERC20Withdrawal_TestFail:test_finalizeERC20Withdrawal_notMessenger_reverts() (gas: 31206) L1StandardBridge_FinalizeERC20Withdrawal_TestFail:test_finalizeERC20Withdrawal_notMessenger_reverts() (gas: 31206)
L1StandardBridge_FinalizeERC20Withdrawal_TestFail:test_finalizeERC20Withdrawal_notOtherBridge_reverts() (gas: 31562) L1StandardBridge_FinalizeERC20Withdrawal_TestFail:test_finalizeERC20Withdrawal_notOtherBridge_reverts() (gas: 31562)
L1StandardBridge_FinalizeETHWithdrawal_Test:test_finalizeETHWithdrawal_succeeds() (gas: 61722) L1StandardBridge_FinalizeETHWithdrawal_Test:test_finalizeETHWithdrawal_succeeds() (gas: 61722)
L1StandardBridge_Getter_Test:test_getters_succeeds() (gas: 32173) L1StandardBridge_Getter_Test:test_getters_succeeds() (gas: 32875)
L1StandardBridge_Initialize_Test:test_initialize_succeeds() (gas: 22050) L1StandardBridge_Initialize_Test:test_initialize_succeeds() (gas: 22050)
L1StandardBridge_Receive_Test:test_receive_succeeds() (gas: 610719) L1StandardBridge_Receive_Test:test_receive_succeeds() (gas: 610719)
L2CrossDomainMessenger_Test:test_messageVersion_succeeds() (gas: 8434) L2CrossDomainMessenger_Test:test_messageVersion_succeeds() (gas: 8434)
...@@ -171,9 +171,9 @@ L2ERC721Bridge_Test:test_finalizeBridgeERC721_notViaLocalMessenger_reverts() (ga ...@@ -171,9 +171,9 @@ L2ERC721Bridge_Test:test_finalizeBridgeERC721_notViaLocalMessenger_reverts() (ga
L2ERC721Bridge_Test:test_finalizeBridgeERC721_selfToken_reverts() (gas: 17659) L2ERC721Bridge_Test:test_finalizeBridgeERC721_selfToken_reverts() (gas: 17659)
L2ERC721Bridge_Test:test_finalizeBridgeERC721_succeeds() (gas: 169375) L2ERC721Bridge_Test:test_finalizeBridgeERC721_succeeds() (gas: 169375)
L2OutputOracleTest:test_computeL2Timestamp_succeeds() (gas: 37298) L2OutputOracleTest:test_computeL2Timestamp_succeeds() (gas: 37298)
L2OutputOracleTest:test_constructor_badTimestamp_reverts() (gas: 70991) L2OutputOracleTest:test_constructor_badTimestamp_reverts() (gas: 70994)
L2OutputOracleTest:test_constructor_l2BlockTimeZero_reverts() (gas: 45954) L2OutputOracleTest:test_constructor_l2BlockTimeZero_reverts() (gas: 45957)
L2OutputOracleTest:test_constructor_submissionInterval_reverts() (gas: 45942) L2OutputOracleTest:test_constructor_submissionInterval_reverts() (gas: 45945)
L2OutputOracleTest:test_constructor_succeeds() (gas: 33805) L2OutputOracleTest:test_constructor_succeeds() (gas: 33805)
L2OutputOracleTest:test_deleteL2Outputs_afterLatest_reverts() (gas: 212306) L2OutputOracleTest:test_deleteL2Outputs_afterLatest_reverts() (gas: 212306)
L2OutputOracleTest:test_deleteL2Outputs_finalized_reverts() (gas: 108990) L2OutputOracleTest:test_deleteL2Outputs_finalized_reverts() (gas: 108990)
...@@ -449,7 +449,7 @@ SequencerFeeVault_Test:test_withdraw_toL1_succeeds() (gas: 169242) ...@@ -449,7 +449,7 @@ SequencerFeeVault_Test:test_withdraw_toL1_succeeds() (gas: 169242)
SetPrevBaseFee_Test:test_setPrevBaseFee_succeeds() (gas: 11515) SetPrevBaseFee_Test:test_setPrevBaseFee_succeeds() (gas: 11515)
StandardBridge_Stateless_Test:test_isCorrectTokenPair_succeeds() (gas: 49936) StandardBridge_Stateless_Test:test_isCorrectTokenPair_succeeds() (gas: 49936)
StandardBridge_Stateless_Test:test_isOptimismMintableERC20_succeeds() (gas: 33072) StandardBridge_Stateless_Test:test_isOptimismMintableERC20_succeeds() (gas: 33072)
SystemConfig_Initialize_TestFail:test_initialize_lowGasLimit_reverts() (gas: 148848) SystemConfig_Initialize_TestFail:test_initialize_lowGasLimit_reverts() (gas: 148851)
SystemConfig_Setters_TestFail:test_setBatcherHash_notOwner_reverts() (gas: 10546) SystemConfig_Setters_TestFail:test_setBatcherHash_notOwner_reverts() (gas: 10546)
SystemConfig_Setters_TestFail:test_setGasConfig_notOwner_reverts() (gas: 10622) SystemConfig_Setters_TestFail:test_setGasConfig_notOwner_reverts() (gas: 10622)
SystemConfig_Setters_TestFail:test_setGasLimit_notOwner_reverts() (gas: 10615) SystemConfig_Setters_TestFail:test_setGasLimit_notOwner_reverts() (gas: 10615)
......
...@@ -6,42 +6,32 @@ import { OptimismPortal } from "./OptimismPortal.sol"; ...@@ -6,42 +6,32 @@ import { OptimismPortal } from "./OptimismPortal.sol";
import { CrossDomainMessenger } from "../universal/CrossDomainMessenger.sol"; import { CrossDomainMessenger } from "../universal/CrossDomainMessenger.sol";
import { Semver } from "../universal/Semver.sol"; import { Semver } from "../universal/Semver.sol";
/** /// @custom:proxied
* @custom:proxied /// @title L1CrossDomainMessenger
* @title L1CrossDomainMessenger /// @notice The L1CrossDomainMessenger is a message passing interface between L1 and L2 responsible
* @notice The L1CrossDomainMessenger is a message passing interface between L1 and L2 responsible /// for sending and receiving data on the L1 side. Users are encouraged to use this
* for sending and receiving data on the L1 side. Users are encouraged to use this /// interface instead of interacting with lower-level contracts directly.
* interface instead of interacting with lower-level contracts directly.
*/
contract L1CrossDomainMessenger is CrossDomainMessenger, Semver { contract L1CrossDomainMessenger is CrossDomainMessenger, Semver {
/** /// @notice Address of the OptimismPortal.
* @notice Address of the OptimismPortal.
*/
OptimismPortal public immutable PORTAL; OptimismPortal public immutable PORTAL;
/** /// @custom:semver 1.4.1
* @custom:semver 1.4.0 /// @notice Constructs the L1CrossDomainMessenger contract.
* /// @param _portal Address of the OptimismPortal contract on this network.
* @param _portal Address of the OptimismPortal contract on this network.
*/
constructor(OptimismPortal _portal) constructor(OptimismPortal _portal)
Semver(1, 4, 0) Semver(1, 4, 1)
CrossDomainMessenger(Predeploys.L2_CROSS_DOMAIN_MESSENGER) CrossDomainMessenger(Predeploys.L2_CROSS_DOMAIN_MESSENGER)
{ {
PORTAL = _portal; PORTAL = _portal;
initialize(); initialize();
} }
/** /// @notice Initializes the contract.
* @notice Initializer.
*/
function initialize() public initializer { function initialize() public initializer {
__CrossDomainMessenger_init(); __CrossDomainMessenger_init();
} }
/** /// @inheritdoc CrossDomainMessenger
* @inheritdoc CrossDomainMessenger
*/
function _sendMessage( function _sendMessage(
address _to, address _to,
uint64 _gasLimit, uint64 _gasLimit,
...@@ -51,16 +41,12 @@ contract L1CrossDomainMessenger is CrossDomainMessenger, Semver { ...@@ -51,16 +41,12 @@ contract L1CrossDomainMessenger is CrossDomainMessenger, Semver {
PORTAL.depositTransaction{ value: _value }(_to, _value, _gasLimit, false, _data); PORTAL.depositTransaction{ value: _value }(_to, _value, _gasLimit, false, _data);
} }
/** /// @inheritdoc CrossDomainMessenger
* @inheritdoc CrossDomainMessenger
*/
function _isOtherMessenger() internal view override returns (bool) { function _isOtherMessenger() internal view override returns (bool) {
return msg.sender == address(PORTAL) && PORTAL.l2Sender() == OTHER_MESSENGER; return msg.sender == address(PORTAL) && PORTAL.l2Sender() == OTHER_MESSENGER;
} }
/** /// @inheritdoc CrossDomainMessenger
* @inheritdoc CrossDomainMessenger
*/
function _isUnsafeTarget(address _target) internal view override returns (bool) { function _isUnsafeTarget(address _target) internal view override returns (bool) {
return _target == address(this) || _target == address(PORTAL); return _target == address(this) || _target == address(PORTAL);
} }
......
...@@ -6,43 +6,35 @@ import { IERC721 } from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; ...@@ -6,43 +6,35 @@ import { IERC721 } from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import { L2ERC721Bridge } from "../L2/L2ERC721Bridge.sol"; import { L2ERC721Bridge } from "../L2/L2ERC721Bridge.sol";
import { Semver } from "../universal/Semver.sol"; import { Semver } from "../universal/Semver.sol";
/** /// @title L1ERC721Bridge
* @title L1ERC721Bridge /// @notice The L1 ERC721 bridge is a contract which works together with the L2 ERC721 bridge to
* @notice The L1 ERC721 bridge is a contract which works together with the L2 ERC721 bridge to /// make it possible to transfer ERC721 tokens from Ethereum to Optimism. This contract
* make it possible to transfer ERC721 tokens from Ethereum to Optimism. This contract /// acts as an escrow for ERC721 tokens deposited into L2.
* acts as an escrow for ERC721 tokens deposited into L2.
*/
contract L1ERC721Bridge is ERC721Bridge, Semver { contract L1ERC721Bridge is ERC721Bridge, Semver {
/** /// @notice Mapping of L1 token to L2 token to ID to boolean, indicating if the given L1 token
* @notice Mapping of L1 token to L2 token to ID to boolean, indicating if the given L1 token /// by ID was deposited for a given L2 token.
* by ID was deposited for a given L2 token.
*/
mapping(address => mapping(address => mapping(uint256 => bool))) public deposits; mapping(address => mapping(address => mapping(uint256 => bool))) public deposits;
/** /// @custom:semver 1.1.2
* @custom:semver 1.1.1 /// @notice Constructs the L1ERC721Bridge contract.
* /// @param _messenger Address of the CrossDomainMessenger on this network.
* @param _messenger Address of the CrossDomainMessenger on this network. /// @param _otherBridge Address of the ERC721 bridge on the other network.
* @param _otherBridge Address of the ERC721 bridge on the other network.
*/
constructor(address _messenger, address _otherBridge) constructor(address _messenger, address _otherBridge)
Semver(1, 1, 1) Semver(1, 1, 2)
ERC721Bridge(_messenger, _otherBridge) ERC721Bridge(_messenger, _otherBridge)
{} {}
/** /// @notice Completes an ERC721 bridge from the other domain and sends the ERC721 token to the
* @notice Completes an ERC721 bridge from the other domain and sends the ERC721 token to the /// recipient on this domain.
* recipient on this domain. ///
* /// @param _localToken Address of the ERC721 token on this domain.
* @param _localToken Address of the ERC721 token on this domain. /// @param _remoteToken Address of the ERC721 token on the other domain.
* @param _remoteToken Address of the ERC721 token on the other domain. /// @param _from Address that triggered the bridge on the other domain.
* @param _from Address that triggered the bridge on the other domain. /// @param _to Address to receive the token on this domain.
* @param _to Address to receive the token on this domain. /// @param _tokenId ID of the token being deposited.
* @param _tokenId ID of the token being deposited. /// @param _extraData Optional data to forward to L2.
* @param _extraData Optional data to forward to L2. Data supplied here will not be used to /// Data supplied here will not be used to execute any code on L2 and is
* execute any code on L2 and is only emitted as extra data for the /// only emitted as extra data for the convenience of off-chain tooling.
* convenience of off-chain tooling.
*/
function finalizeBridgeERC721( function finalizeBridgeERC721(
address _localToken, address _localToken,
address _remoteToken, address _remoteToken,
...@@ -71,9 +63,7 @@ contract L1ERC721Bridge is ERC721Bridge, Semver { ...@@ -71,9 +63,7 @@ contract L1ERC721Bridge is ERC721Bridge, Semver {
emit ERC721BridgeFinalized(_localToken, _remoteToken, _from, _to, _tokenId, _extraData); emit ERC721BridgeFinalized(_localToken, _remoteToken, _from, _to, _tokenId, _extraData);
} }
/** /// @inheritdoc ERC721Bridge
* @inheritdoc ERC721Bridge
*/
function _initiateBridgeERC721( function _initiateBridgeERC721(
address _localToken, address _localToken,
address _remoteToken, address _remoteToken,
......
...@@ -6,48 +6,40 @@ import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; ...@@ -6,48 +6,40 @@ import { Math } from "@openzeppelin/contracts/utils/math/Math.sol";
import { Burn } from "../libraries/Burn.sol"; import { Burn } from "../libraries/Burn.sol";
import { Arithmetic } from "../libraries/Arithmetic.sol"; import { Arithmetic } from "../libraries/Arithmetic.sol";
/** /// @custom:upgradeable
* @custom:upgradeable /// @title ResourceMetering
* @title ResourceMetering /// @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.
*/
abstract contract ResourceMetering is Initializable { 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. /// @custom:field prevBaseFee Base fee from the previous block(s).
* /// @custom:field prevBoughtGas Amount of gas bought so far in the current block.
* @custom:field prevBaseFee Base fee from the previous block(s). /// @custom:field prevBlockNum Last block number that the base fee was updated.
* @custom:field prevBoughtGas Amount of gas bought so far in the current block.
* @custom:field prevBlockNum Last block number that the base fee was updated.
*/
struct ResourceParams { struct ResourceParams {
uint128 prevBaseFee; uint128 prevBaseFee;
uint64 prevBoughtGas; uint64 prevBoughtGas;
uint64 prevBlockNum; uint64 prevBlockNum;
} }
/** /// @notice Represents the configuration for the EIP-1559 based curve for the deposit gas
* @notice Represents the configuration for the EIP-1559 based curve for the deposit gas /// market. These values should be set with care as it is possible to set them in
* market. These values should be set with care as it is possible to set them in /// a way that breaks the deposit gas market. The target resource limit is defined as
* a way that breaks the deposit gas market. The target resource limit is defined as /// maxResourceLimit / elasticityMultiplier. This struct was designed to fit within a
* maxResourceLimit / elasticityMultiplier. This struct was designed to fit within a /// single word. There is additional space for additions in the future.
* single word. There is additional space for additions in the future. /// @custom:field maxResourceLimit Represents the maximum amount of deposit gas that
* /// can be purchased per block.
* @custom:field maxResourceLimit Represents the maximum amount of deposit gas that /// @custom:field elasticityMultiplier Determines the target resource limit along with
* can be purchased per block. /// the resource limit.
* @custom:field elasticityMultiplier Determines the target resource limit along with /// @custom:field baseFeeMaxChangeDenominator Determines max change on fee per block.
* the resource limit. /// @custom:field minimumBaseFee The min deposit base fee, it is clamped to this
* @custom:field baseFeeMaxChangeDenominator Determines max change on fee per block. /// value.
* @custom:field minimumBaseFee The min deposit base fee, it is clamped to this /// @custom:field systemTxMaxGas The amount of gas supplied to the system
* value. /// transaction. This should be set to the same
* @custom:field systemTxMaxGas The amount of gas supplied to the system /// number that the op-node sets as the gas limit
* transaction. This should be set to the same number /// for the system transaction.
* that the op-node sets as the gas limit for the /// @custom:field maximumBaseFee The max deposit base fee, it is clamped to this
* system transaction. /// value.
* @custom:field maximumBaseFee The max deposit base fee, it is clamped to this
* value.
*/
struct ResourceConfig { struct ResourceConfig {
uint32 maxResourceLimit; uint32 maxResourceLimit;
uint8 elasticityMultiplier; uint8 elasticityMultiplier;
...@@ -57,21 +49,14 @@ abstract contract ResourceMetering is Initializable { ...@@ -57,21 +49,14 @@ abstract contract ResourceMetering is Initializable {
uint128 maximumBaseFee; uint128 maximumBaseFee;
} }
/** /// @notice EIP-1559 style gas parameters.
* @notice EIP-1559 style gas parameters.
*/
ResourceParams public params; ResourceParams public params;
/** /// @notice Reserve extra slots (to a total of 50) in the storage layout for future upgrades.
* @notice Reserve extra slots (to a total of 50) in the storage layout for future upgrades.
*/
uint256[48] private __gap; uint256[48] private __gap;
/** /// @notice Meters access to a function based an amount of a requested resource.
* @notice Meters access to a function based an amount of a requested resource. /// @param _amount Amount of the resource requested.
*
* @param _amount Amount of the resource requested.
*/
modifier metered(uint64 _amount) { modifier metered(uint64 _amount) {
// Record initial gas amount so we can refund for it later. // Record initial gas amount so we can refund for it later.
uint256 initialGas = gasleft(); uint256 initialGas = gasleft();
...@@ -83,12 +68,9 @@ abstract contract ResourceMetering is Initializable { ...@@ -83,12 +68,9 @@ abstract contract ResourceMetering is Initializable {
_metered(_amount, initialGas); _metered(_amount, initialGas);
} }
/** /// @notice An internal function that holds all of the logic for metering a resource.
* @notice An internal function that holds all of the logic for metering a resource. /// @param _amount Amount of the resource requested.
* /// @param _initialGas The amount of gas before any modifier execution.
* @param _amount Amount of the resource requested.
* @param _initialGas The amount of gas before any modifier execution.
*/
function _metered(uint64 _amount, uint256 _initialGas) internal { function _metered(uint64 _amount, uint256 _initialGas) internal {
// Update block number and base fee if necessary. // Update block number and base fee if necessary.
uint256 blockDiff = block.number - params.prevBlockNum; uint256 blockDiff = block.number - params.prevBlockNum;
...@@ -163,18 +145,14 @@ abstract contract ResourceMetering is Initializable { ...@@ -163,18 +145,14 @@ abstract contract ResourceMetering is Initializable {
} }
} }
/** /// @notice Virtual function that returns the resource config.
* @notice Virtual function that returns the resource config. Contracts that inherit this /// Contracts that inherit this contract must implement this function.
* contract must implement this function. /// @return ResourceConfig
*
* @return ResourceConfig
*/
function _resourceConfig() internal virtual returns (ResourceConfig memory); function _resourceConfig() internal virtual returns (ResourceConfig memory);
/** /// @notice Sets initial resource parameter values.
* @notice Sets initial resource parameter values. This function must either be called by the /// This function must either be called by the initializer function of an upgradeable
* initializer function of an upgradeable child contract. /// child contract.
*/
// solhint-disable-next-line func-name-mixedcase // solhint-disable-next-line func-name-mixedcase
function __ResourceMetering_init() internal onlyInitializing { function __ResourceMetering_init() internal onlyInitializing {
params = ResourceParams({ params = ResourceParams({
......
...@@ -17,7 +17,7 @@ contract L1StandardBridge_Getter_Test is Bridge_Initializer { ...@@ -17,7 +17,7 @@ contract L1StandardBridge_Getter_Test is Bridge_Initializer {
assert(L1Bridge.OTHER_BRIDGE() == L2Bridge); assert(L1Bridge.OTHER_BRIDGE() == L2Bridge);
assert(L1Bridge.messenger() == L1Messenger); assert(L1Bridge.messenger() == L1Messenger);
assert(L1Bridge.MESSENGER() == L1Messenger); assert(L1Bridge.MESSENGER() == L1Messenger);
assertEq(L1Bridge.version(), "1.1.0"); assertEq(L1Bridge.version(), "1.1.1");
} }
} }
......
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