-
Notifications
You must be signed in to change notification settings - Fork 23
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
feat: add entrypoints.md #163
base: main
Are you sure you want to change the base?
feat: add entrypoints.md #163
Conversation
Regarding expiring messages: ethereum-optimism/specs#460 |
Perfect. I feel like these are two separate types of problems.
|
The following changes are required: | ||
|
||
- `sendMessage` includes `address entrypoint`. | ||
- `SentMessage` event includes `address entrypoint`. |
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.
Let's check with @MSilb7 about which event params should be indexed
Hi guys, I'm Sergey, research scientist at Lisk. I met Skeletor on Devcon and he directed me to these specs since I was very curious about making OP Interop more user friendly. I think this design is a step in the correct direction of making Interop more usable by actual applications. However I have a couple of more practical and some more abstract questions about this design. Maybe I will start with very particular ones:
In general, I see that entrypoints enable all the nice usecases but I am not convinced that sending several messages that go through the entrypoint and also target the entrypoint is the simplest design. However maybe we cannot do much better because sending tokens and doing an action (swap) has to happen in two different cross-chain messages... |
Hey Segey! Thank you for taking the time to read through this design doc.
I agree that using the |
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.
We should make sure to add the "Alternatives Considered" and "Risks & Uncertainties" sections
- Do app layer interop products have a similar problem to solve, and what are their approaches? Why or why not would their designs work for us?
- What risks might this have, for example what if an entrypoint a user specifies is unable to complete the relay? Any other risks and uncertainties to consider?
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 added both sections.
- I searched for a similar design but couldn't find any. The difference with other third-party bridges here is the lack of a centralized relay that already orders messages. Most bridges focus on tokens only and not so much on messages, so custom logic checks, use of storage, and so on might be a bit of overkill for them. We are stepping into unexplored territory here. This has the potential to establish some standards as well.
- Addressed this in the Risks section. It's mainly bad implementations of the entry point (gas, bugs, malicious) and compatibility with existing protocols (only if part of the flow uses the entry point and the other part doesn't).
You might find this comment interesting as well, as using the target directly can be considered an Alternative: #163 (comment)
The updated version is much clearer, especially without the swap example. I think it was a bit confusing because ultimately this logic can be easier implemented with a However now I feel that entrypoint design is skewed in the direction of expiring messages a bit too much. I think the discussion on the context that you had before was important, I have an example of ordered relays to illustrate it: In order to implement message batching / guaranteed ordered execution you need the destination chain to know the message dependencies or to which batch does the message belong. A natural solution would be for the entrypoint to check this ordering condition, but the entrypoint needs to know some additional info except for the message itself (e.g. the list of msg hashes to be relayed before this message). So this context should be passed to the entrypoint somehow. Alternative proposalI have an idea of an alternative entrypoint approach, but for now I struggle to see whether it solves all the problems that your design solves.
Pros of this design:
Cons:
Generally I am curious to hear what you think about this idea. I hope our exchange will make OP Interop as well-designed as possible! |
I will add the context discussion again. I removed it because I was afraid it might introduce too many complexities, but I agree its a very important argument for entrypoints. Regarding the Alternative Design you suggested: I like the approach and I think its a good way of achieving local checks and storage (including expired messages), and it's user-friendly since encoding and decoding are managed by the contracts. Some things that come to mind here are:
After considering your design, I believe the strongest argument for introducing entrypoints is enabling message bundling, i.e. enforcing a specific order for messages on the destination chain. I will try to modify the design doc once again with this, and would love to keep this discussion open. |
@sergeyshemyakov I've given your suggestion further thought, and here's my perspective: While it's technically possible to achieve most of the use cases outlined in the design document by encoding additional information in an Initiator contract (or manually) on the origin chain and then sending messages to a dedicated Receiver contract on the destination chain for decoding and execution, this method significantly complicates the developer experience. Advantages of Using
For message bundles,
This not only adds complexity but also increases the potential for errors and delays. Example: two
|
@0xParticle Thanks for having such a deep dive into my question, appreciate your comments! So what I am taking out of this discussion:
Still I have two comments from my side:
Appendix: Further thoughts on my designNow I am rethinking my receiver contract idea more in terms of cross-chain wallet, where a user "owns" a particular sender / receiver on several different chains and only they can move messages via the receiver (can be enforced e.g. by checking a signature on the sending side). Then it is possible to implement batching and relayer incentivization in the following way (which I have implemented here).
As an outcome, the user bridged tokens A->B, swapped, provided liquidity to staking protocol and paid the relayer all within one transaction. However it is important that user actually controls the "cross-chain wallet" receiver on chain B in the same way as they could control any other smart contract wallet. |
Entrypoint ComposabilityI agree that composability isn't straightforward in all cases. In the scenario you mentioned—having an entrypoint that allows message batching and another that rewards relayers—I was thinking on using the Context event to encode a "chain of callers." Specifically, we can pass the address of the
It would also be possible to encode it the other way around, as long as the check is in both entrypoints. I believe this design is relatively simple and can be standardized—it's akin to a "meta-entrypoint" pattern. It allows us to stack entrypoints by having each one verify the caller based on the context, thus enabling composability without extensive code rewriting. Context enshrinementWe also think that eventually, the context should be enshrined within the protocol. However, for now, we'll start with the entrypoint alone since it's upgradeable, and we want to see how these contracts are used in practice. Enshrining the context is indeed the best way to securely bind a message to its context, but it requires the context to be known upfront at the source—it can't be emitted later or via a call to a contract that isn't context-aware. For that reason, we'll begin without enshrining the context and have the entrypoint trust a sender for the Context event. We want to wait a bit and see how entrypoints and context are utilized before modifying the Message batchingYour approach is very clean and a clever use of the
We've been discussing two possible designs internally that modify the That said, if these two points aren't critical for your use case, your design is excellent, especially since it doesn't require any modifications to the We still need to gather feedback on the key invariants for batching. Also, feel free to reach out via Telegram @parti0x :) |
We continue our work on the specs and the implementation since we had green like from Matt on discord without having the formal approval from him at that time. |
Description
Continues #155
This design document introduces Entrypoint contracts as a new primitive that allows anyone to add custom logic on top of the
L2ToL2CrossDomainMessenger
. It generalizes theL2ToL2CrossDomainMessenger
design and unlocks other interop primitives such as message batching and expiring. To do so, it adds a parameter in theL2ToL2CrossDomainMessenger
that binds the relaying to a particular address, where custom logic can live.