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

Client-side support for redemptions #3609

Closed
4 tasks done
pdyraga opened this issue Jun 6, 2023 · 0 comments · Fixed by #3647
Closed
4 tasks done

Client-side support for redemptions #3609

pdyraga opened this issue Jun 6, 2023 · 0 comments · Fixed by #3647
Assignees
Milestone

Comments

@pdyraga
Copy link
Member

pdyraga commented Jun 6, 2023

The following items need to be implemented so that the client can perform a redemption:

For the WalletCoordinator part, we need to think if any off-chain validation is needed. It may happen the only thing we need to validate are timeouts and if the redemption request exists. The Bridge is just taking tBTC from someone and storing the redemption address on-chain. No manipulation is possible on the coordinator's side.

Pull Requests

Preview Give feedback
  1. ⛓️ solidity
    lukasz-zimnoch
  2. 📟 client
    lukasz-zimnoch
  3. 📟 client
    lukasz-zimnoch
  4. 📟 client
    lukasz-zimnoch
@pdyraga pdyraga added this to the v2.0.0-m4 milestone Jun 7, 2023
pdyraga added a commit that referenced this issue Jun 12, 2023
Refs #3609 

Here we introduce the `assembleRedemptionTransaction` function that
allows constructing an unsigned Bitcoin redemption transaction based on
provided input arguments.
pdyraga added a commit to keep-network/tbtc-v2 that referenced this issue Jun 16, 2023
Refs keep-network/keep-core#3609

Here we add the on-chain coordination for redemptions. This changeset
enhances the `WalletCoordinator` contract with three methods:
- `submitRedemptionProposal` that can be used to submit redemption
proposals for wallets
- `submitRedemptionProposalWithReimbursement` which is the reimbursable
version of `submitRedemptionProposal`
- `validateRedemptionProposal` which can be used by off-chain wallet
operators to validate proposals using static calls

Moreover, during the work on `validateRedemptionProposal` we noticed the
need to harden the validation rules of `validateDepositSweepProposal`
function. We added a rule which enforces that each deposit in the
proposal is used exactly once.
pdyraga added a commit that referenced this issue Jun 21, 2023
Refs #3609

Here is the first part of the client-side redemption support. In this
PR, we are integrating with the recent changes introduced in the
`WalletCoordinator` contract
(keep-network/tbtc-v2#633) and we are adding the
ability to observe incoming redemption proposals. Here is a brief
description of particular changes.

### `WalletCoordinator` contract integration code

We are adding all the boilerplate code required to see redemption
proposals emitted by the `WalletCoordinator` contract. This work
includes:
- Updates of contract bindings
- Integration with the `tbtc` package through the
`tbtc.WalletCoordinatorChain` interface and `chain/ethereum`
implementation
- Implementation of tools allowing to convert between length-prefixed
redeemer output scripts used by the smart contracts and the prefixless
form preferred in the off-chain client

### Observe incoming proposals

This part uses the code described in the previous section to:

- Handle incoming redemption proposals submitted to the
`WalletCoordinator` contract
- De-duplicate incoming proposals
- Confirm the finality of the incoming proposals
pdyraga added a commit that referenced this issue Jun 22, 2023
…tion (#3647)

Closes #3609

Here we add the remaining part necessary to enable redemption support on
the client side. Specific changes include:

### Extracting common components used across wallet actions

During the work on this PR, we identified that some code can be detached
from the existing `depositSweepAction` and live as an independent being
that can be reused across different wallet actions. Those components
are:
- The `walletTransactionExecutor` which is a thin layer encapsulating
some logic necessary to sign and broadcast wallet Bitcoin transactions
- The `EnsureWalletSyncedBetweenChains` function which allows to make
sure the wallet is synced between the Bitcoin and host chain before
starting an action

Thanks to that change, we avoid code duplication across wallet actions.

### Implementation of the `redemptionAction`

We introduce a dedicated `redemptionAction` that encapsulates everything
that must be done to perform a successful redemption. Its structure is
very similar to the existing `depositSweepAction`. It starts by making
the proposal validation, then constructs, signs, and broadcasts the
redemption transaction over the Bitcoin network.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants