Skip to content

[review] MIP-58: Lock/Mint-type Bridge Design - #58

Merged
franck44 merged 51 commits into
mainfrom
mip-58
Jan 16, 2025
Merged

[review] MIP-58: Lock/Mint-type Bridge Design#58
franck44 merged 51 commits into
mainfrom
mip-58

Conversation

@Primata

@Primata Primata commented Nov 16, 2024

Copy link
Copy Markdown
Contributor

Summary

MIP-58

@Primata
Primata requested a review from apenzk as a code owner November 16, 2024 22:45
Comment thread MIP/mip-58/README.md Outdated
Comment thread MIP/mip-58/README.md Outdated
Comment thread MIP/mip-58/README.md Outdated
Comment thread MIP/mip-58/README.md Outdated
Comment thread MIP/mip-58/README.md Outdated

@ganymedio ganymedio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like a good start. I agree a simpler design could be better. Adding more technical details include code samples and diagrams would make this more of a proper MIP and help reviewers evaluate the design.

@ganymedio

ganymedio commented Nov 17, 2024

Copy link
Copy Markdown
Contributor

One great thing about this design from a product perspective is that it removes refunds (cc @rolandoesparza). Because we've changed the HTLC bridge to have only the relayer be allowed to refund, we might as well simply have the relayer complete transfers as a matter of obligation. Refunds are inherently negative and something essential for businesses to minimize. Not offering refunds at all, but instead guaranteeing a successful swap, will result a more net positive user experience in general.

Comment thread MIP/mip-58/README.md Outdated
Comment thread MIP/mip-58/README.md Outdated
Comment thread MIP/mip-58/README.md
Comment thread MIP/mip-58/README.md Outdated
Comment thread MIP/mip-58/README.md
Comment thread MIP/mip-58/README.md
- The current design requires a complete UI/UX overhaul, adding complexity and delay.
6. **Unnecessary Complexity**:
- HTLC-based bridges are largely abandoned in favor of simpler, more effective designs.
- Examples like the [Consensys HTLC](https://github.com/Consensys/htlc-bridge) bridge demonstrate the [pitfalls of such approaches](https://entethalliance.org/crosschain-bridges-overview-where-we-are-now/).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for linking this and cool to see, but I only see one con in the HTLC protocol :

This method is trust minimized, but requires both parties to stay online for the duration of the swap in order to withdraw funds on the other side, which can cause friction for end-users.
It seems that each design has some pro and some con.

Again this was known from the very start. Agree tho that block confirmation time was not fully considered. I do remember discussing with Boy, some limit of a few blocks to wait before continuing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, but it still has to be indicated. I don't think a lot of people knew what it entitled as we were developing it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please write out what is the problem of this example (what is being demonstrated). the reader (us) should not need to go to the link to learn about the TLDR

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As per committee agreement, merging will go ahead without addressing this comment. Please consider to raise an issue if this is of concern @Primata

Comment thread MIP/mip-58/README.md Outdated
Comment thread MIP/mip-58/README.md Outdated
@0xmovses

0xmovses commented Nov 18, 2024

Copy link
Copy Markdown
Contributor

Bar my nits with some of the motivation points, I think this MIP has value and we should consider shipping it for mainnet.

Without block-confirmation-wait HTLC was working well. With that wait, because of the signing required on the L2 it adds significant bad UX hurdle, which I think users wont like. I've been thinking about this a lot and I think it may be worth shipping this soon.

The changes proposed are not dramatic and are just removals of functionality and with some new testing.

cc @musitdev & @franck44

@ganymedio

Copy link
Copy Markdown
Contributor

Bar my nits with some of the motivation points, I think this MIP has value and we should consider shipping it for mainnet.

Without block-confirmation-wait HTLC was working well. With that wait, because of the signing required on the L2 it adds significant bad UX hurdle, which I think users wont like. I've been thinking about this a lot and I think it may be worth shipping this soon.

The changes proposed are not dramatic and are just removals of functionality and with some new testing.

cc @musitdev & @franck44

Regarding bad UX with the HTLC model, if Movement is completing refunds on Ethereum, then that's bad for Movement financially and users still won't be happy, because they lost their L1 fee to initiate their transfer and they didn't get to play on L2.

Given that the decision has been made for the HTLC model to restrict refunds (and transfer the fee) to the relayer, and because users refunding themselves on L1 would also be a bad experience due to losing an Ethereum transaction fee twice, it makes sense to eliminate refunds completely and instead guarantee successful transfers and a positive user experience.

The trust assumption of the relayer not being compromised is present in both the HTLC and Simplified Bridge Design models. So there doesn't appear to me to be much difference, security-wise, other than this design having fewer potential variables such as needing to relay Locked events.

@apenzk

apenzk commented Nov 18, 2024

Copy link
Copy Markdown
Contributor

please provide a more descriptive title. E.g. "whatever-type-of-bridge this is" or "Non-HTLC-based Native Bridge"

@Primata

Primata commented Nov 18, 2024

Copy link
Copy Markdown
Contributor Author

I would simply call this a Rate Limited Relayer

@apenzk apenzk changed the title MIP-58 Simplified Bridge Design [draft] MIP-58: Trusted-Relayer focused Bridge Design Nov 19, 2024
Comment thread MIP/mip-58/README.md Outdated
Comment thread MIP/mip-58/README.md Outdated
@apenzk

apenzk commented Nov 19, 2024

Copy link
Copy Markdown
Contributor

I would simply call this a Rate Limited Relayer

I see you accepted trusted-relayer focused Bridge.. Lets run with that until better name.

The relayer is also limited in the HTLC-type bridge.. it is not descriptive of this solution.

@apenzk

apenzk commented Nov 19, 2024

Copy link
Copy Markdown
Contributor

it makes sense to eliminate refunds completely and instead guarantee successful transfers and a positive user experience.

@andygolay refunds cannot be eliminated. consider the L2 is down for an extensive time and Mvmt would have to accept to refund.

However with this design it is in Mvmt's decision space to call it when refunds can be issued rather than timeouts. Moreover, the refund can be selected to happen when gas price is reasonable n L1.

@ganymedio

ganymedio commented Nov 19, 2024

Copy link
Copy Markdown
Contributor

it makes sense to eliminate refunds completely and instead guarantee successful transfers and a positive user experience.

@andygolay refunds cannot be eliminated. consider the L2 is down for an extensive time and Mvmt would have to accept to refund.

However with this design it is in Mvmt's decision space to call it when refunds can be issued rather than timeouts. Moreover, the refund can be selected to happen when gas price is reasonable n L1.

If the L2 is down for an extensive time, then there is no Movement network for that time. If that were to happen, then bridging should be halted until the network is back up.

When the Movement network is back up, swaps can resume, including completing, on L2, the backlog of transfers initiated on L2.

If refunds are not offered by a business, then the business is not obligated to process refunds as long as they deliver the product that they have offered according to the associated Terms and Conditions users agree to.

Unless the Product team aka @rolandoesparza and @bhenhsi have decided this, then it's not a research or engineering decision whether to eliminate refunds or not. It is a business decision.

If the L2 is down for an extended time, then that would mean the business is obligated to keep a record of transfers initiated on L1 which have not been fulfilled on L2. When the L2 is up again, then transfers must be completed on L2.

To be clear, there are no refunds in MIP #58. So yes, if Movement chooses a model that eliminates refunds, and operates ethically and faithfully as a business, then refunds can be eliminated, assuming eventually the L2 will be up again. If the L2 is never up and usable again after some downtime, then that's a much more catastrophic event, beyond the ability of any bridge design to fix.

@apenzk

apenzk commented Nov 19, 2024

Copy link
Copy Markdown
Contributor

referencing from different conversation channel regarding refunds:

I propose we only complete, because once a bridgeTransferId has been done, it cannot be redone.

Regarding refunds, here are two paths forward:

  1. Do not refund. The user has to wait until the relayer and/or the L2 chain are live again and the transfer can be completed. This is clearly pointed out in the UX: "No refunds!". Transfer will be handled eventually. For this the relayer has to make sure that a bridgeTransferID was successful. Hence bridgeTransferId should increase +=1 . We will have to keep track on L2 what is the lowest bridgeTransferId that has not been processed. Need to 100% ensure the relayer CANNOT forget any bridgeTransferId and that it can read from the L2 chain (on-chain!) where the oldest non-completed bridgeTransferId is. This is because the relayer does NOT have memory (it can crash).

  2. Refund but do so conservatively. This is risky! the relayer MUST send a cancel message to the target chain. It cannot trust itself so it must know that the L2-cancel-message is recorded on-L2-chain BEFORE it can refund on L1. If this is not possible (L2-chain is excessively dead) we MUST ensure that the relayer will not send a L2-complete message on L2 nor that there is a L2-complete message in the L2 mempool. This is hard.

Note that the bridgeTransferId +=1 works because we only consider L1-final blocks. If reorgs would happen this does not work and it could lead to double spends.

All of the above is symmetrical for L2->L1 transfer.
Consequently, we must have the same non-reorg requirement for L2.

@ganymedio

ganymedio commented Nov 19, 2024

Copy link
Copy Markdown
Contributor

referencing from different conversation channel regarding refunds:

I propose we only complete, because once a bridgeTransferId has been done, it cannot be redone.

Regarding refunds, here are two paths forward:

  1. Do not refund. The user has to wait until the relayer and/or the L2 chain are live again and the transfer can be completed. This is clearly pointed out in the UX: "No refunds!". Transfer will be handled eventually. For this the relayer has to make sure that a bridgeTransferID was successful. Hence bridgeTransferId should increase +=1 . We will have to keep track on L2 what is the lowest bridgeTransferId that has not been processed. Need to 100% ensure the relayer CANNOT forget any bridgeTransferId and that it can read from the L2 chain (on-chain!) where the oldest non-completed bridgeTransferId is. This is because the relayer does NOT have memory (it can crash).
  2. Refund but do so conservatively. This is risky! the relayer MUST send a cancel message to the target chain. It cannot trust itself so it must know that the L2-cancel-message is recorded on-L2-chain BEFORE it can refund on L1. If this is not possible (L2-chain is excessively dead) we MUST ensure that the relayer will not send a L2-complete message on L2 nor that there is a L2-complete message in the L2 mempool. This is hard.

Note that the bridgeTransferId +=1 works because we only consider L1-final blocks. If reorgs would happen this does not work and it could lead to double spends.

All of the above is symmetrical for L2->L1 transfer. Consequently, we must have the same non-reorg requirement for L2.

As someone who owned and ran a successful web2 business for 4 years without offering refunds, I'm biased, but strongly in favor of option 1. Do not refund. With very clear messaging upfront as you mention. It results in a more positive experience all-around, when the end result is pre-determined to be a successful outcome.

Refunding is a failure outcome in this context, of bridging from an expensive L1. It still means users lost fees on L1 and didn't get to play on L2. So I think guaranteeing a successful bridge outcome is a better option.

@Primata

Primata commented Nov 19, 2024

Copy link
Copy Markdown
Contributor Author
| src/NativeBridge.sol:NativeBridge contract |                 |         |        |         |         |
|--------------------------------------------|-----------------|---------|--------|---------|---------|
| Deployment Cost                            | Deployment Size |         |        |         |         |
| 1076243                                    | 4822            |         |        |         |         |
| Function Name                              | min             | avg     | median | max     | # calls |
| batchCompleteBridgeTransfer                | 8323            | 1213444 | 58500  | 5167717 | 512     |
| completeBridgeTransfer                     | 3057            | 13236   | 3305   | 63101   | 1535    |
| initialize                                 | 123865          | 123865  | 123865 | 123865  | 3       |
| initiateBridgeTransfer                     | 2531            | 56637   | 10385  | 157151  | 768     |
| noncesToIncomingBridgeTransferIds          | 524             | 524     | 524    | 524     | 12104   |
| outgoingBridgeTransfers                    | 970             | 970     | 970    | 970     | 256     |

@0xmovses

Copy link
Copy Markdown
Contributor

@apenzk

I'd go with option 1.

Do not refund. The user has to wait until the relayer and/or the L2 chain are live again and the transfer can be completed. [...]

Comment thread MIP/mip-58/README.md
- The current audit is outdated and does not reflect the significant changes made since.
- The current design requires a complete UI/UX overhaul, adding complexity and delay.
6. **Unnecessary Complexity**:
- HTLC-based bridges are largely abandoned in favor of simpler, more effective designs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

HTLC is used for atomic swaps. Chainlink has an explainer for atomic swaps.
HTLC-bridges are used to implement atomic swaps between parties that do not trust each other.
HTLC is not largely abandoned (see the link above).
The problem is that we have used an atomic swap architecture RFC-40 to guide the implementation of the bridge.
But a bridge (transfer) is different to a swap: in a swap parties can withdraw from the deal before the end of an agreed period. They also have to escrow funds.
In a bridge, one party wants to transfer assets from one chain A to another chain B.
Most bridges implement a lock/mint or mint/burn mechanism, not an atomic swap.

Comment thread MIP/mip-58/README.md
- The current design requires a complete UI/UX overhaul, adding complexity and delay.
6. **Unnecessary Complexity**:
- HTLC-based bridges are largely abandoned in favor of simpler, more effective designs.
- Examples like the [Consensys HTLC](https://github.com/Consensys/htlc-bridge) bridge demonstrate the [pitfalls of such approaches](https://entethalliance.org/crosschain-bridges-overview-where-we-are-now/).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't see how the first link demonstrates the pitfalls of such approaches.
The first link is outdated (in fact it was not used by Consensys, but rather GPACT was considered, and then abandoned).
The second link Crosschains, where are we now is an overview of the cross chain solutions and their main features. It does not demonstrate the pitfalls of the Consensys HTLC bridge.

This method is trust minimized, but requires both parties to stay online for the duration of the swap in order to withdraw funds on the other side, which can cause friction for end-users.
It seems that each design has some pro and some con.

This applies to an atomic swap. It is unclear to me why there was a decision to use a swap architecture to implement a bridge. I mentioned it 3 weeks ago here.

@apenzk
apenzk requested review from apenzk and franck44 and removed request for andyjsbell January 15, 2025 11:37
@franck44
franck44 merged commit a53539f into main Jan 16, 2025
@franck44
franck44 deleted the mip-58 branch January 16, 2025 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bridge MIP Contains an MIP priority ready-to-merge A PR that is ready to merge Urgent Needs urgent processing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants