For eg: I want to get the balance of an account in Polkadot before I can execute the extrinsic in my parachain. Is it possible to do so?
3 Answers
It is possible but in a somewhat roundabout way.
A parablock candidate is always created against a picked relay-parent — a relay-chain block. The storage root of the relay parent will be passed as a parameter to the parachain validation function (PVF). In the context of Cumulus, PVF is the same as the Runtime.
What's that? How is the relay parent's storage root useful? Well, the storage root identifies the whole storage contents at the corresponding block, and it also allows for verifying proofs of inclusion. Simply put, somebody could create a proof and convince you that a certain key has a certain value in the storage with the specific storage root.
The problem here is how to obtain that proof. The runtime is executed within a box and cannot reach any other data besides the storage and the data from the block itself (e.g., extrinsics). Therefore, to read the state of the relay chain, something should provide the proof through extrinsics.
Luckily, Cumulus already reads some storage from the relay parent, and it is not completely a terra incognito, but it is not exactly a stroll in a park either.
I guess a good entrypoint into this would be this structure and this place where it's collected.
A more user-friendly way is on the radar and is tracked here.
Not as part of your synchronous runtime logic, no, that would require all parachains to run inside one state machine, which conflicts with the sharding model.