Fix back-endorsement fetching race #7540
Open
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.
✅ Long Test passed
It was noticed during one of the flakey long-test runs with huge commit delays, that the very first endorsement fetched may be not the one we expect (current services endorses previous), but rather previous service endorsing it's predecessor (or self-endorsed).
The original freshness check only checked the local state machine for PartOfNetwork, but this can async with the service updating TX on the follower.
In this case, the follower updates it here, and it can happen that the opening TX hasn't reached it yet.
Ultimately the node fails to validate the chain, as it's not linked to the current service identity, so no data corruption here, but it's easy enough to prevent this, and we're doing so in this PR.
I reproduced this manually (and tested the fix) by hardcoding delays in the source code, but struggled to find out a reasonably cheap and reliable e2e test flow for this, therefore this PR doesn't introduce any.
UPD: another repro: https://github.com/microsoft/CCF/actions/runs/20489719417/job/58879405016?pr=7533