-
Notifications
You must be signed in to change notification settings - Fork 2.6k
pallet-mmr: move offchain logic to client-side gadget #12508
Comments
Possible solution outlined here #12498 (comment):
|
Unfortunately, |
I think we need to create a client-side gadget, and move all the offchain stuff there. PROs:
CONs:
@andresilva @svyatonik WDYT? |
I can't say much - @andresilva was there when it was designed that way (offchain worker) - maybe there's some strong reasoning behind that. But do you want to keep using offfchain storage for storing MMR nodes or regular DB? |
We would still use Also generating proofs RPC would not change, but instead of calling runtime API it would call some gadget API. |
I have talked with @andresilva and we're in agreement that client-side gadget to handle all off-chain duties is the best way forward. |
MMR nodes are saved in off-chain db under fork-resistant keys based on
frame_system::block_hash()
, as such only nodes added by latestframe_system::BlockHashCount
can be accessed that way.Nodes added by blocks older than
frame_system::BlockHashCount
are moved byoffchain_worker
to "canon" (not fork resistant) location - thus being made available regardless of age.See #11594 for more details.
PR #12498 fixed the issue that
offchain_worker
doesn't run for blocks imported during initial sync. So for initial syncs >frame_system::BlockHashCount
(practically any node syncing from scratch), MMR nodes aren't moved to canon position and access to them is lost.The fix was that runtime block execution saves node to both fork-resistant and canon locations:
offchain_index::set()
because it will be overwritten byoffchain_worker
with canon values anyway.This results in working system, but with bloated offchain-db where MMR nodes added during initial sync are taking 2x storage than they should (they are duplicated in two locations in the offchain-db).
The text was updated successfully, but these errors were encountered: