housekeeping(server): fixed clippy warns
This commit is contained in:
@@ -22,4 +22,4 @@ steps:
|
||||
- apt-get update && apt-get install -y pkg-config
|
||||
- mise install rust
|
||||
- mise install protoc
|
||||
- mise exec rust -- cargo clippy --all-targets --all-features -- -D warnings
|
||||
- mise exec rust -- cargo clippy --all -- -D warnings
|
||||
@@ -1,4 +1,3 @@
|
||||
use alloy::transports::Transport;
|
||||
use arbiter_proto::transport::Bi;
|
||||
use diesel::{ExpressionMethods as _, OptionalExtension as _, QueryDsl, update};
|
||||
use diesel_async::RunQueryDsl;
|
||||
@@ -8,7 +7,7 @@ use super::Error;
|
||||
use crate::{
|
||||
actors::{
|
||||
bootstrap::ConsumeToken,
|
||||
user_agent::{AuthPublicKey, OutOfBand, UserAgentConnection, auth::Outbound},
|
||||
user_agent::{AuthPublicKey, UserAgentConnection, auth::Outbound},
|
||||
},
|
||||
db::schema,
|
||||
};
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
use alloy::primitives::Address;
|
||||
use arbiter_proto::transport::{Bi, Sender};
|
||||
use kameo::actor::Spawn as _;
|
||||
use tracing::{error, info};
|
||||
|
||||
use crate::{
|
||||
actors::{GlobalActors, evm},
|
||||
actors::GlobalActors,
|
||||
db::{self, models::KeyType},
|
||||
evm::policies::SharedGrantSettings,
|
||||
evm::policies::{Grant, SpecificGrant},
|
||||
};
|
||||
|
||||
/// Abstraction over Ed25519 / ECDSA-secp256k1 / RSA public keys used during the auth handshake.
|
||||
@@ -56,20 +50,20 @@ impl TryFrom<(KeyType, Vec<u8>)> for AuthPublicKey {
|
||||
KeyType::Ed25519 => {
|
||||
let bytes: [u8; 32] = bytes.try_into().map_err(|_| "invalid Ed25519 key length")?;
|
||||
let key = ed25519_dalek::VerifyingKey::from_bytes(&bytes)
|
||||
.map_err(|e| "invalid Ed25519 key")?;
|
||||
.map_err(|_e| "invalid Ed25519 key")?;
|
||||
Ok(AuthPublicKey::Ed25519(key))
|
||||
}
|
||||
KeyType::EcdsaSecp256k1 => {
|
||||
let point =
|
||||
k256::EncodedPoint::from_bytes(&bytes).map_err(|e| "invalid ECDSA key")?;
|
||||
k256::EncodedPoint::from_bytes(&bytes).map_err(|_e| "invalid ECDSA key")?;
|
||||
let key = k256::ecdsa::VerifyingKey::from_encoded_point(&point)
|
||||
.map_err(|e| "invalid ECDSA key")?;
|
||||
.map_err(|_e| "invalid ECDSA key")?;
|
||||
Ok(AuthPublicKey::EcdsaSecp256k1(key))
|
||||
}
|
||||
KeyType::Rsa => {
|
||||
use rsa::pkcs8::DecodePublicKey as _;
|
||||
let key = rsa::RsaPublicKey::from_public_key_der(&bytes)
|
||||
.map_err(|e| "invalid RSA key")?;
|
||||
.map_err(|_e| "invalid RSA key")?;
|
||||
Ok(AuthPublicKey::Rsa(key))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use std::{borrow::Cow, convert::Infallible};
|
||||
use std::borrow::Cow;
|
||||
|
||||
use arbiter_proto::transport::Sender;
|
||||
use async_trait::async_trait;
|
||||
use ed25519_dalek::VerifyingKey;
|
||||
use kameo::{Actor, messages, prelude::Context};
|
||||
use kameo::{Actor, messages};
|
||||
use thiserror::Error;
|
||||
use tokio::{select, sync::watch};
|
||||
use tracing::{error, info};
|
||||
use tokio::sync::watch;
|
||||
use tracing::error;
|
||||
|
||||
use crate::actors::{
|
||||
router::RegisterUserAgent,
|
||||
@@ -36,6 +36,7 @@ impl Error {
|
||||
pub struct UserAgentSession {
|
||||
props: UserAgentConnection,
|
||||
state: UserAgentStateMachine<DummyContext>,
|
||||
#[allow(dead_code, reason = "The session keeps ownership of the outbound transport even before the state-machine flow starts using it directly")]
|
||||
sender: Box<dyn Sender<OutOfBand>>,
|
||||
}
|
||||
|
||||
@@ -82,13 +83,15 @@ impl UserAgentSession {
|
||||
|
||||
#[messages]
|
||||
impl UserAgentSession {
|
||||
#[message(ctx)]
|
||||
#[message]
|
||||
pub async fn request_new_client_approval(
|
||||
&mut self,
|
||||
client_pubkey: VerifyingKey,
|
||||
mut cancel_flag: watch::Receiver<()>,
|
||||
ctx: &mut Context<Self, Result<bool, ()>>,
|
||||
cancel_flag: watch::Receiver<()>,
|
||||
) -> Result<bool, ()> {
|
||||
// temporary use to make clippy happy while we refactor this flow
|
||||
dbg!(client_pubkey);
|
||||
dbg!(cancel_flag);
|
||||
todo!("Think about refactoring it to state-machine based flow, as we already have one")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,10 @@ use crate::{
|
||||
Generate, ListWallets, UseragentCreateGrant, UseragentDeleteGrant, UseragentListGrants,
|
||||
},
|
||||
keyholder::{self, Bootstrap, TryUnseal},
|
||||
user_agent::{
|
||||
OutOfBand,
|
||||
session::{
|
||||
user_agent::session::{
|
||||
UserAgentSession,
|
||||
state::{UnsealContext, UserAgentEvents, UserAgentStates},
|
||||
},
|
||||
},
|
||||
},
|
||||
safe_cell::SafeCellHandle as _,
|
||||
};
|
||||
@@ -139,7 +136,7 @@ impl UserAgentSession {
|
||||
self.transition(UserAgentEvents::ReceivedInvalidKey)?;
|
||||
return Err(UnsealError::InvalidKey);
|
||||
}
|
||||
Err(err) => {
|
||||
Err(_err) => {
|
||||
return Err(Error::internal("Failed to take unseal secret").into());
|
||||
}
|
||||
};
|
||||
@@ -263,7 +260,7 @@ impl UserAgentSession {
|
||||
Ok(state) => state,
|
||||
Err(err) => {
|
||||
error!(?err, actor = "useragent", "keyholder.query.failed");
|
||||
return Err(Error::internal("Vault is in broken state").into());
|
||||
return Err(Error::internal("Vault is in broken state"));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -276,13 +273,13 @@ impl UserAgentSession {
|
||||
#[message]
|
||||
pub(crate) async fn handle_evm_wallet_create(&mut self) -> Result<Address, Error> {
|
||||
match self.props.actors.evm.ask(Generate {}).await {
|
||||
Ok(address) => return Ok(address),
|
||||
Ok(address) => Ok(address),
|
||||
Err(SendError::HandlerError(err)) => Err(Error::internal(format!(
|
||||
"EVM wallet generation failed: {err}"
|
||||
))),
|
||||
Err(err) => {
|
||||
error!(?err, "EVM actor unreachable during wallet create");
|
||||
return Err(Error::internal("EVM actor unreachable"));
|
||||
Err(Error::internal("EVM actor unreachable"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,6 @@ pub async fn start(conn: ClientConnection, mut bi: GrpcBi<ClientRequest, ClientR
|
||||
);
|
||||
let _ = transport.send(Err(e.clone())).await;
|
||||
warn!(error = ?e, "Authentication failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,15 +5,13 @@ use arbiter_proto::{
|
||||
},
|
||||
transport::grpc::GrpcBi,
|
||||
};
|
||||
use tokio::sync::mpsc;
|
||||
use tokio_stream::wrappers::ReceiverStream;
|
||||
use tonic::{Request, Response, Status, async_trait};
|
||||
use tracing::info;
|
||||
|
||||
use crate::{
|
||||
DEFAULT_CHANNEL_SIZE,
|
||||
actors::{client::ClientConnection, user_agent::UserAgentConnection},
|
||||
grpc::{self, user_agent::start},
|
||||
grpc::user_agent::start,
|
||||
};
|
||||
|
||||
pub mod client;
|
||||
|
||||
@@ -11,6 +11,7 @@ pub mod grpc;
|
||||
pub mod safe_cell;
|
||||
pub mod utils;
|
||||
|
||||
#[allow(dead_code, reason = "Reserved as the shared default channel size while server wiring is still being consolidated")]
|
||||
const DEFAULT_CHANNEL_SIZE: usize = 1000;
|
||||
|
||||
pub struct Server {
|
||||
|
||||
Reference in New Issue
Block a user