Here we present the third part of the changes meant to implement RFC 12: Decentralized wallet coordination in the tBTC wallet client. This pull request focuses on proposal generation.
Remove wallet coordination from the maintainer module
So far, the maintainer bot implemented in the pkg/maintainer package was responsible for wallet coordination. The logic was living in the pkg/maintainer/wallet sub-package. As the maintainer bot is no longer responsible for wallet coordination, we are detaching the wallet coordination from there. This has also an impact on the maintainer-cli. Commands responsible for deposit sweep and redemption proposal submission are no longer available.
Move code from pkg/maintainer/wallet package to pkg/tbtcpg
Although the maintainer no longer uses the wallet coordination code, that code is still useful for the new coordination mechanism. It contains the logic necessary to produce coordination proposals. Hence, we moved it to the new pkg/tbtcpg package and exposed an entry point component ProposalGenerator that implements the tbtc.CoordinationProposalGenerator interface. Thanks to that, the pkg/tbtc package can use the code from pkg/tbtcpg to generate coordination proposals.
Ideally, the code from pkg/tbtcpg should be embedded into pkg/tbtc. However, both packages are not compatible out of the box. Merging them would require a lot of breaking changes. As RFC 12 implementation is already a complex task, we decided to keep pkg/tbtcpg as a separate being for now, to reduce risk.
Last but not least, the code in pkg/tbtcpg was simplified. This code no longer needs to handle proposals for multiple wallets at the same time so focusing on a single wallet allowed us to remove redundant code and facilitate further maintenance.
Wire up pkg/tbtcpg package to pkg/tbtc
As mentioned in the previous section, the pkg/tbtcpg implements the tbtc.CoordinationProposalGenerator interface so it can be used to generate proposals within the new coordination mechanism. This was achieved by injecting the tbtcpg.ProposalGenerator as a dependency to tbtc.node, during the setup process.
Next steps
The next steps on the way towards RFC 12 implementation are:
Finalize coordination result processing (i.e. implement the processCoordinationResult function and refactor node's handlers appropriately)
Remove the existing chain-based mechanism (i.e. detach WalletCoordinator's events handlers and remove unnecessary code from chain.go)
Modify the SPV maintainter to not rely on WalletCoordinator's events during unproven transactions lookup
Refs: https://github.com/keep-network/tbtc-v2/issues/737 Depends on: https://github.com/keep-network/keep-core/pull/3745
Here we present the third part of the changes meant to implement RFC 12: Decentralized wallet coordination in the tBTC wallet client. This pull request focuses on proposal generation.
Remove wallet coordination from the maintainer module
So far, the maintainer bot implemented in the
pkg/maintainer
package was responsible for wallet coordination. The logic was living in thepkg/maintainer/wallet
sub-package. As the maintainer bot is no longer responsible for wallet coordination, we are detaching the wallet coordination from there. This has also an impact on the maintainer-cli. Commands responsible for deposit sweep and redemption proposal submission are no longer available.Move code from
pkg/maintainer/wallet
package topkg/tbtcpg
Although the maintainer no longer uses the wallet coordination code, that code is still useful for the new coordination mechanism. It contains the logic necessary to produce coordination proposals. Hence, we moved it to the new
pkg/tbtcpg
package and exposed an entry point componentProposalGenerator
that implements thetbtc.CoordinationProposalGenerator
interface. Thanks to that, thepkg/tbtc
package can use the code frompkg/tbtcpg
to generate coordination proposals.Ideally, the code from
pkg/tbtcpg
should be embedded intopkg/tbtc
. However, both packages are not compatible out of the box. Merging them would require a lot of breaking changes. As RFC 12 implementation is already a complex task, we decided to keeppkg/tbtcpg
as a separate being for now, to reduce risk.Last but not least, the code in
pkg/tbtcpg
was simplified. This code no longer needs to handle proposals for multiple wallets at the same time so focusing on a single wallet allowed us to remove redundant code and facilitate further maintenance.Wire up
pkg/tbtcpg
package topkg/tbtc
As mentioned in the previous section, the
pkg/tbtcpg
implements thetbtc.CoordinationProposalGenerator
interface so it can be used to generate proposals within the new coordination mechanism. This was achieved by injecting thetbtcpg.ProposalGenerator
as a dependency totbtc.node
, during the setup process.Next steps
The next steps on the way towards RFC 12 implementation are:
processCoordinationResult
function and refactornode
's handlers appropriately)WalletCoordinator
's events handlers and remove unnecessary code fromchain.go
)WalletCoordinator
's events during unproven transactions lookup