-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Fix leaf block removal in the backend #12005
Conversation
The fix introduced the new 'removal' method for the backend leaves set and the improvement of the undo features.
Co-authored-by: Bastian Köcher <[email protected]>
|
@skunert applied your suggestion. Thank you. @bkchr fixed another little bug in the This is the new fix substrate/client/db/src/lib.rs Lines 2230 to 2253 in 39a9f30
|
|
The CI pipeline was cancelled due to failure one of the required jobs. |
|
I think this check is still broken, we now always insert the parent 🤔. #[test]
fn removal_breaks() {
let mut set = LeafSet::new();
set.import(10_1u32, 10u32, 0u32);
set.import(11_2, 11, 10_1);
set.import(12_2, 12, 11_2);
set.import(12_3, 12, 11_2);
let outcome = set.remove(12_3, 12, Some(11_2)).unwrap();
assert_eq!(outcome.removed.hash, 12_3);
assert_eq!(outcome.inserted, None);
}Here |
@skunert that test is expected to fail. See this (new) comment here: substrate/client/api/src/leaves.rs Lines 121 to 128 in 8dada46
Within the In your test case the caller should call: Fortunately this function usage is not so widespread... substrate/client/db/src/lib.rs Line 2255 in 8dada46
|
|
Ah sorry, totally missed this, makes sense now 👍. |
* Fix leaf block removal in the backend The fix introduced the new 'removal' method for the backend leaves set and the improvement of the undo features. * Update docs * Apply suggestions from code review Co-authored-by: Bastian Köcher <[email protected]> * Fix docs typo * On block block removal the new children list should be persisted. * Align leaves set removal tests to the new interface Co-authored-by: Bastian Köcher <[email protected]>
This PR introduces a new
removemethod for the leaves set maintained by the backend.The
remove,import, and finalization methods return types were named/renamedRemoveOutcomeImportDisplaced->ImportOutcomeFinalizationDisplaced->FinalizationOutcomeThis naming/renaming has been done to better reflect what the operations are actually doing.
That is, for example:
importalways adds a new leaf, but not always removes its parent from the leaves set (the parent may not be a leaf already)removenot always removes a leaf and not always adds its parent to the set (it should be the last child to add the parent as a leaf).The naming also better fits in the undo operations that were improved and better tested.
The new
removemethod has been immediately used to fix theremove_leaf_blockbackend method.Before it was using
revertand that has not the effect we actually need here.