oasisprotocol / oasisprotocol/oasis-core
updateCached should return (api.EpochTime, bool) to avoid apparent race condition
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 369
- Forks
- 151
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 6
Description
Description of the bug
Ultra tiny nit.
If updateCached were to return (api.EpochTime, bool) instead of just the bool, then we would not need the comment on L74 since the apparent data race does not occur. There is only one goroutine thread running worker() and everything should be fine in all practical concurrency models, but this is potential a future false positive if/when we get a data race analyzer, so we might as well avoid it by using a nicer method signature.
Steps to reproduce
- Read the code.
Expected behavior
In all possible futures where we get a race condition detectors / code analyzers (tsan-like tool for golang), they will not complain about this code, even if the analyzers were not very smart. 😄
Environment
- OS:
- Versions of relevant software and tools:
Additional information
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read go/epochtime/tendermint/tendermint.go at the referenced updateCached and worker locations, then trace how updateCached's return value is used. Change the signature and its caller so the cached EpochTime is returned with the boolean, and verify that the comment about the apparent race is no longer needed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- blockchain
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100