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

Drop --validator-indexes flag #360

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 0 additions & 7 deletions bolt-sidecar/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ BOLT_SIDECAR_CONSTRAINTS_PROXY_PORT=18550
# URL to forward the constraints produced by the Bolt sidecar to a server
# supporting the Constraints API, such as an MEV-Boost fork
BOLT_SIDECAR_CONSTRAINTS_API_URL="http://localhost:18551"
# Validator indexes of connected validators that the sidecar should accept
# commitments on behalf of.
# Accepted values:
# - a comma-separated list of indexes (e.g. "1,2,3,4")
# - a contiguous range of indexes (e.g. "1..4")
# - a mix of the above (e.g. "1,2..4,6..8")
BOLT_SIDECAR_VALIDATOR_INDEXES=
# The JWT secret token to authenticate calls to the engine API. It can be
# either be a hex-encoded string or a file path to a file containing the
# hex-encoded secret.
Expand Down
10 changes: 0 additions & 10 deletions bolt-sidecar/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ use clap::Parser;
use reqwest::Url;
use serde::Deserialize;

pub mod validator_indexes;
pub use validator_indexes::ValidatorIndexes;

pub mod chain;
pub use chain::ChainConfig;

Expand Down Expand Up @@ -58,13 +55,6 @@ pub struct Opts {
default_value_t = DEFAULT_CONSTRAINTS_PROXY_PORT
)]
pub constraints_proxy_port: u16,
/// Validator indexes of connected validators that the sidecar
/// should accept commitments on behalf of. Accepted values:
/// - a comma-separated list of indexes (e.g. "1,2,3,4")
/// - a contiguous range of indexes (e.g. "1..4")
/// - a mix of the above (e.g. "1,2..4,6..8")
#[clap(long, env = "BOLT_SIDECAR_VALIDATOR_INDEXES", default_value_t)]
pub validator_indexes: ValidatorIndexes,
/// The JWT secret token to authenticate calls to the engine API.
///
/// It can either be a hex-encoded string or a file path to a file
Expand Down
101 changes: 0 additions & 101 deletions bolt-sidecar/src/config/validator_indexes.rs

This file was deleted.

1 change: 0 additions & 1 deletion bolt-sidecar/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ impl<C: StateFetcher, ECDSA: SignerECDSA> SidecarDriver<C, ECDSA> {

let consensus = ConsensusState::new(
beacon_client,
opts.validator_indexes.clone(),
opts.chain.commitment_deadline(),
opts.chain.enable_unsafe_lookahead,
);
Expand Down
30 changes: 8 additions & 22 deletions bolt-sidecar/src/state/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use tracing::debug;

use super::CommitmentDeadline;
use crate::{
config::ValidatorIndexes,
primitives::{CommitmentRequest, Slot},
telemetry::ApiMetrics,
BeaconClient,
Expand Down Expand Up @@ -50,7 +49,6 @@ struct Epoch {
pub struct ConsensusState {
beacon_api_client: Client,
epoch: Epoch,
validator_indexes: ValidatorIndexes,
// Timestamp of when the latest slot was received
latest_slot_timestamp: Instant,
// The latest slot received
Expand Down Expand Up @@ -83,13 +81,11 @@ impl ConsensusState {
/// Create a new `ConsensusState` with the given configuration.
pub fn new(
beacon_api_client: BeaconClient,
validator_indexes: ValidatorIndexes,
commitment_deadline_duration: Duration,
unsafe_lookahead_enabled: bool,
) -> Self {
ConsensusState {
beacon_api_client,
validator_indexes,
epoch: Epoch::default(),
latest_slot: Default::default(),
latest_slot_timestamp: Instant::now(),
Expand All @@ -104,7 +100,6 @@ impl ConsensusState {
/// 2. The request hasn't passed the slot deadline.
///
/// If the request is valid, it returns the validator public key for the slot.
/// TODO: Integrate with the registry to check if we are registered.
pub fn validate_request(
&self,
request: &CommitmentRequest,
Expand All @@ -117,8 +112,8 @@ impl ConsensusState {
}

// If the request is for the next slot, check if it's within the commitment deadline
if req.slot == self.latest_slot + 1 &&
self.latest_slot_timestamp + self.commitment_deadline_duration < Instant::now()
if req.slot == self.latest_slot + 1
&& self.latest_slot_timestamp + self.commitment_deadline_duration < Instant::now()
{
return Err(ConsensusError::DeadlineExceeded);
}
Expand Down Expand Up @@ -191,19 +186,17 @@ impl ConsensusState {
self.epoch
.proposer_duties
.iter()
.find(|&duty| {
duty.slot == slot && self.validator_indexes.contains(duty.validator_index as u64)
})
.find(|&duty| duty.slot == slot)
.map(|duty| duty.public_key.clone())
.ok_or(ConsensusError::ValidatorNotFound)
}

/// Returns the furthest slot for which a commitment request is considered valid, whether in
/// the current epoch or next epoch (if unsafe lookahead is enabled)
fn furthest_slot(&self) -> u64 {
self.epoch.start_slot +
SLOTS_PER_EPOCH +
if self.unsafe_lookahead_enabled { SLOTS_PER_EPOCH } else { 0 }
self.epoch.start_slot
+ SLOTS_PER_EPOCH
+ if self.unsafe_lookahead_enabled { SLOTS_PER_EPOCH } else { 0 }
}
}

Expand All @@ -225,16 +218,12 @@ mod tests {
ProposerDuty { public_key: Default::default(), slot: 3, validator_index: 102 },
];

// Validator indexes that we are interested in
let validator_indexes = ValidatorIndexes::from(vec![100, 102]);

// Create a ConsensusState with the sample proposer duties and validator indexes
let state = ConsensusState {
beacon_api_client: Client::new(Url::parse("http://localhost").unwrap()),
epoch: Epoch { value: 0, start_slot: 0, proposer_duties },
latest_slot_timestamp: Instant::now(),
commitment_deadline: CommitmentDeadline::new(0, Duration::from_secs(1)),
validator_indexes,
commitment_deadline_duration: Duration::from_secs(1),
latest_slot: 0,
unsafe_lookahead_enabled: false,
Expand All @@ -256,7 +245,6 @@ mod tests {
let _ = tracing_subscriber::fmt::try_init();

let commitment_deadline_duration = Duration::from_secs(1);
let validator_indexes = ValidatorIndexes::from(vec![100, 101, 102]);

let Some(url) = try_get_beacon_api_url().await else {
warn!("skipping test: beacon API URL is not reachable");
Expand All @@ -271,7 +259,6 @@ mod tests {
epoch: Epoch::default(),
latest_slot: Default::default(),
latest_slot_timestamp: Instant::now(),
validator_indexes,
commitment_deadline: CommitmentDeadline::new(0, commitment_deadline_duration),
commitment_deadline_duration,
unsafe_lookahead_enabled: false,
Expand Down Expand Up @@ -317,16 +304,15 @@ mod tests {
epoch: Epoch::default(),
latest_slot: Default::default(),
latest_slot_timestamp: Instant::now(),
validator_indexes: Default::default(),
commitment_deadline: CommitmentDeadline::new(0, commitment_deadline_duration),
commitment_deadline_duration,
// We test for both epochs
unsafe_lookahead_enabled: true,
};

let epoch =
state.beacon_api_client.get_beacon_header(BlockId::Head).await?.header.message.slot /
SLOTS_PER_EPOCH;
state.beacon_api_client.get_beacon_header(BlockId::Head).await?.header.message.slot
/ SLOTS_PER_EPOCH;

state.fetch_proposer_duties(epoch).await?;
assert_eq!(state.epoch.proposer_duties.len(), SLOTS_PER_EPOCH as usize * 2);
Expand Down
Loading