-
Notifications
You must be signed in to change notification settings - Fork 16
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
[DISCUSSION] ICON Multi protocol Arbitrary Call Service Standard #68
Comments
AntonAndell/btp2-java#1 Some queries i'd like to get discussed are:
|
To add to my second point about decentralization. /**
* Sends a call message to the contract on the destination chain.
*
* @param _to The network address of the callee on the destination chain
* @param _connections List of addresses to send the message
* @param _destinations List of addresses that are required to relay the message to the destination xCall in order to be valid.
* @param _data The calldata specific to the target contract
* @param _rollback (Optional) The data for restoring the caller state when an error occurred
* @return The serial number of the request
*/
@Payable
@External
BigInteger sendCallMessage(String _to, Address[] connections, Byte[][] destinations, byte[] _data, @Optional byte[] _rollback); Then one could build DApp Proxies on the format. @Payable
@External
BigInteger sendCallMessage(String _to, byte[] _data, @Optional byte[] _rollback) {
xCall.sendCallMessage(_to, protocols.get(to.net).connections(), protocols.get(to.net).destinations(), _data, _rollback);
} This would require no interaction from a admin to add or edit a connection and leaves that completely up to the users. |
Why are sendCallMessage |
Only the contracts on the chain itself would be relevant to the security. And when sending messages those would be the destinations of the message and when doing rollbacks it would be the sources. But for one chain the sources of a rollback would be the destinations of a message in most cases. So named that differently, however, i can agree the mixing of protocols and sources/destinations can be confusing, and naming can be improved. |
iip:
title: ICON xCall Standard
author: Anton Andell (@AntonAndell)
discussions-to:
status: Draft
type: Standards Track
category: IRC
created: 2023-04-24
Simple Summary
A standard interface to make an arbitrary call service (a.k.a.
xcall
) between different blockchain networks via any bridging protocol.Abstract
This document describes an extension of xCall as defined in IIP52 that can be used to invoke arbitrary cross-chain contract calls between different blockchains networks using multiple protocols.
The existing interfaces between BMC and BSH (
sendMessage
andhandleBTPMessage
)will be utilized for sending and receiving the requested arbitrary call payloads. Procols other than BTP has to be wrapped to implement the BMC interface.
Motivation
The motivation of
IIP52
applies but to allow dapps to use multiple protocols and multi-protocol verification we need to generalize it beyond BTP. This will allow users and dapps to specify their preferred protocols and security models.Specification
Message centers
xCall will connect to multiple MCs (message centers) implementing the BMC interface.
Encoding of the Calldata Payload
Encoding and decoding of the calldata are up to the DApps implementation.
xcall
only passes the raw byte streams with the predefined method calls.This is simple and easy to implement from the viewpoint of the
xcall
, and also the result can be sent back to the caller using the samesendCallMessage
interface.Addressing format
Network Address
A Network address is address representing a account on a specific chain and contains the chain native address prefixed with chain id represented as a string:
"<chainId>/<Address>"
Basic Interfaces
sendCallMessage
DApps need to invoke the following method of
xcall
on the source chain to send a call message to the destination chain.The
_to
parameter is the network address of the callee contract which receives the_data
payload on the destination chain. If a Network address is supplied use the default protocol.The
_data
parameter is an arbitrary payload defined by the DApp.The
_sources
parameter is a list of addresses representing different connections.The
_destinations
parameter is a list of addresses representing the connections of the receiving chain.The
_rollback
parameter is for handling error cases, see Error Handling section below for details.This method is payable, and DApps need to call this method with proper fees, see Fees Handling section below for details.
When
xcall
on the source chain receives the call request message, it sends the_data
to_to
on the destination chain through all protocols specified in the_to
.CallMessageSent
When
xcall
invokessendMessage
the following event is emittedCallMessage
When the
xcall
on the destination chain receives all the call request through the message centers specified in the call request, it emits the following event for notifying the user.executeCall
The user on the destination chain recognizes the call request and invokes the following method on
xcall
with the given_reqId
.handleCallMessage
When the user calls
executeCall
method, thexcall
invokes the following predefined method in the target DApp with the calldata associated in_reqId
.If the call request was a one-way message and DApp on the destination chain needs to send back the result (or error), it may call the same method interface (i.e.
sendCallMessage
) to send the result message to the caller.Then the user on the source chain would be notified via
CallMessage
event, and callexecuteCall
, then DApp on the source chain may process the result in thehandleCallMessage
method.CallExecuted
To notify the execution result of DApp's
handleCallMessage
method, the following event is emitted after its execution.Error Handling
In success cases, DApp users only need to invoke two transactions (one for the source chain, and the other for
the destination chain). However, there might be some error situations such as the execution of the call request
has failed on the destination chain. In this case, we need to notify the user on the source chain to rollback to the state
before the call request.
If a DApp needs to handle a rollback operation, it would fill some data in the last
_rollback
parameter of thesendCallMessage
,otherwise it would have a null value which indicates no rollback handling is required.
ResponseMessage
For all two-way messages (i.e.,
_rollback
is non-null) the same protocols is used in both directions. When thexcall
on the source chain receives a response message from thexcall
on the destination chain through all of the protocols it emits the following event regardless of its success or not.RollbackMessage
When an error occurred on the destination chain and the
_rollback
is non-null,xcall
on the source chain emits the following event for notifying the user that an additional rollback operation is required.executeRollback
The user on the source chain recognizes the rollback situation and invokes the following method on
xcall
with the given_sn
.Note that the
executeRollback
can be called only when the original call request has responded with a failure.It should be reverted when there is no failure response with the call request.
Then the
xcall
invokes thehandleCallMessage
in the source DApp with the given_rollback
data.At this time, the
_from
would be the network address ofxcall
and the protocols will be the sources specified when sending the message.RollbackExecuted
As with the
CallExecuted
event above, the following event is emitted after the DApp'shandleCallMessage
executionto notify its execution result.
Fees Handling
If a user wants to make a call from ICON to Target Network 1 (T1), he needs to pay X ICX, and for Target Network 2 (T2), he needs to pay Y ICX.
That is, the fees depend on the destination network address.
The fees are divided into two types, one is for relays and the other is for protocol itself.
For example, for a destination network T1, the fees could be relayFee = 0.25 ICX and protocolFee = 0.01 ICX.
And relayFee goes to relays, protocolFee goes to the protocol (eventually, to the Fee Handler).
In this document, we don't address how to deal with these accrued fees for distribution,but just define operational parts like how to get the proper fee amount before sending the call request, etc.
Here are getter and setter methods for the proper fees handling in
xcall
.DApps that want to make a call to
sendCallMessage
, should query the total fee amount for the destinationnetwork via
getFee
interface, and then enclose the appropriate fees in the method call.Note that the protocol fee amount can be get/set via
xcall
, but the relay fee would be obtained from each MC.Implementation
xcall
between ICON to ICONReferences
Copyright
Copyright and related rights waived via CC0.
The text was updated successfully, but these errors were encountered: