Replies: 1 comment 1 reply
-
|
Ack. Sounds like a plan. My suggestion is to try the unification first. It will reduce the current code surface and help identify the key protocol flows for the current P2WSH and Taproot protocols. Once those are clear, we can use clever design with generics and traits to turn it into an "interface". This could be easily integrated into existing Maker and Taker APIs without any additional changes. From a single maker's perspective, all protocols will follow this common flow. Only the messages and their handling details will differ.
This concept can be generalized with a clever design using traits, generics, and associated types. It's not straightforward, but it should be achievable. The final goal of the design should be:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
As mentioned in #694 currently we support only one type of protocol for every hop in a swap i.e. a v1 swap will only have P2WSH hops and a v2 swap will only have P2TR contracts.
Moving forward we want the swaps to be heterogeneous supporting different types of hops in a single swap. To achieve that, we need to significantly refactor our current architecture and messages.
Here's a proposal for a new architecture:
Protocol Abstraction
We are going to create an abstraction by defining two new traits:
IncomingHopProtocolandOutgoingHopProtocol.They will look something like:
The taker is going to keep track of individual hops while co-ordinating the swap. The swaps will happen in three phases:
Once we re-rearchitect with unified messages and handlers, we can have a single maker server and a rpc server, a single api interface for the taker and a single swapcoin module. The differences will only lie in the implementation of protocol critical stuff.
This is a high level overview. A lot more details will be decided and discussed on the go. The goal with this architecture should be to get idiomatic by abstracting what we can and remove all redundancy.
Beta Was this translation helpful? Give feedback.
All reactions