Reputation: 21
I understand that offchain workers operate in a wasm environment, however it is a separate environment to the deterministic wasm runtime. The offchain worker can access the runtime state (read only).
With regards to post-runtime digests, I believe substrate strips these prior to block import? (and are pushed back afterwards).. I imagine this is done as the runtime cannot be aware of the post-digests during block execution.
That all said, as the offchain worker is post-block-execution, post-runtime digests should be available. How can the offchain worker access the full header and post-runtime digests of the block it is referencing? It can access the block hash -
fn offchain_worker(n: T::BlockNumber) { .. <frame_system::Module>::block_hash(n)
If this is attempted in the substrate runtime during execution, you will receive 0x0000000.. (which is expected).
The full header and post-runtime digests can be useful for external indexing or other purposes. I know substrate does not index everything.. nor do I want it to. I only want to access the referenced header and post-runtime digests.
Upvotes: 1
Views: 193
Reputation: 2824
Unfortunately it appears that this capability is not currently available per this open PR https://github.com/paritytech/substrate/pull/7541#issue-521035839
Upvotes: 0