fix: complete fixes

This commit is contained in:
Pravdyvy 2026-02-26 13:46:38 +02:00
parent b2ae6317d2
commit 6e61698ff8
10 changed files with 55 additions and 99 deletions

View File

@ -158,7 +158,7 @@ jobs:
valid-proof-test:
runs-on: ubuntu-latest
timeout-minutes: 60
timeout-minutes: 90
steps:
- uses: actions/checkout@v5
with:

1
Cargo.lock generated
View File

@ -3770,7 +3770,6 @@ dependencies = [
"schemars 1.2.1",
"serde",
"serde_with",
"sha2",
]
[[package]]

View File

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

View File

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

View File

@ -67,7 +67,6 @@ pub fn TransactionPage() -> impl IntoView {
</div>
{
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 {
<h3>"Accounts"</h3>
<div class="accounts-list">
{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 {
<div class="accounts-list">
{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! {
<div class="account-item">
<A href=format!("/account/{}", account_id_str)>
@ -234,6 +235,33 @@ pub fn TransactionPage() -> impl IntoView {
</span>
</div>
}
}
EitherOrBoth::Left(account_id) => {
let account_id_str = account_id.to_string();
view! {
<div class="account-item">
<A href=format!("/account/{}", account_id_str)>
<span class="hash">{account_id_str}</span>
</A>
<span class="nonce">
" (nonce: "{"Not affected by this transaction".to_string()}" )"
</span>
</div>
}
}
EitherOrBoth::Right(_) => {
view! {
<div class="account-item">
<A href=format!("/account/{}", "Account not found")>
<span class="hash">{"Account not found"}</span>
</A>
<span class="nonce">
" (nonce: "{"Account not found".to_string()}" )"
</span>
</div>
}
}
}
})
.collect::<Vec<_>>()}
</div>

View File

@ -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)?)
}
}

View File

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

View File

@ -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<RwLock<u64>>,
}

View File

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

View File

@ -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<AccountId> {
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<AccountId> {
self.witness_set
.signatures_and_public_keys()
.iter()
.map(|(_, public_key)| AccountId::from(public_key))
.collect()
}
pub fn affected_public_account_ids(&self) -> Vec<AccountId> {
let mut acc_set = self
.signer_account_ids()
.into_iter()
.collect::<HashSet<_>>();
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<AccountId> {
self.witness_set
.signatures_and_public_keys()
.iter()
.map(|(_, public_key)| AccountId::from(public_key))
.collect()
}
pub fn affected_public_account_ids(&self) -> Vec<AccountId> {
let mut acc_set = self
.signer_account_ids()
.into_iter()
.collect::<HashSet<_>>();
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<AccountId> {
vec![]
}
}
pub type ViewTag = u8;
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema)]