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

tari-project / tari / 15983436312

30 Jun 2025 08:52PM UTC coverage: 71.686% (-0.2%) from 71.908%
15983436312

push

github

web-flow
feat: auto zero value coinbase reward calculation (#7259)

Description
---
This adds way to auto use correct (max) coinbase value in case you pass
single coinbase with zero value.

Motivation and Context
---
This is hard to guess correct coinbase value to pass its check in
GetNewBlockWithCoinbases and GetNewBlockTemplateWithCoinbases GRPC
methods.

How Has This Been Tested?
---
Tested as part of RandomX-T pool implementation. Will add new
integration tests to this PR but I was not able to run them locally
since I can't find seed node setup environment.

What process can a PR reviewer use to test or verify this change?
---
Run new integration scenario: Verify gprc can create block with zero
value coinbase

<!-- 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 handling of blocks with a single zero-value coinbase,
ensuring it is assigned a minimal or full block reward as appropriate.
- **Tests**
- Added integration tests to verify processing and submission of blocks
containing a single zero-value coinbase output.
- Introduced a test scenario validating block creation with a zero-value
coinbase via the gRPC interface.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: stringhandler <stringhandler@gmail.com>
Co-authored-by: SW van Heerden <swvheerden@gmail.com>

82866 of 115596 relevant lines covered (71.69%)

239780.82 hits per line

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

16.67
/base_layer/core/src/base_node/sync/ban.rs
1
//  Copyright 2023, 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::time::Duration;
24

25
use log::*;
26
use tari_comms::{connectivity::ConnectivityRequester, peer_manager::NodeId};
27

28
use crate::base_node::BlockchainSyncConfig;
29

30
const LOG_TARGET: &str = "c::bn::sync";
31

32
// Sync peers are banned if there exists a ban reason for the error and the peer is not on the allow list for sync.
33

34
pub struct PeerBanManager {
35
    config: BlockchainSyncConfig,
36
    connectivity: ConnectivityRequester,
37
}
38

39
impl PeerBanManager {
40
    pub fn new(config: BlockchainSyncConfig, connectivity: ConnectivityRequester) -> Self {
12✔
41
        Self { config, connectivity }
12✔
42
    }
12✔
43

44
    pub async fn ban_peer_if_required(&mut self, node_id: &NodeId, ban_reason: String, ban_duration: Duration) {
×
45
        if self.config.forced_sync_peers.contains(node_id) {
×
46
            debug!(
×
47
                target: LOG_TARGET,
×
48
                "Not banning peer that is on the allow list for sync. Ban reason = {}", ban_reason
×
49
            );
50
            return;
×
51
        }
×
52
        debug!(target: LOG_TARGET, "Sync peer {} removed from the sync peer list because {}", node_id, ban_reason);
×
53

54
        match self
×
55
            .connectivity
×
56
            .ban_peer_until(node_id.clone(), ban_duration, ban_reason.clone())
×
57
            .await
×
58
        {
59
            Ok(_) => {
60
                warn!(target: LOG_TARGET, "Banned sync peer {} for {:?} because {}", node_id, ban_duration, ban_reason)
×
61
            },
62
            Err(err) => error!(target: LOG_TARGET, "Failed to ban sync peer {}: {}", node_id, err),
×
63
        }
64
    }
×
65
}
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