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

feat(exex): backfill on subscription with head #10787

Merged
merged 17 commits into from
Sep 17, 2024

Conversation

shekhirin
Copy link
Collaborator

@shekhirin shekhirin commented Sep 9, 2024

Closes #10571

notifications: self.notifications,
head,
}
fn with_head(self, head: ExExHead) -> eyre::Result<ExExNotificationsWithHead<Node>> {
Copy link
Contributor

@nkysg nkysg Sep 9, 2024

Choose a reason for hiding this comment

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

If L230 TODO should remove?

@shekhirin shekhirin force-pushed the alexey/exex-notifications-backfill branch from e3b7761 to c48a07c Compare September 11, 2024 10:02
@shekhirin shekhirin added C-enhancement New feature or request A-exex Execution Extensions labels Sep 11, 2024
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

overall I think I could follow along, left some suggestions and questions

Comment on lines 157 to 160
node_head: Head,
components: Node,
notifications: Receiver<ExExNotification>,
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

this needs a few docs now, especially node_head, because we now have two different types of heads

crates/exex/exex/src/manager.rs Outdated Show resolved Hide resolved
crates/exex/exex/src/manager.rs Outdated Show resolved Hide resolved
crates/exex/exex/src/manager.rs Outdated Show resolved Hide resolved
Ok(notifications)
}

fn heal(&mut self, node_head: Head) -> eyre::Result<()> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, unsure what heal means in this context.

this synchronizes the streams, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, including handling of backfill / unwind & backfill

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed to synchronize() and added an extensive doc comment

Comment on lines 260 to 262
/// Whether to wait for the node head to be at the same height as the ExEx head, and then
/// call the [`Self::heal`].
wait_for_head: bool,
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, this naming is slightly confusing, because not immediately obvious which head this references.

I assume we can derive the same functionality by using Option<Notifaction> which is the most recent notification we received from the stream and compare the exexhead against this, or maybe as an additional field

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

renamed the field

I assume we can derive the same functionality by using Option<Notifaction> which is the most recent notification we received from the stream and compare the exexhead against this, or maybe as an additional field

we can do that but unsure what's the benefit because we will set this field to Some(notification) inside the Stream::poll_next and immediately use it to start healing process, if needed

crates/exex/exex/src/manager.rs Outdated Show resolved Hide resolved
crates/exex/exex/src/manager.rs Show resolved Hide resolved
Comment on lines 384 to 394
// If we are waiting for the node head to be at the same height as the ExEx head,
// then we need to check if the ExEx is on the canonical chain. To do this, we need
// to get the block at the ExEx head's height from new chain, and compare its hash
// to the ExEx head's hash.
if let Some((block, tip)) = chain_and_tip.as_ref().and_then(|(chain, tip)| {
chain.blocks().get(&this.head.block.number).zip(Some(tip))
}) {
if block.hash() == this.head.block.hash {
// ExEx is on the canonical chain, proceed with the notification
this.wait_for_head = false;
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this section is a bit hard to follow, unsure I fully understand this yet

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

restructured it a bit and added more comments

let tip = this
.components
.provider()
.sealed_header(*tip)?
Copy link
Collaborator

Choose a reason for hiding this comment

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

isn't tip part of the Chain? then we don't need to fetch it?

Copy link
Collaborator Author

@shekhirin shekhirin Sep 16, 2024

Choose a reason for hiding this comment

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

not necessarily, in case of a revert notification, we take chain.first().number - 1 as a tip

@shekhirin shekhirin force-pushed the alexey/exex-notifications-backfill branch from 67e9f66 to accdfe0 Compare September 16, 2024 13:41
@shekhirin shekhirin force-pushed the alexey/exex-notifications-backfill branch from a086475 to 3712522 Compare September 16, 2024 17:25
@shekhirin shekhirin marked this pull request as ready for review September 17, 2024 10:56
#[allow(dead_code)]
components: Node,
pub struct ExExNotificationsWithHead<P, E> {
node_head: Head,
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this need to be head, or is NumHash sufficient?

Copy link
Collaborator Author

@shekhirin shekhirin Sep 17, 2024

Choose a reason for hiding this comment

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

same reasoning as #10787 (comment) imo

@shekhirin shekhirin added this pull request to the merge queue Sep 17, 2024
Merged via the queue into main with commit 0cde072 Sep 17, 2024
35 checks passed
@shekhirin shekhirin deleted the alexey/exex-notifications-backfill branch September 17, 2024 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-exex Execution Extensions C-enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Subscribe to a channel with ExEx notifications manually
3 participants