• Mark Tyneway's avatar
    contracts-bedrock: bump oz to latest release (#3308) · cdf2163e
    Mark Tyneway authored
    This bumps the open zeppelin contracts used in bedrock to the
    latest release. This bump is happening because `Ownable` becomes
    more flexible, allowing you to overwrite the logic for `onlyOwner`.
    This would enable writing a `CrossDomainOwnable` contract like so:
    
    ```solidity
    // SPDX-License-Identifier: MIT
    pragma solidity 0.8.15;
    
    import { AddressAliasHelper } from "../vendor/AddressAliasHelper.sol";
    import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
    
    abstract contract CrossDomainOwnable is Ownable {
        /**
         * @dev Throws if the sender is not the owner.
         */
        function _checkOwner() internal view {
            address sender = AddressAliasHelper.undoL1ToL2Alias(msg.sender);
            require(owner() == sender, "Ownable: caller is not the owner");
        }
    }
    ```
    
    The main diff to the `Ownable` contract is that is now looks like this:
    
    ```solidity
        /**
         * @dev Throws if called by any account other than the owner.
         */
        modifier onlyOwner() {
            _checkOwner();
            _;
        }
    
        /**
         * @dev Returns the address of the current owner.
         */
        function owner() public view virtual returns (address) {
            return _owner;
        }
    
        /**
         * @dev Throws if the sender is not the owner.
         */
        function _checkOwner() internal view virtual {
            require(owner() == _msgSender(), "Ownable: caller is not the owner");
        }
    ```
    
    The older version of the contracts doesn't have the `virtual`
    `_checkOwner` function. This does add some additional gas overhead
    as seen in the `.gas-snapshot`.
    cdf2163e
Name
Last commit
Last update
.changeset Loading commit data...
.circleci Loading commit data...
.github Loading commit data...
.husky Loading commit data...
.vscode Loading commit data...
.yarn/releases Loading commit data...
batch-submitter Loading commit data...
bss-core Loading commit data...
gas-oracle Loading commit data...
indexer Loading commit data...
infra/op-replica Loading commit data...
integration-tests Loading commit data...
l2geth Loading commit data...
l2geth-exporter Loading commit data...
op-batcher Loading commit data...
op-bindings Loading commit data...
op-chain-ops Loading commit data...
op-e2e Loading commit data...
op-exporter Loading commit data...
op-node Loading commit data...
op-proposer Loading commit data...
op-service Loading commit data...
ops Loading commit data...
ops-bedrock Loading commit data...
packages Loading commit data...
patches Loading commit data...
proxyd Loading commit data...
specs Loading commit data...
technical-documents Loading commit data...
teleportr Loading commit data...
.dockerignore Loading commit data...
.editorconfig Loading commit data...
.eslintrc.js Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.gitmodules Loading commit data...
.markdownlint.json Loading commit data...
.nvmrc Loading commit data...
.prettierrc.js Loading commit data...
.semgrepignore Loading commit data...
.yarnrc Loading commit data...
CONTRIBUTING.md Loading commit data...
LICENSE Loading commit data...
Makefile Loading commit data...
README.md Loading commit data...
SECURITY.md Loading commit data...
cloudbuild.yaml Loading commit data...
go.work Loading commit data...
go.work.sum Loading commit data...
lerna.json Loading commit data...
package.json Loading commit data...
tsconfig.json Loading commit data...
yarn.lock Loading commit data...