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

TIP-246:TRON Cross Chain Contract Transaction #246

Closed
eodiandie opened this issue Mar 15, 2021 · 16 comments
Closed

TIP-246:TRON Cross Chain Contract Transaction #246

eodiandie opened this issue Mar 15, 2021 · 16 comments

Comments

@eodiandie
Copy link

eodiandie commented Mar 15, 2021

tip: 246
title:TRON Cross Chain Contract Transaction
author: xq.lu <xq.lu@tron.network>
discussions to: https://github.com/tronprotocol/tips/issues/246
status: Draft
type: Standards Track
category: Core
created: 2021-03-18

Simple Summary

This TIP describes a solution of TRON cross-chain contract execution in TRON network and parallel chains.

Abstract

TRON's cross-chain architecture only provides message passing and validation; the parallel chain should complete the specific implementation of transaction execution. Parallel chains must ensure the atomicity of transactions, as there is not a rollback function.

Motivation

Currently, there are many cross-chain solutions in the industry, like Polkadot, ETH 2.0, Cosmos, ETC. Each solution has its unique features apart from regular asset transfer and information interaction functions. However, these solutions' architectures and communication protocols are complicated, as they are hard to understand or working as a basis of the parallel chains' implementations.

In TRON's solution, we encourage parallel chain maintainers to manage their transaction and communication details. TRON network is only responsible for message delivery and verification. That is, theoretically, the content format between chains as well as the transaction logic can be any. This lightweight design ensures its scalability.

Technical Specifications

image
The diagram shows the scenario of asset exchange. Assuming Luna wants to transfer 10,000 BTT from A to B in exchange for 100 USDT:

  1. The contract author deploys two contracts separately on a pair of parallel chains A and B.
  2. Luna triggers a cross-contract transaction on chain A. After the successful execution, the result will be sent to TRON network as a cross-contract transaction with some other information.
  3. TRON network receives the transaction and performs checks (whether the transaction was successfully executed/confirmed, ETC), saves the transaction for further processing, then constructs a cross-contract transaction with the information generated before and sends it to B.
  4. Chain B executes the smart contract as soon as receiving the transaction from TRON network. After the execution succeeds, some other information will be attached to the execution result to construct an ACK transaction. The ACK transaction is sent to TRON network to confirm the successful execution of the cross-chain transaction.
  5. The cross-chain transaction completes when TRON network receives the ACK transaction from chain B.

We are going to talk more about the details of TRON's cross-chain architecture:

When TRON network receives a message in a new type, CROSS_MSG, it recognizes a cross-chain transaction and caches the transaction.

Receive Cross-Chain message interface:

receiveCrossMessage(CrossMessage crossMessage)

The format of the cross-chain message is message crossMessage(see "Data Structure", below).

A timing task is kept executing in the background for periodically processing cached cross-chain transactions. Based on the Merkle proof of the transactions submitted by chain A, TRON network can check whether a transaction has been successfully executed and committed in chain A.

Later, when the block is processed again, TRON network will check whether the cross-chain transaction has timed out and then process it after checking that the transaction is correct.

TRON network listens to the PBFT block commit event at the same time. When a cross-chain transaction is found not been processed, a new cross-chain transaction message will be constructed,the construct details include generate the Merkle proof paths of this cross-chain transaction and set the proof and the root height to 'crossMessage'. after we construct the proofs and root height successfully .the data sent to a specified parallel chain with this interface:

sendCrossMessage(CrossMessage crossMessage)

Cross-chain transaction messages will be saved for subsequent processing after it is broadcasted.

Broadcast message interface:

broadcastCrossMessage(CrossMessage crossMessage)

TRON network will delete the cross-chain transaction from the local cache and execute it after receiving the ACK message from chain B.

Rationale

Advantages:

1.Lean but well-designed

Unlike other complex cross-chain solutions, based on solving the core requirements of cross-chain, TRON refines a set of concise technology(SPV, Merkle Root, ETC), which is easy to understand architecture and usage details. We believe this gives our solution a great advantage for the promotion.

2.High Scalability

In cross-chain solutions, as subsequent extensions and specific chain characteristics must be taken into account, communication protocol design is usually complex. Generally, cross-chain solutions will pre-define some supported operation types(transfer, message format, ETC). Modifications of the communication protocol are usually required to support more message formats. These will be the scalability barrier, for these modifications can involve both TRON network and parallel chains.

TRON always focuses on the scalability problem. With the design pattern of 'separation of concerns', TRON makes the specific communication details and the general cross-chain scheme into two parts. That is, TRON only needs to concentrate on the generic technical details, and at the same time, parallel chains can focus on their specific business logic. This clear division of labor dramatically improves scalability.

Data Structure

Message CrossMessage is used between parallel chains and TRON network:

Below are interfaces used between parallel chains and TRON network:

Attentions

Cross-chain transactions cannot be rolled back

A complete cross-chain transaction contains three parts:

  • Contract execution on chain A
  • Cross-chain transaction execution on TRON network
  • Contract execution on chain B

These three transactions are executed and solidified on their chains. Like other transactions, a solidified cross-chain transaction cannot be rolled back.

Atomicity of cross-chain transactions on parallel chains

Due to the non-rollback characteristic of cross-chain transactions, some cross-chain transactions may fail to be executed only on chain A(e.g., insufficient bandwidth on chain B). This makes the atomicity of the transaction unattainable.

Here we come up with a possible solution for the problem: contract authors may deploy a regular contract and a rollback contract simultaneously. Rollback contracts will be efficient to deal with failed executions.

Transaction timeout

Distributed systems can only meet at most two conditions among consistency, Availability, and Partition Tolerance, so cross-chain transactions will inevitably be executed on particular chains, as cross-chain transactions are executed independently on different chains.

We suggest contract authors regularly detect timeout transactions and perform some compensation operations or rollback operations by querying contract transaction execution results.

@eodiandie eodiandie changed the title [Draft]Cross chain contract trasaction [Draft]TRC-246:Tron Cross chain contract transaction Mar 15, 2021
@eodiandie eodiandie changed the title [Draft]TRC-246:Tron Cross chain contract transaction TRC-246:Tron Cross chain contract transaction Mar 17, 2021
@eodiandie eodiandie changed the title TRC-246:Tron Cross chain contract transaction TRC-246:TRON Cross Chain Contract Transaction Mar 22, 2021
@eodiandie eodiandie changed the title TRC-246:TRON Cross Chain Contract Transaction TIP-246:TRON Cross Chain Contract Transaction Mar 25, 2021
@a49688448
Copy link

What are the specific cross-chain usage scenarios?

@jamestompson
Copy link

”the parallel chain should complete the specific implementation of transaction execution“

The code has released? Could you provide the developing guide to implement the interfaces?

@woaichixigua07
Copy link

Which chains are supported first? Ethereum, Polkadot?Is there a relevant testnet to try?

@Vita-Diva
Copy link

Does TRON support heterogeneous cross-chain? Can TRON actively access Ethereum?
As you mention in the 'motivation' part, "TRON network is only responsible for message delivery and verification". Does this mean TRON provides only slots and passively waiting for other chains to make connections?

@xiangyuan-chaoqing
Copy link

Regarding the trading model shown in your picture, I have a few questions:

  1. Is the sendCrossContract message after the transaction is executed on the A chain or after the transaction is solidified on the A chain?
  2. Based on the current implementation, how long does a complete cross-chain transaction take?
  3. The new message type and process have undoubtedly increased the complexity of the current TRON public chain. If multiple chains are involved, the situation will be more complicated. After the realization of cross-chain, how much will the performance of the TRON public chain be affected? For example, how much is the performance reduction? Thank you.

@eodiandie
Copy link
Author

What are the specific cross-chain usage scenarios?

a very common usage for cross-chain is asset exchange. for example, if you want to change 1ETH to 1000TRX.it is easy to implement via cross-chain.

@eodiandie
Copy link
Author

Which chains are supported first? Ethereum, Polkadot?Is there a relevant testnet to try?

you can check out this TIP:https://github.com/tronprotocol/tips/issues/243.which will answer your question.

@eodiandie
Copy link
Author

Does TRON support heterogeneous cross-chain? Can TRON actively access Ethereum?
As you mention in the 'motivation' part, "TRON network is only responsible for message delivery and verification". Does this mean TRON provides only slots and passively waiting for other chains to make connections?

1.currently, we only support homogeneous cross-chain,which means the para-chain should also be a 'java-tron' chain. but we will support heterogeneous cross-chain to support to cross with Ethereum.

2.In TRON's cross-chain arch,TRON network and other para-chains are peer-to-peer(equal).which means TRON can receive other chain's messages and TRON network can also be connected to other para-chain

@eodiandie
Copy link
Author

eodiandie commented Mar 26, 2021

Regarding the trading model shown in your picture, I have a few questions:

  1. Is the sendCrossContract message after the transaction is executed on the A chain or after the transaction is solidified on the A chain?
  2. Based on the current implementation, how long does a complete cross-chain transaction take?
  3. The new message type and process have undoubtedly increased the complexity of the current TRON public chain. If multiple chains are involved, the situation will be more complicated. After the realization of cross-chain, how much will the performance of the TRON public chain be affected? For example, how much is the performance reduction? Thank you.
  1. yes. the'sendCross' message only sends after solidified.
    2.Theoretically,a cross-transaction will take 10~20s.In this cross-chain design, we use mixed consensus(DPOS+PBFT) to replace current consensus(DPOS), you can check this TIP.TRC-247 : Tron Hybrid consensus #247
    3.As you can see in this design, a cross-chain transaction is more than just a normal transaction. so the performance is rarely effected.no need to worry about the performance.

@eodiandie
Copy link
Author

”the parallel chain should complete the specific implementation of transaction execution“

The code has released? Could you provide the developing guide to implement the interfaces?

currently, the project is under heavy testing. and the dev documentation will be ready when testnet launch

@woaichixigua07
Copy link

How long does it take for a cross-chain transaction to succeed? And how to confirm whether the transaction is successful and will not roll back?Is there any interface to confirm?

@a49688448
Copy link

What's TPS of TRON Cross Chain Contract Transaction?
What are the transaction costs?

@dkealervdsf
Copy link

What are the advantages of TRON's compared to Polkadot’s cross-chain solutions?

@eodiandie
Copy link
Author

How long does it take for a cross-chain transaction to

1.Theoretically, ,a cross-transaction will take 10~20s.
2.For the transaction atomicity problem, you can check section ' Atomicity of cross-chain transactions on parallel chains' in this TIP.

@eodiandie
Copy link
Author

What are the advantages of TRON's compared to Polkadot’s cross-chain solutions?

you can check this section 'Advantages', which describe the difference compare with other popular cross-chain solutions.

@eodiandie
Copy link
Author

What's TPS of TRON Cross Chain Contract Transaction?
What are the transaction costs?

1.Actually, the TPS of cross-chain contract transactions depends on TRON’s transaction processing capabilities.
2.for the cross-chain transaction fees(costs), Currently, we are in the process of design.

@lvs007 lvs007 closed this as completed Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants