From 3155a0418981e9e64a3253f8eb7ded4ee4d98ece Mon Sep 17 00:00:00 2001 From: Yueh-Hsuan Chiang <93241502+yhchiang-sol@users.noreply.github.com> Date: Tue, 21 Dec 2021 22:36:13 -0800 Subject: [PATCH] Add comment block for insert_shreds_handle_duplicate in blockstore.rs (#21877) --- ledger/src/blockstore.rs | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index 03e1da2be..00b3ec449 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -775,6 +775,57 @@ impl Blockstore { recovered_data_shreds } + /// The main helper function that performs the shred insertion logic + /// and updates corresponding meta-data. + /// + /// This function updates the following column families: + /// - [`cf::DeadSlots`]: mark a shred as "dead" if its meta-data indicates + /// there is no need to replay this shred. Specifically when both the + /// following conditions satisfy, + /// - We get a new shred N marked as the last shred in the slot S, + /// but N.index() is less than the current slot_meta.received + /// for slot S. + /// - The slot is not currently full + /// It means there's an alternate version of this slot. See + /// `check_insert_data_shred` for more details. + /// - [`cf::ShredData`]: stores data shreds (in check_insert_data_shreds). + /// - [`cf::ShredCode`]: stores coding shreds (in check_insert_coding_shreds). + /// - [`cf::SlotMeta`]: the SlotMeta of the input `shreds` and their related + /// shreds are updated. Specifically: + /// - `handle_chaining()` updates `cf::SlotMeta` in two ways. First, it + /// updates the in-memory slot_meta_working_set, which will later be + /// persisted in commit_slot_meta_working_set(). Second, for the newly + /// chained slots (updated inside handle_chaining_for_slot()), it will + /// directly persist their slot-meta into `cf::SlotMeta`. + /// - In `commit_slot_meta_working_set()`, persists everything stored + /// in the in-memory structure slot_meta_working_set, which is updated + /// by both `check_insert_data_shred()` and `handle_chaining()`. + /// - [`cf::Orphans`]: add or remove the ID of a slot to `cf::Orphans` + /// if it becomes / is no longer an orphan slot in `handle_chaining()`. + /// - [`cf::ErasureMeta`]: the associated ErasureMeta of the coding and data + /// shreds inside `shreds` will be updated and committed to + /// `cf::ErasureMeta`. + /// - [`cf::Index`]: stores (slot id, index to the index_working_set_entry) + /// pair to the `cf::Index` column family for each index_working_set_entry + /// which insert did occur in this function call. + /// + /// Arguments: + /// - `shreds`: the shreds to be inserted. + /// - `is_repaired`: a boolean vector aligned with `shreds` where each + /// boolean indicates whether the corresponding shred is repaired or not. + /// - `leader_schedule`: the leader schedule + /// - `is_trusted`: whether the shreds come from a trusted source. If this + /// is set to true, then the function will skip the shred duplication and + /// integrity checks. + /// - `retransmit_sender`: the sender for transmitting any recovered + /// data shreds. + /// - `handle_duplicate`: a function for handling shreds that have the same slot + /// and index. + /// - `metrics`: the metric for reporting detailed stats + /// + /// On success, the function returns an Ok result with a vector of + /// `CompletedDataSetInfo` and a vector of its corresponding index in the + /// input `shreds` vector. pub fn insert_shreds_handle_duplicate( &self, shreds: Vec,