How to verify the execution proof of an extrinsic #10987
-
Generally speaking, in order to verify a state transition, we need the initial state, extrinsic(data), and a runtime(state transition function), apply the state transition on our own, and then check if the locally produced Currently substrate/primitives/state-machine/src/lib.rs Lines 630 to 640 in 8ce691d Please correct me if I'm wrong, the block execution validation in polkadot is done by re-executing the parachain block and producing a new block header which will be used to compare with the one received from the collator, hence returning the execution result is enough as the header includes the state root already. However, to verify the execution proof of a certain extrinsic, Is there any way to also return the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Parachains don't use this code path here.
You check an execution proof, by re-doing the same execution with the given proof. If that works, it means that the given proof is valid. Not sure why you want to compare the state roots? How should you get a different state root if you execute the same code? |
Beta Was this translation helpful? Give feedback.
-
Thanks to @cheme suggested in #10922 (comment), take |
Beta Was this translation helpful? Give feedback.
Thanks to @cheme suggested in #10922 (comment), take
apply_extrinsic
as an example, one solution here is to an identical API ofapply_extrinsic
but call the storage root at the end and use it as the return value(might be useful to have a look at #11046 to decode the return value properly). And then we can interpret the return value aspost_state_root
and compare it with the one received from the network.