fix(eth/peer/wit): concurrent data read/write cases#1742
Merged
kamuikatsurgi merged 1 commit intodevelopfrom Sep 2, 2025
Merged
fix(eth/peer/wit): concurrent data read/write cases#1742kamuikatsurgi merged 1 commit intodevelopfrom
kamuikatsurgi merged 1 commit intodevelopfrom
Conversation
Closed
kamuikatsurgi
commented
Sep 1, 2025
This was
linked to
issues
Sep 1, 2025
15a4a61 to
2b8742d
Compare
|
cffls
approved these changes
Sep 2, 2025
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.




Fixes #1729 and #1736
Description
Issue in #1729:
The original code had a data race between:
witReqsto createwrapperReq := ðWitRequest{Request: ethReqShim, witReqs: witReqs}.doWitnessRequest()does*witReqs = append(*witReqs, witReq)The race occurred because
buildWitnessRequestswas called asynchronously in a goroutine, allowing the main goroutine to read witReqs while the background goroutine was still populating it via append operations.By calling
buildWitnessRequestssynchronously, we ensure all initial witness requests are built and appended towitReqsBEFORE the main goroutine reads the slice, eliminating the possibility of concurrent read/write access.Issue in #1736:
The original code had a data race between:
announce.timefor logging/timestampinghandleWitnessFetchFailureExt()where it doesstate.announce.time = time.Now().Add(fetchTimeout)The race occurred because this read was unprotected while
handleWitnessFetchFailureExt()was writing to the sameannounce.timefield under mutex protection. Both operations access the same memory location but with different synchronisation. By protecting this read with the same mutex used by the writer, we ensure synchronised access to announce. time, eliminating the data race.