Skip to content

Commit

Permalink
Merge branch 'development' into build_dockers_test1
Browse files Browse the repository at this point in the history
  • Loading branch information
stringhandler authored Apr 26, 2024
2 parents 416c262 + f53fb55 commit 1db7c15
Show file tree
Hide file tree
Showing 272 changed files with 10,543 additions and 830 deletions.
184 changes: 129 additions & 55 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ members = [
"applications/tari_indexer",
"applications/tari_scaffolder",
"applications/tari_signaling_server",
"applications/tari_swarm_daemon",
"applications/tari_validator_node_cli",
"applications/tari_validator_node",
"clients/base_node_client",
Expand Down Expand Up @@ -228,7 +229,7 @@ tokio-stream = "0.1.7"
tokio-util = "0.7.10"
tonic = "0.8.3"
tower = "0.4"
tower-http = { version = "0.3.5", default-features = false }
tower-http = { version = "0.4", default-features = false }
tower-layer = "0.3"
tracing = "0.1.40"
ts-rs = { version = "7.1", features = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ impl<TAddr: NodeAddressable + 'static> BaseLayerScanner<TAddr> {
},
}

self.has_attempted_scan = false;
self.has_attempted_scan = true;

Ok(())
}
Expand Down
5 changes: 4 additions & 1 deletion applications/tari_indexer/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use tari_dan_p2p::TariMessagingSpec;
use tari_dan_storage::global::GlobalDb;
use tari_dan_storage_sqlite::global::SqliteGlobalDbAdapter;
use tari_epoch_manager::base_layer::{EpochManagerConfig, EpochManagerHandle};
use tari_networking::{MessagingMode, NetworkingHandle, SwarmConfig};
use tari_networking::{MessagingMode, NetworkingHandle, RelayCircuitLimits, RelayReservationLimits, SwarmConfig};
use tari_shutdown::ShutdownSignal;
use tari_state_store_sqlite::SqliteStateStore;
use tari_validator_node_rpc::client::TariValidatorNodeRpcClientFactory;
Expand Down Expand Up @@ -96,6 +96,9 @@ pub async fn spawn_services(
protocol_version: format!("/tari/{}/0.0.1", config.network).parse().unwrap(),
user_agent: "/tari/indexer/0.0.1".to_string(),
enable_mdns: config.indexer.p2p.enable_mdns,
enable_relay: true,
relay_circuit_limits: RelayCircuitLimits::high(),
relay_reservation_limits: RelayReservationLimits::high(),
..Default::default()
},
reachability_mode: config.indexer.p2p.reachability_mode.into(),
Expand Down
1 change: 1 addition & 0 deletions applications/tari_indexer/src/event_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ impl EventManager {
let mut stream = client
.sync_blocks(SyncBlocksRequest {
start_block_id: start_block_id.as_bytes().to_vec(),
up_to_epoch: None,
})
.await?;
while let Some(resp) = stream.next().await {
Expand Down
2 changes: 1 addition & 1 deletion applications/tari_signaling_server/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ impl Cli {
pub fn base_dir(&self) -> PathBuf {
self.base_dir
.clone()
.unwrap_or_else(|| dirs::home_dir().unwrap().join(".tari/signallingserver"))
.unwrap_or_else(|| dirs::home_dir().unwrap().join(".tari/signalingserver"))
}
}
47 changes: 47 additions & 0 deletions applications/tari_swarm_daemon/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[package]
name = "tari_swarm_daemon"
version.workspace = true
edition.workspace = true
authors.workspace = true
repository.workspace = true
license.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tari_core = { workspace = true } # Used for VN registration signature
tari_common = { workspace = true } # Needed for the Network enum (-_-)
tari_common_types = { workspace = true }
tari_crypto = { workspace = true }
tari_shutdown = { workspace = true }
tari_engine_types = { workspace = true }
minotari_node_grpc_client = { workspace = true }
minotari_wallet_grpc_client = { workspace = true }
tari_validator_node_client = { workspace = true }

anyhow = { workspace = true }
async-trait = { workspace = true }
axum = { workspace = true, features = ["multipart"] }
axum-jrpc = { workspace = true }
clap = { workspace = true, features = ["derive"] }
fern = { workspace = true, features = ["colored"] }
futures = { workspace = true }
humantime = { workspace = true }
include_dir = { workspace = true }
json5 = { workspace = true }
lockfile = "0.4.0"
log = { workspace = true }
mime_guess = { workspace = true }
reqwest = { workspace = true, features = ["json"] }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["rt-multi-thread", "macros", "signal", "process", "time", "fs"] }
toml = "0.8.12"
tonic = { workspace = true }
tower-http = { workspace = true, features = ["fs"] }
url = { workspace = true }

[target.'cfg(unix)'.dependencies]
nix = { version = "0.28.0", default-features = false, features = ["signal"] }

56 changes: 56 additions & 0 deletions applications/tari_swarm_daemon/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2024 The Tari Project
// SPDX-License-Identifier: BSD-3-Clause

use std::{env, fs, process::Command};

fn exit_on_ci() {
if option_env!("CI").is_some() {
std::process::exit(1);
}
}

const BUILD: &[(&str, &str)] = &[("./webui", "build")];

fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("cargo:rerun-if-changed=./webui/src");

// Ensure that dist path exists
fs::create_dir_all("./webui/dist")?;
fs::File::create("./webui/dist/.gitkeep")?;

if env::var("CARGO_FEATURE_TS").is_ok() {
println!("cargo:warning=The web ui is not being compiled when we are generating typescript types/interfaces.");
return Ok(());
}

let npm = if cfg!(windows) { "npm.cmd" } else { "npm" };

for (target, build_cmd) in BUILD {
if let Err(error) = Command::new(npm).arg("ci").current_dir(target).status() {
println!("cargo:warning='npm ci' error : {:?}", error);
exit_on_ci();
}
match Command::new(npm).args(["run", build_cmd]).current_dir(target).output() {
Ok(output) if !output.status.success() => {
println!("cargo:warning='npm run build' exited with non-zero status code");
println!("cargo:warning=Output: {}", String::from_utf8_lossy(&output.stdout));
println!("cargo:warning=Error: {}", String::from_utf8_lossy(&output.stderr));
exit_on_ci();
break;
},
Err(error) => {
println!("cargo:warning='npm run build' error : {:?}", error);
println!("cargo:warning=The web ui will not be included!");
exit_on_ci();
break;
},
_ => {},
}
}

// Ensure that .gitkeep exists
// This is a hack because the build removes .gitkeep
fs::File::create("./webui/dist/.gitkeep")?;

Ok(())
}
48 changes: 48 additions & 0 deletions applications/tari_swarm_daemon/docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Docker Build Notes

Create a folder ```sources``` and build a docker image.

```bash
mkdir sources
cd sources
git clone https://github.com/tari-project/tari.git
git clone https://github.com/tari-project/tari-dan.git
git clone https://github.com/tari-project/tari-connector.git
cp -v applications/tari_swarm/docker/cross-compile-aarch64.sh .
docker build -f applications/tari_swarm/docker/tari_swarm.Dockerfile \
-t local/tari-swarm .
```

# Targeted testing and cross platform builds

```bash
docker build -f tari_swarm/docker_rig/tari_swarm.Dockerfile \
-t local/tari-swarm-tari-dan --target=builder-tari-dan .
```

or

```bash
docker buildx build -f tari_swarm/docker_rig/tari_swarm.Dockerfile \
-t local/tari-swarm-tari-dan-arm64 --target=builder-tari-dan \
--platform linux/arm64 .
```

# Docker Testing Notes

Launching the docker image with local ports redirected to docker container ports 18000 to 19000

```bash
docker run --rm -it -p 18000-19000:18000-19000 \
quay.io/tarilabs/tari-swarm
```

Using the folder ```sources```, builds can be done with
the docker image.

```bash
docker run --rm -it -p 18000-19000:18000-19000 \
-v $PWD/sources/:/home/tari/sources-build \
quay.io/tarilabs/tari-swarm:development_20230704_790dbea \
/bin/bash
```
29 changes: 29 additions & 0 deletions applications/tari_swarm_daemon/docker/cross-compile-aarch64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
#
# Move all cross-compiling steps into a single script
# Hardcoded ARM64 envs for cross-compiling on x86_64
#

set -e

export BUILD_TARGET="aarch64-unknown-linux-gnu/"
export RUST_TARGET="--target=aarch64-unknown-linux-gnu"
#export ARCH=${ARCH:-generic}
export ARCH=generic
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
export CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++
export BINDGEN_EXTRA_CLANG_ARGS="--sysroot /usr/aarch64-linux-gnu/include/"
export RUSTFLAGS="-C target_cpu=$ARCH"
export ROARING_ARCH=$ARCH
rustup target add aarch64-unknown-linux-gnu
rustup toolchain install stable-aarch64-unknown-linux-gnu --force-non-host

# Check for Debian
if [ -f "/etc/debian_version" ] ; then
dpkg --add-architecture arm64
apt-get update
apt-get install -y pkg-config libssl-dev:arm64
export AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR=/usr/include/aarch64-linux-gnu/openssl/
export PKG_CONFIG_ALLOW_CROSS=1
fi
Loading

0 comments on commit 1db7c15

Please sign in to comment.