Commit 2fa080b1 authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge branch 'develop' into dependabot/go_modules/github.com/onsi/gomega-1.28.0

parents 5c03fe4e cc5cf70d
queue_rules:
- name: urgent
queue_conditions:
- label = C-urgent
- name: default
conditions: []
queue_conditions: []
- name: lowpriority
queue_conditions:
- author=dependabot[bot]
pull_request_rules:
- name: Automatic merge on approval
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -535,7 +535,7 @@ PreimageOracle_Test:test_loadKeccak256PreimagePart_outOfBoundsOffset_reverts() (
PreimageOracle_Test:test_loadKeccak256PreimagePart_succeeds() (gas: 76076)
PreimageOracle_Test:test_loadLocalData_onePart_succeeds() (gas: 75818)
PreimageOracle_Test:test_loadLocalData_outOfBoundsOffset_reverts() (gas: 8803)
ProtocolVersions_Initialize_Test:test_initialize_events_succeeds() (gas: 52175)
ProtocolVersions_Initialize_Test:test_initialize_events_succeeds() (gas: 52181)
ProtocolVersions_Initialize_Test:test_initialize_values_succeeds() (gas: 32301)
ProtocolVersions_Setters_TestFail:test_setRecommended_notOwner_reverts() (gas: 15508)
ProtocolVersions_Setters_TestFail:test_setRequired_notOwner_reverts() (gas: 15520)
......@@ -659,11 +659,14 @@ SequencerFeeVault_Test:test_withdraw_toL1_succeeds() (gas: 171675)
SetPrevBaseFee_Test:test_setPrevBaseFee_succeeds() (gas: 11549)
StandardBridge_Stateless_Test:test_isCorrectTokenPair_succeeds() (gas: 49936)
StandardBridge_Stateless_Test:test_isOptimismMintableERC20_succeeds() (gas: 33072)
SystemConfig_Initialize_Test:test_initialize_events_succeeds() (gas: 71945)
SystemConfig_Initialize_Test:test_initialize_startBlockOverride_succeeds() (gas: 65127)
Storage_Roundtrip_Test:test_setGetAddress_succeeds(bytes32,address) (runs: 64, μ: 31799, ~: 31799)
Storage_Roundtrip_Test:test_setGetBytes32_succeeds(bytes32,bytes32) (runs: 64, μ: 31643, ~: 31643)
Storage_Roundtrip_Test:test_setGetUint_succeeds(bytes32,uint256) (runs: 64, μ: 30998, ~: 31620)
SystemConfig_Initialize_Test:test_initialize_events_succeeds() (gas: 71950)
SystemConfig_Initialize_Test:test_initialize_startBlockOverride_succeeds() (gas: 65132)
SystemConfig_Initialize_Test:test_initialize_values_succeeds() (gas: 64946)
SystemConfig_Initialize_TestFail:test_initialize_lowGasLimit_reverts() (gas: 55589)
SystemConfig_Initialize_TestFail:test_initialize_startBlock_reverts() (gas: 78208)
SystemConfig_Initialize_TestFail:test_initialize_startBlock_reverts() (gas: 78214)
SystemConfig_Setters_TestFail:test_setBatcherHash_notOwner_reverts() (gas: 15607)
SystemConfig_Setters_TestFail:test_setGasConfig_notOwner_reverts() (gas: 15577)
SystemConfig_Setters_TestFail:test_setGasLimit_notOwner_reverts() (gas: 15676)
......
......@@ -7,8 +7,8 @@
"src/L1/L1StandardBridge.sol": "0xdafe88c8b1255202eb674f4ebfb0dca791d2c87480c2c8d00cc46859671a5fa8",
"src/L1/L2OutputOracle.sol": "0xd263f43b79b6f1dca3a27f8bdbacf97deb1a3a95b7e1d395079700eecea65402",
"src/L1/OptimismPortal.sol": "0x8fdab55ab7c18bb7e037f0719c749f2cf1b0ca2da17da4ea0d1a4c5e2243ac60",
"src/L1/ProtocolVersions.sol": "0x2f980d89b583936c7af5d71a1e2c73d026d895c1687abdd09815e4581032cee5",
"src/L1/SystemConfig.sol": "0x4eb501cc372b135bf9c5ceaf66b1bf21a166c8accc5dbd55276c854f12955dd8",
"src/L1/ProtocolVersions.sol": "0xc4f142ed9c195871ee21902245a9e2b902f8e38fcc77e6f61fb98f4d399031e4",
"src/L1/SystemConfig.sol": "0xf23f2c4425996c2719e1baddf468b328de724305f1852b59cd0b09c843075d63",
"src/L2/BaseFeeVault.sol": "0xc347c1aebe69178e72d2b1d3e700bbf84e39975319465bb85d69fd0d60fc1759",
"src/L2/GasPriceOracle.sol": "0x88efffbd40f8d012d700a5d7fde0d92266f65e9d7006cd8f034bacaa036d0eb2",
"src/L2/L1Block.sol": "0x1ed9aa36036ded00a0383692eca81a22f668d64e22af973559d2ccefc86825c0",
......
......@@ -3,6 +3,7 @@ pragma solidity 0.8.15;
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import { ISemver } from "src/universal/ISemver.sol";
import { Storage } from "src/libraries/Storage.sol";
/// @notice ProtocolVersion is a numeric identifier of the protocol version.
type ProtocolVersion is uint256;
......@@ -34,8 +35,8 @@ contract ProtocolVersions is OwnableUpgradeable, ISemver {
event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data);
/// @notice Semantic version.
/// @custom:semver 0.1.0
string public constant version = "0.1.0";
/// @custom:semver 0.2.0
string public constant version = "0.2.0";
/// @notice Constructs the ProtocolVersion contract. Cannot set
/// the owner to `address(0)` due to the Ownable contract's
......@@ -67,30 +68,10 @@ contract ProtocolVersions is OwnableUpgradeable, ISemver {
_setRecommended(_recommended);
}
/// @notice Returns a ProtocolVersion stored in an arbitrary storage slot.
/// These storage slots decouple the storage layout from solc's automation.
/// @param _slot The storage slot to retrieve the address from.
function _getProtocolVersion(bytes32 _slot) internal view returns (ProtocolVersion out_) {
assembly {
out_ := sload(_slot)
}
}
/// @notice Stores a ProtocolVersion in an arbitrary storage slot, `_slot`.
/// @param _version The protocol version to store
/// @param _slot The storage slot to store the address in.
/// @dev WARNING! This function must be used cautiously, as it allows for overwriting values
/// in arbitrary storage slots.
function _setProtocolVersion(ProtocolVersion _version, bytes32 _slot) internal {
assembly {
sstore(_slot, _version)
}
}
/// @notice High level getter for the required protocol version.
/// @return out_ Required protocol version to sync to the head of the chain.
function required() external view returns (ProtocolVersion out_) {
out_ = _getProtocolVersion(REQUIRED_SLOT);
out_ = ProtocolVersion.wrap(Storage.getUint(REQUIRED_SLOT));
}
/// @notice Updates the required protocol version. Can only be called by the owner.
......@@ -102,7 +83,7 @@ contract ProtocolVersions is OwnableUpgradeable, ISemver {
/// @notice Internal function for updating the required protocol version.
/// @param _required New required protocol version.
function _setRequired(ProtocolVersion _required) internal {
_setProtocolVersion(_required, REQUIRED_SLOT);
Storage.setUint(REQUIRED_SLOT, ProtocolVersion.unwrap(_required));
bytes memory data = abi.encode(_required);
emit ConfigUpdate(VERSION, UpdateType.REQUIRED_PROTOCOL_VERSION, data);
......@@ -111,7 +92,7 @@ contract ProtocolVersions is OwnableUpgradeable, ISemver {
/// @notice High level getter for the recommended protocol version.
/// @return out_ Recommended protocol version to sync to the head of the chain.
function recommended() external view returns (ProtocolVersion out_) {
out_ = _getProtocolVersion(RECOMMENDED_SLOT);
out_ = ProtocolVersion.wrap(Storage.getUint(RECOMMENDED_SLOT));
}
/// @notice Updates the recommended protocol version. Can only be called by the owner.
......@@ -123,7 +104,7 @@ contract ProtocolVersions is OwnableUpgradeable, ISemver {
/// @notice Internal function for updating the recommended protocol version.
/// @param _recommended New recommended protocol version.
function _setRecommended(ProtocolVersion _recommended) internal {
_setProtocolVersion(_recommended, RECOMMENDED_SLOT);
Storage.setUint(RECOMMENDED_SLOT, ProtocolVersion.unwrap(_recommended));
bytes memory data = abi.encode(_recommended);
emit ConfigUpdate(VERSION, UpdateType.RECOMMENDED_PROTOCOL_VERSION, data);
......
......@@ -4,6 +4,7 @@ pragma solidity 0.8.15;
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import { ISemver } from "src/universal/ISemver.sol";
import { ResourceMetering } from "src/L1/ResourceMetering.sol";
import { Storage } from "src/libraries/Storage.sol";
/// @title SystemConfig
/// @notice The SystemConfig contract is used to manage configuration of an Optimism network.
......@@ -99,8 +100,8 @@ contract SystemConfig is OwnableUpgradeable, ISemver {
uint256 public startBlock;
/// @notice Semantic version.
/// @custom:semver 1.7.1
string public constant version = "1.7.1";
/// @custom:semver 1.8.0
string public constant version = "1.8.0";
/// @notice Constructs the SystemConfig contract. Cannot set
/// the owner to `address(0)` due to the Ownable contract's
......@@ -174,13 +175,13 @@ contract SystemConfig is OwnableUpgradeable, ISemver {
_setGasLimit(_gasLimit);
_setUnsafeBlockSigner(_unsafeBlockSigner);
_setAddress(_batchInbox, BATCH_INBOX_SLOT);
_setAddress(_addresses.l1CrossDomainMessenger, L1_CROSS_DOMAIN_MESSENGER_SLOT);
_setAddress(_addresses.l1ERC721Bridge, L1_ERC_721_BRIDGE_SLOT);
_setAddress(_addresses.l1StandardBridge, L1_STANDARD_BRIDGE_SLOT);
_setAddress(_addresses.l2OutputOracle, L2_OUTPUT_ORACLE_SLOT);
_setAddress(_addresses.optimismPortal, OPTIMISM_PORTAL_SLOT);
_setAddress(_addresses.optimismMintableERC20Factory, OPTIMISM_MINTABLE_ERC20_FACTORY_SLOT);
Storage.setAddress(BATCH_INBOX_SLOT, _batchInbox);
Storage.setAddress(L1_CROSS_DOMAIN_MESSENGER_SLOT, _addresses.l1CrossDomainMessenger);
Storage.setAddress(L1_ERC_721_BRIDGE_SLOT, _addresses.l1ERC721Bridge);
Storage.setAddress(L1_STANDARD_BRIDGE_SLOT, _addresses.l1StandardBridge);
Storage.setAddress(L2_OUTPUT_ORACLE_SLOT, _addresses.l2OutputOracle);
Storage.setAddress(OPTIMISM_PORTAL_SLOT, _addresses.optimismPortal);
Storage.setAddress(OPTIMISM_MINTABLE_ERC20_FACTORY_SLOT, _addresses.optimismMintableERC20Factory);
_setStartBlock(_startBlock);
......@@ -203,65 +204,43 @@ contract SystemConfig is OwnableUpgradeable, ISemver {
/// key corresponding to this address.
/// @return addr_ Address of the unsafe block signer.
// solhint-disable-next-line ordering
function unsafeBlockSigner() external view returns (address addr_) {
addr_ = _getAddress(UNSAFE_BLOCK_SIGNER_SLOT);
}
/// @notice Stores an address in an arbitrary storage slot, `_slot`.
/// @param _addr The address to store
/// @param _slot The storage slot to store the address in.
/// @dev WARNING! This function must be used cautiously, as it allows for overwriting values
/// in arbitrary storage slots. Solc will add checks that the data passed as `_addr`
/// is 20 bytes or less.
function _setAddress(address _addr, bytes32 _slot) internal {
assembly {
sstore(_slot, _addr)
}
}
/// @notice Returns an address stored in an arbitrary storage slot.
/// These storage slots decouple the storage layout from
/// solc's automation.
/// @param _slot The storage slot to retrieve the address from.
function _getAddress(bytes32 _slot) internal view returns (address addr_) {
assembly {
addr_ := sload(_slot)
}
function unsafeBlockSigner() public view returns (address addr_) {
addr_ = Storage.getAddress(UNSAFE_BLOCK_SIGNER_SLOT);
}
/// @notice Getter for the L1CrossDomainMessenger address.
function l1CrossDomainMessenger() external view returns (address addr_) {
addr_ = _getAddress(L1_CROSS_DOMAIN_MESSENGER_SLOT);
addr_ = Storage.getAddress(L1_CROSS_DOMAIN_MESSENGER_SLOT);
}
/// @notice Getter for the L1ERC721Bridge address.
function l1ERC721Bridge() external view returns (address addr_) {
addr_ = _getAddress(L1_ERC_721_BRIDGE_SLOT);
addr_ = Storage.getAddress(L1_ERC_721_BRIDGE_SLOT);
}
/// @notice Getter for the L1StandardBridge address.
function l1StandardBridge() external view returns (address addr_) {
addr_ = _getAddress(L1_STANDARD_BRIDGE_SLOT);
addr_ = Storage.getAddress(L1_STANDARD_BRIDGE_SLOT);
}
/// @notice Getter for the L2OutputOracle address.
function l2OutputOracle() external view returns (address addr_) {
addr_ = _getAddress(L2_OUTPUT_ORACLE_SLOT);
addr_ = Storage.getAddress(L2_OUTPUT_ORACLE_SLOT);
}
/// @notice Getter for the OptimismPortal address.
function optimismPortal() external view returns (address addr_) {
addr_ = _getAddress(OPTIMISM_PORTAL_SLOT);
addr_ = Storage.getAddress(OPTIMISM_PORTAL_SLOT);
}
/// @notice Getter for the OptimismMintableERC20Factory address.
function optimismMintableERC20Factory() external view returns (address addr_) {
addr_ = _getAddress(OPTIMISM_MINTABLE_ERC20_FACTORY_SLOT);
addr_ = Storage.getAddress(OPTIMISM_MINTABLE_ERC20_FACTORY_SLOT);
}
/// @notice Getter for the BatchInbox address.
function batchInbox() external view returns (address addr_) {
addr_ = _getAddress(BATCH_INBOX_SLOT);
addr_ = Storage.getAddress(BATCH_INBOX_SLOT);
}
/// @notice Sets the start block in a backwards compatible way. Proxies
......@@ -294,7 +273,7 @@ contract SystemConfig is OwnableUpgradeable, ISemver {
/// @notice Updates the unsafe block signer address.
/// @param _unsafeBlockSigner New unsafe block signer address.
function _setUnsafeBlockSigner(address _unsafeBlockSigner) internal {
_setAddress(_unsafeBlockSigner, UNSAFE_BLOCK_SIGNER_SLOT);
Storage.setAddress(UNSAFE_BLOCK_SIGNER_SLOT, _unsafeBlockSigner);
bytes memory data = abi.encode(_unsafeBlockSigner);
emit ConfigUpdate(VERSION, UpdateType.UNSAFE_BLOCK_SIGNER, data);
......
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title Storage
/// @notice Storage handles reading and writing to arbitary storage locations
library Storage {
/// @notice Returns an address stored in an arbitrary storage slot.
/// These storage slots decouple the storage layout from
/// solc's automation.
/// @param _slot The storage slot to retrieve the address from.
function getAddress(bytes32 _slot) internal view returns (address addr_) {
assembly {
addr_ := sload(_slot)
}
}
/// @notice Stores an address in an arbitrary storage slot, `_slot`.
/// @param _slot The storage slot to store the address in.
/// @param _address The protocol version to store
/// @dev WARNING! This function must be used cautiously, as it allows for overwriting addresses
/// in arbitrary storage slots.
function setAddress(bytes32 _slot, address _address) internal {
assembly {
sstore(_slot, _address)
}
}
/// @notice Returns a uint256 stored in an arbitrary storage slot.
/// These storage slots decouple the storage layout from
/// solc's automation.
/// @param _slot The storage slot to retrieve the address from.
function getUint(bytes32 _slot) internal view returns (uint256 value_) {
assembly {
value_ := sload(_slot)
}
}
/// @notice Stores a value in an arbitrary storage slot, `_slot`.
/// @param _slot The storage slot to store the address in.
/// @param _value The protocol version to store
/// @dev WARNING! This function must be used cautiously, as it allows for overwriting values
/// in arbitrary storage slots.
function setUint(bytes32 _slot, uint256 _value) internal {
assembly {
sstore(_slot, _value)
}
}
/// @notice Returns a bytes32 stored in an arbitrary storage slot.
/// These storage slots decouple the storage layout from
/// solc's automation.
/// @param _slot The storage slot to retrieve the address from.
function getBytes32(bytes32 _slot) internal view returns (bytes32 value_) {
assembly {
value_ := sload(_slot)
}
}
/// @notice Stores a bytes32 value in an arbitrary storage slot, `_slot`.
/// @param _slot The storage slot to store the address in.
/// @param _value The protocol version to store
/// @dev WARNING! This function must be used cautiously, as it allows for overwriting values
/// in arbitrary storage slots.
function setBytes32(bytes32 _slot, bytes32 _value) internal {
assembly {
sstore(_slot, _value)
}
}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// Target contract
import { Storage } from "src/libraries/Storage.sol";
import { Test } from "forge-std/Test.sol";
import { console } from "forge-std/console.sol";
/// @title StorageWrapper
/// @notice StorageWrapper wraps the Storage library for testing purposes.
/// It exists to prevent storage collisions with the `Test` contract.
contract StorageWrapper {
function getAddress(bytes32 _slot) external view returns (address) {
return Storage.getAddress(_slot);
}
function setAddress(bytes32 _slot, address _address) external {
Storage.setAddress(_slot, _address);
}
function getUint(bytes32 _slot) external view returns (uint256) {
return Storage.getUint(_slot);
}
function setUint(bytes32 _slot, uint256 _value) external {
Storage.setUint(_slot, _value);
}
function getBytes32(bytes32 _slot) external view returns (bytes32) {
return Storage.getBytes32(_slot);
}
function setBytes32(bytes32 _slot, bytes32 _value) external {
Storage.setBytes32(_slot, _value);
}
}
contract Storage_Roundtrip_Test is Test {
StorageWrapper wrapper;
function setUp() external {
wrapper = new StorageWrapper();
}
function test_setGetUint_succeeds(bytes32 slot, uint256 num) external {
wrapper.setUint(slot, num);
assertEq(wrapper.getUint(slot), num);
assertEq(num, uint256(vm.load(address(wrapper), slot)));
}
function test_setGetAddress_succeeds(bytes32 slot, address addr) external {
wrapper.setAddress(slot, addr);
assertEq(wrapper.getAddress(slot), addr);
assertEq(addr, address(uint160(uint256(vm.load(address(wrapper), slot)))));
}
function test_setGetBytes32_succeeds(bytes32 slot, bytes32 hash) external {
wrapper.setBytes32(slot, hash);
assertEq(wrapper.getBytes32(slot), hash);
assertEq(hash, vm.load(address(wrapper), slot));
}
}
......@@ -80,6 +80,6 @@
"@testing-library/react": "^14.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"viem": "^1.3.1"
"viem": "^1.13.0"
}
}
......@@ -44,7 +44,7 @@
"jsdom": "^22.1.0",
"tsup": "^7.2.0",
"typescript": "^5.2.2",
"viem": "^1.3.1",
"viem": "^1.13.0",
"vite": "^4.4.6",
"vitest": "^0.34.2"
},
......
......@@ -56,7 +56,7 @@
"ts-node": "^10.9.1",
"typedoc": "^0.25.1",
"typescript": "^5.2.2",
"viem": "^1.6.0",
"viem": "^1.13.0",
"vitest": "^0.34.2",
"zod": "^3.22.1"
},
......
......@@ -37,7 +37,7 @@
"@vitest/coverage-istanbul": "^0.34.1",
"tsup": "^7.2.0",
"typescript": "^5.2.2",
"viem": "^1.6.0",
"viem": "^1.13.0",
"vite": "^4.4.9",
"vitest": "^0.34.1",
"zod": "^3.22.0"
......
This diff is collapsed.
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