Skip to content
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

xross chain element #18

Open
Lomet opened this issue Jun 2, 2024 · 2 comments
Open

xross chain element #18

Lomet opened this issue Jun 2, 2024 · 2 comments
Labels
question Further information is requested

Comments

@Lomet
Copy link
Member

Lomet commented Jun 2, 2024

we can use this :
https://docs.omni.network/develop/contracts

to have it work cross-chain.
for example, when the user clicks refund or withdraw, the token is on Matic and the USD is on BSC.
Some flags appear in the other chain. and block the other option.

need to check:

  1. how fast it is ? Will the TX be in limbo for a long time?
  2. how much it cost?

It will add more Defi to the system. and can make part of the backend obsolete.

@Lomet Lomet added the question Further information is requested label Jun 2, 2024
@Lomet
Copy link
Member Author

Lomet commented Jun 2, 2024

this is the part to extend:

mapping(uint256 => mapping(address => bool)) public isTaken;

@idea404
Copy link

idea404 commented Jun 3, 2024

adding answers here too:

how fast it is ? Will the TX be in limbo for a long time?

Omni will support multiple streams for different "completion levels" of messages (finalisation levels).

xmsg (in finalised completion level cross chain message streams) will be relayed once it is finalised in L1. This means typically within one to two epochs and approximately 12.8 minutes (2 epochs x 6.4 minutes). Also means longer if the message comes from a rollup (that posts transactions in batches to L1). In which case the time taken to post the transaction batch to L1 is added to these 12.8 minutes.

xmsg for fastest completion level cross chain message streams will be relayed once they are finalised by the Omni consensus layer (almost instant) at one block after they have been transmitted on the source chain. On Ethereum, this would mean about 12 seconds after they have been transmitted (12 second block time). ⚠️ Warning: these transactions may possibly not be included in the finalised state of the blockchain, and it is the responsibility of your application to deal with this scenario if it makes use of these streams.

how much it cost?

fee for performing an xcall in contract code can be queried by calling feeFor helper function from the XApp helper contract:

uint256 fee = feeFor(
   destChainId,  // destination chain id
   data,         // abi encoded calldata, ex abi.encodeWithSignature("foo()")
   gasLimit      // gas limit to enforce on execution, if omitted uses default gas limit
)

This is the main interface returning the fee required for performing the cross-chain call at any time.

This is implemented as follows (currently, and subject to change):

/// @inheritdoc IFeeOracle
function feeFor(uint64 destChainId, bytes calldata, uint64 gasLimit) external view returns (uint256) {
    require(gasPriceOn[destChainId] > 0 && toNativeRate[destChainId] > 0, "FeeOracleV1: no fee params");
    uint256 gasPrice = gasPriceOn[destChainId] * toNativeRate[destChainId] / CONVERSION_RATE_DENOM;
    return protocolFee + (baseGasLimit * gasPrice) + (gasLimit * gasPrice);
}

protocolFee is currently set to 0 (pre-testnet) and baseGasLimit to 50K gas and gasLimit defaults to 200K gas. Costs should be expected to be at least 250K gas times 12 Gwei (average yearly) gas price, or 0.003 ETH per xmsg if sent from Ethereum (otherwise in other native from source chain). Note: 80% of this fee is attributed to gasLimit which may be override to any other value between 21K and 5M gas, it's best to evaluate gas consumption in testing to set this value to a level that closer resembles to the expected consumption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants