-
Notifications
You must be signed in to change notification settings - Fork 76
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
Remove pkg/coordinator
package
#3659
Conversation
The tbtc v2 system defines two type of sweeps: deposit sweeps and moved funds sweeps. Here we narrow the existing nomenclature used within the wallet maintainer to remove ambiguity and make it clear it refers to deposit sweeps.
…let` Here we move all code related to deposit sweeps. By the way, some simplifications were made in order to make the public API cleaner and more readable.
For now, we agreed that all chain objects should live in the `pkg/tbtc` which is the core package representing the tbtc domain.
EndBlock *uint64 | ||
EcdsaWalletID [][32]byte | ||
WalletPublicKeyHash [][20]byte | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need a clarification of this part of the PR description:
We also moved the remaining chain types living so far in the
pkg/coordinator
(coordinator. NewWalletRegisteredEvent
andcoordinator. NewWalletRegisteredEventFilter
) to thepkg/tbtc
package. This package should be the right place for them according to the recent discussion (see #3650 (comment)), at least until #3652 is done.
This move makes sense if there are more than two chain interfaces using the type. In this particular case, only the pkg/maintainer/wallet
uses it. Wouldn't it make more sense to keep this type defined inside the pkg/maintainer/wallet/chain.go
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it will be much easier to declare all chain types in pkg/tbtc
, regardless of what actually uses them.
First reason: we avoid scattering those types around packages and we have everything in one place - the core pkg/tbtc
package. This makes reasoning easier.
Second reason: Imagine pkg/tbtc
needs to use those types one day. If so, we will have an import cycle and we will have to move those types to pkg/tbtc
anyway. Also, if we introduce a new package pkg/abc
that will need those types, it will be cleaner if it depends on pkg/tbtc
and not on pkg/maintainer/wallet
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense to me. Let's just make sure to be consistent about it cc @tomaszslabon @nkuba.
Not necessarily in this PR, but what do you think about going one step further and moving the coordinator CLI under When we deploy the automated version to mainnet, we should ideally have only one maintainer instance running that will take care of updating the light relay, submitting SPV proofs, and coordinating the wallet actions. |
Yeah, that makes sense! |
Awsome, I added this to the tasklist in #3614 but let's not hold this PR. The diff is large enough already. |
Refs: #3614
Here we remove the
pkg/coordinator
by moving their contents topkg/maintainer/wallet
. This package seems to be no longer needed so this operation makes the package structure and dependency graph simpler. This refactoring was done in several steps:Step 1: Make the nomenclature in
pkg/maintainer/wallet
more preciseThe tBTC v2 system defines two types of sweeps: deposit sweeps and moved funds sweeps. In the first step, we narrowed the existing nomenclature used within the wallet maintainer to remove ambiguity and make it clear that the existing code refers to deposit sweeps.
Step 2: Move the deposit sweep code from
pkg/coordinator
topkg/maintainer/wallet
packageIn the second step, we moved the deposit sweep code living so far in the
pkg/coordinator
. By the way, somesimplifications were made in order to make the public API cleaner and more readable. After this change, the
pkg/maintainer/wallet
package exposes the following public API:FindDeposits
that allows to find deposits according to the given criteriaFindDepositsToSweep
that finds a batch of deposits that are most suitable to become part of a deposit sweepProposeDepositsSweep
which submits a deposit sweep proposal to theWalletCoordinator
contractEstimateDepositsSweepFee
that estimates the deposit sweep transaction feeDepositReference
which is a set of data allowing to identify and refer to a depositDeposit
that holds some detailed data about a depositParseDepositsReferences
that allows creating an array ofDepositReference
based on the provided input stringValidateDepositReferenceString
that allows to validate whether the given string can be used to create a validDepositReference
instanceThis step also involved moving unit tests stressing the deposit sweep code described above.
Step 3: Move the redemption code from
pkg/coordinator
topkg/maintainer/wallet
packageIn this step, we moved the redemption code from
pkg/coordinator
to thepkg/maintainer/wallet
package. This was similar to the previous step but much simpler. After this step, the public API of thepkg/maintainer/wallet
package was extended with the following items:FindPendingRedemptions
which allows to find pending redemption requestsProposeRedemption
which submits a redemption proposal to theWalletCoordinator
contractEstimateRedemptionFee
that estimates the redemption transaction feeThis step also involved moving unit tests stressing the redemption code described above.
Step 4: Move the
coordinator.Chain
interfaceIn the fourth step, we moved the
coordinator.Chain
interface by merging it with themaintainer/wallet.Chain
interface.This change clarifies the chain expectations defined by the
pkg/maintainer/wallet
package. We also moved the remaining chain types living so far in thepkg/coordinator
(coordinator. NewWalletRegisteredEvent
andcoordinator. NewWalletRegisteredEventFilter
) to thepkg/tbtc
package. This package should be the right place for them according to the recent discussion (see #3650 (comment)), at least until #3652 is done.Step 5: Remove
pkg/coordinator
packageIn the last step, we removed the
pkg/coordinator
package and made sure all references from thecmd
package were correctly replaced.