Skip to content

fix(statesync): statesync stops the node when light block request fails - #514

Merged
lklimek merged 23 commits into
v0.10-devfrom
retry-statesync
Dec 1, 2022
Merged

lklimek merged 23 commits into
v0.10-devfrom
retry-statesync

Conversation

@lklimek

@lklimek lklimek commented Nov 28, 2022 •

Copy link
Copy Markdown
Collaborator

Issue being fixed or feature implemented

When node starts, it executes state sync. If the state sync fails, node terminates.
This breaks end-to-end tests.

In some scenarios, state sync might not receive responses to light block request.
This happens in e2e tests, when connection between nodes is not fully established,
for example when handshake is not finalized correctly (see this comment).

What was done?

  1. Implemented retry mechanism in state sync to retry failed state sync initialization in case of error.
  2. Improved locking in statesync to make critical sections shorter
  3. Removed unused Reactor.providers
  4. Modified rotate e2e test to give more time for state sync

How Has This Been Tested?

Running end-to-end tests.

Breaking Changes

None

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

@lklimek lklimek changed the title Retry statesync fix(statesync): statesync stops the node when light block request fails Nov 28, 2022
@lklimek
lklimek marked this pull request as ready for review November 30, 2022 14:47

@shotonoff shotonoff left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM
left a couple of suggestions

Comment thread internal/statesync/reactor.go Resolved
Comment thread internal/statesync/reactor.go Resolved
Comment thread internal/statesync/reactor.go Outdated
if sp, ok := stateProvider.(*stateProviderP2P); ok {
// we do this in a separate routine to not block whilst waiting for the light client to finish
// whatever call it's currently executing
go sp.addProvider(newProvider)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is it safe to call addProvider concurrently?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It is, as sp.lc (which is pointer to light client) never changes.
Logic inside sp.lc has its own mtx locked properly.

Comment thread internal/statesync/reactor.go Outdated
break
}
r.logger.Error("failed to init state provider, retrying", "retry", retry, "error", err)
time.Sleep(time.Second)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is this a sleep call correct here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Maybe a bit redundant, but I added it here to just delay another retry a bit, so that networking has time to stabilize before next attempt

Comment thread internal/statesync/reactor.go Resolved
@lklimek
lklimek merged commit a32cee3 into v0.10-dev Dec 1, 2022
@lklimek
lklimek deleted the retry-statesync branch December 1, 2022 12:57
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.

2 participants