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

fix(sidecar): use validator keys and not delegated ones for pub key check #347

Merged
merged 1 commit into from
Oct 30, 2024
Merged
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
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
Loading