This repository implements a generic CCIP-Read gateway for fetching state proofs of data on other EVM chains. The intended use is for contracts on L1 to be able to fetch and verify data from contracts on L2 in a read context.
Change StateProof interface from stateTrieWitness: string[];, storageProofs: string[][]; to stateTrieWitness: string;, storageProofs: string[];
Modify getStorageValues to take a proof verification function which isn't dependent on SecureMerkleTrie
Move getStorageRoot from EVMHelper.sol to MerkleTrieProofHelper.sol
Gas comparison
Arbitrum
ArbVerifier
Gas estimate 770439
✔ simple proofs for fixed values (2154ms)
Gas estimate 722247
✔ simple proofs for dynamic values (1314ms)
Gas estimate 777244
✔ nested proofs for dynamic values (1361ms)
Gas estimate 1045721
✔ nested proofs for long dynamic values (1437ms)
Gas estimate 887013
✔ nested proofs with lookbehind (1206ms)
Gas estimate 940514
✔ nested proofs with lookbehind for dynamic values (1631ms)
Gas estimate 726250
✔ mappings with variable-length keys (1337ms)
Gas estimate 840324
✔ nested proofs of mappings with variable-length keys (1479ms)
Gas estimate 679429
✔ treats uninitialized storage elements as zeroes (1040ms)
Gas estimate 683462
✔ treats uninitialized dynamic values as empty strings (1426ms)
Scroll
ScrollVerifier
Gas estimate 1187799
✔ simple proofs for fixed values (2016ms)
Gas estimate 1188778
✔ simple proofs for dynamic values (1545ms)
Gas estimate 1128781
✔ nested proofs for dynamic values (1849ms)
Gas estimate 3391568
✔ nested proofs for long dynamic values (1673ms)
Gas estimate 2294214
✔ nested proofs with lookbehind (1449ms)
Gas estimate 2231340
✔ nested proofs with lookbehind for dynamic values (1838ms)
Gas estimate 1160883
✔ mappings with variable-length keys (1364ms)
Gas estimate 2295970
✔ nested proofs of mappings with variable-length keys (1510ms)
Gas estimate 1093162
✔ treats uninitialized storage elements as zeroes (1357ms)
Gas estimate 1097201
✔ treats uninitialized dynamic values as empty strings (1488ms)
Things to improve
ScrollProofService is currently fetching the batch_index via centralised API server. Should replace it with l1 smart contract call once Scroll team provides the functionality.
verifier.verifyZkTrieProof currently verifies account proof every time it tries to verify storage proof which is unnecessary. We are currently requesting Scroll team to provide function that can only verify account proof or storage proof, not both at the same time.
List of changes
StateProof
interface fromstateTrieWitness: string[];, storageProofs: string[][];
tostateTrieWitness: string;, storageProofs: string[];
getStorageValues
to take a proof verification function which isn't dependent on SecureMerkleTriegetStorageRoot
fromEVMHelper.sol
toMerkleTrieProofHelper.sol
Gas comparison
Arbitrum
Scroll
Things to improve
ScrollProofService
is currently fetching thebatch_index
via centralised API server. Should replace it with l1 smart contract call once Scroll team provides the functionality.verifier.verifyZkTrieProof
currently verifies account proof every time it tries to verify storage proof which is unnecessary. We are currently requesting Scroll team to provide function that can only verify account proof or storage proof, not both at the same time.