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

tari-project / tari / 19333426770

13 Nov 2025 01:37PM UTC coverage: 50.497% (-1.0%) from 51.536%
19333426770

push

github

web-flow
feat: add noreadahead to lmdb as config option  (#7581)

Description
---
Added `open::NORDAHEAD` flag to the LMDB builder as config option.

_"**Quote:** Most operating systems perform readahead on read requests
by default. This option turns it off if the OS supports it. Turning it
off may help random read performance when the DB is larger than RAM and
system RAM is full. The option is not implemented on Windows."_

As per LMDB documentation, this might help with the seed nodes' RAM
usage when needed, or for other Linux users.

Motivation and Context
---
See #7578 for background.

How Has This Been Tested?
---
Not tested.

What process can a PR reviewer use to test or verify this change?
---
Code review.

<!-- Checklist -->
<!-- 1. Is the title of your PR in the form that would make nice release
notes? The title, excluding the conventional commit
tag, will be included exactly as is in the CHANGELOG, so please think
about it carefully. -->


Breaking Changes
---

- [x] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [ ] Other - Please specify

<!-- Does this include a breaking change? If so, include this line as a
footer -->
<!-- BREAKING CHANGE: Description what the user should do, e.g. delete a
database, resync the chain -->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added a configuration option to control OS readahead behavior for
database storage; can be disabled for performance tuning (defaults
preserve prior behavior).
* **Chores**
  * Storage initialization now respects the new readahead setting.
* **Tests**
  * Internal tests updated to reflect the new configuration parameter.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

21 of 22 new or added lines in 2 files covered. (95.45%)

1256 existing lines in 34 files now uncovered.

57979 of 114817 relevant lines covered (50.5%)

325976.36 hits per line

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

0.0
/base_layer/core/src/validation/error.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
use tari_common_types::{epoch::VnEpoch, types::HashOutput};
23
use tari_node_components::blocks::{BlockHeaderValidationError, BlockValidationError};
24
use tari_sidechain::SidechainProofValidationError;
25
use tari_transaction_components::{
26
    tari_proof_of_work::{DifficultyError, PowError},
27
    transaction_components::{covenants::CovenantError, OutputType, TransactionError},
28
    validation::AggregatedBodyValidationError,
29
    BanPeriod,
30
    BanReason,
31
};
32
use tari_utilities::ByteArrayError;
33
use thiserror::Error;
34

35
use crate::{
36
    chain_storage::ChainStorageError,
37
    proof_of_work::{cuckaroo_pow::CuckarooVerificationError, monero_rx::MergeMineError},
38
};
39

40
#[derive(Debug, Error)]
41
pub enum ValidationError {
42
    #[error("Serialization failed: {0}")]
43
    SerializationError(String),
44
    #[error("Block header validation failed: {0}")]
45
    BlockHeaderError(#[from] BlockHeaderValidationError),
46
    #[error("Block validation error: {0}")]
47
    BlockError(#[from] BlockValidationError),
48
    #[error("Contains kernels or inputs that are not yet spendable")]
49
    MaturityError,
50
    #[error("The block weight ({actual_weight}) is above the maximum ({max_weight})")]
51
    BlockTooLarge { actual_weight: u64, max_weight: u64 },
52
    #[error("Contains {} unknown inputs", .0.len())]
53
    UnknownInputs(Vec<HashOutput>),
54
    #[error("Contains an unknown input")]
55
    UnknownInput,
56
    #[error("The transaction is invalid: {0}")]
57
    TransactionError(#[from] TransactionError),
58
    #[error("Fatal storage error during validation: {0}")]
59
    FatalStorageError(String),
60
    #[error(
61
        "The total expected supply plus the total accumulated (offset) excess does not equal the sum of all UTXO \
62
         commitments."
63
    )]
64
    InvalidAccountingBalance,
65
    #[error("Transaction contains already spent inputs")]
66
    ContainsSTxO,
67
    #[error("Transaction contains an output commitment that already exists")]
68
    ContainsDuplicateUtxoCommitment,
69
    #[error("Final state validation failed: The UTXO set did not balance with the expected emission at height {0}")]
70
    ChainBalanceValidationFailed(u64),
71
    #[error("The total value + fees of the block exceeds the maximum allowance on chain")]
72
    CoinbaseExceedsMaxLimit,
73
    #[error("Proof of work error: {0}")]
74
    ProofOfWorkError(#[from] PowError),
75
    #[error("Attempted to validate genesis block")]
76
    ValidatingGenesis,
77
    #[error("Duplicate or unsorted input found in block body")]
78
    UnsortedOrDuplicateInput,
79
    #[error("Duplicate or unsorted output found in block body")]
80
    UnsortedOrDuplicateOutput,
81
    #[error("Error in merge mine data:{0}")]
82
    MergeMineError(#[from] MergeMineError),
83
    #[error("Maximum transaction weight exceeded")]
84
    MaxTransactionWeightExceeded,
85
    #[error("Expected block height to be {expected}, but was {block_height}")]
86
    IncorrectHeight { expected: u64, block_height: u64 },
87
    #[error("Expected block previous hash to be {expected}, but was {block_hash}")]
88
    IncorrectPreviousHash { expected: String, block_hash: String },
89
    #[error("Bad block with hash '{hash}' and reason '{reason}' found")]
90
    BadBlockFound { hash: String, reason: String },
91
    #[error("Consensus Error: {0}")]
92
    ConsensusError(String),
93
    #[error("Duplicate kernel Error: {0}")]
94
    DuplicateKernelError(String),
95
    #[error("Covenant failed to validate: {0}")]
96
    CovenantError(#[from] CovenantError),
97
    #[error("Invalid or unsupported blockchain version {version}")]
98
    InvalidBlockchainVersion { version: u16 },
99
    #[error("Contains Invalid Burn: {0}")]
100
    InvalidBurnError(String),
101
    #[error("Validator node registration signature failed verification")]
102
    IncorrectNumberOfTimestampsProvided { expected: u64, actual: u64 },
103
    #[error("Invalid difficulty: {0}")]
104
    DifficultyError(#[from] DifficultyError),
105
    #[error("Invalid Serialized Public key: {0}")]
106
    InvalidSerializedPublicKey(String),
107
    #[error("Sidechain proof invalid: `{0}`")]
108
    SidechainProofInvalid(#[from] SidechainProofValidationError),
109
    #[error("Sidechain eviction proof submitted for unregistered validator {validator_pk}")]
110
    SidechainEvictionProofValidatorNotFound { validator_pk: String },
111
    #[error(
112
        "Sidechain eviction proof invalid: given epoch {epoch} is greater than the epoch at tip height {tip_height}"
113
    )]
114
    SidechainEvictionProofInvalidEpoch { epoch: VnEpoch, tip_height: u64 },
115
    #[error("Validator node already registered: {public_key}")]
116
    ValidatorNodeAlreadyRegistered { public_key: String },
117
    #[error("Validator node {public_key} not registered: {details}")]
118
    ValidatorNodeNotRegistered { public_key: String, details: String },
119
    #[error("Validator registration {public_key} invalid: max epoch {max_epoch} < current epoch {current_epoch}")]
120
    ValidatorNodeRegistrationMaxEpoch {
121
        public_key: String,
122
        current_epoch: VnEpoch,
123
        max_epoch: VnEpoch,
124
    },
125
    #[error("{output_type} output rule disallows the spend: {details}")]
126
    OutputSpendRuleDisallow { output_type: OutputType, details: String },
127
    #[error("Output type '{output_type}' does not match sidechain data")]
128
    OutputTypeNotMatchSidechainData { output_type: OutputType, details: String },
129
    #[error("Validation error: {0}")]
130
    AggregatedBodyValidationError(#[from] AggregatedBodyValidationError),
131
    #[error("Cuckaroo POW error: {0}")]
132
    CuckarooPowError(#[from] CuckarooVerificationError),
133
}
134

135
// ChainStorageError has a ValidationError variant, so to prevent a cyclic dependency we use a string representation in
136
// for storage errors that cause validation failures.
137
impl From<ChainStorageError> for ValidationError {
138
    fn from(err: ChainStorageError) -> Self {
×
139
        Self::FatalStorageError(err.to_string())
×
140
    }
×
141
}
142

143
impl From<ByteArrayError> for ValidationError {
144
    fn from(err: ByteArrayError) -> Self {
×
145
        Self::InvalidSerializedPublicKey(err.to_string())
×
146
    }
×
147
}
148

149
impl ValidationError {
UNCOV
150
    pub fn get_ban_reason(&self) -> Option<BanReason> {
×
UNCOV
151
        match self {
×
152
            ValidationError::ProofOfWorkError(e) => e.get_ban_reason(),
×
153
            err @ ValidationError::SerializationError(_) |
×
154
            err @ ValidationError::BlockHeaderError(_) |
×
155
            err @ ValidationError::BlockError(_) |
×
156
            err @ ValidationError::MaturityError |
×
157
            err @ ValidationError::BlockTooLarge { .. } |
×
158
            err @ ValidationError::UnknownInputs(_) |
×
159
            err @ ValidationError::UnknownInput |
×
160
            err @ ValidationError::TransactionError(_) |
×
161
            err @ ValidationError::InvalidAccountingBalance |
×
162
            err @ ValidationError::ContainsSTxO |
×
163
            err @ ValidationError::ContainsDuplicateUtxoCommitment |
×
164
            err @ ValidationError::ChainBalanceValidationFailed(_) |
×
165
            err @ ValidationError::ValidatingGenesis |
×
166
            err @ ValidationError::UnsortedOrDuplicateInput |
×
167
            err @ ValidationError::UnsortedOrDuplicateOutput |
×
168
            err @ ValidationError::MaxTransactionWeightExceeded |
×
169
            err @ ValidationError::IncorrectHeight { .. } |
×
170
            err @ ValidationError::IncorrectPreviousHash { .. } |
×
171
            err @ ValidationError::BadBlockFound { .. } |
×
UNCOV
172
            err @ ValidationError::ConsensusError(_) |
×
173
            err @ ValidationError::DuplicateKernelError(_) |
×
174
            err @ ValidationError::CovenantError(_) |
×
175
            err @ ValidationError::InvalidBlockchainVersion { .. } |
×
176
            err @ ValidationError::InvalidBurnError(_) |
×
177
            err @ ValidationError::DifficultyError(_) |
×
178
            err @ ValidationError::CoinbaseExceedsMaxLimit |
×
179
            err @ ValidationError::InvalidSerializedPublicKey(_) |
×
180
            err @ ValidationError::SidechainEvictionProofValidatorNotFound { .. } |
×
181
            err @ ValidationError::SidechainProofInvalid(_) |
×
182
            err @ ValidationError::SidechainEvictionProofInvalidEpoch { .. } |
×
183
            err @ ValidationError::ValidatorNodeAlreadyRegistered { .. } |
×
184
            err @ ValidationError::ValidatorNodeNotRegistered { .. } |
×
185
            err @ ValidationError::ValidatorNodeRegistrationMaxEpoch { .. } |
×
186
            err @ ValidationError::OutputTypeNotMatchSidechainData { .. } |
×
187
            err @ ValidationError::AggregatedBodyValidationError(_) |
×
188
            err @ ValidationError::CuckarooPowError(_) |
×
UNCOV
189
            err @ ValidationError::OutputSpendRuleDisallow { .. } => Some(BanReason {
×
UNCOV
190
                reason: err.to_string(),
×
UNCOV
191
                ban_duration: BanPeriod::Long,
×
UNCOV
192
            }),
×
193
            ValidationError::MergeMineError(e) => e.get_ban_reason(),
×
194
            ValidationError::FatalStorageError(_) | ValidationError::IncorrectNumberOfTimestampsProvided { .. } => None,
×
195
        }
UNCOV
196
    }
×
197
}
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