I'm playing around with a variation a of Substrate's PoW block production. Contrary to existing PoW engine my design relies on a PoW generation mechanism which is external to Substrate.
The PoW results are obtained by a HTTP listener and the liveness is backed up by a secondary mechanism which involves a set of trusted nodes that produce dummy blocks based on timeouts.
I need to store certain information on chain whenever a "real" PoW block is imported.
First I tried to submit an inherent transaction with the relevant data, but I realized that the inherent transaction is not gossiped even if it is verified by implementing ValidateUnsigned
.
This possibly refers to
Is it possible to gossip inherents?
The next possible solution was to use Pre-Runtime Digests like so:
- inject the relevant data into the Seal
- modify the source code of
start_mining_worker
loop in such a way that the data from theDigestItem::Seal
from the imported block is pushed intoinherent_digest
as aDigestItem::PreRuntime
inherent_digest
is inserted into the proposal - no change here- the
DigestItem::PreRuntime
is accessible from the Runtime (contrary toDigestItem::Seal
)
This approach seems to work, at least I can see that the information is shared, but I'm uncertain it does not break things, like e.g. fork rules etc.
I also tried a more relaxed approach by fetching a pre-runtime digest and submitting an offchain extrinsic, but it runs too early on the imported block, while the digest is pushed to the next block proposal which is not guaranteed to be produced by the same node.