AcalaNetwork / chopsticks

Create parallel reality of your Substrate network.
Apache License 2.0
138 stars 84 forks source link

Add possibility of proving additional relay storage keys in set validation data #561

Closed girazoki closed 11 months ago

girazoki commented 11 months ago

Chains like Tanssi require collators to prove additional relay storage keys (in this case, the para head of a particular parachain-id). The way chopsticks works right now is that in the set_validation_data a newrelay storage root is computed and injected based, among other things, on the incoming xcms and the relay slot number.

It could be good that we can add a set of additional key_values that we can inject in the generation of the proof, in a similar manner to how we did it with rust: https://github.com/paritytech/polkadot-sdk/pull/1757. Tipically the relay storage root provided in set_validation_data is used to verify any other inherents proving relay-storage, so we need would need to take any additional key-value pair into account in the mocked version.

Additionally, it would be good if the trie-nodes generated by the proof were accessible for other inherents. Currently each inherent is quite isolated, and know from each other. Potentially there could be a way in which both set_validation_data and any other inherent use the same proofGenerator instance.

ermalkaleci commented 11 months ago

can you give an example how you intend to use it?

girazoki commented 11 months ago

yes we have our own sort of hacky implementation here: https://github.com/moondance-labs/chopsticks/pull/6

Essentially we generate a proof for additional keys in set_validation_data, and then we use these trie nodes in a the new inherent where the new keys are proved

ermalkaleci commented 11 months ago

@girazoki is storage authorInherent.highestSlotSeen() best way to get slot from your chain?

girazoki commented 11 months ago

sorry @ermalkaleci I somehow missed this! yes it is!