SPV in Tron cross chain

Background

How to verify whether a transaction is confirmed on the other chain?

Merkle tree is a kind of hash binary tree. One of its obvious advantages is that it can use a branch(as a small tree) to verify part of the data, which is more efficient. The block structure in the above figure shows that a block body contains such a Merkle tree, which is used to summarize all transactions in the block. Each leaf node is the hash of each transaction, and the two adjacent hashes are merged into a string and then hashed, and repeat the similar operation until only one node left, that is the Merkle root, which is stored in the block header.
  1. Merkle proof: It can be used to verify whether a transaction is included in the Merkle tree, which is represented by the Merkle root;
  2. Block header: Contains the Merkle Root of the Merkle tree composed of all transactions in the block, and uses this Merkle Root to represent this block;
  • The latest block header list of chain B.
  • Merkle Proof list of the transaction.
message BlockHeader {
message raw {
int64 timestamp = 1;
bytes txTrieRoot = 2;
bytes parentHash = 3;
int64 number = 7;
int64 witness_id = 8;
bytes witness_address = 9;
int32 version = 10;
bytes accountStateRoot = 11;
bytes chainId = 12;
bytes crossTxRoot = 13;
}
raw raw_data = 1;
bytes witness_signature = 2;
}
The Merkle path of the transaction hash K (green square) is the list of hashes in the blue square above.
  1. High efficiency: To verify two transactions, just compare whether the Merkle Root of the two Merkle trees is the same. If the same, it means the transactions are the same.
  2. High security: If a transaction K changes, it will lead to the Merkle Root change, so it is difficult to forge a transaction.
1. Given a transaction hash value.
2. Obtain the transaction hash values list ​​of the related block from the full node and mark them as leaf nodes.
3. Traverse all leaf nodes in a group of two, calculates the parent hash value of each two leaf node, adds it to the parent list, and finds the leaf node that matches the given transaction hash value.
4. Add the hash values ​​of the other nodes in the group to the Merkle proof list and mark its parent node.
5. Iterate the parent node list in a group of two each time, calculate the hash value of each two nodes, and add it to the temporary parent node list and find the marked node.
6. Add the other node of the group to the Merkle proof list and mark its parent node.
7. Replace the left nodes list with the temporary parent node list, check the size of the node list, If it is greater than 1, go to step 5, otherwise return to the Merkle proof list
public boolean validProof(Sha256Hash root, List<ProofLeaf> proofPath, Sha256Hash src)

How does TRON innovatively solve the existing problems of the SPV?

message SignedBlockHeader {
BlockHeader blockHeader = 1;
repeated bytes srs_signature = 2;
PBFTCommitResult sr_list = 3;
}
message SRL {
repeated bytes srAddress = 1;
}
public boolean validSrList(PBFTCommitResult dataSign, Set<ByteString> preSRL)

Summary

References

For more information

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Launching Porta Ecosystem Grants to Grow Its Network

Decentralized storage

How Amazon Became a Part of the Blockchain Community

PlatON Bi-Weekly Report, 11.16–30, 2020

[Updated on 11.05]

Safe Practice of TRON Solidity Smart Contracts: Implement Random Numbers in the Contracts

MEXC Global Research: Kusama Ecosystem DeFi Infrastructure Karura (KAR) Market Analysis

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
TRON Core Devs

TRON Core Devs

More from Medium

3WM Bridge BSC / ETH

🎉MYCE token homepage renewal🎉

HORGI TOKEN

Polygon to Make a Splash at ETHDenver