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

tari-project / tari / 16933396277

13 Aug 2025 09:35AM UTC coverage: 54.463% (+0.2%) from 54.254%
16933396277

push

github

web-flow
feat: add seed peer exclusion to the proactive dialer (#7396)

Description
---
Added seed peer exclusion to proactive dialing when selecting available
candidates from the peer_db.

Motivation and Context
---
Seed peers are known entities; they have been dialled during initial
seed_strap, and a well-connected network should try to learn about and
connect to other peers as well.

How Has This Been Tested?
---
System-level testing.

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

* **Bug Fixes**
* Improved connection management by excluding seed peers from proactive
dialing candidates, enhancing network stability and reducing unnecessary
connection attempts and failed dials.

* **Documentation**
* Added a brief doc comment describing how to retrieve the list of seed
peers.

* **Tests**
* Expanded test coverage to validate discovery and syncing behavior when
seed peers are present and when filtering by external addresses.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

41 of 42 new or added lines in 3 files covered. (97.62%)

1673 existing lines in 28 files now uncovered.

76415 of 140305 relevant lines covered (54.46%)

194087.6 hits per line

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

0.0
/base_layer/core/src/proof_of_work/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

23
use thiserror::Error;
24

25
#[cfg(feature = "base_node")]
26
use crate::proof_of_work::monero_rx::MergeMineError;
27
use crate::{
28
    common::{BanPeriod, BanReason},
29
    proof_of_work::Difficulty,
30
};
31

32
/// Errors that can occur when validating a proof of work
33
#[derive(Debug, Error)]
34
pub enum PowError {
35
    #[error("ProofOfWorkFailed")]
36
    InvalidProofOfWork,
37
    #[error("Achieved difficulty is below the minimum")]
38
    AchievedDifficultyBelowMin,
39
    #[error("Proof of work data must be empty for Sha3 blocks")]
40
    Sha3HeaderNonEmptyPowBytes,
41
    #[error("Proof of work data is too long. Max allowed is 32 bytes")]
42
    RandomxTPowDataTooLong,
43
    #[error("Target difficulty {target} not achieved. Achieved difficulty: {achieved}")]
44
    AchievedDifficultyTooLow { target: Difficulty, achieved: Difficulty },
45
    #[error("Invalid target difficulty (expected: {expected}, got: {got})")]
46
    InvalidTargetDifficulty { expected: Difficulty, got: Difficulty },
47
    #[cfg(feature = "base_node")]
48
    #[error("Invalid merge mining data or operation: {0}")]
49
    MergeMineError(#[from] MergeMineError),
50
    #[error("Cuckaroo proof of work data size mismatch (expected: {expected}, got: {actual})")]
51
    CuckarooPowDataSizeMismatch { expected: usize, actual: usize },
52
    #[error("Cuckaroo proof of work data has non-zero padding (padding: {padding})")]
53
    CuckarooPowDataNonZeroPadding { padding: u8 },
54
}
55

56
impl PowError {
57
    pub fn get_ban_reason(&self) -> Option<BanReason> {
×
58
        match self {
×
59
            err @ PowError::InvalidProofOfWork |
×
60
            err @ PowError::AchievedDifficultyBelowMin |
×
61
            err @ PowError::Sha3HeaderNonEmptyPowBytes |
×
62
            err @ PowError::RandomxTPowDataTooLong |
×
63
            err @ PowError::AchievedDifficultyTooLow { .. } |
×
UNCOV
64
            err @ PowError::CuckarooPowDataSizeMismatch { .. } |
×
65
            err @ PowError::CuckarooPowDataNonZeroPadding { .. } |
×
UNCOV
66
            err @ PowError::InvalidTargetDifficulty { .. } => Some(BanReason {
×
67
                reason: err.to_string(),
×
UNCOV
68
                ban_duration: BanPeriod::Long,
×
UNCOV
69
            }),
×
70
            #[cfg(feature = "base_node")]
UNCOV
71
            PowError::MergeMineError(e) => e.get_ban_reason(),
×
72
        }
UNCOV
73
    }
×
74
}
75

76
/// Errors that can occur when adjusting the difficulty
77
#[derive(Debug, Error, Clone, PartialEq, Eq)]
78
pub enum DifficultyAdjustmentError {
79
    #[error("Accumulated difficulty values can only strictly increase")]
80
    DecreasingAccumulatedDifficulty,
81
    #[error("Other difficulty algorithm error")]
82
    Other,
83
}
84

85
/// Errors that can occur when converting a difficulty
86
#[derive(Debug, Error, PartialEq, Eq)]
87
pub enum DifficultyError {
88
    #[error("Difficulty conversion less than the minimum difficulty")]
89
    InvalidDifficulty,
90
    #[error("Maximum block time overflowed u64")]
91
    MaxBlockTimeOverflow,
92
    #[error("Divide by zero")]
93
    DivideByZero,
94
    #[error("Overflow")]
95
    Overflow,
96
}
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