-
Notifications
You must be signed in to change notification settings - Fork 1.1k
BucketList state consistency invariant #5043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a new BucketListStateConsistency invariant that validates the consistency between the in-memory Soroban state cache and the live BucketList. The invariant performs comprehensive checks to ensure data integrity across multiple dimensions:
- Validates cache-BucketList synchronization for CONTRACT_DATA and CONTRACT_CODE entries
- Ensures every live Soroban entry has an associated TTL entry
- Verifies no live entry exists in both the live and hot archive BucketLists (refactored from
ArchivedStateConsistency)
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/invariant/BucketListStateConsistency.h |
Defines the new snapshot invariant interface |
src/invariant/BucketListStateConsistency.cpp |
Implements the 5 key consistency checks between cache and BucketList |
src/invariant/ArchivedStateConsistency.h |
Removes checkSnapshot method declaration (refactored to new invariant) |
src/invariant/ArchivedStateConsistency.cpp |
Changes from snapshot to non-snapshot invariant, removes hot archive overlap check |
src/ledger/InMemorySorobanState.h |
Adds methods to query CONTRACT_DATA and CONTRACT_CODE entry counts |
src/ledger/InMemorySorobanState.cpp |
Implements entry count accessors |
src/invariant/test/InvariantTests.cpp |
Adds comprehensive test suite with 10 test sections covering all invariant properties |
src/main/ApplicationImpl.cpp |
Registers the new invariant during application initialization |
3c8cb7b to
ceeb145
Compare
ceeb145 to
d67fb41
Compare
d67fb41 to
6d03a13
Compare
| app->getInvariantManager().runStateSnapshotInvariant( | ||
| getLedgerState(), lm.getInMemorySorobanStateForTesting()), | ||
| InvariantDoesNotHold); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to also verify that only contract data and code entries exist in the hot archive?
| // BucketList, along with other important properties. We check these properties: | ||
| // 1. Every live entry in the BL is reflected in the in-memory cache | ||
| // 2. No entry exists in the cache, but not the BL | ||
| // 3. Each live soroban entry also has a live TTL entry associated with it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: We should mention somewhere that we also verify that TTLs in cache match TTLs in BL (currently that's done in step 3)
Description
Resolves #5004
This PR adds the BucketListStateConsistency invariant. This is a snapshot invariant that checks the following properties:
ArchivedStateConsistency, but it has been refactored over to the new invariant).Checklist
clang-formatv8.0.0 (viamake formator the Visual Studio extension)