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

Moving funds commitment implementation #3748

Merged
merged 55 commits into from
Feb 8, 2024
Merged

Conversation

tomaszslabon
Copy link
Contributor

@tomaszslabon tomaszslabon commented Nov 30, 2023

#Refs: #3733.

This PR introduces functionalities that enable a wallet to submit a moving funds commitment. These functionalities have been incorporated into the tbtcpg package through the creation and execution of a MovingFundsTask.
They were implemented in the same manner as other procedures such as deposit sweeps and redemptions.

The task results in a moving funds proposal, which is needed for generating the Bitcoin transaction that transfer funds between wallets. Usually, this process will also involve submitting the moving funds commitment transaction to the Bridge. This submission step may be skipped if the commitment has already been submitted, which can occur if a previously initiated moving funds procedure was interrupted post-commitment submission and still needs completion.

Executing a moving funds task consists of several key steps:

  1. Verifying the eligibility of the wallet for moving funds, involving checks on the wallet's state and balance.
  2. Preparing the target wallets, which includes either creating a new list of wallets or retrieving an existing list from a previous, interrupted moving funds procedure.
  3. Submitting the moving funds transaction to the Bridge, unless it has already been submitted.
  4. Creating and validating the moving funds proposal, a process that involves estimating the Bitcoin transaction fee.

Upon completion of the moving funds task, all necessary prerequisites for the Bitcoin moving funds transaction should be satisfied.

@lukasz-zimnoch lukasz-zimnoch removed the request for review from pdyraga December 1, 2023 08:53
@tomaszslabon tomaszslabon self-assigned this Dec 1, 2023
pkg/tbtc/node.go Outdated Show resolved Hide resolved
pkg/tbtc/node.go Outdated Show resolved Hide resolved
pkg/tbtc/node.go Outdated Show resolved Hide resolved
pkg/tbtc/moving_funds.go Outdated Show resolved Hide resolved
pkg/tbtc/node.go Outdated Show resolved Hide resolved
pkg/tbtc/node.go Outdated Show resolved Hide resolved
pkg/tbtc/node.go Outdated Show resolved Hide resolved
pkg/tbtc/node.go Outdated Show resolved Hide resolved
pkg/tbtc/node.go Outdated Show resolved Hide resolved
pkg/tbtc/node.go Outdated Show resolved Hide resolved
@tomaszslabon tomaszslabon force-pushed the moving-funds-commitment branch from e467cc2 to 6ff4af7 Compare December 1, 2023 14:45
@tomaszslabon tomaszslabon changed the base branch from main to rfc-12-impl-2 December 1, 2023 14:46
Base automatically changed from rfc-12-impl-2 to main December 4, 2023 17:03
@tomaszslabon tomaszslabon force-pushed the moving-funds-commitment branch from 80e34b6 to 590e84d Compare January 3, 2024 15:41
@tomaszslabon tomaszslabon force-pushed the moving-funds-commitment branch from 8f67d89 to 875f5f5 Compare January 5, 2024 17:47
@tomaszslabon tomaszslabon marked this pull request as ready for review January 26, 2024 09:25
Copy link
Member

@lukasz-zimnoch lukasz-zimnoch left a comment

Choose a reason for hiding this comment

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

Amazing work 💯 Leaving a last batch of comments. I'm happy to merge once they are addressed!

pkg/tbtc/marshaling.go Show resolved Hide resolved
pkg/tbtc/marshaling_test.go Outdated Show resolved Hide resolved
pkg/tbtc/moving_funds.go Outdated Show resolved Hide resolved
pkg/tbtc/moving_funds.go Show resolved Hide resolved
pkg/tbtc/moving_funds.go Show resolved Hide resolved
pkg/tbtcpg/moving_funds.go Outdated Show resolved Hide resolved
pkg/tbtcpg/moving_funds.go Outdated Show resolved Hide resolved
pkg/tbtcpg/moving_funds.go Outdated Show resolved Hide resolved
pkg/tbtcpg/moving_funds.go Outdated Show resolved Hide resolved
pkg/tbtcpg/moving_funds.go Outdated Show resolved Hide resolved
@tomaszslabon tomaszslabon force-pushed the moving-funds-commitment branch from 3244708 to 62e8f0a Compare February 5, 2024 13:50
@tomaszslabon tomaszslabon force-pushed the moving-funds-commitment branch from 62e8f0a to d2b5cc0 Compare February 5, 2024 14:21
pkg/chain/ethereum/tbtc.go Show resolved Hide resolved
pkg/tbtcpg/chain_test.go Show resolved Hide resolved
pkg/tbtcpg/moving_funds.go Outdated Show resolved Hide resolved
@tomaszslabon tomaszslabon force-pushed the moving-funds-commitment branch from a1f5e64 to 4672795 Compare February 8, 2024 10:04
// Search for the operator address in the cache. Store the operator
// address in the cache if it's not there.
if operatorID, found := operatorIDCache[operatorAddress]; !found {
operatorID, err := mft.chain.GetOperatorID(operatorAddress)
Copy link
Member

Choose a reason for hiding this comment

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

Non-blocking and we can address this in the next PR: Let's rename this operatorID to fetchedOperatorID to not shadow the variable declared in the if.

@lukasz-zimnoch lukasz-zimnoch merged commit cdda81b into main Feb 8, 2024
29 checks passed
@lukasz-zimnoch lukasz-zimnoch deleted the moving-funds-commitment branch February 8, 2024 10:23
@lukasz-zimnoch lukasz-zimnoch added this to the v2.1.0 milestone Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants