Skip to content

Commit

Permalink
fix(api): fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mempirate committed Jan 9, 2025
1 parent 31238a6 commit 3ea3571
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
8 changes: 5 additions & 3 deletions src/api/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ use alloy::primitives::Address;
use tokio::sync::{mpsc, oneshot};
use tokio_stream::Stream;

use super::{spec, DeregistrationBatch, RegistrationBatch};
use super::spec;
use crate::primitives::{
registry::{Lookahead, Operator, Registration, RegistryEntry},
registry::{
DeregistrationBatch, Lookahead, Operator, Registration, RegistrationBatch, RegistryEntry,
},
BlsPublicKey,
};

Expand All @@ -35,7 +37,7 @@ pub(crate) enum Action {
response: oneshot::Sender<Result<Vec<RegistryEntry>, spec::RegistryError>>,
},
GetValidatorsByIndices {
indices: Vec<usize>,
indices: Vec<u64>,
response: oneshot::Sender<Result<Vec<RegistryEntry>, spec::RegistryError>>,
},
GetValidatorByPubkey {
Expand Down
20 changes: 11 additions & 9 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Module `api` contains the API server for the registry. The API server is defined in
//! [`spec::ValidatorSpec`] and [`spec::DiscoverySpec`], and is implemented by [`RegistryApi`].
//! [`spec::ApiSpec`];
use std::{io, net::SocketAddr, sync::Arc, time::Duration};

Expand Down Expand Up @@ -31,7 +31,7 @@ use crate::primitives::{
pub(crate) mod actions;
use actions::{Action, ActionStream};

pub(crate) mod spec;
mod spec;
use spec::{
DiscoverySpec, ValidatorSpec, DISCOVERY_LOOKAHEAD_PATH, DISCOVERY_OPERATORS_PATH,
DISCOVERY_OPERATOR_PATH, DISCOVERY_VALIDATORS_PATH, DISCOVERY_VALIDATOR_PATH,
Expand Down Expand Up @@ -69,7 +69,7 @@ impl Default for ApiConfig {
#[derive(Deserialize, Default)]
struct ValidatorFilter {
pubkeys: Option<Vec<BlsPublicKey>>,
indices: Option<Vec<usize>>,
indices: Option<Vec<u64>>,
}

impl RegistryApi {
Expand Down Expand Up @@ -231,7 +231,7 @@ impl spec::DiscoverySpec for RegistryApi {
#[tracing::instrument(skip(self))]
async fn get_validators_by_indices(
&self,
indices: Vec<usize>,
indices: Vec<u64>,
) -> Result<Vec<RegistryEntry>, spec::RegistryError> {
let (tx, rx) = oneshot::channel();

Expand Down Expand Up @@ -292,8 +292,6 @@ impl spec::DiscoverySpec for RegistryApi {
mod tests {
use tokio_stream::StreamExt;

use crate::primitives::registry::RegistrationBatch;

use super::*;

#[tokio::test]
Expand All @@ -302,11 +300,15 @@ mod tests {

let (api, mut stream) = RegistryApi::new(Default::default());

let operator = Address::random();
let gas_limit = 10_000u64;
let expiry = 0u64;

let registration = RegistrationBatch {
validator_pubkeys: vec![BlsPublicKey::random()],
operator: Address::random(),
gas_limit: 10_000,
expiry: 0,
operator,
gas_limit,
expiry,
signatures: vec![],
};

Expand Down
9 changes: 6 additions & 3 deletions src/api/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ use serde::{Deserialize, Serialize};
use thiserror::Error;
use tokio::sync::{mpsc::error::SendTimeoutError, oneshot::error::RecvError};

use super::{actions::Action, DeregistrationBatch, RegistrationBatch};
use super::actions::Action;
use crate::{
client::beacon::BeaconClientError,
db::DbError,
primitives::{
registry::{Lookahead, Operator, Registration, RegistryEntry},
registry::{
DeregistrationBatch, Lookahead, Operator, Registration, RegistrationBatch,
RegistryEntry,
},
BlsPublicKey,
},
};
Expand Down Expand Up @@ -55,7 +58,7 @@ pub(super) trait DiscoverySpec {
/// /registry/v1/discovery/validators?indices=...
async fn get_validators_by_indices(
&self,
indices: Vec<usize>,
indices: Vec<u64>,
) -> Result<Vec<RegistryEntry>, RegistryError>;

/// /registry/v1/discovery/validators/{pubkey}
Expand Down

0 comments on commit 3ea3571

Please sign in to comment.