Repository navigation
Add phase invariants to LedgerManager::ApplyState - #4819
Merged
Merged
Conversation
dmkozh
reviewed
Jul 8, 2025
SirTyson
force-pushed
the
ledger-apply-invariants
branch
from
July 8, 2025 18:11
b71c7f5 to
eed6dcf
Compare
Contributor
Author
|
I've cleaned up the thread asserts and fixed a phase transition issue in the genesis ledger path that was causing an |
dmkozh
reviewed
Jul 8, 2025
marta-lokhova
requested changes
Jul 8, 2025
marta-lokhova
left a comment
Contributor
There was a problem hiding this comment.
A couple of suggestions, mostly around consistent commentary, and avoiding unnecessary asserts in const functions.
SirTyson
force-pushed
the
ledger-apply-invariants
branch
from
July 10, 2025 01:04
2ccb363 to
8e77b0b
Compare
SirTyson
force-pushed
the
ledger-apply-invariants
branch
from
July 10, 2025 01:07
8e77b0b to
b568cab
Compare
marta-lokhova
approved these changes
Jul 10, 2025
marta-lokhova
enabled auto-merge
July 10, 2025 16:24
pull Bot
pushed a commit
to mikeyhodl/stellar-core
that referenced
this pull request
May 28, 2026
This does a little simplification on the arithmetic we were doing to track thresholds of module cache rebuilding, as well as clarifying when we're measuring _input_ vs. _output_ values in the cost model. Also it moves the module cache tests to a separate file, as part of my long term dream to split InvokeHostFunctionTests.cpp into multiple files. One disappointing part about this is that the tweak above reveals that the `ApplyState` state-invariant-checking that @SirTyson put in back in stellar#4819 was actually _slightly_ incorrect: the `finishPendingCompilation` method does actually write to `ApplyState` when it's in `READY_TO_APPLY` (it did back then too, it just didn't happen to _occur_ in tests before). I can't think of any really great way to avoid this (the whole point is to defer the implied variable-update/stall until the last moment before we'll need it) besides I guess we could like add in another state? I don't know if that would win much, but I'd be willing to if that's your preference @SirTyson ?
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.
Description
Adds additional invariant to
LedgerManager::ApplyState. Now that there are multiple apply threads accessingApplyState, sometimes the state is expected to be an immutable snapshot (i.e. during transaction execution), and other timesApplyStateis modified by the apply thread to commit state changes and advance the ledger. This codifies these invariants. There's still some room for further hardening. For example,getNetworkConfigisn't protected by these invariants yet, as that's a larger overhaul that probably also requires changes to the LedgerStateSnapshot interface.Checklist
clang-formatv8.0.0 (viamake formator the Visual Studio extension)