Skip to content
Closed
Show file tree
Hide file tree
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 Apr 6, 2021
346e159
Move continuous integration to GitHub
krebernisak Apr 6, 2021
cfbe92d
Add target (OVM) support to getContractFactroy fn
krebernisak Apr 6, 2021
952e412
Add optimism-integration bootstrap to CI integration job
krebernisak Apr 7, 2021
a6cadd5
Add OVM_EOACodeHashSet contract
krebernisak Apr 7, 2021
d7dfa07
Increase deposit-withdraw test timeout to 90s
krebernisak Apr 7, 2021
48a0863
Strictly declare Versions and Targets
krebernisak Apr 7, 2021
7f6a529
Polish Optimism integration tests
krebernisak Apr 7, 2021
45d2276
Update to the latest Optimism release
krebernisak Apr 12, 2021
1c8c81b
Integrating @chainlink/optimism-utils
krebernisak Apr 12, 2021
29e59e0
Update env loading and docs
krebernisak Apr 13, 2021
cc7d72e
Update Optimism deps
krebernisak Apr 13, 2021
9b10c3a
Fix CI run
krebernisak Apr 13, 2021
940a4ee
Add helpful OE integration scripts & update docs
krebernisak Apr 14, 2021
b8edd93
Use waitForXDomainTransaction helper fn in deposit-withdraw script
krebernisak Apr 14, 2021
944083d
Force compile OZ TransparentUpgradeableProxy.sol
krebernisak Apr 14, 2021
8c90ff9
Use 1_000_000 optimizer runs for v0.7
krebernisak Apr 14, 2021
454fa8f
Remove old OVM_ProxyEOA.sol EXTCODEHASH
krebernisak Apr 14, 2021
6d99b94
Add LinkTokenChild contract
krebernisak Apr 15, 2021
1d2e42e
Run on self-hosted CI runner
krebernisak Apr 16, 2021
dbd55e7
Split Optimism L2 gateway and token contract
krebernisak Apr 16, 2021
aef60f6
Update scripts/tests to new contract structure
krebernisak Apr 16, 2021
add2c60
Add ERC677Receiver functionality to L1/L2 gateways
krebernisak Apr 18, 2021
873b3e4
Polish contracts, improve docs
krebernisak Apr 18, 2021
0a984b2
Add proxy deployment of OE bridge [WIP]
krebernisak Apr 18, 2021
edb9ca4
Update OE contracts lib
krebernisak Apr 19, 2021
efa1575
Polish contracts
krebernisak Apr 19, 2021
f15a4b9
Add yargs lib to parse argv
krebernisak Apr 19, 2021
9c17fa6
Add another OVM_ProxyEOA.sol EXTCODEHASH (Kovan)
krebernisak Apr 19, 2021
791916d
Improve proxy deployment of OE bridge
krebernisak Apr 20, 2021
c2f1c5b
Patch OE upstream & refactor
krebernisak Apr 19, 2021
d874349
Pull OE upstream changes
krebernisak Apr 25, 2021
3efc12d
Cleanup Hardhat integration
krebernisak Apr 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/changelog.yml
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
37 changes: 37 additions & 0 deletions .github/workflows/main.yml
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ coverage.json

# Misc
.DS_STORE

# Optimism monorepo used for integration tests
/optimism
2 changes: 1 addition & 1 deletion .prettierrc.js
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',
}
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node 14.16.0
yarn 1.22.4
27 changes: 0 additions & 27 deletions .travis.yml

This file was deleted.

35 changes: 35 additions & 0 deletions CHANGELOG.md
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!
42 changes: 37 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# LINK Token Contracts [![Build Status](https://travis-ci.org/smartcontractkit/LinkToken.svg?branch=master)](https://travis-ci.org/smartcontractkit/LinkToken)
# LINK Token Contracts

The LINK token is an [EIP20](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md) token with additional [ERC677](https://github.com/ethereum/EIPs/issues/677) functionality.

Expand All @@ -16,26 +16,58 @@ Security audit for [v0.4 version of the contracts](./contracts/v0.4/) is availab
- Name: ChainLink Token
- Symbol: LINK

## Installation
## Setup

The project contains [v0.4 contracts](./contracts/v0.4/) that were used for LINK Ethereum Mainnet deployment in 2017. For deployments moving forward, we use the updated [v0.6 contracts](./contracts/v0.6/) which use a more recent version of solc and the OpenZeppelin token standards. These updates include a minor ABI change around approval/allowance naming.

```bash
yarn install
```

## Testing

Setup contracts:

```bash
yarn setup
```

This will compile all versions of the contracts.

## Testing

Run tests:

```bash
yarn test
```

This will test both v0.4 and v0.6 versions of the contracts.
This will run unit tests for all versions of the contracts.

## Integration testing

Integration tests are currently setup for Optimism bridge contracts, and to run them make sure you have a local network running first.

The network can be started using a helpful script, which will clone the [Optimism monorepo](https://github.com/ethereum-optimism/optimism), build the :

```bash
yarn script:oe:up
```

Run tests:

```bash
yarn test:integration
```

This will run unit tests for all versions of the contracts, plus supported integration tests against the local L1 & L2 networks.

The network can be stopped using another script:

```bash
yarn script:oe:down
```

Or use the clean script, which will also delete all the images:

```bash
yarn script:oe:clean
```
5 changes: 5 additions & 0 deletions contracts/v0.7/README.md
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.
16 changes: 16 additions & 0 deletions contracts/v0.7/bridge/README.md
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).
19 changes: 19 additions & 0 deletions contracts/v0.7/bridge/mocks/ERC677CallerMock.sol
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);
}
}
109 changes: 109 additions & 0 deletions contracts/v0.7/bridge/optimism/OVM_EOACodeHashSet.sol
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 {

Copy link
Copy Markdown

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 :)

// 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);
}
}
Loading