Use LfmbTree for locks, introducing LockIndex and an index from LockId - #1652
Merged
limemloh merged 7 commits intoJun 8, 2026
Merged
Conversation
limemloh
force-pushed
the
limemloh/cor-2295-locks-real-state-implementation
branch
2 times, most recently
from
June 3, 2026 14:40
669dacc to
ceb53a6
Compare
limemloh
force-pushed
the
limemloh/cor-2295-locks-real-state-implementation
branch
from
June 3, 2026 14:46
ceb53a6 to
5870058
Compare
limemloh
commented
Jun 3, 2026
soerenbf
approved these changes
Jun 4, 2026
limemloh
force-pushed
the
limemloh/cor-2295-locks-real-state-implementation
branch
from
June 4, 2026 13:02
2ea498a to
7762f5e
Compare
allanbrondum
reviewed
Jun 4, 2026
allanbrondum
reviewed
Jun 4, 2026
allanbrondum
reviewed
Jun 4, 2026
allanbrondum
reviewed
Jun 4, 2026
allanbrondum
reviewed
Jun 4, 2026
allanbrondum
approved these changes
Jun 4, 2026
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.
Purpose
Implements the real persistent state model for protocol-level locks, replacing the dummy in-memory
BTreeMap-backed implementation. Closes COR-2295.Changes
Introduced
LockIndex: a sequential internal key type for the lockLfmbTree, consistent with howTokenIndexworks for tokens. It is intentionally internal and must never appear in the public API, events, or state hashing.Replaced
BTreeMap<LockId, PersistentLockP11>withLfmbTree<LockIndex, Option<PersistentLockP11>>: the tree usesNoneentries as tombstones for deleted (cancelled) locks. A companionim::HashMap<LockId, LockIndex>serves as a derived in-memoryreverse index, rebuilt on every load from the blob store by scanning the tree and reading each live lock's configuration.
Embedded
LockIdinsideLockConfiguration: thecreate_lockcall no longer takes a separatelock_idargument — the ID is extracted from the configuration. This avoids dual-passing and makes the configuration self-contained.Changed
delete_lockto returnbool: the return type changed fromOption<LockP11>(the deleted lock) tobool(whether a lock was deleted). All callers already held aLockP11reference and only needed to know whether deletion occurred.PersistentLockP11::configurationstored asHashedCacheableRef: the lock configuration is now stored as a blob-store reference rather than inlined, consistent with how token configuration is stored.Fixed
lock_listordering and documented the lack of guarantee: the switch fromBTreeMaptoim::HashMapfor the internal index meanslock_listno longer returns lock IDs in sorted order. The trait doc now explicitly states no ordering guarantee andwarns callers not to drive state-mutating scheduler operations from the unordered iterator without first sorting, to preserve consensus safety.
Checklist
hard-to-understand areas.
CLA acceptance
_Remove if not applicable.
By submitting the contribution I accept the terms and conditions of the
Contributor License Agreement v1.0
link: https://developers.concordium.com/CLAs/Contributor-License-Agreement-v1.0.pdf
I accept the above linked CLA.