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

L2 direct bridging #792

Merged
merged 26 commits into from
Mar 13, 2024
Merged

L2 direct bridging #792

merged 26 commits into from
Mar 13, 2024

Commits on Feb 28, 2024

  1. Draft implementation of the L2BitcoinDepositor contract

    Here we present a draft implementation of the `L2BitcoinDepositor` contract
    that acts as an entrypoint of the tBTC direct bridging feature on the given
    L2 chain. This contract exposes the `initializeDeposit` function that takes the
    deposit data (funding tx, reveal info, original depositor) and relays it to the
    `L1BitcoinDepositor` contract using the Wormhole Relayer infrastructure.
    lukasz-zimnoch committed Feb 28, 2024
    Configuration menu
    Copy the full SHA
    970fed2 View commit details
    Browse the repository at this point in the history
  2. Draft implementation of the L1BitcoinDepositor contract

    Here we present a draft implementation of the `L1BitcoinDepositor` contract
    that acts as the central point of the tBTC direct bridging feature on the
    L1 Ethereum chain where TBTC minting occurs. This contract exposes the
    `receiveWormholeMessages` function that receives a message from
    `L2BitcoinDepositor` contract (using the Wormhole Relayer infrastructure),
    extracts deposit data from it, and initiates the deposit on the tBTC `Bridge`
    side. Moreover, the contract also exposes the `initializeDeposit` function
    directly. The goal here is to satisfy future use cases that don't rely on
    Wormhole Relayer for cross-chain messaging.
    lukasz-zimnoch committed Feb 28, 2024
    Configuration menu
    Copy the full SHA
    9241003 View commit details
    Browse the repository at this point in the history
  3. Change calldata to memory in AbstractTBTCDepositor contract

    So far, the `_initializeDeposit` accepted `calldata` parameters. This
    does not work for integrator contracts that obtain deposit parameters
    as `memory` objects (the conversion `memory -> calldata` is not possible).
    
    To overcome this problem, we are changing parameters of `_initializeDeposit`
    to be `memory` as well. This is not breaking integrators that receive
    deposit parameters as `calldata` because the `calldata -> memory` conversion
    is fine.
    lukasz-zimnoch committed Feb 28, 2024
    Configuration menu
    Copy the full SHA
    df436e1 View commit details
    Browse the repository at this point in the history

Commits on Feb 29, 2024

  1. Expose tbtcToken from the ITBTCVault interface

    This will be useful to get TBTC token address directly from the vault
    contract.
    lukasz-zimnoch committed Feb 29, 2024
    Configuration menu
    Copy the full SHA
    34971b0 View commit details
    Browse the repository at this point in the history
  2. Finalize deposit flow

    Here we implement the finalization of the deposit flow. This process
    is started on the `L1BitcoinDepositor` side once the tBTC `Bridge` completes
    minting of the TBTC token. The process consists of multiple steps:
    
    1. The `L1BitcoinDepositor` marks the given deposit as finalized and determines
       the amount of TBTC minted.
    2. The `L1BitcoinDepositor` initiates a Wormhole token transfer. This transfer
       locks minted TBTC on L1 within the Wormhole Token Bridge and unlocks
       Wormhole-wrapped L2 TBTC for the `L2WormholeGateway` contract.
    3. The `L2BitcoinDepositor` sends the transfer VAA to `L2BitcoinDepositor`.
    4. The `L2BitcoinDepositor` finalizes the transfer by calling the
       `L2WormholeGateway` that redeems Wormhole-wrapped L2 TBTC from the
       Wormhole Token Bridge and uses it to mint canonical L2 TBTC for the
       L2 deposit owner.
    lukasz-zimnoch committed Feb 29, 2024
    Configuration menu
    Copy the full SHA
    5a179fd View commit details
    Browse the repository at this point in the history

Commits on Mar 1, 2024

  1. Deployment adjustments

    Here we adjust the new contracts for deployment:
    - We are introducing the `attach*BitcoinDepositor` functions to solve
      the chicken & egg problem that occurs upon deployment
    - We are adjusting gas limits for Wormhole to real-world values
    - We are getting rid of cross-chain Wormhole refunds that don't work
      for small amounts
    lukasz-zimnoch committed Mar 1, 2024
    Configuration menu
    Copy the full SHA
    7f81fbe View commit details
    Browse the repository at this point in the history
  2. Deployment scripts for Base

    Here we add deployment scripts for both `L*BitcoinDepositor` contracts.
    We use Base as the reference chain.
    lukasz-zimnoch committed Mar 1, 2024
    Configuration menu
    Copy the full SHA
    533e889 View commit details
    Browse the repository at this point in the history
  3. Deployment artifacts for Base Sepolia

    We are testing the implementation by deploying it on Base Sepolia chain.
    Here are the relevant deployment artifacts.
    lukasz-zimnoch committed Mar 1, 2024
    Configuration menu
    Copy the full SHA
    e927830 View commit details
    Browse the repository at this point in the history

Commits on Mar 4, 2024

  1. Do not use Wormhole Relayer for L2 -> L1 deposit reveal

    Such a deposit reveal was tested for Base -> Ethereum and turned out
    to be super expensive. It takes ~0,045 ETH so ~150 USD to transfer deposit
    data to Ethereum. This is an unacceptable cost. To overcome that problem,
    we are abandoning the idea of using Wormhole Relay for that in favor
    of our own relay bot implementation. This also makes sense as eventually,
    we are aiming towards using gas-less reveals on Base.
    lukasz-zimnoch committed Mar 4, 2024
    Configuration menu
    Copy the full SHA
    4adf553 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    59a337f View commit details
    Browse the repository at this point in the history

Commits on Mar 5, 2024

  1. Configuration menu
    Copy the full SHA
    4aa0886 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    49d2bb9 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    2ea028b View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    9a3555c View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    fa89a62 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    fac595d View commit details
    Browse the repository at this point in the history

Commits on Mar 6, 2024

  1. Configuration menu
    Copy the full SHA
    105a52d View commit details
    Browse the repository at this point in the history

Commits on Mar 7, 2024

  1. Configuration menu
    Copy the full SHA
    3fc19ad View commit details
    Browse the repository at this point in the history
  2. Use upgradable OZ token types

    The OZ upgrade plugin complains about unsafe upgrade if standard versions of
    `IERC20` and `SafeERC20` are used.
    lukasz-zimnoch committed Mar 7, 2024
    Configuration menu
    Copy the full SHA
    ce5f849 View commit details
    Browse the repository at this point in the history
  3. Add missing test scenario for attachL1BitcoinDepositor function

    We need to make sure only owner can call this function.
    lukasz-zimnoch committed Mar 7, 2024
    Configuration menu
    Copy the full SHA
    e902f81 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    d7c0955 View commit details
    Browse the repository at this point in the history

Commits on Mar 8, 2024

  1. Configuration menu
    Copy the full SHA
    4616e6d View commit details
    Browse the repository at this point in the history
  2. Optimize the GasReimbursement structure

    It's enough to store the `gasSpent` as `uint96` which allows us to save
    one storage slot. Moreover, we are increasing the default value of
    `initializeDepositGasOffset` to adhere to real-world gas consumption.
    lukasz-zimnoch committed Mar 8, 2024
    Configuration menu
    Copy the full SHA
    d6cabdb View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    f754ebc View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    a438e1a View commit details
    Browse the repository at this point in the history

Commits on Mar 13, 2024

  1. Configuration menu
    Copy the full SHA
    b2d57ce View commit details
    Browse the repository at this point in the history