Skip to content

Commit

Permalink
chore(sidecar): fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
thedevbirb committed Oct 29, 2024
1 parent e455d3c commit a68065b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
6 changes: 3 additions & 3 deletions bolt-sidecar/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ impl<C: StateFetcher, ECDSA: SignerECDSA> SidecarDriver<C, ECDSA> {
fetcher: C,
) -> eyre::Result<Self> {
// Verify the operator and validator keys with the bolt manager
let bolt_manager =
BoltManager::from_chain(opts.execution_api_url.clone(), opts.chain.chain);
if let Some(bolt_manager) = bolt_manager {
if let Some(bolt_manager) =
BoltManager::from_chain(opts.execution_api_url.clone(), opts.chain.chain)
{
bolt_manager.verify_operator(commitment_signer.public_key()).await?;
bolt_manager
.verify_validator_pubkeys(&Vec::from_iter(constraint_signer.available_pubkeys()))
Expand Down
7 changes: 4 additions & 3 deletions bolt-sidecar/src/signer/keystore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ mod tests {
const KEYSTORES_DEFAULT_PATH_TEST: &str = "test_data/keys";
const KEYSTORES_SECRETS_DEFAULT_PATH_TEST: &str = "test_data/secrets";

/// If `path` is `Some`, returns a clone of it. Otherwise, returns the path to the `fallback_relative_path`
/// starting from the root of the cargo project.
/// If `path` is `Some`, returns a clone of it. Otherwise, returns the path to the
/// `fallback_relative_path` starting from the root of the cargo project.
fn make_path(relative_path: &str) -> PathBuf {
let project_root = env!("CARGO_MANIFEST_DIR");
Path::new(project_root).join(relative_path)
Expand Down Expand Up @@ -302,7 +302,8 @@ mod tests {
let keystore_path = PathBuf::from(keystore_path);

for test_keystore_json in tests_keystore_json {
// 1. Write the keystore in a `test-voting-keystore.json` file so we test both scrypt and PBDKF2
// 1. Write the keystore in a `test-voting-keystore.json` file so we test both scrypt
// and PBDKF2

let mut tmp_keystore_file =
File::create(keystore_path.join("test-voting-keystore.json"))
Expand Down
17 changes: 9 additions & 8 deletions bolt-sidecar/src/state/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,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 @@ -161,7 +161,8 @@ impl ConsensusState {
Ok(())
}

/// Fetch proposer duties for the given epoch and the next one if the unsafe lookahead flag is set
/// Fetch proposer duties for the given epoch and the next one if the unsafe lookahead flag is
/// set
async fn fetch_proposer_duties(&mut self, epoch: u64) -> Result<(), ConsensusError> {
let duties = if self.unsafe_lookahead_enabled {
let two_epoch_duties = join!(
Expand Down Expand Up @@ -200,9 +201,9 @@ impl ConsensusState {
/// 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 Down Expand Up @@ -324,8 +325,8 @@ mod tests {
};

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

0 comments on commit a68065b

Please sign in to comment.