Skip to content

Conflux-Chain/conflux-light-contracts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Conflux Light Node Contracts

Conflux light node contracts are used to verify transactions or receipts on other blockchain in manner of zero-knowledge.

Provable

Provable contract is an utility to verify MPT proof of Conflux network.

LegerInfo

LedgerInfo contract is an utility to verify BLS signatures of ledger info.

Light Node

LightNode contract is deployed on any blockchain for Conflux transaction or receipt verification. It could be deployed behind a LightNodeProxy.

Firstly, light node contract should be initialized with any trusted PoS/PoW block. Then, Off-chain service is required to relay PoS blocks periodically. However, PoW blocks relay is not mandatory, since receipt proof contains PoW blocks to prove on chain. You could relay as many as PoW blocks whenever the gas fee for receipt proof verification is higher than PoW blocks relay.

function initialize(
    address _controller,
    address _ledgerInfoUtil,
    address _mptVerify,
    LedgerInfoLib.LedgerInfoWithSignatures memory ledgerInfo
) external;

function updateLightClient(LedgerInfoLib.LedgerInfoWithSignatures memory ledgerInfo) external;

function updateBlockHeader(Types.BlockHeader[] memory headers) external;

To avoid too many records persisted on chain, relayer could garbage collect stale blocks, e.g. 1 week ago.

function removeBlockHeader(uint256 limit) external;

Once blocks relayed, transaction or receipt proof could be verified cryptographically:

function verifyReceiptProof(Types.ReceiptProof memory proof) external view returns (bool success, Types.TxLog[] memory logs);

function verifyProofData(bytes memory receiptProof) external view returns (bool success, string memory message, bytes memory rlpLogs);

Differences from Ethereum

  1. RLP Encoding: encode false into 0x00 instead of 0x80.
  2. MPT: Only branch node and leaf node in Conflux MPT. Whereas, there is extension node in Ethereum.
  3. Conflux use BLS12-381 algorithm for PoS blocks, but the hash_to_curve is different from Ethereum. For more details, please refer to the implementation.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published