-
-
Notifications
You must be signed in to change notification settings - Fork 405
rough-out new BackfillSync class structure #8353
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
base: backfill
Are you sure you want to change the base?
rough-out new BackfillSync class structure #8353
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @vedant-asati, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request initiates the restructuring of the backfill synchronization mechanism by introducing a new BackfillSync class. The primary goal is to establish a clear and robust architecture for future backfill operations, focusing on defining the core components and interactions without delving into the full implementation details at this stage.
Highlights
- New BackfillSync Class Structure: Introduces the foundational structure for a new BackfillSync class within packages/beacon-node/src/sync/backfill/v2/index.ts to address backfill issues.
- Core Components Defined: Defines essential types and interfaces such as BackfillSyncModules, BackfillSyncOpts, and BackFillSyncAnchor, laying out the dependencies and configuration for the backfill synchronization process.
- Initial Class Implementation: The BackfillSync class includes basic functional flow, peer connection/disconnection handling, and an init static method for proper initialization, while removing implementation-specific code as it's a rough-out.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a new, restructured BackfillSync
class. The overall structure is a good starting point for the backfill sync logic. My review includes a couple of suggestions to improve maintainability and robustness: one regarding a naming inconsistency and another about the handling of the asynchronous sync process initialization.
type BackFillSyncAnchor = | ||
| { | ||
anchorBlock: SignedBeaconBlock; | ||
anchorBlockRoot: Root; | ||
anchorSlot: Slot; | ||
lastBackSyncedBlock: BackfillBlock; | ||
} | ||
| {anchorBlock: null; anchorBlockRoot: Root; anchorSlot: null; lastBackSyncedBlock: BackfillBlock} | ||
| {anchorBlock: null; anchorBlockRoot: Root; anchorSlot: Slot; lastBackSyncedBlock: null}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a typo in the type name BackFillSyncAnchor
. For consistency with other names in this file (e.g., BackfillSyncModules
, BackfillSyncOpts
), it should be BackfillSyncAnchor
.
Please correct this typo here and in its usages on lines 29 and 71.
type BackFillSyncAnchor = | |
| { | |
anchorBlock: SignedBeaconBlock; | |
anchorBlockRoot: Root; | |
anchorSlot: Slot; | |
lastBackSyncedBlock: BackfillBlock; | |
} | |
| {anchorBlock: null; anchorBlockRoot: Root; anchorSlot: null; lastBackSyncedBlock: BackfillBlock} | |
| {anchorBlock: null; anchorBlockRoot: Root; anchorSlot: Slot; lastBackSyncedBlock: null}; | |
type BackfillSyncAnchor = | |
| { | |
anchorBlock: SignedBeaconBlock; | |
anchorBlockRoot: Root; | |
anchorSlot: Slot; | |
lastBackSyncedBlock: BackfillBlock; | |
} | |
| {anchorBlock: null; anchorBlockRoot: Root; anchorSlot: null; lastBackSyncedBlock: BackfillBlock} | |
| {anchorBlock: null; anchorBlockRoot: Root; anchorSlot: Slot; lastBackSyncedBlock: null}; |
this.sync() | ||
.then(() => { | ||
this.logger.info("BackfillSync completed"); | ||
this.close(); | ||
}) | ||
.catch((e) => { | ||
this.logger.error("BackfillSync processor error", e); | ||
this.status = BackfillSyncStatus.aborted; | ||
this.close(); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Starting an async operation in the constructor without awaiting it (a "fire-and-forget" promise) can make the system harder to reason about, especially for error handling and testing. Errors from the sync()
process are only logged and not propagated to the creator of the BackfillSync
instance.
Consider modifying the init
method to return the sync()
promise along with the instance. This would give the caller control over handling the completion or failure of the sync process.
For example:
// In BackfillSync class
public readonly syncPromise: Promise<void>;
constructor(...) {
// ...
this.syncPromise = this.sync().then(() => {
this.logger.info("BackfillSync completed");
this.close();
}).catch((e) => {
this.logger.error("BackfillSync processor error", e);
this.status = BackfillSyncStatus.aborted;
this.close();
// Re-throw or handle to reject syncPromise
throw e;
});
}
static async init<T extends BackfillSync = BackfillSync>(
opts: BackfillSyncOpts,
modules: BackfillSyncModules
): Promise<{instance: T, done: Promise<void>}> {
// ...
const instance = new BackfillSync(opts, { ... }) as T;
return {instance, done: instance.syncPromise};
}
This would be a more robust pattern.
Motivation
This goal of this pr is to restructure and rough-out new BackfillSync class structure.
Backfill issue: #7753
Description
WIP