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

tari-project / tari / 20715266036

05 Jan 2026 12:22PM UTC coverage: 59.702% (-0.9%) from 60.642%
20715266036

push

github

web-flow
chore(deps): bump azure/trusted-signing-action from 0.5.10 to 0.5.11 (#7632)

Bumps
[azure/trusted-signing-action](https://github.com/azure/trusted-signing-action)
from 0.5.10 to 0.5.11.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/azure/trusted-signing-action/releases">azure/trusted-signing-action's
releases</a>.</em></p>
<blockquote>
<h2>v0.5.11</h2>
<h2>What's Changed</h2>
<ul>
<li>fix: map to environment variables instead of directly from inputs by
<a href="https://github.com/Jaxelr"><code>@​Jaxelr</code></a> in <a
href="https://redirect.github.com/Azure/trusted-signing-action/pull/102">Azure/trusted-signing-action#102</a></li>
<li>chore: update codeowners to trusted signing team by <a
href="https://github.com/Jaxelr"><code>@​Jaxelr</code></a> in <a
href="https://redirect.github.com/Azure/trusted-signing-action/pull/103">Azure/trusted-signing-action#103</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/Azure/trusted-signing-action/compare/v0...v0.5.11">https://github.com/Azure/trusted-signing-action/compare/v0...v0.5.11</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/Azure/trusted-signing-action/commit/1d365fec1"><code>1d365fe</code></a>
chore: update codeowners to trusted signing team (<a
href="https://redirect.github.com/azure/trusted-signing-action/issues/103">#103</a>)</li>
<li><a
href="https://github.com/Azure/trusted-signing-action/commit/34bc367eb"><code>34bc367</code></a>
fix: map to environment variables instead of directly from inputs (<a
href="https://redirect.github.com/azure/trusted-signing-action/issues/102">#102</a>)</li>
<li>See full diff in <a
href="https://github.com/azure/trusted-signing-action/compare/v0.5.10...v0.5.11">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubap... (continued)

69282 of 116047 relevant lines covered (59.7%)

300086.98 hits per line

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

75.0
/base_layer/node_components/src/blocks/block.rs
1
// Copyright 2018 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
// Portions of this file were originally copyrighted (c) 2018 The Grin Developers, issued under the Apache License,
24
// Version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0.
25

26
use std::{
27
    fmt,
28
    fmt::{Display, Formatter},
29
};
30

31
use borsh::{BorshDeserialize, BorshSerialize};
32
use serde::{Deserialize, Serialize};
33
use tari_common_types::types::{FixedHash, PrivateKey};
34
use tari_transaction_components::{
35
    aggregated_body::AggregateBody,
36
    consensus::ConsensusConstants,
37
    crypto_factories::CryptoFactories,
38
    tari_proof_of_work::ProofOfWork,
39
    transaction_components::{
40
        KernelFeatures,
41
        OutputType,
42
        Transaction,
43
        TransactionError,
44
        TransactionInput,
45
        TransactionKernel,
46
        TransactionOutput,
47
    },
48
    MicroMinotari,
49
};
50
use thiserror::Error;
51

52
use crate::blocks::BlockHeader;
53

54
#[derive(Clone, Debug, Error)]
55
pub enum BlockValidationError {
56
    #[error("A transaction in the block failed to validate: `{0}`")]
57
    TransactionError(#[from] TransactionError),
58
    #[error("Mismatched {kind} MMR roots")]
59
    MismatchedMmrRoots { kind: &'static str },
60
    #[error("MMR size for {mmr_tree} does not match. Expected: {expected}, received: {actual}")]
61
    MismatchedMmrSize {
62
        mmr_tree: String,
63
        expected: u64,
64
        actual: u64,
65
    },
66
}
67

68
/// A Minotari block. Blocks are linked together into a blockchain.
69
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
×
70
pub struct Block {
71
    /// The BlockHeader contains all the metadata for the block, including proof of work, a link to the previous block
72
    /// and the transaction kernels.
73
    pub header: BlockHeader,
74
    /// The components of the block or transaction. The same struct can be used for either, since in Mimblewimble,
75
    /// blocks consist of inputs, outputs and kernels, rather than transactions.
76
    pub body: AggregateBody,
77
}
78

79
impl Block {
80
    pub fn new(header: BlockHeader, body: AggregateBody) -> Self {
76✔
81
        Self { header, body }
76✔
82
    }
76✔
83

84
    pub fn version(&self) -> u16 {
483✔
85
        self.header.version
483✔
86
    }
483✔
87

88
    /// This function will calculate the total fees contained in a block
89
    pub fn calculate_fees(&self) -> MicroMinotari {
×
90
        self.body.kernels().iter().fold(0.into(), |sum, x| sum + x.fee)
×
91
    }
×
92

93
    /// Run through the outputs of the block and check that
94
    /// 1. There is exactly ONE coinbase output
95
    /// 2. The output's maturity is correctly set
96
    /// 3. The amount is correct.
97
    pub fn check_coinbase_output(
83✔
98
        &self,
83✔
99
        reward: MicroMinotari,
83✔
100
        consensus_constants: &ConsensusConstants,
83✔
101
        factories: &CryptoFactories,
83✔
102
    ) -> Result<(), BlockValidationError> {
83✔
103
        self.body.check_coinbase_output(
83✔
104
            reward,
83✔
105
            consensus_constants.coinbase_min_maturity(),
83✔
106
            factories,
83✔
107
            self.header.height,
83✔
108
            consensus_constants.max_block_coinbase_count(),
83✔
109
        )?;
7✔
110
        Ok(())
76✔
111
    }
83✔
112

113
    /// Destroys the block and returns the pieces of the block: header, inputs, outputs and kernels
114
    pub fn dissolve(
4✔
115
        self,
4✔
116
    ) -> (
4✔
117
        BlockHeader,
4✔
118
        Vec<TransactionInput>,
4✔
119
        Vec<TransactionOutput>,
4✔
120
        Vec<TransactionKernel>,
4✔
121
    ) {
4✔
122
        let (inputs, outputs, kernels) = self.body.dissolve();
4✔
123
        (self.header, inputs, outputs, kernels)
4✔
124
    }
4✔
125

126
    /// Destroys the block and returns the pieces of the block: header, body
127
    pub fn into_header_body(self) -> (BlockHeader, AggregateBody) {
×
128
        (self.header, self.body)
×
129
    }
×
130

131
    /// Return a cloned version of this block with the TransactionInputs in their compact form
132
    pub fn to_compact(&self) -> Self {
×
133
        Self {
×
134
            header: self.header.clone(),
×
135
            body: self.body.to_compact(),
×
136
        }
×
137
    }
×
138

139
    /// The block hash is just the header hash, since the inputs, outputs and range proofs are captured by their
140
    /// respective MMR roots in the header itself.
141
    pub fn hash(&self) -> FixedHash {
2,470✔
142
        self.header.hash()
2,470✔
143
    }
2,470✔
144
}
145

146
impl Display for Block {
147
    fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
×
148
        writeln!(f, "----------------- Block -----------------")?;
×
149
        writeln!(f, "--- Header ---")?;
×
150
        writeln!(f, "Hash: {}", self.header.hash())?;
×
151
        writeln!(f, "{}", self.header)?;
×
152
        writeln!(f, "---  Body  ---")?;
×
153
        writeln!(f, "{}", self.body)
×
154
    }
×
155
}
156

157
pub struct BlockBuilder {
158
    header: BlockHeader,
159
    inputs: Vec<TransactionInput>,
160
    outputs: Vec<TransactionOutput>,
161
    kernels: Vec<TransactionKernel>,
162
}
163

164
impl BlockBuilder {
165
    pub fn new(blockchain_version: u16) -> BlockBuilder {
511✔
166
        BlockBuilder {
511✔
167
            header: BlockHeader::new(blockchain_version),
511✔
168
            inputs: Vec::new(),
511✔
169
            outputs: Vec::new(),
511✔
170
            kernels: Vec::new(),
511✔
171
        }
511✔
172
    }
511✔
173

174
    /// This function adds a header to the block
175
    pub fn with_header(mut self, header: BlockHeader) -> Self {
507✔
176
        self.header = header;
507✔
177
        self
507✔
178
    }
507✔
179

180
    /// This function adds the provided transaction inputs to the block
181
    pub fn add_inputs(mut self, mut inputs: Vec<TransactionInput>) -> Self {
430✔
182
        self.inputs.append(&mut inputs);
430✔
183
        self
430✔
184
    }
430✔
185

186
    /// This function adds the provided transaction outputs to the block WITHOUT updating output_mmr_size in the header
187
    pub fn add_outputs(mut self, mut outputs: Vec<TransactionOutput>) -> Self {
451✔
188
        self.outputs.append(&mut outputs);
451✔
189
        self
451✔
190
    }
451✔
191

192
    /// This function adds the provided transaction kernels to the block WITHOUT updating kernel_mmr_size in the header
193
    pub fn add_kernels(mut self, mut kernels: Vec<TransactionKernel>) -> Self {
451✔
194
        self.kernels.append(&mut kernels);
451✔
195
        self
451✔
196
    }
451✔
197

198
    /// This functions adds the provided transactions to the block, modifying the header MMR counts and offsets
199
    pub fn with_transactions(mut self, txs: Vec<Transaction>) -> Self {
319✔
200
        for tx in txs {
621✔
201
            self = self.add_transaction(tx)
302✔
202
        }
203
        self
319✔
204
    }
319✔
205

206
    /// This functions adds the provided transaction to the block, modifying the header MMR counts and offsets
207
    pub fn add_transaction(mut self, tx: Transaction) -> Self {
302✔
208
        let (inputs, outputs, kernels) = tx.body.dissolve();
302✔
209
        self = self.add_inputs(inputs);
302✔
210
        self.header.output_smt_size += outputs.len() as u64;
302✔
211
        self = self.add_outputs(outputs);
302✔
212
        self.header.kernel_mmr_size += kernels.len() as u64;
302✔
213
        self = self.add_kernels(kernels);
302✔
214
        self.header.total_kernel_offset = self.header.total_kernel_offset + tx.offset;
302✔
215
        self.header.total_script_offset = self.header.total_script_offset + tx.script_offset;
302✔
216
        self
302✔
217
    }
302✔
218

219
    /// This will add the given coinbase UTXO to the block
220
    pub fn with_coinbase_utxo(mut self, coinbase_utxo: TransactionOutput, coinbase_kernel: TransactionKernel) -> Self {
223✔
221
        self.kernels.push(coinbase_kernel);
223✔
222
        self.outputs.push(coinbase_utxo);
223✔
223
        self
223✔
224
    }
223✔
225

226
    /// Add the provided ProofOfWork metadata to the block
227
    pub fn with_pow(mut self, pow: ProofOfWork) -> Self {
×
228
        self.header.pow = pow;
×
229
        self
×
230
    }
×
231

232
    /// This will finish construction of the block and create the block
233
    pub fn build(self) -> Block {
507✔
234
        let mut block = Block {
507✔
235
            header: self.header,
507✔
236
            body: AggregateBody::new(self.inputs, self.outputs, self.kernels),
507✔
237
        };
507✔
238
        block.body.sort();
507✔
239
        block
507✔
240
    }
507✔
241
}
242

243
//---------------------------------- NewBlock --------------------------------------------//
244
pub struct NewBlock {
245
    /// The block header.
246
    pub header: BlockHeader,
247
    /// Coinbase kernel of the block
248
    pub coinbase_kernels: Vec<TransactionKernel>,
249
    /// Coinbase output of the block
250
    pub coinbase_outputs: Vec<TransactionOutput>,
251
    /// The scalar `s` component of the kernel excess signatures of the transactions contained in the block.
252
    pub kernel_excess_sigs: Vec<PrivateKey>,
253
}
254

255
impl Display for NewBlock {
256
    fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
×
257
        writeln!(f, "----------------- New Block -----------------")?;
×
258
        writeln!(f, "--- Header ---")?;
×
259
        writeln!(f, "Hash: {}", self.header.hash())?;
×
260
        writeln!(f, "{}", self.header)?;
×
261
        writeln!(f, "---  Coinbase Kernels  ---")?;
×
262
        for kernel in &self.coinbase_kernels {
×
263
            writeln!(f, "{}", kernel)?;
×
264
        }
265
        writeln!(f, "---  Coinbase Outputs  ---")?;
×
266
        for output in &self.coinbase_outputs {
×
267
            writeln!(f, "{}", output)?;
×
268
        }
269
        Ok(())
×
270
    }
×
271
}
272

273
impl From<&Block> for NewBlock {
274
    fn from(block: &Block) -> Self {
33✔
275
        let coinbase_kernels = block
33✔
276
            .body
33✔
277
            .kernels()
33✔
278
            .clone()
33✔
279
            .into_iter()
33✔
280
            .filter(|k| k.features.contains(KernelFeatures::COINBASE_KERNEL))
39✔
281
            .collect();
33✔
282
        let coinbase_outputs = block
33✔
283
            .body
33✔
284
            .outputs()
33✔
285
            .clone()
33✔
286
            .into_iter()
33✔
287
            .filter(|o| o.features.output_type == OutputType::Coinbase)
46✔
288
            .collect();
33✔
289

290
        Self {
291
            header: block.header.clone(),
33✔
292
            coinbase_kernels,
33✔
293
            coinbase_outputs,
33✔
294
            kernel_excess_sigs: block
33✔
295
                .body
33✔
296
                .kernels()
33✔
297
                .iter()
33✔
298
                .filter(|k| !k.features.contains(KernelFeatures::COINBASE_KERNEL))
39✔
299
                .map(|kernel| kernel.excess_sig.get_signature().clone())
33✔
300
                .collect(),
33✔
301
        }
302
    }
33✔
303
}
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