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

Adding Base module for canonical TBTC #673

Merged
merged 9 commits into from
Aug 1, 2023
Merged

Conversation

dimpar
Copy link
Contributor

@dimpar dimpar commented Jul 27, 2023

Part of #542

This PR is a continuation of tBTC expansion to L2s - BASE chain. Code was largely copied from the existing cross-chain/* modules with some naming modifications, addresses and chain ids. It creates a new cross-chain/base module to bring tBTC to BASE with the help of Wormhole. Here's a diagram to illustrate the flow

+----------------------------+         +-------------------------------------------------------------------+
|          Ethereum          |         |                                Base                               |
|                            |         |                                                                   |
|  +----------------------+  |         |  +----------------------+  +---------------------+  +----------+  |
|  | Wormhole TokenBridge |--|---------|--| Wormhole TokenBridge |--| BaseWormholeGateway |--| BaseTBTC |  |
|  +----------------------+  |         |  +----------------------+  +---------------------+  +----------+  |
|                            |         |                                                                   |
+----------------------------+         +-------------------------------------------------------------------+
  • Wormhole TokenBridge on Ethereum - holds all TBTC bridged to BASE. This is an external contract created by the Wormhole team.
  • Wormhole TokenBridge on BASE - mints Wormhole wrapped TBTC ie. wormholeTBTC. This is an external contract created by the Wormhole team.
  • BaseWormholeGateway on BASE - acts as a vending machine that wraps and unwraps wormholeTBTC to the canonical tBTC token on BASE. This is an upgradable Gateway behind OZ transparent proxy. The Threshold team creates it.
  • BaseTBTC canonical tBTC token on BASE. It is upgradable behind OZ transparent proxy. The Threshold team creates it.
    All the ownership of Threshold-created contracts is transferred to the Threshold governance including a proxy admin ownership.

A couple of things to pay closer attention at:

  • addresses under the external/ dir
  • gateway address to a wormhole chain id: 30
  • gateway addresses to other wormhole chains id: 23 - Arbitrum, 24 - Optimism, 5 - Polygon
  • Goerli BASE and Mainnet BASE chain ids: 84531 and 8453

Deploy on BASE testnet / mainnet

Create a .envrc file and include the following:

export L2_CHAIN_API_URL=<API_URL> // e.g. "https://goerli.base.org"
export L2_ACCOUNTS_PRIVATE_KEYS=<0xOWNER_PRIV_KEY>
export BASESCAN_API_KEY=<API_KEY> // needs to be created on [basescan](https://basescan.org/)
  yarn deploy --network <network>

where network can be:

  • baseGeorli // testnet
  • base // mainnet

Useful links:

https://docs.base.org/network-information/
https://docs.wormhole.com/wormhole/supported-environments/evm#base

TODO:

  • Register TBTC on BASE using Portal on Testnet and Mainnet. After that replace the address in BaseWormholeTBTC.json under external/base and external/goerliBase with a newly registered token.

Most of the files were copied from the Optimism module and adjusted for
the Base chain, ie. ids and addresses. There is one change that had to
be added which is a custom network for hardhat etherscan plugin. Base is
not supported by this plugin by default and a custom network
configuration had to be added.
@dimpar dimpar requested review from nkuba and pdyraga July 27, 2023 17:26
@dimpar dimpar self-assigned this Jul 27, 2023
@dimpar dimpar mentioned this pull request Jul 28, 2023
36 tasks
dimpar and others added 5 commits July 28, 2023 17:04
The implementation contract was failing basescan verification unless the
constructor params were empty.
We don't use this script currently so there is no need to push it.
Most of the transactions pass without gasPrice parameter. We need to set
it in case we have problems.
@nkuba nkuba self-assigned this Aug 1, 2023
const { execute } = deployments
const { deployer } = await getNamedAccounts()

// See https://docs.wormhole.com/wormhole/reference/environments/evm#base
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB: This link does not work. I think the proper one now is https://docs.wormhole.com/wormhole/blockchain-environments/evm#base

@@ -0,0 +1,3 @@
{
"address": "0x9EE95E6Bd1B3C5740F105d6fb06b8BDeF64Eec70"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB: I could not double-check this address as I don't know where it comes from. Keep this in mind during deployment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, this was confirmed by @dimpar on Discord. The address comes from the wrapped tBTC token registration on Base (tx: https://basescan.org/tx/0x82af9e68b6be7db6b89cfb6e09368f524e04a317c938e367047f6467484e47a3).

@lukasz-zimnoch lukasz-zimnoch merged commit 990dc97 into main Aug 1, 2023
38 checks passed
@lukasz-zimnoch lukasz-zimnoch deleted the cross-chain-base branch August 1, 2023 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants