Feature/fabric optimizations #5361
Open
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.
PR Summary: Private Data Enhancements and Performance Optimization
New Test Case for Rollback and Data Revival
Test Implemented: TestRollbackKVLedgerPvtDataRevival
Location: core/ledger/kvledger/tests/rollback_pvtdata_revival_test.go
Scenario Verified: Ensures private data is correctly accessible (revived) when the ledger is rolled back to a block height before the data's purging block.
Gap Addressed: Fills an integrity testing gap identified in rollback_test.go.
Cleanup: The stale TODO regarding FAB-15704 was removed.
Efficient Private Data Retrieval
Component: core/ledger/pvtdatastorage
Issue: Identified an N+1 database query inefficiency in GetPvtDataByBlockNum. retrieveLatestPurgeKeyCollMarkerHt was repeatedly called for every key in the same collection.
Fix: Introduced a local cache (purgeMarkerCache) within the retrieval loop to store and reuse purge markers.
Impact: Significantly reduces DB reads, changing the retrieval scaling from O(N) per key to O(1) per collection.
✅ Verification
Successful addition and execution of TestRollbackKVLedgerPvtDataRevival in core/ledger/kvledger/tests.
Verified compilation and logic of the pvtdatastorage optimization.