This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
pallet-mmr: fix offchain db for sync from zero #12498
Merged
paritytech-processbot
merged 4 commits into
paritytech:master
from
acatangiu:mmr-offchain-db-hotfix
Oct 17, 2022
Merged
pallet-mmr: fix offchain db for sync from zero #12498
paritytech-processbot
merged 4 commits into
paritytech:master
from
acatangiu:mmr-offchain-db-hotfix
Oct 17, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
acatangiu
added
A0-please_review
Pull request needs code review.
B0-silent
Changes should not be mentioned in any release notes
C1-low
PR touches the given topic and has a low impact on builders.
D2-notlive 💤
PR contains changes in a runtime directory that is not deployed to a chain that requires an audit.
labels
Oct 14, 2022
acatangiu
requested review from
svyatonik,
serban300,
Lederstrumpf and
andresilva
October 14, 2022 14:55
@andresilva @svyatonik @serban300 @Lederstrumpf please prioritize reviewing this PR as it fixes a not-yet released |
serban300
approved these changes
Oct 14, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch ! The solution looks good. I just left 2 nits.
svyatonik
approved these changes
Oct 17, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
serban300
approved these changes
Oct 17, 2022
…nt_hash)` Do this so that both canon and fork-resitant keys have the same `(prefix, pos).encode()` prefix. Might be useful in the future if we'd be able to to "get" offchain db entries using key prefixes as well. Signed-off-by: acatangiu <[email protected]>
bot merge |
Waiting for commit status. |
ark0f
pushed a commit
to gear-tech/substrate
that referenced
this pull request
Feb 27, 2023
* pallet-mmr: cosmetic improvements * pallet-mmr: fix offchain storage for initial sync * address review comments * pallet-mmr: change offchain fork-resistant key to `(prefix, pos, parent_hash)` Do this so that both canon and fork-resitant keys have the same `(prefix, pos).encode()` prefix. Might be useful in the future if we'd be able to to "get" offchain db entries using key prefixes as well. Signed-off-by: acatangiu <[email protected]> Signed-off-by: acatangiu <[email protected]>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
A0-please_review
Pull request needs code review.
B0-silent
Changes should not be mentioned in any release notes
C1-low
PR touches the given topic and has a low impact on builders.
D2-notlive 💤
PR contains changes in a runtime directory that is not deployed to a chain that requires an audit.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Issue is 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.Solution proposed by this PR: 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.