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

Harden moving funds against edge cases #3813

Merged
merged 7 commits into from
May 6, 2024
Merged

Conversation

tomaszslabon
Copy link
Contributor

@tomaszslabon tomaszslabon commented Apr 30, 2024

#Refs #3812.
This PR modifies the safety margin validation process used during moving funds.
It is possible that a wallet may receive deposits just before it changes states to MovingFunds.
It is also possible another wallets in MovingFunds state may commit to transfer their funds to it.
To avoid a situation where a wallet ends up with additional funds after it has already moved their own funds we must apply a safety margin.
In #3810 we already added a 24-hour safety margin.
In this PR we add a longer 14-days safety margin when the wallet is a target of a moving funds process from another wallet. We also make sure the calculated safety margin is not greater than half of the movingFundsTimeout, so that a wallet has enough time to finish their moving funds process.

@tomaszslabon tomaszslabon marked this pull request as ready for review May 2, 2024 08:33
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.

LGTM! Some minor comments and I'm happy to merge!

pkg/tbtc/moving_funds.go Outdated Show resolved Hide resolved
pkg/tbtc/moving_funds.go Outdated Show resolved Hide resolved
pkg/tbtc/moving_funds.go Outdated Show resolved Hide resolved
pkg/tbtc/moving_funds.go Outdated Show resolved Hide resolved
@lukasz-zimnoch lukasz-zimnoch merged commit a3904dd into main May 6, 2024
29 checks passed
@lukasz-zimnoch lukasz-zimnoch deleted the harden-moving-funds branch May 6, 2024 12:37
@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