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

eth/downloader: fix error aggregator #27217

Merged
merged 1 commit into from
May 5, 2023

Conversation

rjl493456442
Copy link
Member

@rjl493456442 rjl493456442 commented May 4, 2023

This PR fixes an incorrect error aggregation in downloader.

Downloader has a few components used to sync up chain. Whenever an error occurs in any of
these components, the sync procedure needs to be aborted and the error is expected to be
bubbled up. This error is an important marker, one use case is as an indicator if transactions
from network should be accepted or not.

However this error aggregation is wrong. Previously the aggregated error is always overwritten
by the returned value from components, but the fact is some components(e.g. processFullSyncContent)
won't return error in some cases.

This PR fixes this error, and I believe it can prevent accepting transactions when syncing.

@holiman
Copy link
Contributor

holiman commented May 4, 2023

To clarify.. if the sequence of errors is errCanceled, errCanceled, nil, then the original code would return nil, and the new code would return errCanceled.

The outer handling looks like this:

		// If the downloader fails, report an error as in beacon chain mode there
		// should be no errors as long as the chain we're syncing to is valid.
		if err := b.downloader.synchronise("", common.Hash{}, nil, nil, mode, true, b.started); err != nil {
			log.Error("Beacon backfilling failed", "err", err)
			return
		}
		// Synchronization succeeded. Since this happens async, notify the outer
		// context to disable snap syncing and enable transaction propagation.
		if b.success != nil {
			b.success()
		}

So the original code would flag this as succeeded, whereas this PR would (correctly) mark it as backfilling failed.

Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM

@holiman
Copy link
Contributor

holiman commented May 4, 2023

@karalabe ptal

@karalabe
Copy link
Member

karalabe commented May 4, 2023

The original code was somewhat the same as the one being corrected to now: 7641bbe#diff-80cc409bf7f1e4a3d19174ed878e4dcb3d40b19b6e0580bd3816a174c57e0fb2L558

@karalabe
Copy link
Member

karalabe commented May 4, 2023

Is there a reason to have this special case of checking for cancel and doing a break if not, or could we just break out even in case of a cancel (i.e. the original code). Feels a bit convoluted why cancel is special cased.

@rjl493456442
Copy link
Member Author

Because whenever error occurs, all components will be aborted with errCancel returned. We special handle the errCancel in order to dig out the real error message.

@rjl493456442
Copy link
Member Author

The original code was somewhat the same as the one being corrected to now: 7641bbe#diff-80cc409bf7f1e4a3d19174ed878e4dcb3d40b19b6e0580bd3816a174c57e0fb2L558

Yep

@karalabe
Copy link
Member

karalabe commented May 5, 2023

SGTM?

@karalabe karalabe merged commit 79a57d4 into ethereum:master May 5, 2023
@karalabe karalabe added this to the 1.11.7 milestone May 5, 2023
holiman added a commit to holiman/go-ethereum that referenced this pull request May 16, 2023
shekhirin pushed a commit to shekhirin/go-ethereum that referenced this pull request Jun 6, 2023
devopsbo3 pushed a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
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.

3 participants