From c3aa3a5495041d234bb5fd6dcf3a226661e57eba Mon Sep 17 00:00:00 2001 From: Pravdyvy Date: Tue, 10 Feb 2026 15:54:57 +0200 Subject: [PATCH] fix: some ci fix --- Cargo.lock | 9 ---- common/src/transaction.rs | 8 +-- indexer/core/src/block_store.rs | 10 +--- indexer/core/src/lib.rs | 2 +- indexer/service/Cargo.toml | 1 - indexer/service/protocol/Cargo.toml | 3 +- indexer/service/src/mock_service.rs | 2 +- indexer/service/src/service.rs | 80 ++++++++--------------------- integration_tests/Cargo.toml | 4 -- integration_tests/tests/indexer.rs | 25 ++++++--- nssa/core/Cargo.toml | 3 +- sequencer_core/Cargo.toml | 1 - sequencer_runner/Cargo.toml | 1 - storage/src/indexer.rs | 6 +-- 14 files changed, 54 insertions(+), 101 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6c17002c..4ed0c882 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3360,7 +3360,6 @@ dependencies = [ "indexer_service_rpc", "jsonrpsee", "log", - "serde", "serde_json", "tokio", "tokio-util", @@ -3371,7 +3370,6 @@ name = "indexer_service_protocol" version = "0.1.0" dependencies = [ "base64 0.22.1", - "borsh", "common", "nssa", "nssa_core", @@ -3439,7 +3437,6 @@ dependencies = [ name = "integration_tests" version = "0.1.0" dependencies = [ - "actix-web", "anyhow", "base64 0.22.1", "borsh", @@ -3447,14 +3444,12 @@ dependencies = [ "env_logger", "futures", "hex", - "indexer_core", "indexer_service", "indexer_service_rpc", "key_protocol", "log", "nssa", "nssa_core", - "rand 0.8.5", "sequencer_core", "sequencer_runner", "serde_json", @@ -3464,7 +3459,6 @@ dependencies = [ "tokio", "url", "wallet", - "wallet-ffi", ] [[package]] @@ -5016,7 +5010,6 @@ dependencies = [ name = "nssa_core" version = "0.1.0" dependencies = [ - "anyhow", "base58", "borsh", "bytemuck", @@ -6674,7 +6667,6 @@ dependencies = [ "nssa", "nssa_core", "rand 0.8.5", - "reqwest", "serde", "serde_json", "storage", @@ -6719,7 +6711,6 @@ dependencies = [ "common", "env_logger", "futures", - "indexer_service_protocol", "indexer_service_rpc", "log", "sequencer_core", diff --git a/common/src/transaction.rs b/common/src/transaction.rs index 440d52fe..87e31a4c 100644 --- a/common/src/transaction.rs +++ b/common/src/transaction.rs @@ -38,10 +38,10 @@ impl From for NSSATransaction { impl NSSATransaction { pub fn affected_public_account_ids(&self) -> Vec { - match &self { - &NSSATransaction::ProgramDeployment(tx) => tx.affected_public_account_ids(), - &NSSATransaction::Public(tx) => tx.affected_public_account_ids(), - &NSSATransaction::PrivacyPreserving(tx) => tx.affected_public_account_ids(), + match self { + NSSATransaction::ProgramDeployment(tx) => tx.affected_public_account_ids(), + NSSATransaction::Public(tx) => tx.affected_public_account_ids(), + NSSATransaction::PrivacyPreserving(tx) => tx.affected_public_account_ids(), } } } diff --git a/indexer/core/src/block_store.rs b/indexer/core/src/block_store.rs index 0d8bb5f7..b5de3896 100644 --- a/indexer/core/src/block_store.rs +++ b/indexer/core/src/block_store.rs @@ -52,20 +52,14 @@ impl IndexerStore { .body .transactions .iter() - .find_map(|enc_tx| { - if enc_tx.hash().0 == tx_hash { - Some(enc_tx) - } else { - None - } - }) + .find(|enc_tx| enc_tx.hash().0 == tx_hash) .ok_or_else(|| anyhow::anyhow!("Transaction not found in DB"))?; Ok(transaction.clone()) } pub fn get_block_by_hash(&self, hash: [u8; 32]) -> Result { - Ok(self.get_block_at_id(self.dbio.get_block_id_by_hash(hash)?)?) + self.get_block_at_id(self.dbio.get_block_id_by_hash(hash)?) } pub fn get_transactions_by_account( diff --git a/indexer/core/src/lib.rs b/indexer/core/src/lib.rs index 90b61ec3..6e3f9b34 100644 --- a/indexer/core/src/lib.rs +++ b/indexer/core/src/lib.rs @@ -68,7 +68,7 @@ impl IndexerCore { bedrock_client: BedrockClient::new( config.bedrock_client_config.backoff, config.bedrock_client_config.addr.clone(), - config.bedrock_client_config.auth.clone().map(Into::into), + config.bedrock_client_config.auth.clone(), )?, config, // ToDo: Implement restarts diff --git a/indexer/service/Cargo.toml b/indexer/service/Cargo.toml index 543039c5..eec69101 100644 --- a/indexer/service/Cargo.toml +++ b/indexer/service/Cargo.toml @@ -15,7 +15,6 @@ tokio-util.workspace = true env_logger.workspace = true log.workspace = true jsonrpsee.workspace = true -serde.workspace = true serde_json.workspace = true futures.workspace = true async-trait = "0.1.89" diff --git a/indexer/service/protocol/Cargo.toml b/indexer/service/protocol/Cargo.toml index 2646086c..cf18b721 100644 --- a/indexer/service/protocol/Cargo.toml +++ b/indexer/service/protocol/Cargo.toml @@ -12,8 +12,7 @@ common = { workspace = true, optional = true } serde = { workspace = true, features = ["derive"] } schemars.workspace = true base64.workspace = true -borsh = { workspace = true, optional = true } [features] # Enable conversion to/from NSSA core types -convert = ["dep:nssa_core", "dep:nssa", "dep:common", "dep:borsh"] +convert = ["dep:nssa_core", "dep:nssa", "dep:common"] diff --git a/indexer/service/src/mock_service.rs b/indexer/service/src/mock_service.rs index d4f430a7..df72c609 100644 --- a/indexer/service/src/mock_service.rs +++ b/indexer/service/src/mock_service.rs @@ -185,7 +185,7 @@ impl indexer_service_rpc::RpcServer for MockIndexerService { .last() .map(|bl| bl.header.block_id) .ok_or_else(|| { - ErrorObjectOwned::owned(-32001, format!("Last block not found"), None::<()>) + ErrorObjectOwned::owned(-32001, "Last block not found".to_string(), None::<()>) }) } diff --git a/indexer/service/src/service.rs b/indexer/service/src/service.rs index 7fd7e1f7..ac02fd27 100644 --- a/indexer/service/src/service.rs +++ b/indexer/service/src/service.rs @@ -50,76 +50,52 @@ impl indexer_service_rpc::RpcServer for IndexerService { async fn get_last_finalized_block_id(&self) -> Result { self.indexer.store.get_last_block_id().map_err(|err| { - ErrorObjectOwned::owned(-32001, format!("DBError"), Some(format!("{err:#?}"))) + ErrorObjectOwned::owned(-32001, "DBError".to_string(), Some(format!("{err:#?}"))) }) } async fn get_block_by_id(&self, block_id: BlockId) -> Result { - self.indexer + Ok(self + .indexer .store .get_block_at_id(block_id) .map_err(|err| { - ErrorObjectOwned::owned(-32001, format!("DBError"), Some(format!("{err:#?}"))) + ErrorObjectOwned::owned(-32001, "DBError".to_string(), Some(format!("{err:#?}"))) })? - .try_into() - .map_err(|err| { - ErrorObjectOwned::owned( - -32000, - format!("Conversion error"), - Some(format!("{err:#?}")), - ) - }) + .into()) } async fn get_block_by_hash(&self, block_hash: HashType) -> Result { - self.indexer + Ok(self + .indexer .store .get_block_by_hash(block_hash.0) .map_err(|err| { - ErrorObjectOwned::owned(-32001, format!("DBError"), Some(format!("{err:#?}"))) + ErrorObjectOwned::owned(-32001, "DBError".to_string(), Some(format!("{err:#?}"))) })? - .try_into() - .map_err(|err| { - ErrorObjectOwned::owned( - -32000, - format!("Conversion error"), - Some(format!("{err:#?}")), - ) - }) + .into()) } async fn get_account(&self, account_id: AccountId) -> Result { - self.indexer + Ok(self + .indexer .store .get_account_final(&account_id.into()) .map_err(|err| { - ErrorObjectOwned::owned(-32001, format!("DBError"), Some(format!("{err:#?}"))) + ErrorObjectOwned::owned(-32001, "DBError".to_string(), Some(format!("{err:#?}"))) })? - .try_into() - .map_err(|err| { - ErrorObjectOwned::owned( - -32000, - format!("Conversion error"), - Some(format!("{err:#?}")), - ) - }) + .into()) } async fn get_transaction(&self, tx_hash: HashType) -> Result { - self.indexer + Ok(self + .indexer .store .get_transaction_by_hash(tx_hash.0) .map_err(|err| { - ErrorObjectOwned::owned(-32001, format!("DBError"), Some(format!("{err:#?}"))) + ErrorObjectOwned::owned(-32001, "DBError".to_string(), Some(format!("{err:#?}"))) })? - .try_into() - .map_err(|err| { - ErrorObjectOwned::owned( - -32000, - format!("Conversion error"), - Some(format!("{err:#?}")), - ) - }) + .into()) } async fn get_blocks(&self, offset: u32, limit: u32) -> Result, ErrorObjectOwned> { @@ -128,19 +104,13 @@ impl indexer_service_rpc::RpcServer for IndexerService { .store .get_block_batch(offset as u64, limit as u64) .map_err(|err| { - ErrorObjectOwned::owned(-32001, format!("DBError"), Some(format!("{err:#?}"))) + ErrorObjectOwned::owned(-32001, "DBError".to_string(), Some(format!("{err:#?}"))) })?; let mut block_res = vec![]; for block in blocks { - block_res.push(block.try_into().map_err(|err| { - ErrorObjectOwned::owned( - -32000, - format!("Conversion error"), - Some(format!("{err:#?}")), - ) - })?) + block_res.push(block.into()) } Ok(block_res) @@ -157,19 +127,13 @@ impl indexer_service_rpc::RpcServer for IndexerService { .store .get_transactions_by_account(account_id.value, offset as u64, limit as u64) .map_err(|err| { - ErrorObjectOwned::owned(-32001, format!("DBError"), Some(format!("{err:#?}"))) + ErrorObjectOwned::owned(-32001, "DBError".to_string(), Some(format!("{err:#?}"))) })?; let mut tx_res = vec![]; for tx in transactions { - tx_res.push(tx.try_into().map_err(|err| { - ErrorObjectOwned::owned( - -32000, - format!("Conversion error"), - Some(format!("{err:#?}")), - ) - })?) + tx_res.push(tx.into()) } Ok(tx_res) @@ -178,7 +142,7 @@ impl indexer_service_rpc::RpcServer for IndexerService { async fn healthcheck(&self) -> Result<(), ErrorObjectOwned> { // Checking, that indexer can calculate last state let _ = self.indexer.store.final_state().map_err(|err| { - ErrorObjectOwned::owned(-32001, format!("DBError"), Some(format!("{err:#?}"))) + ErrorObjectOwned::owned(-32001, "DBError".to_string(), Some(format!("{err:#?}"))) })?; Ok(()) diff --git a/integration_tests/Cargo.toml b/integration_tests/Cargo.toml index d54b2eb0..5fbbae07 100644 --- a/integration_tests/Cargo.toml +++ b/integration_tests/Cargo.toml @@ -13,8 +13,6 @@ wallet.workspace = true common.workspace = true key_protocol.workspace = true indexer_service.workspace = true -indexer_core.workspace = true -wallet-ffi.workspace = true serde_json.workspace = true token_core.workspace = true indexer_service_rpc.workspace = true @@ -23,12 +21,10 @@ url.workspace = true anyhow.workspace = true env_logger.workspace = true log.workspace = true -actix-web.workspace = true base64.workspace = true tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } hex.workspace = true tempfile.workspace = true borsh.workspace = true futures.workspace = true -rand.workspace = true testcontainers = { version = "0.26.3", features = ["docker-compose"] } diff --git a/integration_tests/tests/indexer.rs b/integration_tests/tests/indexer.rs index 5569c167..a000182d 100644 --- a/integration_tests/tests/indexer.rs +++ b/integration_tests/tests/indexer.rs @@ -2,7 +2,10 @@ use std::time::Duration; use anyhow::{Context, Result}; use indexer_service_rpc::RpcClient; -use integration_tests::{TIME_TO_WAIT_FOR_BLOCK_SECONDS, TestContext, format_private_account_id, format_public_account_id, verify_commitment_is_in_state}; +use integration_tests::{ + TIME_TO_WAIT_FOR_BLOCK_SECONDS, TestContext, format_private_account_id, + format_public_account_id, verify_commitment_is_in_state, +}; use log::info; use nssa::AccountId; use tokio::test; @@ -71,7 +74,7 @@ async fn indexer_block_batching() -> Result<()> { info!("Block {} chain-consistent", block.header.block_id); prev_block_hash = block.header.hash; - } + } Ok(()) } @@ -143,18 +146,28 @@ async fn indexer_state_consistency() -> Result<()> { info!("Waiting for indexer to parse blocks"); tokio::time::sleep(std::time::Duration::from_millis(L2_TO_L1_TIMEOUT_MILLIS)).await; - let acc1_ind_state = ctx.indexer_client().get_account(ctx.existing_public_accounts()[0].into()).await.unwrap(); - let acc2_ind_state = ctx.indexer_client().get_account(ctx.existing_public_accounts()[1].into()).await.unwrap(); + let acc1_ind_state = ctx + .indexer_client() + .get_account(ctx.existing_public_accounts()[0].into()) + .await + .unwrap(); + let acc2_ind_state = ctx + .indexer_client() + .get_account(ctx.existing_public_accounts()[1].into()) + .await + .unwrap(); info!("Checking correct state transition"); let acc1_seq_state = ctx .sequencer_client() .get_account(ctx.existing_public_accounts()[0]) - .await?.account; + .await? + .account; let acc2_seq_state = ctx .sequencer_client() .get_account(ctx.existing_public_accounts()[1]) - .await?.account; + .await? + .account; assert_eq!(acc1_ind_state, acc1_seq_state.into()); assert_eq!(acc2_ind_state, acc2_seq_state.into()); diff --git a/nssa/core/Cargo.toml b/nssa/core/Cargo.toml index 92c6fefe..93f2a4a8 100644 --- a/nssa/core/Cargo.toml +++ b/nssa/core/Cargo.toml @@ -13,7 +13,6 @@ thiserror.workspace = true bytemuck.workspace = true base58.workspace = true k256 = { workspace = true, optional = true } -anyhow = { workspace = true, optional = true } chacha20 = { version = "0.9", default-features = false } [dev-dependencies] @@ -21,4 +20,4 @@ serde_json.workspace = true [features] default = [] -host = ["dep:k256", "dep:anyhow"] +host = ["dep:k256"] diff --git a/sequencer_core/Cargo.toml b/sequencer_core/Cargo.toml index 66479984..870e22df 100644 --- a/sequencer_core/Cargo.toml +++ b/sequencer_core/Cargo.toml @@ -23,7 +23,6 @@ tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } logos-blockchain-key-management-system-service.workspace = true logos-blockchain-core.workspace = true rand.workspace = true -reqwest.workspace = true borsh.workspace = true url.workspace = true jsonrpsee = { workspace = true, features = ["ws-client"] } diff --git a/sequencer_runner/Cargo.toml b/sequencer_runner/Cargo.toml index 2780f4c9..04861c7f 100644 --- a/sequencer_runner/Cargo.toml +++ b/sequencer_runner/Cargo.toml @@ -8,7 +8,6 @@ license = { workspace = true } common.workspace = true sequencer_core = { workspace = true, features = ["testnet"] } sequencer_rpc.workspace = true -indexer_service_protocol.workspace = true indexer_service_rpc = { workspace = true, features = ["client"] } clap = { workspace = true, features = ["derive", "env"] } diff --git a/storage/src/indexer.rs b/storage/src/indexer.rs index 526bc132..ea98155b 100644 --- a/storage/src/indexer.rs +++ b/storage/src/indexer.rs @@ -932,7 +932,7 @@ mod tests { assert_eq!(last_id, 1); assert_eq!(first_id, 1); - assert_eq!(is_first_set, true); + assert!(is_first_set); assert_eq!(last_br_id, 0); assert_eq!(last_block.header.hash, genesis_block().header.hash); assert_eq!( @@ -969,7 +969,7 @@ mod tests { assert_eq!(last_id, 2); assert_eq!(first_id, 1); - assert_eq!(is_first_set, true); + assert!(is_first_set); assert_eq!(last_br_id, 0); assert_ne!(last_block.header.hash, genesis_block().header.hash); assert_eq!( @@ -1014,7 +1014,7 @@ mod tests { assert_eq!(last_id, 100); assert_eq!(first_id, 1); - assert_eq!(is_first_set, true); + assert!(is_first_set); assert_eq!(last_br_id, 1); assert_ne!(last_block.header.hash, genesis_block().header.hash); assert_eq!(