Support multiple IndexOperation::Renew calls within a single extrinsic index in sc-client-db#11474
Open
rosarp wants to merge 3 commits intoparitytech:masterfrom
Open
Support multiple IndexOperation::Renew calls within a single extrinsic index in sc-client-db#11474rosarp wants to merge 3 commits intoparitytech:masterfrom
IndexOperation::Renew calls within a single extrinsic index in sc-client-db#11474rosarp wants to merge 3 commits intoparitytech:masterfrom
Conversation
required for Bulletin Chain
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Currently,
apply_index_opsusesrenewed_map: HashMap<u32, DbHash>which means if multipleRenewoperations target the same extrinsic index, only the last hash survives — earlier ones are silently overwritten. This blocks batch-renewal use cases where a single mandatory inherent renews multiple previously-stored data items (e.g. the Bulletin chain'sprocess_auto_renewalsinherent which callssp_io::transaction_index::renew()N times within one extrinsic).This PR changes
renewed_maptoHashMap<u32, Vec<DbHash>>and introduces a newDbExtrinsic::MultiRenewvariant to correctly store, reconstruct, retrieve, and prune blocks containing multi-renewal extrinsics.Integration
Downstream projects using
sc-client-dbthat readBODY_INDEXdata directly (rather than through theBlockchainDbAPI) will need to handle the newDbExtrinsic::MultiRenewvariant. Projects using the standardblockchain.body(),blockchain.block_indexed_body(), orblockchain.indexed_transaction()APIs require no changes.Single-renewal extrinsics continue to produce
DbExtrinsic::Indexed(backwards-compatible). TheMultiRenewvariant is only emitted when 2+Renewoperations share the same extrinsic index.Review Notes
All changes are in
substrate/client/db/src/lib.rs. There are five logical changes:1. New
DbExtrinsic::MultiRenewvariant2.
apply_index_ops— core fixWhen building extrinsic entries:
DbExtrinsic::Indexed(backwards-compatible, same as before)DbExtrinsic::MultiRenewwith ref count bumped for each hash3.
body_uncached— body reconstructionMultiRenew'sheadercontains the full encoded extrinsic (unlikeIndexedwhere header is partial and joined with indexed data). Decoded directly viaBlock::Extrinsic::decode(&mut &header[..]).4.
block_indexed_body— indexed data retrievalReturns transaction data for all hashes in
MultiRenew, not just a single hash.5.
prune_block— ref count releaseReleases all hashes in
MultiRenewwhen pruning, instead of just the single hash fromIndexed.