Commit 13faa913 authored by Mark Tyneway's avatar Mark Tyneway

contracts-bedrock: fully deprecate semver

Removes the implementation of `Semver` in favor of `ISemver` fully.
Now all contracts that previously used `Semver` should use `ISemver`
and manually implement the `version()(string)` getter. Also update
some import paths in files that were modified with the `Semver` change.

Also removes any semver from `SchemaResolver` because it is an abstract
contract. The contracts that inherit it should implement `ISemver` so
that they can be versioned independently.

Each contract that had its source code updated had a minor version bump.
Regenerate the bindings, gas-snapshot and semver-lock.

Note that the `OptimismMintableERC20Factory` had its semver bumped
because it deploys `OptimismMintableERC20` tokens, which had its
bytecode changed by moving from `Semver` to `ISemver`.
parent c4d9b85e
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -3,16 +3,16 @@ pragma solidity 0.8.15;
import { console } from "forge-std/console.sol";
import { Script } from "forge-std/Script.sol";
import { Semver } from "../../src/universal/Semver.sol";
import { ISemver } from "../../src/universal/ISemver.sol";
/// @title EnhancedScript
/// @notice Enhances forge-std' Script.sol with some additional application-specific functionality.
/// Logs simulation links using Tenderly.
abstract contract EnhancedScript is Script {
/// @notice Helper function used to compute the hash of Semver's version string to be used in a
/// @notice Helper function used to compute the hash of ISemver's version string to be used in a
/// comparison.
function _versionHash(address _addr) internal view returns (bytes32) {
return keccak256(bytes(Semver(_addr).version()));
return keccak256(bytes(ISemver(_addr).version()));
}
/// @notice Log a tenderly simulation link. The TENDERLY_USERNAME and TENDERLY_PROJECT
......
......@@ -10,7 +10,6 @@ import { ProxyAdmin } from "src/universal/ProxyAdmin.sol";
import { Constants } from "src/libraries/Constants.sol";
import { SystemConfig } from "src/L1/SystemConfig.sol";
import { ResourceMetering } from "src/L1/ResourceMetering.sol";
import { Semver } from "src/universal/Semver.sol";
import { DeployConfig } from "scripts/DeployConfig.s.sol";
import { SystemConfig } from "src/L1/SystemConfig.sol";
......
{
"src/EAS/EAS.sol": "0xea04b7a9ec170ce9cbd466ede87650f9e9ffe3d725d7951cef5777a98a840173",
"src/EAS/EAS.sol": "0xe5e9700b94a88a2e1baabe4bfa66d5c1c94e811bcc5d2c64526afc649df59118",
"src/EAS/SchemaRegistry.sol": "0x5ee1a0c3b2bf1eb5edb53fb0967cf13856be546f0f16fe7acdc3e4f286db6831",
"src/L1/DelayedVetoable.sol": "0x276c6276292095e6aa37a70008cf4e0d1cbcc020dbc9107459bbc72ab5ed744f",
"src/L1/L1CrossDomainMessenger.sol": "0x2aa4e06827bc48484212eb2bdc30fd604ffd23b37e401b78ef428c12fa9b8385",
......@@ -26,12 +26,12 @@
"src/legacy/DeployerWhitelist.sol": "0x0a6840074734c9d167321d3299be18ef911a415e4c471fa92af7d6cfaa8336d4",
"src/legacy/L1BlockNumber.sol": "0x20d83a636c5e2067fca8c0ed505b295174e6eddb25960d8705e6b6fea8e77fa6",
"src/legacy/LegacyMessagePasser.sol": "0x80f355c9710af586f58cf6a86d1925e0073d1e504d0b3d814284af1bafe4dece",
"src/periphery/op-nft/AttestationStation.sol": "0x9cf6f2fd909f9bcff229a137198186749a839cfa3d11ddbb3021fe71c30a2fa9",
"src/periphery/op-nft/Optimist.sol": "0x38407f766aa9d394403e9da388dd0265b48901789f3e8a28af50014f9f5251d9",
"src/periphery/op-nft/OptimistAllowlist.sol": "0x53e9a9dfecbae036fd468e8f34c80c7d9c35bd8908c8a6483db44dbc5128ad69",
"src/periphery/op-nft/OptimistInviter.sol": "0xfdd5b9d45205ef9372ba37f7a6394724695e676d27a47cb154ee6e4148490013",
"src/universal/OptimismMintableERC20.sol": "0x716db294648fce1bb41c5f95a20f92445f165a568886f21edd922d5c9b2cb0b5",
"src/universal/OptimismMintableERC20Factory.sol": "0xfcf2eb56777478f47f3bf2f1111aa2e3769d5ed28a6f5fceff4517683447131a",
"src/periphery/op-nft/AttestationStation.sol": "0x067b29fe24734c121469c1cb2e9b2602ddabb9e07792338b766cab341776cd78",
"src/periphery/op-nft/Optimist.sol": "0x128113cd97433987220f25b59d883d5ee7e70ff2214a536c0df3d892e13287fc",
"src/periphery/op-nft/OptimistAllowlist.sol": "0x7691e96cff85ab225459d075c86dc325abf437c35d9314c395005ba057a3b044",
"src/periphery/op-nft/OptimistInviter.sol": "0x92a7d11cc93aeb079ccaa28bdc56e42534a21a8c137a43bec2620961d57e9050",
"src/universal/OptimismMintableERC20.sol": "0xc5d38eec0497fa6901f49502a479eb8bed0d14d1902b4c0075bb2fb00ba6a55f",
"src/universal/OptimismMintableERC20Factory.sol": "0x8d4cbf4cc30a0bb72925b5d2e0386b8f91559f00933a9c7cf3dcc118e34fe61b",
"src/universal/OptimismMintableERC721.sol": "0x4c73bf8474fa7eb091796a4db7e57bc5f26d50a3d1cfcb78d5efa47ced5ced2b",
"src/universal/OptimismMintableERC721Factory.sol": "0x935fd97018b6ef10fa813d9d43ab7a77c80885f7a8d7feb430097645cb2abd2c",
"src/universal/StorageSetter.sol": "0x6372647d8a67d243bc2fb40d2c4bf5807022d94d52d9423cfed27a7d57918635"
......
......@@ -16,7 +16,7 @@ import {
NotFound,
NO_EXPIRATION_TIME,
uncheckedInc
} from "./Common.sol";
} from "src/EAS/Common.sol";
import {
Attestation,
......@@ -31,9 +31,9 @@ import {
MultiRevocationRequest,
RevocationRequest,
RevocationRequestData
} from "./IEAS.sol";
} from "src/EAS/IEAS.sol";
import { ISchemaRegistry, SchemaRecord } from "./ISchemaRegistry.sol";
import { ISchemaRegistry, SchemaRecord } from "src/EAS/ISchemaRegistry.sol";
struct AttestationsResult {
uint256 usedValue; // Total ETH amount that was sent to resolvers.
......
......@@ -10,7 +10,7 @@ import {
DelegatedAttestationRequest,
DelegatedRevocationRequest,
RevocationRequestData
} from "../IEAS.sol";
} from "src/EAS/IEAS.sol";
import {
DeadlineExpired,
......@@ -20,7 +20,7 @@ import {
MAX_GAP,
stringToBytes32,
bytes32ToString
} from "../Common.sol";
} from "src/EAS/Common.sol";
/// @title EIP1271Verifier
/// @notice EIP1271Verifier typed signatures verifier for EAS delegated attestations.
......
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import { Semver } from "../../universal/Semver.sol";
import { IEAS, Attestation } from "src/EAS/IEAS.sol";
import { AccessDenied, InvalidEAS, InvalidLength, uncheckedInc } from "src/EAS/Common.sol";
import { IEAS, Attestation } from "../IEAS.sol";
import { AccessDenied, InvalidEAS, InvalidLength, uncheckedInc } from "../Common.sol";
import { ISchemaResolver } from "./ISchemaResolver.sol";
import { ISchemaResolver } from "src/EAS/resolver/ISchemaResolver.sol";
/// @title SchemaResolver
/// @notice The base schema resolver contract.
abstract contract SchemaResolver is ISchemaResolver, Semver {
abstract contract SchemaResolver is ISchemaResolver {
error InsufficientValue();
error NotPayable();
......@@ -19,7 +17,7 @@ abstract contract SchemaResolver is ISchemaResolver, Semver {
/// @dev Creates a new resolver.
/// @param eas The address of the global EAS contract.
constructor(IEAS eas) Semver(1, 2, 0) {
constructor(IEAS eas) {
if (address(eas) == address(0)) {
revert InvalidEAS();
}
......
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { Semver } from "../../universal/Semver.sol";
import { ISemver } from "src/universal/ISemver.sol";
/// @title AttestationStation
/// @author Optimism Collective
/// @author Gitcoin
/// @notice Where attestations live.
contract AttestationStation is Semver {
contract AttestationStation is ISemver {
/// @notice Struct representing data that is being attested.
/// @custom:field about Address for which the attestation is about.
/// @custom:field key A bytes32 key for the attestation.
......@@ -28,8 +28,9 @@ contract AttestationStation is Semver {
/// @param val Value of the attestation.
event AttestationCreated(address indexed creator, address indexed about, bytes32 indexed key, bytes val);
/// @custom:semver 1.1.2
constructor() Semver(1, 1, 2) { }
/// @notice Semantic version.
/// @custom:semver 1.2.0
string public constant version = "1.2.0";
/// @notice Allows anyone to create an attestation.
/// @param _about Address that the attestation is about.
......
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { Semver } from "../../universal/Semver.sol";
import { ISemver } from "src/universal/ISemver.sol";
import { ERC721BurnableUpgradeable } from
"@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721BurnableUpgradeable.sol";
import { AttestationStation } from "./AttestationStation.sol";
import { OptimistAllowlist } from "./OptimistAllowlist.sol";
import { AttestationStation } from "src/periphery/op-nft/AttestationStation.sol";
import { OptimistAllowlist } from "src/periphery/op-nft/OptimistAllowlist.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
/// @author Optimism Collective
/// @author Gitcoin
/// @title Optimist
/// @notice A Soul Bound Token for real humans only(tm).
contract Optimist is ERC721BurnableUpgradeable, Semver {
contract Optimist is ERC721BurnableUpgradeable, ISemver {
/// @notice Attestation key used by the attestor to attest the baseURI.
bytes32 public constant BASE_URI_ATTESTATION_KEY = bytes32("optimist.base-uri");
......@@ -25,7 +25,10 @@ contract Optimist is ERC721BurnableUpgradeable, Semver {
/// @notice Address of the OptimistAllowlist contract.
OptimistAllowlist public immutable OPTIMIST_ALLOWLIST;
/// @custom:semver 2.0.2
/// @notice Semantic version.
/// @custom:semver 2.1.0
string public constant version = "2.1.0";
/// @param _name Token name.
/// @param _symbol Token symbol.
/// @param _baseURIAttestor Address of the baseURI attestor.
......@@ -37,9 +40,7 @@ contract Optimist is ERC721BurnableUpgradeable, Semver {
address _baseURIAttestor,
AttestationStation _attestationStation,
OptimistAllowlist _optimistAllowlist
)
Semver(2, 0, 2)
{
) {
BASE_URI_ATTESTOR = _baseURIAttestor;
ATTESTATION_STATION = _attestationStation;
OPTIMIST_ALLOWLIST = _optimistAllowlist;
......
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { Semver } from "../../universal/Semver.sol";
import { AttestationStation } from "./AttestationStation.sol";
import { OptimistConstants } from "./libraries/OptimistConstants.sol";
import { ISemver } from "src/universal/ISemver.sol";
import { AttestationStation } from "src/periphery/op-nft/AttestationStation.sol";
import { OptimistConstants } from "src/periphery/op-nft/libraries/OptimistConstants.sol";
/// @title OptimistAllowlist
/// @notice Source of truth for whether an address is able to mint an Optimist NFT.
/// isAllowedToMint function checks various signals to return boolean value
/// for whether an address is eligible or not.
contract OptimistAllowlist is Semver {
contract OptimistAllowlist is ISemver {
/// @notice Attestation key used by the AllowlistAttestor to manually add addresses to the
/// allowlist.
bytes32 public constant OPTIMIST_CAN_MINT_ATTESTATION_KEY = bytes32("optimist.can-mint");
......@@ -30,6 +30,10 @@ contract OptimistAllowlist is Semver {
/// attestations.
address public immutable OPTIMIST_INVITER;
/// @notice Semantic version.
/// @custom:semver 1.1.0
string public constant version = "1.1.0";
/// @custom:semver 1.0.2
/// @param _attestationStation Address of the AttestationStation contract.
/// @param _allowlistAttestor Address of the allowlist attestor.
......@@ -40,9 +44,7 @@ contract OptimistAllowlist is Semver {
address _allowlistAttestor,
address _coinbaseQuestAttestor,
address _optimistInviter
)
Semver(1, 0, 2)
{
) {
ATTESTATION_STATION = _attestationStation;
ALLOWLIST_ATTESTOR = _allowlistAttestor;
COINBASE_QUEST_ATTESTOR = _coinbaseQuestAttestor;
......
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { OptimistConstants } from "./libraries/OptimistConstants.sol";
import { Semver } from "../../universal/Semver.sol";
import { AttestationStation } from "./AttestationStation.sol";
import { OptimistConstants } from "src/periphery/op-nft/libraries/OptimistConstants.sol";
import { ISemver } from "src/universal/ISemver.sol";
import { AttestationStation } from "src/periphery/op-nft/AttestationStation.sol";
import { SignatureChecker } from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import { EIP712Upgradeable } from "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
......@@ -32,7 +32,7 @@ import { EIP712Upgradeable } from "@openzeppelin/contracts-upgradeable/utils/cry
/// 6) claimer waits for the MIN_COMMITMENT_PERIOD to pass.
/// 7) claimer reveals the plaintext ClaimableInvite and the signature using the
/// claimInvite function, receiving the "optimist.can-mint-from-invite" attestation
contract OptimistInviter is Semver, EIP712Upgradeable {
contract OptimistInviter is ISemver, EIP712Upgradeable {
/// @notice Emitted when an invite is claimed.
/// @param issuer Address that issued the signature.
/// @param claimer Address that claimed the invite.
......@@ -87,10 +87,14 @@ contract OptimistInviter is Semver, EIP712Upgradeable {
/// @notice Maps from addresses to number of invites they have.
mapping(address => uint256) public inviteCounts;
/// @notice Semantic version.
/// @custom:semver 1.1.0
string public constant version = "1.1.0";
/// @custom:semver 1.0.2
/// @param _inviteGranter Address of the invite granter.
/// @param _attestationStation Address of the AttestationStation contract.
constructor(address _inviteGranter, AttestationStation _attestationStation) Semver(1, 0, 2) {
constructor(address _inviteGranter, AttestationStation _attestationStation) {
INVITE_GRANTER = _inviteGranter;
ATTESTATION_STATION = _attestationStation;
}
......
......@@ -4,7 +4,7 @@ pragma solidity 0.8.15;
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import { ILegacyMintableERC20, IOptimismMintableERC20 } from "src/universal/IOptimismMintableERC20.sol";
import { Semver } from "src/universal/Semver.sol";
import { ISemver } from "src/universal/ISemver.sol";
/// @title OptimismMintableERC20
/// @notice OptimismMintableERC20 is a standard extension of the base ERC20 token contract designed
......@@ -12,7 +12,7 @@ import { Semver } from "src/universal/Semver.sol";
/// use an OptimismMintablERC20 as the L2 representation of an L1 token, or vice-versa.
/// Designed to be backwards compatible with the older StandardL2ERC20 token which was only
/// meant for use on L2.
contract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20, ERC20, Semver {
contract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20, ERC20, ISemver {
/// @notice Address of the corresponding version of this token on the remote chain.
address public immutable REMOTE_TOKEN;
......@@ -38,6 +38,10 @@ contract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20,
_;
}
/// @notice Semantic version.
/// @custom:semver 1.3.0
string public constant version = "1.3.0";
/// @custom:semver 1.2.1
/// @param _bridge Address of the L2 standard bridge.
/// @param _remoteToken Address of the corresponding L1 token.
......@@ -51,7 +55,6 @@ contract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20,
uint8 _decimals
)
ERC20(_name, _symbol)
Semver(1, 2, 1)
{
REMOTE_TOKEN = _remoteToken;
BRIDGE = _bridge;
......
......@@ -32,8 +32,8 @@ contract OptimismMintableERC20Factory is ISemver, Initializable {
event OptimismMintableERC20Created(address indexed localToken, address indexed remoteToken, address deployer);
/// @notice Semantic version.
/// @custom:semver 1.6.1
string public constant version = "1.6.1";
/// @custom:semver 1.7.0
string public constant version = "1.7.0";
/// @notice The semver MUST be bumped any time that there is a change in
/// the OptimismMintableERC20 token contract since this contract
......
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
/// @title Semver
/// @notice Semver is a simple contract for managing contract versions.
contract Semver {
/// @notice Contract version number (major).
uint256 private immutable MAJOR_VERSION;
/// @notice Contract version number (minor).
uint256 private immutable MINOR_VERSION;
/// @notice Contract version number (patch).
uint256 private immutable PATCH_VERSION;
/// @param _major Version number (major).
/// @param _minor Version number (minor).
/// @param _patch Version number (patch).
constructor(uint256 _major, uint256 _minor, uint256 _patch) {
MAJOR_VERSION = _major;
MINOR_VERSION = _minor;
PATCH_VERSION = _patch;
}
/// @notice Returns the full semver contract version.
/// @return Semver contract version as a string.
function version() public view returns (string memory) {
return string(
abi.encodePacked(
Strings.toString(MAJOR_VERSION),
".",
Strings.toString(MINOR_VERSION),
".",
Strings.toString(PATCH_VERSION)
)
);
}
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { CommonTest } from "test/CommonTest.t.sol";
import { Semver } from "src/universal/Semver.sol";
import { Proxy } from "src/universal/Proxy.sol";
/// @notice Test the Semver contract that is used for semantic versioning
/// of various contracts.
contract Semver_Test is CommonTest {
/// @notice Global semver contract deployed in setUp. This is used in
/// the test cases.
Semver semver;
/// @notice Deploy a Semver contract
function setUp() public virtual override {
semver = new Semver(7, 8, 0);
}
/// @notice Test the version getter
function test_version_succeeds() external {
assertEq(semver.version(), "7.8.0");
}
/// @notice Since the versions are all immutable, they should
/// be able to be accessed from behind a proxy without needing
/// to initialize the contract.
function test_behindProxy_succeeds() external {
Proxy proxy = new Proxy(alice);
vm.prank(alice);
proxy.upgradeTo(address(semver));
assertEq(Semver(address(proxy)).version(), "7.8.0");
}
}
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