How to make the runtime API call error out during the execution when the recorded storage proof size exceeds the maximum proof size #14350
Replies: 1 comment 9 replies
-
Sure things like
I dont understand where the proof is verified. Why is it verified in a runtime API and not an extrinsic? |
Beta Was this translation helpful? Give feedback.
-
In Subspace, we employ an optimistic rollup solution for the execution chain. When a dispute arises, the operator generates a fraud proof, which is then sent to the consensus layer as an unsigned extrinsic. As is commonly understood, extrinsic inherently carries a size limit. Therefore, it's imperative that the size of the fraud proof does not exceed this limit, ensuring it fits within the extrinsic.
The most substantial portion of the fraud proof is the storage proof recorded during the challenged state transition (InitializeBlock/ApplyExtirnsic/FinalizeBlock). Given that the exact size of the storage proof cannot be determined until execution, we need to limit storage access during regular block execution. If the storage proof, required to verify the transition, exceeds the maximum proof size limit, the execution fails.
substrate/primitives/trie/src/recorder.rs
Lines 235 to 238 in 689da49
If I'm not mistaken, we currently have the ability to determine the exact proof size using the existing
TrieRecorder.encoded_size_estimation
. Our challenge now is figuring out how to trigger an error during runtime API execution when the proof size surpasses its limit. Do you have any insights on the best way to tackle this? Also, we would be more than willing to contribute to Substrate if this feature is considered broadly beneficial.Beta Was this translation helpful? Give feedback.
All reactions