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

[Audit remediation] Issue B: Race Condition Between FilterSequenceBatches and handleReorgs #94

Merged
merged 4 commits into from
Jun 24, 2024

Conversation

goran-ethernal
Copy link
Collaborator

@goran-ethernal goran-ethernal commented Jun 20, 2024

This PR fixes the issue found by audit, where a race condition can happen while handling reorgs in the batchSyncronizer when a new sequence of batches is being synced.

Since both routines update the start block from which we sync batches, it may happen that reorg detector will update the start block while the sync routine is downloading batches, which can lead to some inconsistent batches.

PR introduces a sync lock which both routines will use, meaning, we will not handle reorg until we finish syncing batches, or we will not sync batches, until we handle a reorg first.

@goran-ethernal goran-ethernal requested a review from a team as a code owner June 20, 2024 11:55
@goran-ethernal goran-ethernal force-pushed the CDK-336-Audit-remediation-race-condition branch 2 times, most recently from e8eb595 to cc2b364 Compare June 20, 2024 12:34
synchronizer/batches.go Outdated Show resolved Hide resolved
Base automatically changed from feature/CDK-352 to main June 21, 2024 13:27
@goran-ethernal goran-ethernal force-pushed the CDK-336-Audit-remediation-race-condition branch from ea1741f to a209970 Compare June 21, 2024 13:38
@goran-ethernal goran-ethernal force-pushed the CDK-336-Audit-remediation-race-condition branch from a209970 to 5b61f6b Compare June 23, 2024 17:08
synchronizer/batches.go Outdated Show resolved Hide resolved
synchronizer/batches.go Outdated Show resolved Hide resolved
synchronizer/batches.go Show resolved Hide resolved
Copy link

sonarcloud bot commented Jun 24, 2024

@goran-ethernal goran-ethernal merged commit bce3046 into main Jun 24, 2024
8 of 9 checks passed
@goran-ethernal goran-ethernal deleted the CDK-336-Audit-remediation-race-condition branch June 24, 2024 09:33
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