Fixes for go races and miner crashes #42
Merged
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.
This is a stability improvement pull request. In the Go node implementation there are several races which are detected by
go -race
and have been fixed.1. Fixed race in gRPC client
send
,recv
andclose
handler:2. Fixed race in gRPC client error handler:
This is a workaround for current implementation to set
RLock
for non-atomic error handler, some parts are atomic already. It is also necessary to store new valueisError
otherwise concurrent connections can block each other but without lock no atomicread
andwrite
is guaranteed. The gRPC client implementation with a shared error handler betweensend
andrecv
should be reworked.3. Fixed
karlsenminer
crash:The miner routines are asynchronous and in stability tests the miner regularly crashes when you set very low limit of blocks to be mined. If running the miner
karlsenminer --simnet -s localhost:9000 --mine-when-not-synced --miningaddr karlsensim:qre0nh3wemr8c4zqlwsd5tch78dx93mmx2u2pvrugheny7ja8k6t682pvpx83 --numblocks 1
, it will fail with:Root cause for this issue is that in
simnet
with very low difficulty we can mine and submit blocks very fast and while submitting an already mined block, the miner will find several others. It can be easily reproduced via:The limit was only applied for submitting blocks, but not for mining blocks. It is fixed now.