Skip to content
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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ repository = "https://github.com/init4tech/bin-base"
init4-from-env-derive = "0.1.0"

# Signet
signet-constants = { version = "0.16.0-rc.4" }
signet-tx-cache = { version = "0.16.0-rc.4", optional = true }
signet-constants = { version = "0.16.0-rc.7" }
signet-tx-cache = { version = "0.16.0-rc.7", optional = true }

# alloy
alloy = { version = "1.0.35", optional = true, default-features = false, features = ["std", "signer-local", "consensus", "network"] }
Expand Down Expand Up @@ -92,4 +92,4 @@ required-features = ["perms"]
# signet-extract = { path = "../sdk/crates/extract"}
# signet-tx-cache = { path = "../sdk/crates/tx-cache"}
# signet-types = { path = "../sdk/crates/types"}
# signet-zenith = { path = "../sdk/crates/zenith"}
# signet-zenith = { path = "../sdk/crates/zenith"}
32 changes: 21 additions & 11 deletions src/utils/calc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::utils::from_env::{EnvItemInfo, FromEnv, FromEnvErr, FromEnvVar};
use signet_constants::KnownChains;
#[allow(deprecated)]
use signet_constants::{mainnet, parmigiana, pecorino, test_utils, KnownChains};
use std::{num::ParseIntError, str::FromStr};

/// A slot calculator, which can calculate slot numbers, windows, and offsets
Expand Down Expand Up @@ -95,27 +96,32 @@ impl SlotCalculator {
/// Create a new slot calculator for Parmigiana host network.
pub const fn parmigiana_host() -> Self {
Self {
start_timestamp: 1765226348,
slot_offset: 0,
slot_duration: 12,
start_timestamp: parmigiana::HOST_START_TIMESTAMP,
slot_offset: parmigiana::HOST_SLOT_OFFSET as usize,
slot_duration: parmigiana::HOST_SLOT_DURATION,
}
}

/// Create a new slot calculator for Pecorino host network.
#[deprecated(note = "Pecorino is being deprecated in favor of Parmigiana")]
#[expect(
deprecated,
reason = "This deprecated function consumes deprecated consts"
)]
pub const fn pecorino_host() -> Self {
Self {
start_timestamp: 1754584265,
slot_offset: 0,
slot_duration: 12,
start_timestamp: pecorino::HOST_START_TIMESTAMP,
slot_offset: pecorino::HOST_SLOT_OFFSET as usize,
slot_duration: pecorino::HOST_SLOT_DURATION,
}
}

/// Create a new slot calculator for Ethereum mainnet.
pub const fn mainnet() -> Self {
Self {
start_timestamp: 1663224179,
slot_offset: 4700013,
slot_duration: 12,
start_timestamp: mainnet::HOST_START_TIMESTAMP,
slot_offset: mainnet::HOST_SLOT_OFFSET as usize,
slot_duration: mainnet::HOST_SLOT_DURATION,
}
}

Expand Down Expand Up @@ -338,7 +344,11 @@ impl From<KnownChains> for SlotCalculator {
KnownChains::Parmigiana => SlotCalculator::parmigiana_host(),
#[allow(deprecated)]
KnownChains::Pecorino => SlotCalculator::pecorino_host(),
KnownChains::Test => SlotCalculator::new(12, 0, 12),
KnownChains::Test => SlotCalculator::new(
test_utils::HOST_START_TIMESTAMP,
test_utils::HOST_SLOT_OFFSET as usize,
test_utils::HOST_SLOT_DURATION,
),
}
}
}
Expand Down