fix: some ci fix

This commit is contained in:
Pravdyvy 2026-02-10 15:54:57 +02:00
parent 92d254b66e
commit c3aa3a5495
14 changed files with 54 additions and 101 deletions

9
Cargo.lock generated
View File

@ -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",

View File

@ -38,10 +38,10 @@ impl From<nssa::PrivacyPreservingTransaction> for NSSATransaction {
impl NSSATransaction {
pub fn affected_public_account_ids(&self) -> Vec<AccountId> {
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(),
}
}
}

View File

@ -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<Block> {
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(

View File

@ -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

View File

@ -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"

View File

@ -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"]

View File

@ -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::<()>)
})
}

View File

@ -50,76 +50,52 @@ impl indexer_service_rpc::RpcServer for IndexerService {
async fn get_last_finalized_block_id(&self) -> Result<BlockId, ErrorObjectOwned> {
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<Block, ErrorObjectOwned> {
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<Block, ErrorObjectOwned> {
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<Account, ErrorObjectOwned> {
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<Transaction, ErrorObjectOwned> {
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<Vec<Block>, 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(())

View File

@ -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"] }

View File

@ -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());

View File

@ -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"]

View File

@ -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"] }

View File

@ -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"] }

View File

@ -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!(