Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pt 167837421 race in sc state deletion #2641

Merged
merged 2 commits into from Aug 13, 2019

Conversation

velzevur
Copy link
Member

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's chan_vsn is undefined. 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 a chan_vsn still being undefined. 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.

%% reestablish
%%
ChId = maps:get(channel_id, RLocal),
mine_key_blocks(dev1, 6), % min depth at 4, so more than 4
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of waiting for 500ms, now we mine 6 blocks

@velzevur velzevur force-pushed the PT-167837421_race_in_SC_state_deletion branch from c85c1ec to 5f75a64 Compare August 12, 2019 15:11
@evdoks evdoks added this to the 4.2.0 milestone Aug 13, 2019
@velzevur velzevur merged commit 7f8e34f into master Aug 13, 2019
@velzevur velzevur deleted the PT-167837421_race_in_SC_state_deletion branch August 13, 2019 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants