diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63ed8b9e..cbec5360 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: - name: Run cargo fmt uses: actions-rs/cargo@v1 - continue-on-error: true # WARNING: only for this example, remove it! + continue-on-error: false with: command: fmt args: --all -- --check @@ -63,4 +63,4 @@ jobs: uses: actions-rs/cargo@v1 with: command: test - args: --all --verbose \ No newline at end of file + args: --all --verbose diff --git a/crates/common/src/commit/request.rs b/crates/common/src/commit/request.rs index 06760a13..676c8d9f 100644 --- a/crates/common/src/commit/request.rs +++ b/crates/common/src/commit/request.rs @@ -40,11 +40,7 @@ pub struct SignRequest { } impl SignRequest { - pub fn new( - pubkey: BlsPublicKey, - is_proxy: bool, - object_root: [u8; 32], - ) -> SignRequest { + pub fn new(pubkey: BlsPublicKey, is_proxy: bool, object_root: [u8; 32]) -> SignRequest { Self { pubkey, is_proxy, object_root } } diff --git a/crates/common/src/config/signer.rs b/crates/common/src/config/signer.rs index 988d22a2..0ed3e5fa 100644 --- a/crates/common/src/config/signer.rs +++ b/crates/common/src/config/signer.rs @@ -1,5 +1,4 @@ use bimap::BiHashMap; - use eyre::Result; use serde::{Deserialize, Serialize}; @@ -8,7 +7,10 @@ use super::{ utils::{load_env_var, load_jwts}, CommitBoostConfig, }; -use crate::{loader::SignerLoader, types::{Chain, Jwt, ModuleId}}; +use crate::{ + loader::SignerLoader, + types::{Chain, Jwt, ModuleId}, +}; #[derive(Debug, Serialize, Deserialize, Clone)] pub struct SignerConfig { diff --git a/crates/common/src/config/utils.rs b/crates/common/src/config/utils.rs index ce5b810a..cd7bf927 100644 --- a/crates/common/src/config/utils.rs +++ b/crates/common/src/config/utils.rs @@ -2,9 +2,8 @@ use bimap::BiHashMap; use eyre::{Context, Result}; use serde::de::DeserializeOwned; -use crate::types::{Jwt, ModuleId}; - use super::constants::JWTS_ENV; +use crate::types::{Jwt, ModuleId}; pub fn load_env_var(env: &str) -> Result { std::env::var(env).wrap_err(format!("{env} is not set")) diff --git a/crates/common/src/types.rs b/crates/common/src/types.rs index 68db796e..3e9b9e35 100644 --- a/crates/common/src/types.rs +++ b/crates/common/src/types.rs @@ -1,5 +1,4 @@ -use derive_more::{Deref, From, Into, Display}; - +use derive_more::{Deref, Display, From, Into}; use serde::{Deserialize, Serialize}; use crate::constants::{ @@ -54,4 +53,4 @@ pub struct ModuleId(pub String); #[derive(Clone, Debug, Display, PartialEq, Eq, Hash, Deref, From, Into, Serialize, Deserialize)] #[into(owned, ref, ref_mut)] #[serde(transparent)] -pub struct Jwt(pub String); \ No newline at end of file +pub struct Jwt(pub String); diff --git a/crates/signer/src/manager.rs b/crates/signer/src/manager.rs index 53e74b08..09ce3696 100644 --- a/crates/signer/src/manager.rs +++ b/crates/signer/src/manager.rs @@ -160,7 +160,8 @@ mod tests { async fn test_proxy_key_is_valid_proxy_for_consensus_key() { let (mut signing_manager, consensus_pk) = init_signing_manager(); - let signed_delegation = signing_manager.create_proxy(MODULE_ID.clone(), consensus_pk.clone()).await.unwrap(); + let signed_delegation = + signing_manager.create_proxy(MODULE_ID.clone(), consensus_pk.clone()).await.unwrap(); let validation_result = signed_delegation.validate(*CHAIN); @@ -179,24 +180,23 @@ mod tests { async fn test_tampered_proxy_key_is_invalid() { let (mut signing_manager, consensus_pk) = init_signing_manager(); - let mut signed_delegation = signing_manager.create_proxy(MODULE_ID.clone(), consensus_pk.clone()).await.unwrap(); + let mut signed_delegation = + signing_manager.create_proxy(MODULE_ID.clone(), consensus_pk.clone()).await.unwrap(); let m = &mut signed_delegation.signature.0[0]; (*m, _) = m.overflowing_add(1); let validation_result = signed_delegation.validate(*CHAIN); - assert!( - validation_result.is_err(), - "Tampered proxy key must be invalid." - ); + assert!(validation_result.is_err(), "Tampered proxy key must be invalid."); } #[tokio::test] async fn test_proxy_key_signs_message() { let (mut signing_manager, consensus_pk) = init_signing_manager(); - let signed_delegation = signing_manager.create_proxy(MODULE_ID.clone(), consensus_pk.clone()).await.unwrap(); + let signed_delegation = + signing_manager.create_proxy(MODULE_ID.clone(), consensus_pk.clone()).await.unwrap(); let proxy_pk = signed_delegation.message.proxy; let data_root = Hash256::random(); diff --git a/crates/signer/src/service.rs b/crates/signer/src/service.rs index 1dc6fed4..86bdfc1c 100644 --- a/crates/signer/src/service.rs +++ b/crates/signer/src/service.rs @@ -34,7 +34,8 @@ pub struct SigningService; struct SigningState { /// Mananger handling different signing methods manager: Arc>, - /// Map of JWTs to module ids. This also acts as registry of all modules running + /// Map of JWTs to module ids. This also acts as registry of all modules + /// running jwts: Arc>, } diff --git a/examples/da_commit/src/main.rs b/examples/da_commit/src/main.rs index 1b91099e..87ead506 100644 --- a/examples/da_commit/src/main.rs +++ b/examples/da_commit/src/main.rs @@ -58,16 +58,19 @@ impl DaCommitService { } } - pub async fn send_request(&self, data: u64, pubkey: BlsPublicKey, proxy_delegation: SignedProxyDelegation) -> Result<()> { + pub async fn send_request( + &self, + data: u64, + pubkey: BlsPublicKey, + proxy_delegation: SignedProxyDelegation, + ) -> Result<()> { let datagram = Datagram { data }; - let request = SignRequest::builder(pubkey) - .with_msg(&datagram); + let request = SignRequest::builder(pubkey).with_msg(&datagram); let signature = self.config.signer_client.request_signature(&request); - let proxy_request = SignRequest::builder(proxy_delegation.message.proxy) - .is_proxy() - .with_msg(&datagram); + let proxy_request = + SignRequest::builder(proxy_delegation.message.proxy).is_proxy().with_msg(&datagram); let proxy_signature = self.config.signer_client.request_signature(&proxy_request); let (signature, proxy_signature) = {