integration of MAP with Non-EVM-Compatible Chains
The cross-chain process of the Mapo Protocol involves multiple steps, from locking assets to verifying data, ensuring the secure transfer and interoperability of assets across different blockchains. Here, we are only discussing the onboarding process for non-EMV-compatible chains. Completing the development and deployment of the following modules will allow you to integrate with the Mapo Protocol.
Light-client
Both chains involved in integrating with the Mapo Protocol need to deploy each other's light clients
. Here, we are discussing how to implement the Mapo-Relay-Chain
's light client
on a target chain that supports smart contracts. Since the target chain supports on-chain smart contracts (wasm or others), so Mapo-Relay-Chain
's light clients
will be implemented in the smart contract language supported by the target chain. In this context, we will primarily introduce some data structures and validation methods for the Mapo-Relay-Chain
's light client
to assist users in implementing this light client in a specific language.
Due to the target chain's deployment of the Mapo-Relay-Chain
's light client
, it only needs to meet one requirement, which is verifying cross-chain messages from the Mapo-Relay-Chain
. To fulfill this requirement, the Mapo-Relay-Chain
's light client
should provide two functions:
Maintain and Update the
Light Client
's State: This involves storing a certain number ofblock headers
and continuously updating to verify newblock headers
.Verify Source Chain Contract Events: This typically involves verifying transaction receipts (Merkle Patricia Tree - MPT verification information) based on the current state of the
light client
.
These functionalities are crucial for the proper operation of the Mapo-Relay-Chain
's light client
on the target chain.
light-client state
The light client
can maintain its current state by storing a certain number of consecutive block headers
. When a user submits a new block header
to the light client
, the light client
can verify the signature of that block header
to determine its legitimacy. This ensures that the light client
is continuously updated with valid block headers
, which are crucial for its proper operation.
In the Mapo Relay Chain
's mainnet, validators sign every block, and this signature is stored in the block header
's "Extra" field. The light client
can verify this signature. Additionally, changes in the validator set are not included in the block header
's "Extra" field. Therefore, the light client
can verify the block header
based on the updated validator set.
The signature data (Msg
) includes the hash
of the block header, the consensus round
that has been reached, and a MsgCommit
component:
The data from the IstanbulExtra
structure is encoded using RLP and stored in the header's "Extra"
field. This data includes information about the consensus round
, BLS signature data (AggregatedSeal
.Signature
), and changes in the validator set. The light client
can use this data to update its state and the validator set.
This process allows the light client to maintain an up-to-date view of the blockchain and verify the headers and transactions effectively. It's a crucial component for cross-chain communication and verification in Mapo Protocol. more
light-client verify the event
Once the light client
is updated to the latest state, it can be used to verify cross-chain messages. These messages are often represented using the logs included in on-chain transactions. To prove the validity of a cross-chain message, you need to verify the legitimacy of the transaction receipt in which the message is located. This involves ensuring that the Merkle Patricia Tree (MPT) root
of the transaction receipt matches the ReceiptHash
found in the corresponding block header.
To prove the legitimacy of a transaction receipt, you only need to verify that the MPT root of the receipt matches the ReceiptHash
in the block header. Users can obtain the proof data for a specific transaction and provide both the receipt and the proof data to the deployed light client
. This will complete the verification of a cross-chain message.
In Mapo Protocol, the light client
plays a crucial role in ensuring the integrity and validity of cross-chain messages, providing security and trust between different blockchains.
The following obtains the certification data of a transaction receipt:
Maintainer
The Maintainer service is a separate program designed to update and synchronize the light client
's state. It submits block header data to the light client
on both the source and target chains. As the Maintainer service already supports the Mapo Relay Chain
, developers of the target chain only need to add support for their chain within the Maintainer service.
Developers of the connecting chain can fork the Mapo Protocol's provided Maintainer service and make modifications to add support for their own chain. This allows them to tailor the Maintainer service to work seamlessly with their specific blockchain.
get the
light-client
'stateRetrieve block header data for the corresponding chain based on the current state of the
light client
and submit it to thelight client
Mos
The "Mos" layer defines the general message cross-chain framework and implementation logic for the Mapo protocol
. The Mos layer needs to be deployed on both chains involved in the cross-chain communication. As mapo-relay-chain
has already implemented this module, developers of the target chain should refer to the following data and interfaces to implement this module.
Main data structure and interface:
Messenger
The Messenger
service is an independent program designed to monitor and route specific events on the source and target chains involving the Mos
module. These events include common message events like mapMessageOut
and mapMessageIn
. The Messenger service constructs corresponding proof data for these events and ultimately submits cross-chain messages along with proof data to the target chain. Since the Messenger service already supports map-relay-chain
, developers of the integrating chain only need to add support for their own chain within the Messenger service. Developers can fork a Messenger service provided by Mapo Protocol and customize it to add support for their own chain.
In this process, the Messenger service plays a crucial role in facilitating the transmission of cross-chain messages and their associated proofs, ensuring the secure and reliable transfer of information between the source and target chains. It abstracts the complexity of interacting with smart contracts and handling events, making it easier for developers to integrate their chain into the Mapo Protocol framework.
Application layer
The application layer represents the true business logic of the cross-chain framework. Users define specific business logic at this layer, such as asset management and operations like lock, unlock, mint, burn, and more. The actual cross-chain operations take place within the application layer, where the transferOut
interface from the Mos layer is invoked to write specific cross-chain messages onto the chain.
Here's how the cross-chain process flows within the application layer:
User Interaction: Users interact with the application layer to initiate cross-chain actions, such as locking, unlocking, or transferring assets between chains.
Invoke transferOut: When a user initiates a cross-chain action, the application layer invokes the
transferOut
interface from theMos
layer. This interface constructs and formats the cross-chain message, including details of the action to be performed on the target chain.Relay Message: Once the cross-chain message is constructed, the Messenger service is notified. The Messenger service gathers the necessary proof data and submits the cross-chain message along with the proofs to the target chain.
Target Chain Verification: On the target chain, the
light-client
deployed for the source chain is used to verify the authenticity and legality of the received cross-chain message. Thelight-client
ensures that the data is consistent with the source chain's data, confirming the message's validity.Execution and Action: After successful verification, the application layer on the target chain decodes the received message and performs the corresponding action, such as minting new tokens, unlocking locked assets, etc.
The application layer acts as the bridge between the user's intent and the technical complexities of cross-chain communication. It provides a user-friendly interface where users can trigger cross-chain operations and ensures that these operations are securely executed and verified across the involved chains.
Last updated