Skip to content

Commit

Permalink
fix(sidecar): use validator keys and not delegated ones for pub key c…
Browse files Browse the repository at this point in the history
…heck
  • Loading branch information
thedevbirb committed Oct 30, 2024
1 parent b61069d commit 690f15e
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions bolt-sidecar/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,40 @@ impl<C: StateFetcher, ECDSA: SignerECDSA> SidecarDriver<C, ECDSA> {
commitment_signer: ECDSA,
fetcher: C,
) -> eyre::Result<Self> {
let mut constraints_client = ConstraintsClient::new(opts.constraints_api_url.clone());

// read the delegations from disk if they exist and add them to the constraints client.
let validator_public_keys = if let Some(delegations_file_path) =
opts.constraint_signing.delegations_path.as_ref()
{
let delegations = read_signed_delegations_from_file(delegations_file_path)?;
let delegatees =
delegations.iter().map(|d| d.message.delegatee_pubkey.clone()).collect::<Vec<_>>();
constraints_client.add_delegations(delegations);
delegatees
} else {
Vec::from_iter(constraint_signer.available_pubkeys())
};

// Verify the operator and validator keys with the bolt manager
if let Some(bolt_manager) =
BoltManager::from_chain(opts.execution_api_url.clone(), opts.chain.chain)
{
let commitment_signer_pubkey = commitment_signer.public_key();
let available_pubkeys = Vec::from_iter(constraint_signer.available_pubkeys());
let available_pubkeys_len = available_pubkeys.len();
let validator_public_keys_len = validator_public_keys.len();
bolt_manager
.verify_validator_pubkeys(available_pubkeys, commitment_signer_pubkey)
.verify_validator_pubkeys(validator_public_keys, commitment_signer_pubkey)
.await?;
info!(
available_pubkeys_len,
validator_public_keys_len,
commitment_signer_pubkey = ?commitment_signer_pubkey,
"Validators and operator keys verified with Bolt Manager successfully"
);
} else {
warn!(
"No Bolt Manager contract deployed on {} chain, skipping validators and operator public keys verification",
opts.chain.name()
);
}

let beacon_client = BeaconClient::new(opts.beacon_api_url.clone());
Expand Down Expand Up @@ -216,14 +235,6 @@ impl<C: StateFetcher, ECDSA: SignerECDSA> SidecarDriver<C, ECDSA> {
let (api_events_tx, api_events_rx) = mpsc::channel(1024);
CommitmentsApiServer::new(api_addr).run(api_events_tx).await;

let mut constraints_client = ConstraintsClient::new(opts.constraints_api_url.clone());

// read the delegaitons from disk if they exist and add them to the constraints client
if let Some(delegations_file_path) = opts.constraint_signing.delegations_path.as_ref() {
let delegations = read_signed_delegations_from_file(delegations_file_path)?;
constraints_client.add_delegations(delegations);
}

Ok(SidecarDriver {
head_tracker,
execution,
Expand Down

0 comments on commit 690f15e

Please sign in to comment.