-
Notifications
You must be signed in to change notification settings - Fork 74
Optimism L2 integration [Hardhat - v2] #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 29 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
8fd25ca
Add support for Optimism L2 bridge [WIP]
krebernisak 346e159
Move continuous integration to GitHub
krebernisak cfbe92d
Add target (OVM) support to getContractFactroy fn
krebernisak 952e412
Add optimism-integration bootstrap to CI integration job
krebernisak a6cadd5
Add OVM_EOACodeHashSet contract
krebernisak d7dfa07
Increase deposit-withdraw test timeout to 90s
krebernisak 48a0863
Strictly declare Versions and Targets
krebernisak 7f6a529
Polish Optimism integration tests
krebernisak 45d2276
Update to the latest Optimism release
krebernisak 1c8c81b
Integrating @chainlink/optimism-utils
krebernisak 29e59e0
Update env loading and docs
krebernisak cc7d72e
Update Optimism deps
krebernisak 9b10c3a
Fix CI run
krebernisak 940a4ee
Add helpful OE integration scripts & update docs
krebernisak b8edd93
Use waitForXDomainTransaction helper fn in deposit-withdraw script
krebernisak 944083d
Force compile OZ TransparentUpgradeableProxy.sol
krebernisak 8c90ff9
Use 1_000_000 optimizer runs for v0.7
krebernisak 454fa8f
Remove old OVM_ProxyEOA.sol EXTCODEHASH
krebernisak 6d99b94
Add LinkTokenChild contract
krebernisak 1d2e42e
Run on self-hosted CI runner
krebernisak dbd55e7
Split Optimism L2 gateway and token contract
krebernisak aef60f6
Update scripts/tests to new contract structure
krebernisak add2c60
Add ERC677Receiver functionality to L1/L2 gateways
krebernisak 873b3e4
Polish contracts, improve docs
krebernisak 0a984b2
Add proxy deployment of OE bridge [WIP]
krebernisak edb9ca4
Update OE contracts lib
krebernisak efa1575
Polish contracts
krebernisak f15a4b9
Add yargs lib to parse argv
krebernisak 9c17fa6
Add another OVM_ProxyEOA.sol EXTCODEHASH (Kovan)
krebernisak 791916d
Improve proxy deployment of OE bridge
krebernisak c2f1c5b
Patch OE upstream & refactor
krebernisak d874349
Pull OE upstream changes
krebernisak 3efc12d
Cleanup Hardhat integration
krebernisak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # | ||
| # This action checks PRs to see if any CHANGELOG* files were updated. | ||
| # If none were, it will add a message to the PR asking if it would make sense to do so. | ||
| # | ||
| name: Changelog | ||
|
|
||
| on: pull_request | ||
|
|
||
| jobs: | ||
| changelog: | ||
| name: Changelog checker | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check for changed files | ||
| id: changedfiles | ||
| uses: futuratrepadeira/changed-files@186b5b30b1f5e44ed655a59652746c3ce00d53ef # Version v3.1.1 | ||
| with: | ||
| repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
| pattern: '^CHANGELOG.*$' | ||
| - name: Make a comment | ||
| uses: unsplash/comment-on-pr@d1a1d5dd1eb1bb657a01f4d92dd5e4d5bb7857d3 # Version v1.2.0 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| if: contains(steps.changedfiles.outputs.files_updated, 'CHANGELOG') != true && contains(steps.changedfiles.outputs.files_created, 'CHANGELOG') != true | ||
| with: | ||
| msg: "I see that you haven't updated any CHANGELOG files. Would it make sense to do so?" | ||
| check_for_duplicate_msg: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| name: Main | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| pull_request: ~ | ||
|
|
||
| jobs: | ||
| run-basic-checks: | ||
| name: Run linters and unit tests | ||
| runs-on: [self-hosted] | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - uses: actions/setup-node@v2 | ||
| with: | ||
| node-version: '14.x' | ||
| - run: npm install -g yarn | ||
| - run: yarn install | ||
| - run: yarn setup | ||
| - run: yarn lint | ||
| - run: yarn test | ||
| run-integration: | ||
| name: Setup and run integration tests | ||
| needs: [run-basic-checks] | ||
| runs-on: [self-hosted] | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - uses: actions/setup-node@v2 | ||
| with: | ||
| node-version: '14.x' | ||
| - run: npm install -g yarn | ||
| - run: yarn install | ||
| - run: yarn setup | ||
| - name: Setup Optimism L2 local network | ||
| run: yarn script:oe:up | ||
| - run: yarn test:integration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,3 +8,6 @@ coverage.json | |
|
|
||
| # Misc | ||
| .DS_STORE | ||
|
|
||
| # Optimism monorepo used for integration tests | ||
| /optimism | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| module.exports = { | ||
| semi: false, | ||
| singleQuote: true, | ||
| printWidth: 120, | ||
| printWidth: 100, | ||
| endOfLine: 'auto', | ||
| trailingComma: 'all', | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| node 14.16.0 | ||
| yarn 1.22.4 |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Changelog LinkToken | ||
|
|
||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [Unreleased] - Apr 2021 | ||
|
|
||
| ### Added | ||
|
|
||
| - Optimism L2 bridge support | ||
| - Access controlled mintable & burnable LinkToken, for use on sidechains and L2 networks. | ||
|
|
||
| ### Changed | ||
|
|
||
| - Migrated to Hardhat and Waffle | ||
|
|
||
| ### Fixed | ||
|
|
||
| ### Removed | ||
|
|
||
| - Truffle framework and tests dependencies | ||
|
|
||
| ## [1.1.0] - Mar 2021 | ||
|
|
||
| Initial @chainlink/token release! | ||
|
|
||
| ### Added | ||
|
|
||
| - Solidity v0.6 support | ||
| - Simple token swapping contract | ||
|
|
||
| ## [1.0.6] - Sep 2018 | ||
|
|
||
| Initial link_token release! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # LINK Token Contracts v0.7 | ||
|
|
||
| ## Token bridge contracts | ||
|
|
||
| LinkToken bridge contracts can be found in the [./bridge](./bridge) directory. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # LINK Token Bridge v0.7 | ||
|
|
||
| - `./LinkTokenChild.sol`: A mintable & burnable child LinkToken contract to be used on child networks. | ||
| - `./utils/OpUnsafe.sol`: Contract module that used to mark and check safe/unsafe calls to a function. | ||
|
|
||
| ## Optimism L2 bridge | ||
|
|
||
| The Optimistic Virtual Machine (OVM) is a scalable form of the EVM. Optimistic Rollup, by [Optimism](https://optimism.io), is the core scaling solution which enables the off-chain OVM to achieve cheap, instant transactions that still inherit L1 security. The OVM is an EVM-based VM which supports optimistically executing EVM smart contracts on a layer 1 blockchain like Ethereum. It is structured in such a way that it is possible to verify individual steps of its computation on Ethereum mainnet. This allows the mainnet to enforce validity of state roots with fraud proofs in the layer 2 Optimistic Rollup chain. For more information consult the [Optimism developer documentation](https://community.optimism.io/docs/). | ||
|
|
||
| The set of contracts needed for the Optimism L2 LinkToken bridge can be found in the [./optimism](./optimism) dir. | ||
|
|
||
| - `./optimism/OVM_EOACodeHashSet.sol`: Abstract helper contract used to keep track of OVM EOA contract set (OVM specific) | ||
| - `./optimism/OVM_L1ERC20Gateway.sol`: Contract which stores deposited L1 funds that are in use on L2, and unlocks/transfers L1 funds on withdrawal. It synchronizes a corresponding L2 ERC20 Gateway, informing it of deposits, and listening to it for newly finalized withdrawals. (delegate proxy deployment) | ||
| - `./optimism/OVM_L2ERC20Gateway.sol`: Contract which mints deposited L2 funds that are locked on L1, and burns L2 funds on withdrawal. It synchronizes a corresponding L1 ERC20 Gateway, informing it of withdrawals, and listening to it for newly finalized deposits. (delegate proxy deployment) | ||
|
|
||
| These contracts are an implementation of [abstracts bridge contracts provided by Optimism](https://github.com/ethereum-optimism/optimism/tree/master/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity >0.6.0 <0.8.0; | ||
|
|
||
| /* Interface Imports */ | ||
| import { ERC677 } from "../../../v0.6/token/ERC677.sol"; | ||
|
|
||
| contract ERC677CallerMock { | ||
| /// @dev Forward transferAndCall to destination contract | ||
| function callTransferAndCall( | ||
| address destintion, | ||
| address to, | ||
| uint value, | ||
| bytes memory data | ||
| ) | ||
| external | ||
| { | ||
| ERC677(destintion).transferAndCall(to, value, data); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity >0.6.0 <0.8.0; | ||
|
|
||
| /* Library Imports */ | ||
| import { EnumerableSet } from "@openzeppelin/contracts/utils/EnumerableSet.sol"; | ||
|
|
||
| /* Contract Imports */ | ||
| import { ConfirmedOwner } from "@chainlink/contracts/src/v0.7/dev/ConfirmedOwner.sol"; | ||
|
|
||
| /** | ||
| * @dev Abstract helper contract used to keep track of OVM EOA contract set (OVM specific) | ||
| * | ||
| * The OVM implements a basic form of account abstraction. In effect, this means | ||
| * that the only type of account is a smart contract (no EOAs), and all user wallets | ||
| * are in fact smart contract wallets. So to check for EOA, we need to actually check if | ||
| * the sender is an OVM_ProxyEOA contract, which gets deployed by the ovmCREATEEOA opcode. | ||
| * | ||
| * As the OVM_ProxyEOA.sol contract source could potentially change in the future (i.e., due to a fork), | ||
| * here we actually track a set of possible EOA proxy contracts. | ||
| */ | ||
| abstract contract OVM_EOACodeHashSet is ConfirmedOwner { | ||
| // Add the EnumerableSet library | ||
| using EnumerableSet for EnumerableSet.Bytes32Set; | ||
|
|
||
| // Declare a Bytes32Set of code hashes | ||
| EnumerableSet.Bytes32Set private s_codeHasheSet; | ||
|
|
||
| // Declare the genesis OVM_ProxyEOA.sol EXTCODEHASH | ||
| bytes32 constant OVM_EOA_CODE_HASH_V0 = 0x93bb081a7dd92bde63b4d0aa9b8612352b2ec585176a80efc0a2a277ecfc010e; | ||
| bytes32 constant OVM_EOA_CODE_HASH_V1 = 0x8b4ea2cb36c232a7bab9d385b7054ff04752ec4c0fad5dc2ed4b1c18d982154c; | ||
|
|
||
| /// @notice Adds genesis OVM_ProxyEOA.sol EXTCODEHASH to the default set. | ||
| constructor() | ||
| ConfirmedOwner(msg.sender) | ||
| { | ||
| s_codeHasheSet.add(OVM_EOA_CODE_HASH_V0); | ||
| s_codeHasheSet.add(OVM_EOA_CODE_HASH_V1); | ||
| } | ||
|
|
||
| /// @notice Reverts if called by anyone other than whitelisted EOA contracts. | ||
| modifier onlyEOAContract() { | ||
| require(_isEOAContract(msg.sender), "Only callable by whitelisted EOA"); | ||
| _; | ||
| } | ||
|
|
||
| /** | ||
| * @dev Returns true if the EOA contract code hash value is in the set. O(1). | ||
| * | ||
| * @param value EOA contract code hash to check | ||
| */ | ||
| function containsEOACodeHash( | ||
| bytes32 value | ||
| ) | ||
| public | ||
| view | ||
| returns (bool) | ||
| { | ||
| return s_codeHasheSet.contains(value); | ||
| } | ||
|
|
||
| /** | ||
| * @dev Adds a EOA contract code hash value to the set. O(1). | ||
| * | ||
| * Returns true if the value was added to the set, that is if it was not already present. | ||
| * @param value EOA contract code hash to add | ||
| */ | ||
| function addEOACodeHash( | ||
| bytes32 value | ||
| ) | ||
| public | ||
| onlyOwner() | ||
| returns (bool) | ||
| { | ||
| return s_codeHasheSet.add(value); | ||
| } | ||
|
|
||
| /** | ||
| * @dev Removes a EOA contract code hash value from the set. O(1). | ||
| * | ||
| * Returns true if the value was removed from the set, that is if it was present. | ||
| * @param value EOA contract code hash to remove | ||
| */ | ||
| function removeEOACodeHash( | ||
| bytes32 value | ||
| ) | ||
| public | ||
| onlyOwner() | ||
| returns (bool) | ||
| { | ||
| return s_codeHasheSet.remove(value); | ||
| } | ||
|
|
||
| /** | ||
| * @dev Returns true if `account` is a whitelisted EOA contract. | ||
| * @param account Address to check | ||
| */ | ||
| function _isEOAContract( | ||
| address account | ||
| ) | ||
| internal | ||
| view | ||
| returns (bool) | ||
| { | ||
| bytes32 codehash; | ||
| // solhint-disable-next-line no-inline-assembly | ||
| assembly { codehash := extcodehash(account) } | ||
| return s_codeHasheSet.contains(codehash); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like something we should pull into our repo and give you a nice library for :)