From 6e61698ff835b7404e2ebaa496beca23850938ac Mon Sep 17 00:00:00 2001 From: Pravdyvy Date: Thu, 26 Feb 2026 13:46:38 +0200 Subject: [PATCH] fix: complete fixes --- .github/workflows/ci.yml | 2 +- Cargo.lock | 1 - .../src/components/transaction_preview.rs | 14 ++-- explorer_service/src/pages/main_page.rs | 2 +- .../src/pages/transaction_page.rs | 40 +++++++++-- indexer/core/src/block_store.rs | 12 +++- indexer/core/src/lib.rs | 1 - indexer/core/src/state.rs | 9 --- indexer/service/protocol/Cargo.toml | 1 - indexer/service/protocol/src/lib.rs | 72 +------------------ 10 files changed, 55 insertions(+), 99 deletions(-) delete mode 100644 indexer/core/src/state.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce9903b5..990ccdef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -158,7 +158,7 @@ jobs: valid-proof-test: runs-on: ubuntu-latest - timeout-minutes: 60 + timeout-minutes: 90 steps: - uses: actions/checkout@v5 with: diff --git a/Cargo.lock b/Cargo.lock index 7d240a64..1baf7d84 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3770,7 +3770,6 @@ dependencies = [ "schemars 1.2.1", "serde", "serde_with", - "sha2", ] [[package]] diff --git a/explorer_service/src/components/transaction_preview.rs b/explorer_service/src/components/transaction_preview.rs index 7fc98e77..68c1e86e 100644 --- a/explorer_service/src/components/transaction_preview.rs +++ b/explorer_service/src/components/transaction_preview.rs @@ -19,12 +19,14 @@ pub fn TransactionPreview(transaction: Transaction) -> impl IntoView { let (type_name, type_class) = transaction_type_info(&transaction); // Get additional metadata based on transaction type - let affected_pub_account_ids = transaction - .affected_public_account_ids(); - let metadata = match &transaction { - Transaction::Public(_) => { - format!("{} accounts involved", affected_pub_account_ids.len()) + Transaction::Public(tx) => { + let indexer_service_protocol::PublicTransaction { + hash: _, + message, + witness_set: _, + } = tx; + format!("{} accounts involved", message.account_ids.len()) } Transaction::PrivacyPreserving(tx) => { let indexer_service_protocol::PrivacyPreservingTransaction { @@ -34,7 +36,7 @@ pub fn TransactionPreview(transaction: Transaction) -> impl IntoView { } = tx; format!( "{} public accounts, {} commitments", - affected_pub_account_ids.len(), + message.public_account_ids.len(), message.new_commitments.len() ) } diff --git a/explorer_service/src/pages/main_page.rs b/explorer_service/src/pages/main_page.rs index 3f6ec808..3cfb832d 100644 --- a/explorer_service/src/pages/main_page.rs +++ b/explorer_service/src/pages/main_page.rs @@ -47,7 +47,7 @@ pub fn MainPage() -> impl IntoView { Ok(last_id) => { api::get_blocks( std::cmp::max(last_id.saturating_sub(RECENT_BLOCKS_LIMIT) as u32, 1), - RECENT_BLOCKS_LIMIT as u32, + (RECENT_BLOCKS_LIMIT + 1) as u32, ) .await } diff --git a/explorer_service/src/pages/transaction_page.rs b/explorer_service/src/pages/transaction_page.rs index 8ab33ff9..2859719f 100644 --- a/explorer_service/src/pages/transaction_page.rs +++ b/explorer_service/src/pages/transaction_page.rs @@ -67,7 +67,6 @@ pub fn TransactionPage() -> impl IntoView { { - let affected_pub_acc_ids = tx.affected_public_account_ids(); match tx { Transaction::Public(ptx) => { let PublicTransaction { @@ -77,7 +76,7 @@ pub fn TransactionPage() -> impl IntoView { } = ptx; let PublicMessage { program_id, - account_ids: _, + account_ids, nonces, instruction_data, } = message; @@ -116,7 +115,7 @@ pub fn TransactionPage() -> impl IntoView {

"Accounts"

- {affected_pub_acc_ids + {account_ids .into_iter() .zip_longest(nonces.into_iter()) .map(|maybe_pair| { @@ -221,9 +220,11 @@ pub fn TransactionPage() -> impl IntoView {
{public_account_ids .into_iter() - .zip(nonces.into_iter()) - .map(|(account_id, nonce)| { - let account_id_str = account_id.to_string(); + .zip_longest(nonces.into_iter()) + .map(|maybe_pair| { + match maybe_pair { + EitherOrBoth::Both(account_id, nonce) => { + let account_id_str = account_id.to_string(); view! { } + } + EitherOrBoth::Left(account_id) => { + let account_id_str = account_id.to_string(); + view! { + + } + } + EitherOrBoth::Right(_) => { + view! { + + } + } + } }) .collect::>()}
diff --git a/indexer/core/src/block_store.rs b/indexer/core/src/block_store.rs index 496d0bf3..2c1e960c 100644 --- a/indexer/core/src/block_store.rs +++ b/indexer/core/src/block_store.rs @@ -1,7 +1,10 @@ use std::{path::Path, sync::Arc}; use anyhow::Result; -use common::{block::Block, transaction::NSSATransaction}; +use common::{ + block::{BedrockStatus, Block}, + transaction::NSSATransaction, +}; use nssa::{Account, AccountId, V02State}; use storage::indexer::RocksDBIO; @@ -92,7 +95,7 @@ impl IndexerStore { Ok(self.final_state()?.get_account_by_id(*account_id)) } - pub fn put_block(&self, block: Block) -> Result<()> { + pub fn put_block(&self, mut block: Block) -> Result<()> { let mut final_state = self.dbio.final_state()?; for transaction in &block.body.transactions { @@ -102,6 +105,11 @@ impl IndexerStore { .execute_check_on_state(&mut final_state)?; } + // ToDo: Currently we are fetching only finalized blocks + // if it changes, the following lines need to be updated + // to represent correct block finality + block.bedrock_status = BedrockStatus::Finalized; + Ok(self.dbio.put_block(block)?) } } diff --git a/indexer/core/src/lib.rs b/indexer/core/src/lib.rs index 0497e68a..3111be6d 100644 --- a/indexer/core/src/lib.rs +++ b/indexer/core/src/lib.rs @@ -14,7 +14,6 @@ use crate::{block_store::IndexerStore, config::IndexerConfig}; pub mod block_store; pub mod config; -pub mod state; #[derive(Clone)] pub struct IndexerCore { diff --git a/indexer/core/src/state.rs b/indexer/core/src/state.rs deleted file mode 100644 index bd05971f..00000000 --- a/indexer/core/src/state.rs +++ /dev/null @@ -1,9 +0,0 @@ -use std::sync::Arc; - -use tokio::sync::RwLock; - -#[derive(Debug, Clone)] -pub struct IndexerState { - // Only one field for now, for testing. - pub latest_seen_block: Arc>, -} diff --git a/indexer/service/protocol/Cargo.toml b/indexer/service/protocol/Cargo.toml index 2f787d2d..f9a3c2ad 100644 --- a/indexer/service/protocol/Cargo.toml +++ b/indexer/service/protocol/Cargo.toml @@ -16,7 +16,6 @@ base64.workspace = true base58.workspace = true hex.workspace = true anyhow.workspace = true -sha2.workspace = true [features] # Enable conversion to/from NSSA core types diff --git a/indexer/service/protocol/src/lib.rs b/indexer/service/protocol/src/lib.rs index f13a51c5..47dc20cc 100644 --- a/indexer/service/protocol/src/lib.rs +++ b/indexer/service/protocol/src/lib.rs @@ -3,14 +3,13 @@ //! Currently it mostly mimics types from `nssa_core`, but it's important to have a separate crate //! to define a stable interface for the indexer service RPCs which evolves in its own way. -use std::{collections::HashSet, fmt::Display, str::FromStr}; +use std::{fmt::Display, str::FromStr}; use anyhow::anyhow; use base58::{FromBase58 as _, ToBase58 as _}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use serde_with::{DeserializeFromStr, SerializeDisplay}; -use sha2::{Digest, Sha256}; #[cfg(feature = "convert")] mod convert; @@ -54,18 +53,6 @@ pub struct AccountId { pub value: [u8; 32], } -impl From<&PublicKey> for AccountId { - fn from(key: &PublicKey) -> Self { - const PUBLIC_ACCOUNT_ID_PREFIX: &[u8; 32] = - b"/LEE/v0.3/AccountId/Public/\x00\x00\x00\x00\x00"; - - let mut hasher = Sha256::new(); - hasher.update(PUBLIC_ACCOUNT_ID_PREFIX); - hasher.update(key.0); - Self{ value: hasher.finalize().into()} - } -} - impl Display for AccountId { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.value.to_base58()) @@ -161,15 +148,6 @@ impl Transaction { Transaction::ProgramDeployment(tx) => &tx.hash, } } - - /// Get affected public account ids - pub fn affected_public_account_ids(&self) -> Vec { - match self { - Transaction::Public(tx) => tx.affected_public_account_ids(), - Transaction::PrivacyPreserving(tx) => tx.affected_public_account_ids(), - Transaction::ProgramDeployment(tx) => tx.affected_public_account_ids(), - } - } } #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)] @@ -179,28 +157,6 @@ pub struct PublicTransaction { pub witness_set: WitnessSet, } -impl PublicTransaction { - - - pub(crate) fn signer_account_ids(&self) -> Vec { - self.witness_set - .signatures_and_public_keys() - .iter() - .map(|(_, public_key)| AccountId::from(public_key)) - .collect() - } - - pub fn affected_public_account_ids(&self) -> Vec { - let mut acc_set = self - .signer_account_ids() - .into_iter() - .collect::>(); - acc_set.extend(&self.message.account_ids); - - acc_set.into_iter().collect() - } -} - #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)] pub struct PrivacyPreservingTransaction { pub hash: HashType, @@ -208,26 +164,6 @@ pub struct PrivacyPreservingTransaction { pub witness_set: WitnessSet, } -impl PrivacyPreservingTransaction { - pub(crate) fn signer_account_ids(&self) -> Vec { - self.witness_set - .signatures_and_public_keys() - .iter() - .map(|(_, public_key)| AccountId::from(public_key)) - .collect() - } - - pub fn affected_public_account_ids(&self) -> Vec { - let mut acc_set = self - .signer_account_ids() - .into_iter() - .collect::>(); - acc_set.extend(&self.message.public_account_ids); - - acc_set.into_iter().collect() - } -} - #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)] pub struct PublicMessage { pub program_id: ProgramId, @@ -280,12 +216,6 @@ pub struct ProgramDeploymentTransaction { pub message: ProgramDeploymentMessage, } -impl ProgramDeploymentTransaction { - pub fn affected_public_account_ids(&self) -> Vec { - vec![] - } -} - pub type ViewTag = u8; #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]