8.3.2 Interchain Architecture based on IRITA
1. Cross-chain Contract
1) Service Market
Service Market is a module responsible for managing interchain service information. It contains the following functions:
Add Service Binding: Add interchain service information to the application chain, including: service name, service description, service provider, etc.
Update Service Binding: Function to modify the service binding information.
Get Service Bindings: Query the available interchain services.
2) Service Core
As the core of the entire cross-chain contract, Service Core is responsible for receiving a cross-chain request from the application contract, the request result from the relayer, and return the cross-chain call result, including the following functions:
Call Service: Function to make a cross-chain request. It is invoked by the application contract by passing the interchain service name, input parameters, callback contract info, etc. A successful invocation will return a unique request ID.
Set Response: Return the cross-chain invocation result called by relayer and write the result to the application chain. If an application contract method needs to be called back during service invocation, it needs to be called in this function.
Get Response: Query the cross-chain invocation result by request ID.
2. Application Contract Application contract is developed by the developer for the interchain services. In an application contract, the developer can invoke the call service function of the cross-chain contract to make a cross chain call. A callback function in the application contract also needs to be provided to get the call result, otherwise developers will have to call the Get Response function in an application contract to query the service invocation results.
3. Relayer Relayer is a service that listens for the cross-chain request submitted to ICH by a source chain. It is responsible for listening the call service function event, and submitting to the ICH.
4. Service Provider Service provider, connects the HUB to the destination chain. It is a service that listens for the cross-chain request from the ICH, invokes the destination chain, and returns the transaction results to the ICH.
5. Interchain Service The interchain service is developed by the service provider. It could be the smart contract deployed on one blockchain for an application on another blockchain to call across the chain. Support from the service provider is required to turn a service into an interchain service.
6. Interchain Communications Hub As the core component of BSN's interchain service, the ICH is responsible for receiving cross chain requests submitted by the source chain Relayer, verifying the transaction and initiating the cross-chain transaction with the Service Provider of the destination chain. After the transaction is complete, it is also responsible for obtaining the transaction result from the Service Provider, verifying and returning the result to the source chain Relayer.