EVM Chains
Contract Address
Here to get MAPO mainnet and testnet light client contract address.
How it works
MAPO light clients can be deployed on contracts compatible with EVM blockchains. It updates and saves the validators' information of MAPO blockchain periodically, and uses them to verify the proof generated by MAPO blockchain. Here is the main workflow about how it works:
The light client contract is deployed and initialized with the MAPO blockchain information, e.g., the epoch size, the validators threshold, and the trusted validators' information for a specific epoch(we call this epoch current epoch).
The light client receives the last block header of current epoch from an off-chain program called maintainer. The block header can be verified by the stored validators. After the successful verification, the light client gets the validators' information from the block header for the next epoch. The light client then stores the validators and updates the current epoch to the next epoch. This step is triggered once per epoch, and the light client can store validators for the latest 20 epochs at most.
The light client can verify the validity of the receipt in a certain MAPO block only if the validators information for the corresponding epoch are stored. So if an application want to use the MAPO light client to verify the proof, it can first check if the corresponding validators are stored by getting the verifiable header range from the MAPO light client.
How to verify
The content of proof data includes:
MAPO block header where the receipt exists
The aggregated G2 public key of the signed validators
The receipt to prove
The index of the receipt in the block
The proof to prove the existence of the above receipt
The light client follows these steps to verify the proof data:
Compute the epoch number of the block header and get the validators record by epoch number. If no record exists, an error is returned.
Use the validators to verify the ecdsa signature of the block header, and use validator and the aggregated G2 public key to verify the BLS signature of the block header. This proves the validity of the block header. If verification fails, an error is returned.
All the receipts hashes in a MAPO block constructs a Merkle Patricia Tree, and the tree root is recorded in the block header. The light client retrieves the tree leaf through the tree root from block header, the key index and the proof in the proof data. Then it checks whether the tree leaf equals to the hash of the receipt included in the proof data. If not, an error is returned.
If all above verifications pass, the proof data is proved to be valid.
Proof
Here is the data structure about the proof.
Last updated