-
Notifications
You must be signed in to change notification settings - Fork 1
fix: make block query cutoff properly configurable #181
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
Open
dylanlott
wants to merge
10
commits into
main
Choose a base branch
from
dylan/fix-deadline-cutoff
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+40
−26
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b4b2446
fix: make block query cutoff properly configurable
dylanlott a880eff
put alloy db back
dylanlott bcd8ed6
fmt
dylanlott 28f4c12
fmt
dylanlott 54f665c
refactor: avoid using Duration
dylanlott 3a170ff
cleanup
dylanlott 5dc8569
deps: update to signet-sdk@0.16.0-rc.0 to align bin-base version
dylanlott a4c85e7
clippy
dylanlott 0ffbd09
cleanup
dylanlott 8199d03
fmt
dylanlott File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,7 +127,6 @@ impl SimulatorTask { | |
| let concurrency_limit = self.config.concurrency_limit(); | ||
|
|
||
| let rollup_env = sim_env.sim_rollup_env(self.constants(), self.ru_provider.clone()); | ||
|
|
||
| let host_env = sim_env.sim_host_env(self.constants(), self.host_provider.clone()); | ||
|
|
||
| let block_build = BlockBuild::new( | ||
|
|
@@ -226,24 +225,30 @@ impl SimulatorTask { | |
| } | ||
| } | ||
|
|
||
| /// Calculates the deadline for the current block simulation. | ||
| /// Calculates the deadline for the current block simulation in milliseconds. | ||
| /// | ||
| /// # Returns | ||
| /// | ||
| /// An `Instant` representing the simulation deadline, as calculated by | ||
| /// determining the time left in the current slot and adding that to the | ||
| /// current timestamp in UNIX seconds. | ||
| /// An `Instant` representing the simulation deadline as calculated by determining | ||
| /// the milliseconds left in the current slot and adding that to the current | ||
| /// timestamp in UNIX seconds. | ||
| pub fn calculate_deadline(&self) -> Instant { | ||
| // Get the current timepoint within the slot. | ||
| let timepoint = | ||
| self.slot_calculator().current_point_within_slot().expect("host chain has started"); | ||
|
|
||
| // We have the timepoint in seconds into the slot. To find out what's | ||
| // remaining, we need to subtract it from the slot duration | ||
| // we also subtract 3 seconds to account for the sequencer stopping signing. | ||
| let remaining = (self.slot_calculator().slot_duration() - timepoint).saturating_sub(3); | ||
|
|
||
| let deadline = Instant::now() + Duration::from_secs(remaining); | ||
| // Get the current number of milliseconds into the slot. | ||
| let timepoint_ms = | ||
| self.slot_calculator().current_point_within_slot_ms().expect("host chain has started"); | ||
|
|
||
| let slot_duration = self.slot_calculator().slot_duration() * 1000; // convert to milliseconds | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. kinda wish we had this as a fn on the calculator, but no need to take action on this now |
||
| let query_cutoff_buffer = self.config.block_query_cutoff_buffer; | ||
|
|
||
| // To find the remaining slot time, subtract the timepoint from the slot duration. | ||
| // Then subtract the block query cutoff buffer from the slot duration to account for | ||
| // the sequencer stopping signing. | ||
| let remaining = | ||
| slot_duration.saturating_sub(timepoint_ms).saturating_sub(query_cutoff_buffer); | ||
|
|
||
| // The deadline is then calculated by adding the remaining time from this instant. | ||
| // NB: Downcast is okay because u64 will work for 500 million+ years. | ||
| let deadline = Instant::now() + Duration::from_millis(remaining); | ||
| deadline.max(Instant::now()) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.