Skip to content
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

Cross chain arbitrum module #554

Merged
merged 101 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from 83 commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
2e66f71
Setting up Hardhat project for arbitrum cross chain
dimpar Feb 22, 2023
50e79d3
Drafting ArbitrumTBTC and ArbitrumWormholeGateway contracts
dimpar Feb 22, 2023
76672bc
Drafting deployment scripts
dimpar Feb 22, 2023
ee0ad0d
Adding deployment/ to .gitignore and more hardhat setup
dimpar Feb 23, 2023
fa8f8fd
Initializing ArbitrumTBTC token
dimpar Feb 23, 2023
3bf2868
Making arbi wormhole gateway a minter
dimpar Feb 23, 2023
16ecc25
Drafting Readme
dimpar Feb 23, 2023
1732e95
Adding governance account
dimpar Feb 23, 2023
e23043c
Transfering ownership of Wormhole gateway to governance
dimpar Feb 23, 2023
ad4ef76
Initialization will be a part of deployment scripts
dimpar Feb 24, 2023
3d6b2e9
Deploying a token through transperent proxy pattern
dimpar Feb 24, 2023
9f7d482
Transfering proxy adnin ownershipt to governance
dimpar Feb 24, 2023
c4acaf2
Merge remote-tracking branch 'origin' into cross-chain-arbitrum-module
dimpar Feb 27, 2023
4fca8fb
Adding Wormhole TokenBridge ABIs for goerli and mainnet on L1 and L2
dimpar Mar 1, 2023
ceb46d6
Updating deployment scripts
dimpar Mar 1, 2023
07e8924
Adding Wormhole interfaces
dimpar Mar 1, 2023
fe39ad2
Importing L2TBTC.sol for ArbtitrumTBTC
dimpar Mar 1, 2023
349cfe6
Drafting ArbtitrumWormholeGateway
dimpar Mar 1, 2023
0d32d79
Adding configs
dimpar Mar 1, 2023
3b98071
Linting deployment scripts
dimpar Mar 1, 2023
5ed50bd
Linting contracts
dimpar Mar 1, 2023
29e8acf
Adding configuration files
dimpar Mar 1, 2023
e0dd25b
Linting config files
dimpar Mar 1, 2023
b273b4e
Referencing tbtc-v2 development version
dimpar Mar 1, 2023
d508949
Adding tests around upgradability for ArbitrumTBTC
dimpar Mar 2, 2023
0b5c5e9
Changing config files to align with /solidity
dimpar Mar 2, 2023
bae296f
Linting
dimpar Mar 2, 2023
687a16a
Linting
dimpar Mar 2, 2023
894bb3e
Adding /cross-chain to paths with own formatting configuration
dimpar Mar 2, 2023
9e93f20
Drafting cross-chain arbitrum npm package publishing
dimpar Mar 6, 2023
87bfae4
Changes in npm-cross-chain-arbitrum.yml
dimpar Mar 8, 2023
41c8991
Adding a CI script to deploy to testnet
dimpar Mar 8, 2023
282c178
Removing tenderly and adding api keys for (ether)scan
dimpar Mar 8, 2023
610fa4f
Removing tenderly verification and adding (ether)scan verification
dimpar Mar 8, 2023
8890135
Removing tenderly verification and adding L2 prefix
dimpar Mar 8, 2023
d7de7a3
Renames of a project name and description. Putting scripts in alphabe…
dimpar Mar 8, 2023
3da37cf
Aligning tsconfig.json to the root solidity package
dimpar Mar 8, 2023
e4ffa9b
Fixing the TokenBridges contract addresses on Goerli
dimpar Mar 8, 2023
8cf7248
Fixing name of a transferred contract
dimpar Mar 8, 2023
a812bc2
Adding a doc reference to cross-chain/arbitrum module
dimpar Mar 8, 2023
2ca3347
Adding pre-hook formatting check for cross-chain/arbitrum
dimpar Mar 9, 2023
b92e713
Linting
dimpar Mar 9, 2023
ccf9c0a
Adjusting CI workflows to run with arbitrum network
dimpar Mar 10, 2023
6cfed8a
Changing the version from 0.0.1 to 0.0.1-dev
dimpar Mar 10, 2023
22b3fc5
tbtc-2 -> tbtc-v2
dimpar Mar 10, 2023
8f62e49
Merging with npm-cross-chain-arbitrum.yml
dimpar Mar 10, 2023
7ebc0cf
Adding prepack and prepublishOnly
dimpar Mar 13, 2023
2ba4314
Adding a comment around using Arbiscan verification
dimpar Mar 14, 2023
1ddab3e
Adding a TODO for Tenderly verification
dimpar Mar 14, 2023
6f718fe
Making transfer_proxy_admin_ownership run at the end
dimpar Mar 14, 2023
8aa8135
Forcing authorize_wormhole_gateway_as_minter run at the end
dimpar Mar 14, 2023
58728b5
Changes in cross-chain-arbitrum
dimpar Mar 14, 2023
e2104dd
Added an empty line in .prettierignore
dimpar Mar 14, 2023
f958a53
Inheriting from a generic L2WormholeGateway
dimpar Mar 15, 2023
b8e7f3e
Adding upgradability tests for ArbitrumWormholeGateway contract
dimpar Mar 15, 2023
11fbc92
Renaming ARBISCAN_GOERLI_API_KEY -> ARBISCAN_API_KEY
dimpar Mar 16, 2023
1e261cc
Adjusting env vars for CI workflow
dimpar Mar 16, 2023
9fd895d
Merge remote-tracking branch 'origin' into cross-chain-arbitrum-module
dimpar Mar 27, 2023
0b426d8
Updating tbtc-v2 dependency to the latest dev version
dimpar Mar 27, 2023
24fca27
Replacing IERC20 with IERC20Upgradeable for testing purposes
dimpar Mar 27, 2023
7aa2683
Changing name and a symbol for tBTC Arbitrum
dimpar Mar 27, 2023
9eee461
Adding input env vars for the mainnet network
dimpar Mar 28, 2023
8887512
Removing child contracts that inherit from the L2* base contracts
dimpar Mar 29, 2023
1350624
Using 'cross-chain' instead of 'cross chain'
dimpar Mar 29, 2023
8865d6b
Changing license to GPL-3.0-only
dimpar Mar 29, 2023
41d3c42
Adding mainnet deployment under version control
dimpar Mar 29, 2023
e8f116c
Keeping mainnet OZ manifest under version control
dimpar Mar 29, 2023
7d0e004
Improving README for Arbitrum module
dimpar Mar 29, 2023
39c830d
Leaving external Wormhole addresses only
dimpar Mar 29, 2023
dbe2d7f
Trimming dev dependencies
dimpar Mar 29, 2023
0e5f877
Faking external wormhole contracts
dimpar Mar 29, 2023
61f2697
Setting mainnet named account addresses
dimpar Mar 29, 2023
c4a8155
Changing the order of deployment scripts
dimpar Mar 29, 2023
312e29b
Updating mappings of Arbitrum Wormhole chain ID (23) to gateway address
dimpar Mar 29, 2023
e853dd5
Using fake contracts only if the network name is hardhat
dimpar Mar 29, 2023
33a2ace
GatewayAddress -> SetGatewayAddress
dimpar Mar 29, 2023
ee35831
Adding runAtTheEnd flags in the ownershipt transfers scripts
dimpar Mar 29, 2023
9b1b5c7
Simplifying network names in the arbitrum module
dimpar Mar 29, 2023
f38a39c
Using hardhat-helpers instead of OZ for the upgrades in tests
dimpar Mar 29, 2023
4ecb25e
Extracting publishing and deployment jobs
dimpar Mar 29, 2023
8c58d02
Removing non-relevant comment
dimpar Mar 30, 2023
c95995d
Removing upgrades.ts
dimpar Mar 30, 2023
9346c4d
Changing the version of the module to 1.0.0-dev
dimpar Mar 30, 2023
4b03b09
Removing part of CI that is meant to be added in the follow up PR
dimpar Mar 30, 2023
c57adce
Changing the name of the Arbitrum CI workflow
dimpar Mar 30, 2023
b71e739
Resolving contracts in separate scripts
dimpar Mar 30, 2023
2229003
Linting
dimpar Mar 30, 2023
d2c5a17
Using specific contract names with provided path
dimpar Mar 30, 2023
d4c157b
Improving README
dimpar Mar 30, 2023
11104fc
Renaming arbitrumMainnet -> arbitrumOne
dimpar Mar 30, 2023
17aa468
Refactroing hardhat config
dimpar Mar 30, 2023
a76415c
Changing the order
dimpar Mar 30, 2023
7114cbc
Refactoring README
dimpar Mar 30, 2023
dc0321f
Adding AuthorizeWormholeGateway dependency to 21_* deployment script
dimpar Mar 30, 2023
5e0098b
Renaming the workflow to Cross-chain Arbitrum
dimpar Mar 30, 2023
a40b23e
Prefix contracts names with arbitrum
nkuba Mar 30, 2023
c1b2a71
Check contract address for hardhat network
nkuba Mar 30, 2023
729e206
Comment out deploy_l1 for hardhat network
nkuba Mar 30, 2023
d9ee3c3
Use account with indx 0 for goerli addresses
nkuba Mar 30, 2023
4e80910
Add tiny doc improvement
nkuba Mar 30, 2023
0fd6344
Ignore artifacts dir in gitignore
nkuba Mar 30, 2023
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
181 changes: 181 additions & 0 deletions .github/workflows/cross-chain-arbitrum.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
name: Cross-chain Arbitrum module
nkuba marked this conversation as resolved.
Show resolved Hide resolved

on:
schedule:
- cron: "0 0 * * *"
push:
branches:
- main
paths:
- "cross-chain/arbitrum/**"
michalinacienciala marked this conversation as resolved.
Show resolved Hide resolved
- ".github/workflows/cross-chain-arbitrum.yml"
pull_request:
workflow_dispatch:
michalinacienciala marked this conversation as resolved.
Show resolved Hide resolved
inputs:
environment:
description: "Environment (network) for workflow execution, e.g. `goerli`"
required: false
lukasz-zimnoch marked this conversation as resolved.
Show resolved Hide resolved
upstream_builds:
description: "Upstream builds"
required: false
upstream_ref:
michalinacienciala marked this conversation as resolved.
Show resolved Hide resolved
description: "Git reference to checkout (e.g. branch name)"
required: false
default: "main"
nkuba marked this conversation as resolved.
Show resolved Hide resolved

jobs:
contracts-detect-changes:
runs-on: ubuntu-latest
outputs:
path-filter: ${{ steps.filter.outputs.path-filter }}
steps:
- uses: actions/checkout@v3
if: github.event_name == 'pull_request'

- uses: dorny/paths-filter@v2
if: github.event_name == 'pull_request'
id: filter
with:
filters: |
path-filter:
- './cross-chain/arbitrum/**'
- './.github/workflows/cross-chain-arbitrum.yml'

contracts-build-and-test:
needs: contracts-detect-changes
if: |
github.event_name != 'pull_request'
|| needs.contracts-detect-changes.outputs.path-filter == 'true'
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./cross-chain/arbitrum
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: "14.x"
cache: "yarn"
cache-dependency-path: cross-chain/arbitrum/yarn.lock

# A workaround for transitive dependencies that use the obsolete git://
# prefix instead of the recommended https://
- name: Configure git to not use unauthenticated protocol
run: git config --global url."https://".insteadOf git://

- name: Install dependencies
run: yarn install

- name: Build contracts
run: yarn build

- name: Run tests
run: yarn test

contracts-deployment-dry-run:
needs: contracts-detect-changes
if: |
github.event_name != 'pull_request'
|| needs.contracts-detect-changes.outputs.path-filter == 'true'
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./cross-chain/arbitrum
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: "14.x"
cache: "yarn"
cache-dependency-path: cross-chain/arbitrum/yarn.lock

# A workaround for transitive dependencies that use the obsolete git://
# prefix instead of the recommended https://
- name: Configure git to not use unauthenticated protocol
run: git config --global url."https://".insteadOf git://

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Deploy contracts
run: yarn deploy

contracts-format:
needs: contracts-detect-changes
if: |
github.event_name == 'push'
|| needs.contracts-detect-changes.outputs.path-filter == 'true'
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./cross-chain/arbitrum
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: "14.x"
cache: "yarn"
cache-dependency-path: cross-chain/arbitrum/yarn.lock

michalinacienciala marked this conversation as resolved.
Show resolved Hide resolved
# A workaround for transitive dependencies that use the obsolete git://
# prefix instead of the recommended https://
- name: Configure git to not use unauthenticated protocol
run: git config --global url."https://".insteadOf git://

- name: Install dependencies
run: yarn install

- name: Build
run: yarn build

- name: Check formatting
run: yarn format

contracts-slither:
needs: contracts-detect-changes
if: |
github.event_name == 'push'
|| needs.contracts-detect-changes.outputs.path-filter == 'true'
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./cross-chain/arbitrum
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: "14.x"
cache: "yarn"
cache-dependency-path: cross-chain/arbitrum/yarn.lock

- uses: actions/setup-python@v4
with:
python-version: 3.10.8

- name: Install Solidity
env:
SOLC_VERSION: 0.8.17 # according to solidity.version in hardhat.config.ts
run: |
pip3 install solc-select
solc-select install $SOLC_VERSION
solc-select use $SOLC_VERSION

- name: Install Slither
env:
SLITHER_VERSION: 0.8.3
run: pip3 install slither-analyzer==$SLITHER_VERSION

# A workaround for transitive dependencies that use the obsolete git://
# prefix instead of the recommended https://
- name: Configure git to not use unauthenticated protocol
run: git config --global url."https://".insteadOf git://

- name: Install dependencies
run: yarn install

- name: Run Slither
run: slither --hardhat-artifacts-directory build .
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,9 @@ repos:
files: "^monitoring/"
language: script
description: "Checks monitoring directory code according to the formatting configuration"
- id: cross-chain-arbitrum-format
name: "Check cross-chain/arbitrum directory code formatting"
entry: /usr/bin/env bash -c "cd cross-chain/arbitrum && yarn format"
files: "^cross-chain/arbitrum/"
language: script
description: "Checks cross-chain/arbitrum directory code according to the formatting configuration"
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ yearn/
typescript/
system-tests/
monitoring/
cross-chain/
lukasz-zimnoch marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 2 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ This repository contains:
- TBTC v2 link:system-tests/[System tests]
- TBTC v2 link:docs/[documentation],
- TBTC v2 Yearn vault link:yearn/[Solidity smart contracts],
- TBTC v2 link:monitoring/[monitoring tool].
- TBTC v2 link:monitoring/[monitoring tool],
- TBTC v2 Cross-chain link:cross-chain/[smart contracts].

toc::[]

Expand Down
8 changes: 8 additions & 0 deletions cross-chain/arbitrum/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
artifacts/
build/
cache/
deployments/
export/
hardhat-dependency-compiler/
typechain/
export.json
18 changes: 18 additions & 0 deletions cross-chain/arbitrum/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"root": true,
"extends": ["@thesis-co"],
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module"
},
"env": {
"es6": true,
"mocha": true
},
"rules": {
"new-cap": "off",
"import/no-extraneous-dependencies": "off",
"@typescript-eslint/no-use-before-define": "off",
"no-plusplus": ["error", { "allowForLoopAfterthoughts": true }]
}
}
12 changes: 12 additions & 0 deletions cross-chain/arbitrum/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Hardhat
/build/
/cache/
/export/
/external/npm
/typechain/
/export.json
/deployments/*
!/deployments/mainnet/
nkuba marked this conversation as resolved.
Show resolved Hide resolved

# OZ
/.openzeppelin/unknown-*.json
3 changes: 3 additions & 0 deletions cross-chain/arbitrum/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"require": "ts-node/register/files"
}
9 changes: 9 additions & 0 deletions cross-chain/arbitrum/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.openzeppelin/
artifacts/
build/
cache/
deployments/
export/
hardhat-dependency-compiler/
typechain/
export.json
11 changes: 11 additions & 0 deletions cross-chain/arbitrum/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
...require("@thesis-co/prettier-config"),
overrides: [
{
files: "*.sol",
options: {
tabWidth: 4,
},
},
],
}
7 changes: 7 additions & 0 deletions cross-chain/arbitrum/.solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "keep",
"plugins": [],
"rules": {
"func-visibility": ["error", { "ignoreConstructors": true }]
}
}
2 changes: 2 additions & 0 deletions cross-chain/arbitrum/.solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hardhat-dependency-compiler/
node_modules/
1 change: 1 addition & 0 deletions cross-chain/arbitrum/.tsconfig-eslint.json
42 changes: 42 additions & 0 deletions cross-chain/arbitrum/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
:toc: macro

= Threshold cross-chain - Arbitrum

This package brings Bitcoin to Ethereum L2 Arbitrum. For more details please
see link:https://github.com/keep-network/tbtc-v2/blob/main/docs/rfc/rfc-8.adoc[Cross-chain Tokenized Threshold BTC]
nkuba marked this conversation as resolved.
Show resolved Hide resolved

== How it works?

```
+----------------------------+ +---------------------------------------------------------------------------+
| Ethereum | | Arbitrum |
| | | |
| +----------------------+ | | +----------------------+ +-------------------------+ +--------------+ |
| | Wormhole TokenBridge |--|---------|--| Wormhole TokenBridge |--| ArbitrumWormholeGateway |--| ArbitrumTBTC | |
| +----------------------+ | | +----------------------+ +-------------------------+ +--------------+ |
| | | |
+----------------------------+ +---------------------------------------------------------------------------+
```

- `ArbitrumTBTC` canonical tBTC token on Arbitrum with a minting authority
delegated to `ArbitrumWormholeGateway`.
- `ArbitrumWormholeGateway` is a smart contract wrapping and unwrapping
Wormhole-specific tBTC representation into the canonical `ArbitrumTBTC` token.

=== Deploy contracts

nkuba marked this conversation as resolved.
Show resolved Hide resolved
To deploy all contracts on the given network, please run:
```
yarn deploy --network <network>
nkuba marked this conversation as resolved.
Show resolved Hide resolved
```

If contracts haven't been built yet or changes occurred, this task will build
the contracts before running the deployment script. This command produces
an `export.json` file containing contract deployment info. Note that for the
chains other than 'hardhat' the following env. variables are needed:

- `CHAIN_L2_API_URL` - URL to access blockchain services, e.g. `\https://arb-goerli.g.alchemy.com/v2/<alchemy_api_key>`
nkuba marked this conversation as resolved.
Show resolved Hide resolved
- `CONTRACT_L2_OWNER_ADDRESS` - Deployer / Contract Owner address
- `THRESHOLD_L2_COUNCIL_ADDRESS` - Council / Governance address
- `ACCOUNTS_L2_PRIVATE_KEYS` - Private keys for the deployer and council `<0xOwnerPrivKey,0xCouncilPrivKey>`
- `ARBISCAN_API_KEY` - Arbiscan API key
18 changes: 18 additions & 0 deletions cross-chain/arbitrum/contracts/test/ArbitrumTBTCUpgraded.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity ^0.8.17;

import "@keep-network/tbtc-v2/contracts/l2/L2TBTC.sol";

/// @notice Canonical tBTC Token on Arbitrum - upgraded version.
/// @dev This contract is intended solely for testing purposes. As it currently
/// stands in the implementation of L2TBTC.sol, there are no reserved
/// storage gap slots available, thereby limiting the upgradability to a
/// child contract only.
contract ArbitrumTBTCUpgraded is L2TBTC {
string public newVar;

function initializeV2(string memory _newVar) public {
newVar = _newVar;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity ^0.8.17;

import "@keep-network/tbtc-v2/contracts/l2/L2WormholeGateway.sol";

/// @notice Wormhole gateway for L2 Arbitrum - upgraded version.
/// @dev This contract is intended solely for testing purposes. As it currently
/// stands in the implementation of L2WormholeGateway.sol, there are no
/// reserved storage gap slots available, thereby limiting the upgradability
/// to a child contract only.
contract ArbitrumWormholeGatewayUpgraded is L2WormholeGateway {
string public newVar;

function initializeV2(string memory _newVar) public {
newVar = _newVar;
}
}
Loading