• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tari-project / tari / 15998966652

01 Jul 2025 12:13PM UTC coverage: 71.633% (-0.05%) from 71.686%
15998966652

push

github

web-flow
fix!: payref migration and indexes, add grpc query via output hash (#7266)

Description
---
- Added gRPC method to retrieve output information via output hash
- Updated the gRPC payref search to return spent and unspent output
information
- Added migration to rebuild payref indexes due to missing payrefs
(_added periodic call to `LMDBStore::resize_if_required`_)
- Fixed error in lmdb migration counter where it recorded a higher
version done than what it should

Fixes #7263 

Motivation and Context
---
- Payref information was deleted when the outputs were spent.
- With migrations, payref information was only created for the current
output set, not all outputs.
- Payref lookups for spent outputs were not possible.
- Output and payref information was not possible via output hash.

How Has This Been Tested?
---
- New lmdb migration tested at the system level for fresh and existing
base nodes.
- New gRPC method system-level testing [_tested with block explorer
upgrade_].
- General system-level testing.

Fresh base node with a restart afterwards
```rust
2025-06-27 09:09:24.013840800 [c::cs::lmdb_db::lmdb_db] INFO  [MIGRATIONS] Blockchain database is at v0 (required version: 5)
2025-06-27 09:09:24.013873800 [c::cs::lmdb_db::lmdb_db] INFO  [MIGRATIONS] v1: No accumulated difficulty found for block height 14999
2025-06-27 09:09:24.013877800 [c::cs::lmdb_db::lmdb_db] INFO  [MIGRATIONS] v1: No migration to perform for version network
2025-06-27 09:09:24.013883100 [c::cs::lmdb_db::lmdb_db] INFO  [MIGRATIONS] v2: Starting PayRef migration
2025-06-27 09:09:24.013899700 [c::cs::lmdb_db::lmdb_db] INFO  [MIGRATIONS] v2: Cleared PayRef index
2025-06-27 09:09:24.038671500 [c::cs::lmdb_db::lmdb_db] INFO  [MIGRATIONS] v2: PayRef index rebuild completed
2025-06-27 09:09:24.038693200 [c::cs::lmdb_db::lmdb_db] INFO  [MIGRATIONS] Migrated database from version 2 to version 3
2025-06-27 09:09:24.039646900 [c::cs::lmdb_db::lmdb_db] INFO  [MIGRATIONS] Migrated database from ver... (continued)

24 of 136 new or added lines in 11 files covered. (17.65%)

68 existing lines in 17 files now uncovered.

82832 of 115634 relevant lines covered (71.63%)

239334.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/base_layer/core/src/base_node/comms_interface/comms_response.rs
1
// Copyright 2019. The Tari Project
2
//
3
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
4
// following conditions are met:
5
//
6
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
7
// disclaimer.
8
//
9
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
10
// following disclaimer in the documentation and/or other materials provided with the distribution.
11
//
12
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
13
// products derived from this software without specific prior written permission.
14
//
15
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
16
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
20
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
21
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22

23
use std::{
24
    fmt::{self, Display, Formatter},
25
    sync::Arc,
26
};
27

28
use tari_common_types::{
29
    chain_metadata::ChainMetadata,
30
    types::{CompressedPublicKey, FixedHash, HashOutput, PrivateKey},
31
};
32

33
use crate::{
34
    blocks::{Block, ChainHeader, HistoricalBlock, NewBlockTemplate},
35
    chain_storage::{InputMinedInfo, MinedInfo, OutputMinedInfo, TemplateRegistrationEntry},
36
    proof_of_work::Difficulty,
37
    transactions::transaction_components::{Transaction, TransactionKernel, TransactionOutput},
38
};
39

40
/// API Response enum
41
#[allow(clippy::large_enum_variant)]
42
#[derive(Debug, Clone)]
43
pub enum NodeCommsResponse {
44
    ChainMetadata(ChainMetadata),
45
    TransactionKernels(Vec<TransactionKernel>),
46
    BlockHeaders(Vec<ChainHeader>),
47
    BlockHeader(Option<ChainHeader>),
48
    Block(Box<Option<Block>>),
49
    TransactionOutputs(Vec<TransactionOutput>),
50
    HistoricalBlocks(Vec<HistoricalBlock>),
51
    HistoricalBlock(Box<Option<HistoricalBlock>>),
52
    NewBlockTemplate(NewBlockTemplate),
53
    NewBlock {
54
        success: bool,
55
        error: Option<String>,
56
        block: Option<Block>,
57
    },
58
    TargetDifficulty(Difficulty),
59
    MmrNodes(Vec<HashOutput>, Vec<u8>),
60
    FetchMempoolTransactionsByExcessSigsResponse(FetchMempoolTransactionsResponse),
61
    FetchValidatorNodesKeysResponse(Vec<(CompressedPublicKey, [u8; 32])>),
62
    GetShardKeyResponse(Option<[u8; 32]>),
63
    FetchTemplateRegistrationsResponse(Vec<TemplateRegistrationEntry>),
64
    OutputMinedInfo(Option<OutputMinedInfo>),
65
    MinedInfo(MinedInfo),
66
    InputMinedInfo(Option<InputMinedInfo>),
67
    PayRef(Option<FixedHash>),
68
}
69

70
impl Display for NodeCommsResponse {
71
    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
×
72
        #[allow(clippy::enum_glob_use)]
73
        use NodeCommsResponse::*;
74
        match self {
×
75
            ChainMetadata(_) => write!(f, "ChainMetadata"),
×
76
            TransactionKernels(_) => write!(f, "TransactionKernel"),
×
77
            BlockHeaders(_) => write!(f, "BlockHeaders"),
×
78
            BlockHeader(_) => write!(f, "BlockHeader"),
×
79
            Block(_) => write!(f, "Block"),
×
80
            HistoricalBlock(_) => write!(f, "HistoricalBlock"),
×
81
            TransactionOutputs(_) => write!(f, "TransactionOutputs"),
×
82
            HistoricalBlocks(_) => write!(f, "HistoricalBlocks"),
×
83
            NewBlockTemplate(_) => write!(f, "NewBlockTemplate"),
×
84
            NewBlock {
85
                success,
×
86
                error,
×
87
                block: _,
×
88
            } => write!(
×
89
                f,
×
90
                "NewBlock({},{},...)",
×
91
                success,
×
92
                error.as_ref().unwrap_or(&"Unspecified".to_string())
×
93
            ),
×
94
            TargetDifficulty(_) => write!(f, "TargetDifficulty"),
×
95
            MmrNodes(_, _) => write!(f, "MmrNodes"),
×
96
            FetchMempoolTransactionsByExcessSigsResponse(resp) => write!(
×
97
                f,
×
98
                "FetchMempoolTransactionsByExcessSigsResponse({} transaction(s), {} not found)",
×
99
                resp.transactions.len(),
×
100
                resp.not_found.len()
×
101
            ),
×
102
            FetchValidatorNodesKeysResponse(_) => write!(f, "FetchValidatorNodesKeysResponse"),
×
103
            GetShardKeyResponse(_) => write!(f, "GetShardKeyResponse"),
×
104
            FetchTemplateRegistrationsResponse(_) => write!(f, "FetchTemplateRegistrationsResponse"),
×
105
            OutputMinedInfo(_) => write!(f, "OutputMinedInfo"),
×
NEW
106
            MinedInfo(_) => write!(f, "MinedInfo"),
×
UNCOV
107
            InputMinedInfo(_) => write!(f, "InputMinedInfo"),
×
NEW
108
            PayRef(_) => write!(f, "PayRef"),
×
109
        }
110
    }
×
111
}
112

113
/// Container struct for mempool transaction responses
114
#[derive(Debug, Clone)]
115
pub struct FetchMempoolTransactionsResponse {
116
    pub transactions: Vec<Arc<Transaction>>,
117
    pub not_found: Vec<PrivateKey>,
118
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc