-
Notifications
You must be signed in to change notification settings - Fork 23
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
fix: commitment deadline in case of missed block #188
Conversation
bolt-sidecar/src/driver.rs
Outdated
// TODO: this can be replaced with ethereum_consensus::clock::from_system_time() | ||
// but using beacon node events is easier to work on a custom devnet for now | ||
// (as we don't need to specify genesis time and slot duration) | ||
let head_tracker = HeadTracker::start(beacon_client.clone()); | ||
|
||
// Initialize the consensus clock. | ||
let consensus_clock = from_system_time( | ||
head_tracker.beacon_genesis_timestamp(), | ||
cfg.chain.slot_time(), | ||
SLOTS_PER_EPOCH, | ||
); |
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.
reminder: this is not great because head tracker initializes the genesis timestamp to 0.
We should add a fn to simply async fetch that value instead for safety
This can be done in another issue
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.
I added a comment for this.
but I don't understand how the soln for this should be.
let genesis_time = loop {
match beacon_client.get_genesis_details().await {
Ok(genesis_info) => break genesis_info.genesis_time,
Err(err) => {
warn!(?err, "failed to get genesis details");
sleep(RETRY_DELAY).await;
continue;
}
}
};
I am fetching the value like this
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.
on second thought, we should really have this value in ChainConfig
anyway - for now it's fine though 👍
bolt-sidecar/src/driver.rs
Outdated
@@ -35,6 +40,23 @@ pub struct SidecarDriver<C, BLS, ECDSA> { | |||
mevboost_client: MevBoostClient, | |||
api_events_rx: mpsc::Receiver<CommitmentEvent>, | |||
payload_requests_rx: mpsc::Receiver<FetchPayloadRequest>, | |||
consensus_clock: Clock<SystemTimeProvider>, |
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.
if we only need the SlotStream from the clock, I would prefer to keep that in the struct instead of the Clock.
It should be of type SlotStream<something>
but if it's an issue let me know!
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.
Nice one, some smol nits
bolt-sidecar/src/driver.rs
Outdated
@@ -110,6 +139,7 @@ impl<C: StateFetcher, BLS: SignerBLS, ECDSA: SignerECDSA> SidecarDriver<C, BLS, | |||
mevboost_client, | |||
api_events_rx, | |||
payload_requests_rx, | |||
consensus_clock, |
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.
We can already turn it into a stream here!
bolt-sidecar/src/state/consensus.rs
Outdated
@@ -117,22 +114,17 @@ impl ConsensusState { | |||
} | |||
|
|||
/// Update the latest head and fetch the relevant data from the beacon chain. | |||
pub async fn update_head(&mut self, head: u64) -> Result<(), ConsensusError> { | |||
pub async fn update_slot(&mut self, head: u64) -> Result<(), ConsensusError> { |
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.
Rename param head
-> slot
for consistency
bolt-sidecar/src/driver.rs
Outdated
Some(slot) = slot_stream.next() => { | ||
if let Err(e) = self.consensus.update_slot(slot).await { | ||
error!(err = ?e, "Failed to update consensus state slot"); | ||
} |
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.
Awesome!
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.
Very nice work! Just left some minor comments
@coderabbitai review |
WalkthroughAhoy there! This grand update brings a treasure trove of changes to the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant SidecarDriver
participant ConsensusClock
participant HeadTracker
User->>SidecarDriver: Start driver
SidecarDriver->>ConsensusClock: Initialize clock
ConsensusClock-->>SidecarDriver: Clock ready
SidecarDriver->>HeadTracker: Subscribe to new heads
HeadTracker-->>SidecarDriver: New head event
SidecarDriver->>ConsensusClock: Check for slot updates
ConsensusClock-->>SidecarDriver: Slot updated
SidecarDriver->>User: Respond with latest state
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
Thanks for the speedy review! Addressed it |
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.
LGTM!
Fixes #180
Summary by CodeRabbit
New Features
consensus_clock
for improved time representation related to consensus slots.HeadTracker
.Bug Fixes
Refactor
ConsensusState
by removing theheader
field and renamingupdate_head
toupdate_slot
for clearer slot management.HeadTracker
.Tests