Pt 167837421 race in sc state deletion #2641
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.
SC state: race condition
Fixes a race condition in State Channel's keeping of state.
When a
aesc_chain_watcher
process is spawned for the first time for a new channel, the channel object is not yet present in state trees, thus the watcher'schan_vsn
isundefined
. It is properly updated on subsequent microblocks. Later on when the channel's connection is closed a watcher is started in order to check if the channel is being closed on-chain.When the channel is being reestablished the
aesc_chain_watcher
is being restarted with achan_vsn
still beingundefined
. If now the connection is closed again, the close waiting check is being mislead that the channel is already closed on-chain and thus - both cached and persisted states are being deleted in 4 blocks' time.This PR fixes the issue with optionally initiating the
chan_vsn
with its proper value at watcher's init time.