Skip to content

Commit 10cbb61

Browse files
author
stringhandler
authored
Merge branch 'development' into qtari-dev
2 parents 9189e85 + b5f2c46 commit 10cbb61

File tree

24 files changed

+484
-267
lines changed

24 files changed

+484
-267
lines changed

.github/workflows/base_node_binaries.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ jobs:
130130
run: |
131131
echo "VBRANCH=${{ github.ref_name }}" >> $GITHUB_ENV
132132
echo "VSHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
133-
TARI_VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/["]/, "", $2); printf("%s",$2) }' "$GITHUB_WORKSPACE/applications/minotari_node/Cargo.toml")
133+
TARI_VERSION=$(awk -F ' = ' '$1 ~ /^version/ \
134+
{ gsub(/["]/, "", $2); printf("%s",$2) }' \
135+
"$GITHUB_WORKSPACE/applications/minotari_node/Cargo.toml")
134136
echo "TARI_VERSION=${TARI_VERSION}" >> $GITHUB_ENV
135137
echo "TARI_VERSION=${TARI_VERSION}" >> $GITHUB_OUTPUT
136138
if [[ "${{ matrix.builds.features }}" == "" ]]; then

.github/workflows/build_dockers_workflow.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,9 @@ jobs:
134134
if [ -z "${{ inputs.version }}" ] ; then
135135
echo "Get tari version"
136136
TARI_SOURCE_ROOT="tari/"
137-
VAPP=$(awk -F ' = ' \
138-
'$1 ~ /version/ { gsub(/["]/, "", $2); printf("%s",$2) }' \
137+
VAPP=$(awk -F ' = ' '$1 ~ /^version/ \
138+
{ gsub(/["]/, "", $2); printf("%s",$2) }' \
139139
"${TARI_SOURCE_ROOT}/applications/minotari_node/Cargo.toml")
140-
141140
VBRANCH=$(git --git-dir ${TARI_SOURCE_ROOT}/.git branch --show-current)
142141
VSHA_SHORT=$(git --git-dir ${TARI_SOURCE_ROOT}/.git rev-parse --short HEAD)
143142
VERSION="v${VAPP}_${VBRANCH}_$(date -u '+%Y%m%d')_${VSHA_SHORT}"

.github/workflows/build_libffis.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ jobs:
5050
## build only single target image
5151
# matrix_selection=$( jq -c '.[] | select( ."runs-on" == "ubuntu-latest" )' ${{ env.matrix-json-file }} )
5252
# matrix_selection=$( jq -c '.[] | select( ."target" == "x86_64-linux-android" )' ${{ env.matrix-json-file }} )
53+
# matrix_selection=$( jq -c '.[] | select( ."target" | contains("android") )' ${{ env.matrix-json-file }} )
5354
#
5455
## buid select target images - build_enabled
5556
matrix_selection=$( jq -c '.[] | select( ."build_enabled" != false )' ${{ env.matrix-json-file }} )
@@ -225,9 +226,12 @@ jobs:
225226
path: ${{ runner.temp }}/lib${{ matrix.libffis }}-${{ env.TARGET_PLATFORM }}-${{ env.TARGET_ARCH }}${{ env.TARGET_SIM }}
226227

227228
ios_assemble:
228-
name: Assemble iOS multiArch for ${{ matrix.libffis }}"
229+
name: Assemble iOS multiArch for ${{ matrix.libffis }}
230+
# Disable iOS Assembly workflow
231+
#if: ${{ false }}
232+
#continue-on-error: true
229233

230-
# Limits to only iOS builds
234+
# Limits to only iOS builds?
231235
runs-on: macos-latest
232236
needs: [matrix-prep, builds]
233237

@@ -353,9 +357,11 @@ jobs:
353357

354358
create_release:
355359
name: Create release for ffi libraries
360+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
361+
356362
runs-on: ubuntu-latest
357363
needs: [matrix-prep, builds, ios_assemble]
358-
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
364+
359365
steps:
360366
- name: Download all ffi libraries
361367
uses: actions/download-artifact@v4

Cross.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ passthrough = [
1414
"FEATURES",
1515
"ROARING_ARCH",
1616
"TARI_NETWORK",
17+
"TARI_TARGET_NETWORK",
18+
"TARI_NETWORK_DIR",
1719
]
1820

1921
# Don't forget export:

applications/minotari_node/src/bootstrap.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@
2020
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
2121
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2222

23-
use std::{cmp, str::FromStr, sync::Arc, time::Duration};
23+
use std::{
24+
cmp,
25+
str::FromStr,
26+
sync::{Arc, RwLock},
27+
time::Duration,
28+
};
2429

2530
use log::*;
2631
use minotari_app_utilities::{consts, identity_management, identity_management::load_from_json};
@@ -52,6 +57,7 @@ use tari_core::{
5257
mempool::{service::MempoolHandle, Mempool, MempoolServiceInitializer, MempoolSyncInitializer},
5358
proof_of_work::randomx_factory::RandomXFactory,
5459
transactions::CryptoFactories,
60+
OutputSmt,
5561
};
5662
use tari_p2p::{
5763
auto_update::SoftwareUpdaterService,
@@ -81,6 +87,7 @@ pub struct BaseNodeBootstrapper<'a, B> {
8187
pub factories: CryptoFactories,
8288
pub randomx_factory: RandomXFactory,
8389
pub interrupt_signal: ShutdownSignal,
90+
pub smt: Arc<RwLock<OutputSmt>>,
8491
}
8592

8693
impl<B> BaseNodeBootstrapper<'_, B>

applications/minotari_node/src/builder.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
2121
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2222

23-
use std::sync::Arc;
23+
use std::sync::{Arc, RwLock};
2424

2525
use log::*;
2626
use tari_common::{
@@ -42,6 +42,7 @@ use tari_core::{
4242
transaction::TransactionFullValidator,
4343
DifficultyCalculator,
4444
},
45+
OutputSmt,
4546
};
4647
use tari_p2p::{auto_update::SoftwareUpdaterHandle, services::liveness::LivenessHandle};
4748
use tari_service_framework::ServiceHandles;
@@ -210,6 +211,7 @@ async fn build_node_context(
210211
let factories = CryptoFactories::default();
211212
let randomx_factory = RandomXFactory::new(app_config.base_node.max_randomx_vms);
212213
let difficulty_calculator = DifficultyCalculator::new(rules.clone(), randomx_factory.clone());
214+
let smt = Arc::new(RwLock::new(OutputSmt::new()));
213215
let validators = Validators::new(
214216
BlockBodyFullValidator::new(rules.clone(), true),
215217
HeaderFullValidator::new(rules.clone(), difficulty_calculator.clone()),
@@ -226,6 +228,7 @@ async fn build_node_context(
226228
validators,
227229
app_config.base_node.storage,
228230
difficulty_calculator,
231+
smt.clone(),
229232
)
230233
.map_err(|err| {
231234
if let ChainStorageError::DatabaseResyncRequired(reason) = err {
@@ -262,6 +265,7 @@ async fn build_node_context(
262265
factories: factories.clone(),
263266
randomx_factory,
264267
interrupt_signal: interrupt_signal.clone(),
268+
smt,
265269
}
266270
.bootstrap()
267271
.await?;

applications/minotari_node/src/recovery.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use std::{
2525
env::temp_dir,
2626
fs,
2727
io::{self, Write},
28-
sync::Arc,
28+
sync::{Arc, RwLock},
2929
};
3030

3131
use anyhow::anyhow;
@@ -53,6 +53,7 @@ use tari_core::{
5353
mocks::MockValidator,
5454
DifficultyCalculator,
5555
},
56+
OutputSmt,
5657
};
5758

5859
use crate::{BaseNodeConfig, DatabaseType};
@@ -97,6 +98,7 @@ pub async fn run_recovery(node_config: &BaseNodeConfig) -> Result<(), anyhow::Er
9798
let factories = CryptoFactories::default();
9899
let randomx_factory = RandomXFactory::new(node_config.max_randomx_vms);
99100
let difficulty_calculator = DifficultyCalculator::new(rules.clone(), randomx_factory);
101+
let smt = Arc::new(RwLock::new(OutputSmt::new()));
100102
let validators = Validators::new(
101103
BlockBodyFullValidator::new(rules.clone(), true),
102104
HeaderFullValidator::new(rules.clone(), difficulty_calculator.clone()),
@@ -114,6 +116,7 @@ pub async fn run_recovery(node_config: &BaseNodeConfig) -> Result<(), anyhow::Er
114116
validators,
115117
node_config.storage,
116118
difficulty_calculator,
119+
smt,
117120
)?;
118121
do_recovery(db.into(), temp_db).await?;
119122

@@ -142,12 +145,14 @@ async fn do_recovery<D: BlockchainBackend + 'static>(
142145
MockValidator::new(true),
143146
MockValidator::new(true),
144147
);
148+
let smt = Arc::new(RwLock::new(OutputSmt::new()));
145149
let source_database = BlockchainDatabase::new(
146150
source_backend,
147151
rules.clone(),
148152
validators,
149153
BlockchainDatabaseConfig::default(),
150154
DifficultyCalculator::new(rules, Default::default()),
155+
smt,
151156
)?;
152157
let max_height = source_database
153158
.get_chain_metadata()

base_layer/core/src/base_node/sync/block_sync/synchronizer.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,8 @@ impl<'a, B: BlockchainBackend + 'static> BlockSynchronizer<'a, B> {
321321
let validator = self.block_validator.clone();
322322
let res = task::spawn_blocking(move || {
323323
let txn = db.db_read_access()?;
324-
validator.validate_body(&*txn, &task_block)
324+
let smt = db.smt().clone();
325+
validator.validate_body(&*txn, &task_block, smt)
325326
})
326327
.await?;
327328

@@ -367,7 +368,7 @@ impl<'a, B: BlockchainBackend + 'static> BlockSynchronizer<'a, B> {
367368
self.db
368369
.write_transaction()
369370
.delete_orphan(header_hash)
370-
.insert_tip_block_body(block.clone())
371+
.insert_tip_block_body(block.clone(), self.db.inner().smt())
371372
.set_best_block(
372373
block.height(),
373374
header_hash,

base_layer/core/src/base_node/sync/horizon_state_sync/synchronizer.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,14 @@ impl<'a, B: BlockchainBackend + 'static> HorizonStateSynchronization<'a, B> {
298298
debug!(target: LOG_TARGET, "Synchronizing kernels");
299299
self.synchronize_kernels(sync_peer.clone(), client, to_header).await?;
300300
debug!(target: LOG_TARGET, "Synchronizing outputs");
301+
let cloned_backup_smt = self.db.inner().smt_read_access()?.clone();
301302
match self.synchronize_outputs(sync_peer, client, to_header).await {
302303
Ok(_) => Ok(()),
303304
Err(err) => {
304305
// We need to clean up the outputs
305306
let _ = self.clean_up_failed_output_sync(to_header).await;
307+
let mut smt = self.db.inner().smt_write_access()?;
308+
*smt = cloned_backup_smt;
306309
Err(err)
307310
},
308311
}
@@ -618,7 +621,7 @@ impl<'a, B: BlockchainBackend + 'static> HorizonStateSynchronization<'a, B> {
618621
let mut utxo_counter = 0u64;
619622
let mut stxo_counter = 0u64;
620623
let timer = Instant::now();
621-
let mut output_smt = db.fetch_tip_smt().await?;
624+
let mut output_smt = (*db.inner().smt_write_access()?).clone();
622625
let mut last_sync_timer = Instant::now();
623626
let mut avg_latency = RollingAverageTime::new(20);
624627

@@ -766,8 +769,8 @@ impl<'a, B: BlockchainBackend + 'static> HorizonStateSynchronization<'a, B> {
766769
txn.commit().await?;
767770
}
768771
}
769-
// This has a very low probability of failure
770-
db.set_tip_smt(output_smt).await?;
772+
let mut writing_lock_output_smt = db.inner().smt_write_access()?;
773+
*writing_lock_output_smt = output_smt;
771774
debug!(
772775
target: LOG_TARGET,
773776
"Finished syncing TXOs: {} unspent and {} spent downloaded in {:.2?}",

base_layer/core/src/chain_storage/async_db.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@
1919
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2020
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
2121
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22-
use std::{mem, ops::RangeBounds, sync::Arc, time::Instant};
22+
use std::{
23+
mem,
24+
ops::RangeBounds,
25+
sync::{Arc, RwLock},
26+
time::Instant,
27+
};
2328

2429
use log::*;
2530
use primitive_types::U256;
@@ -222,10 +227,6 @@ impl<B: BlockchainBackend + 'static> AsyncBlockchainDb<B> {
222227

223228
make_async_fn!(fetch_tip_header() -> ChainHeader, "fetch_tip_header");
224229

225-
make_async_fn!(fetch_tip_smt() -> OutputSmt, "fetch_tip_smt");
226-
227-
make_async_fn!(set_tip_smt(smt: OutputSmt) -> (), "set_tip_smt");
228-
229230
make_async_fn!(insert_valid_headers(headers: Vec<ChainHeader>) -> (), "insert_valid_headers");
230231

231232
//---------------------------------- Block --------------------------------------------//
@@ -393,8 +394,8 @@ impl<'a, B: BlockchainBackend + 'static> AsyncDbTransaction<'a, B> {
393394
self
394395
}
395396

396-
pub fn insert_tip_block_body(&mut self, block: Arc<ChainBlock>) -> &mut Self {
397-
self.transaction.insert_tip_block_body(block);
397+
pub fn insert_tip_block_body(&mut self, block: Arc<ChainBlock>, smt: Arc<RwLock<OutputSmt>>) -> &mut Self {
398+
self.transaction.insert_tip_block_body(block, smt);
398399
self
399400
}
400401

0 commit comments

Comments
 (0)