-
Notifications
You must be signed in to change notification settings - Fork 8
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
Basic message channel protocol #41
Conversation
MMRLeaf Spec
MMR Leaf Encode
Message commitment
Inbound Message Spec
OutBound Message Spec
Dapps only needs to define its own payload and which basic channel they use. Mapping Token Dapp SpecInbound message
Outbound message
|
https://github.com/darwinia-network/darwinia-bridge-sol/blob/master/contracts/utils/contracts/Bitfield.sol#L94-L114 |
还是觉得这里的设计有问题 |
首先, 这里这个作为基础的通道, 它的职责是保证消息的可达性, 并不保证消息的正确性, 所以这里可以是允许消息 |
我理解协议是要求不需要回执的,https://www.notion.so/itering/Basic-Message-Channel-c41f0c9e453c478abb68e93f6a067c52 ,“它们是异步的、单向的调用,不需要任何回应”,意思是说正确的消息一定会被对方验证、接收并得到执行。一般来说我们没有从源链上面重试的机会,只能重试该消息。比如用户在源链上锁定一笔资产,在Ethereum上面发行,发行失败,如果在源链上面重试相当于重新锁定一笔资产。 |
这里确实存在一定的歧义, 但是在实践中, 如果我们保证APP消息执行的正确性, 是不需要回执的, 但是往往会出现意料之外的错误, 这时候即使重试也是无济于事的, 只能在保证APP层协议也正确的情况下, 消息才能正确执行. |
The document need to be update, and changed to: The message protocol will require delivery process(provide delivery proof) to source chain, in addition, the delivery event ( This delivery process and remote call execution result will help application level with necessary primitives to build atomic transactional ability. This will resolve the issues mentioned here. The message must be verified in source chain being delivered, but the call could fail and its result will be included in delivery so source chain can receive remote call result and how to handle it. (e.g. unlock the assets back to origin user in the Current implementation is compatible with this design and require no change. |
Message
A message is used by an application on one chain to call a function with parameters on another chain. You may be familiar with that concept as a remote procedure call or RPC. A message contains data to identify the source application, target application and a payload which the target application is expected to understand.
Channel
A channel is a concept used as part of the bridge which facilitates the delivery of messages in a single direction. A channel consists of a sender and a receiver, each being a piece of business logic that runs on opposite chains, as well as a feature set as described below. Any user or system wanting to send a message across the bridge must submit it to the channel. Different channels may exist that provide varying deliverability guarantees to a message, such as replay protection across multiple messages.
For more ideas around channels, see Channels
Basic Inbound Message Channel (Polkadot → Ethereum)
This basic channel provides a mechanism for sending messages out from Polkadot to Ethereum via darwinia message commitments. It consists of Commitments pallet, which operates a basic channel that provides replay protection.
The Commitments pallet is responsible for accepting requests from other pallets or parachains via XCMP for Ethereum RPCs to be sent over to Ethereum. After accepting a request, it adds a nonce and puts the message into a queue. At a fixed interval (initially once a minute) it produces a commitment to that queue in the form of a single hash of all the messages in that queue that is added to the darwinia header.
The corresponding receiving Darwinia Light Client smart contract accepts as input this commitment as well as the set of messages in that commitment. It validates the inclusion of the commitment in the MMR as described here and then verifies that those messages are included in the commitment by hashing them and then processes them in order by calling out to the Ethereum smart contracts for each Ethereum RPC.
Basic Outbound Message Channel (Ethereum → Polkadot)
This basic channel provides a mechanism for sending messages out from Ethereum to Polkadot via events. It consists of a smart contract on the Ethereum side and a corresponding pallet on the parachain side.
The smart contract is responsible for accepting requests from other smart contracts for Polkadot RPCs to be sent over to Polkadot. It uses Ethereum Events as the medium for sending messages, so after accepting a request, it adds a nonce and emits an event that the corresponding pallet will receive on the Polkadot side.
The corresponsing receiving pallet accepts as input a set of events and a transaction receipt proof, calls out to the Ethereum Light Client Verifier to confirm that the containing block is considered final by having a predefined number of confirmations and to verify that each Ethereum event is in fact valid and included in the Ethereum chain, and then it processes those events by forwarding them to their destination pallet.
Mapping token dapp
Mapping token dapp is a cross-chain dApp that facilitates the registration, creation and movement of pegged ERC20 assets. It is based on the security of the basic channel and focuses on its own cross-chain transfer logic.