Skip to content

chore(deps): bump bin-base #124

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

Merged
merged 2 commits into from
Jul 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ path = "bin/submit_transaction.rs"
integration = []

[dependencies]
init4-bin-base = { version = "0.5.0", features = ["perms"] }
init4-bin-base = { version = "0.6.0", features = ["perms"] }

signet-constants = { version = "0.4.2" }
signet-sim = { version = "0.4.2" }
Expand Down
3 changes: 2 additions & 1 deletion src/tasks/block/sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ impl Simulator {
/// the time 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_timepoint_within_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
Expand Down
42 changes: 28 additions & 14 deletions src/tasks/submit/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use init4_bin_base::deps::{
tracing::{Instrument, debug, debug_span, error, info, warn},
};
use signet_constants::SignetSystemConstants;
use std::time::Instant;
use std::{ops::Range, time::Instant};
use tokio::{sync::mpsc, task::JoinHandle};

macro_rules! spawn_provider_send {
Expand Down Expand Up @@ -131,8 +131,16 @@ impl SubmitTask {
) -> eyre::Result<ControlFlow> {
let submitting_start_time = Instant::now();
let now = utils::now();
let (expected_slot, start, end) = self.calculate_slot_window();
debug!(expected_slot, start, end, now, "calculating target slot window");

let (expected_slot, window) = self.get_expected_slot_and_window();

debug!(
expected_slot,
start = window.start,
end = window.end,
now,
"calculating target slot window"
);

let mut req = bumpable.req().clone();

Expand Down Expand Up @@ -172,7 +180,10 @@ impl SubmitTask {
return Ok(ControlFlow::Skip);
}
drop(guard);
debug!(retries = bumpable.bump_count(), start, end, "retrying block");
debug!(
retries = bumpable.bump_count(),
window.start, window.end, "retrying block"
);
continue;
}
ControlFlow::Skip => {
Expand All @@ -199,9 +210,20 @@ impl SubmitTask {
Ok(result)
}

/// Gets the expected slot and the slot window for the current slot.
fn get_expected_slot_and_window(&self) -> (usize, Range<u64>) {
let expected_slot =
self.config.slot_calculator.current_slot().expect("host chain has started");

let window = self.config.slot_calculator.slot_window(expected_slot);

(expected_slot, window)
}

/// Checks if a slot is still valid during submission retries.
fn slot_still_valid(&self, initial_slot: u64) -> Option<Result<ControlFlow, eyre::Error>> {
let (current_slot, _, _) = self.calculate_slot_window();
fn slot_still_valid(&self, initial_slot: usize) -> Option<Result<ControlFlow, eyre::Error>> {
let current_slot =
self.config.slot_calculator.current_slot().expect("host chain has started");
if current_slot != initial_slot {
// If the slot has changed, skip the block
debug!(current_slot, initial_slot, "slot changed before submission - skipping block");
Expand All @@ -212,14 +234,6 @@ impl SubmitTask {
None
}

/// Calculates and returns the slot number and its start and end timestamps for the current instant.
fn calculate_slot_window(&self) -> (u64, u64, u64) {
let now_ts = utils::now();
let current_slot = self.config.slot_calculator.calculate_slot(now_ts);
let (start, end) = self.config.slot_calculator.calculate_slot_window(current_slot);
(current_slot, start, end)
}

/// Task future for the submit task. This function runs the main loop of the task.
async fn task_future(self, mut inbound: mpsc::UnboundedReceiver<SimResult>) {
loop {
Expand Down