Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
645 changes: 365 additions & 280 deletions Cargo.lock

Large diffs are not rendered by default.

35 changes: 18 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,16 @@ libp2p-messaging = { path = "networking/libp2p-messaging" }
libp2p-substream = { path = "networking/libp2p-substream" }

# third-party dependencies
anyhow = "1.0.75"
async-graphql = "5.0.7"
async-graphql-axum = "5.0.7"
async-semaphore = "1.2.0"
anyhow = "1.0.100"
async-graphql = "7.0.17"
async-graphql-axum = "7.0.17"
async-semaphore = "1.2.1"
async-trait = "0.1.74"
asynchronous-codec = "0.7.0"
axum = "0.6"
axum-jrpc = "0.3.2"
base64 = "0.20.0"
axum = "0.8"
axum-extra = "0.10.1"
axum-jrpc = "0.8"
base64 = "0.22.1"
bigdecimal = "0.4.1"
bincode = "2.0.1"
bitflags = "2.9.2"
Expand All @@ -170,7 +171,7 @@ bytes = "1.10.0"
bnum = "0.13.0"
bech32 = "0.11.0"
bounded-vec = "0.9.0"
cargo_toml = "0.20.5"
cargo_toml = "0.22.3"
ciborium = { version = "0.2.2", default-features = false }
ciborium-io = { version = "0.2.2", default-features = false }
clap = "3.2.25"
Expand All @@ -196,7 +197,7 @@ hex = "0.4"
humantime = "2.1.0"
humantime-serde = "1.1.1"
include_dir = "0.7.2"
indexmap = "2.6.0"
indexmap = "2.11.4"
indoc = "1.0.6"
lazy_static = "1.4.0"
# Use Tari's libp2p fork that adds support for Schnorr-Ristretto
Expand All @@ -216,20 +217,20 @@ once_cell = "1.18.0"
pin-project = "1.1"
proc-macro2 = "1.0"
prometheus-client = { version = "0.23", default-features = false }
prost = "0.13"
prost-build = "0.13"
prost-types = "0.13"
prost = "0.14"
prost-build = "0.14"
prost-types = "0.14"
quick-protobuf = "0.8"
quick-protobuf-codec = "0.3.1"
quote = "1.0.7"
rand = "0.8.5"
rayon = "1.7.0"
reqwest = "0.11.16"
rocksdb = "0.23.0"
rocksdb = "0.24.0"
semver = "1.0"
serde = { version = "1.0", default-features = false }
serde_json = "1.0"
serde_with = "3.14.0"
serde_with = "3.14.1"
sha2 = "0.10.8"
smallvec = "2.0.0-alpha.11"
std-semaphore = "0.1.0"
Expand All @@ -241,10 +242,10 @@ tokio = { version = "1.44.1", default-features = false }
tokio-stream = "0.1.7"
tokio-util = "0.7.10"
tonic = "0.13.1"
tower = "0.4"
tower-http = { version = "0.4", default-features = false }
tower = "0.5"
tower-http = { version = "0.6", default-features = false }
tracing = "0.1.40"
toml = "0.8"
toml = "0.9"
ts-rs = { version = "11.0", features = ["chrono-impl", "no-serde-warnings", "indexmap-impl"] }
url = "2.4.1"
urlencoding = "2.1.3"
Expand Down
6 changes: 3 additions & 3 deletions applications/tari_app_utilities/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license.workspace = true
[dependencies]
tari_common = { workspace = true }
tari_common_types = { workspace = true }
tari_crypto = { workspace = true }
tari_crypto = { workspace = true, features = ["serde"] }
tari_ootle_common_types = { workspace = true }
tari_engine = { workspace = true }
tari_ootle_storage = { workspace = true }
Expand All @@ -34,10 +34,10 @@ libp2p-identity = { workspace = true }
log = { workspace = true, features = ["std"] }
multiaddr = { workspace = true }
rand = { workspace = true }
serde = { workspace = true, features = ["default", "derive"] }
serde = { workspace = true, features = ["default", "derive", "rc"] }
serde_json = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true, features = ["default", "macros", "time", "sync", "rt-multi-thread", "fs"] }
tokio = { workspace = true, features = ["default", "macros", "time", "sync", "rt-multi-thread", "fs", "net"] }
url = { workspace = true, features = ["serde"] }
toml = { workspace = true }
config = { workspace = true }
1 change: 1 addition & 0 deletions applications/tari_app_utilities/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ pub mod fee_tables;
pub mod keypair;
pub mod p2p_config;
pub mod seed_peer;
pub mod tcp;
pub mod template_download_queue;
pub mod transaction_executor;
23 changes: 23 additions & 0 deletions applications/tari_app_utilities/src/tcp.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2025 The Tari Project
// SPDX-License-Identifier: BSD-3-Clause

use std::{io, net::SocketAddr};

use log::warn;
use tokio::net::TcpListener;

const LOG_TARGET: &str = "tari::ootle::app_utilities::tcp";

pub async fn try_bind_with_fallback(mut preferred_address: SocketAddr) -> io::Result<TcpListener> {
match TcpListener::bind(preferred_address).await {
Ok(l) => Ok(l),
Err(e) => {
warn!(
target: LOG_TARGET,
"🕸️ Failed to bind on preferred address ({e}). Trying OS-assigned",
);
preferred_address.set_port(0);
TcpListener::bind(preferred_address).await
},
}
}
3 changes: 2 additions & 1 deletion applications/tari_indexer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ diesel = { workspace = true, default-features = false, features = [
"returning_clauses_for_sqlite_3_35",
"time",
] }
indexmap = { workspace = true }
diesel_migrations = { workspace = true }
futures = { workspace = true }
include_dir = { workspace = true, optional = true }
Expand All @@ -64,7 +65,7 @@ log4rs = { workspace = true, features = [
mime_guess = { workspace = true }
serde = { workspace = true, features = ["default", "derive"] }
serde_json = { workspace = true }
serde_with = { workspace = true, features = ["indexmap"] }
serde_with = { workspace = true, features = ["indexmap_2"] }
thiserror = { workspace = true }
time = { workspace = true, features = ["serde"] }
tokio = { workspace = true, features = [
Expand Down
14 changes: 4 additions & 10 deletions applications/tari_indexer/src/graphql/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use axum::{
};
use log::*;
use serde::Serialize;
use tari_ootle_app_utilities::tcp::try_bind_with_fallback;
use tower_http::cors::CorsLayer;

use crate::{
Expand All @@ -64,16 +65,9 @@ pub async fn run_graphql(
.layer(CorsLayer::permissive())
.layer(Extension(schema));

let server = axum::Server::try_bind(&preferred_address)
.or_else(|_| {
warn!(
target: LOG_TARGET,
"🌐 Failed to bind on preferred address {}. Trying OS-assigned", preferred_address
);
axum::Server::try_bind(&"127.0.0.1:0".parse().unwrap())
})?
.serve(router.into_make_service());
let bind_addr = server.local_addr();
let listener = try_bind_with_fallback(preferred_address).await?;
let server = axum::serve(listener, router);
let bind_addr = server.local_addr()?;
info!(target: LOG_TARGET, "🌐 GraphQL listening on {bind_addr}");
server.await?;

Expand Down
14 changes: 4 additions & 10 deletions applications/tari_indexer/src/http_ui/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use axum::{
};
use include_dir::{include_dir, Dir};
use log::*;
use tari_ootle_app_utilities::tcp::try_bind_with_fallback;
use url::Url;

const LOG_TARGET: &str = "tari::indexer::web_ui::server";
Expand All @@ -50,16 +51,9 @@ pub async fn run_http_ui_server(
.fallback(handler);

info!(target: LOG_TARGET, "🕸️ Web UI started at http://{}", address);
let server = axum::Server::try_bind(&address).or_else(|_| {
warn!(
target: LOG_TARGET,
"🕸️ Failed to bind on preferred address {}. Trying OS-assigned", address
);
axum::Server::try_bind(&"127.0.0.1:0".parse().unwrap())
})?;

let server = server.serve(router.into_make_service());
info!(target: LOG_TARGET, "🕸️ Web UI listening on {}", server.local_addr());
let listener = try_bind_with_fallback(address).await?;
let server = axum::serve(listener, router);
info!(target: LOG_TARGET, "🕸️ Web UI listening on {}", server.local_addr()?);
server.await?;

info!(target: LOG_TARGET, "Stopping Web UI");
Expand Down
4 changes: 2 additions & 2 deletions applications/tari_indexer/src/json_rpc/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use axum_jrpc::{

const LOG_TARGET: &str = "tari::indexer::json_rpc";

pub fn internal_error<T: Display>(answer_id: i64) -> impl Fn(T) -> JsonRpcResponse {
pub fn internal_error<T: Display>(answer_id: axum_jrpc::Id) -> impl Fn(T) -> JsonRpcResponse {
move |err| {
let msg = if cfg!(debug_assertions) || option_env!("CI").is_some() {
err.to_string()
Expand All @@ -19,7 +19,7 @@ pub fn internal_error<T: Display>(answer_id: i64) -> impl Fn(T) -> JsonRpcRespon
"Something went wrong".to_string()
};
JsonRpcResponse::error(
answer_id,
answer_id.clone(),
JsonRpcError::new(JsonRpcErrorReason::InternalError, msg, serde_json::Value::Null),
)
}
Expand Down
Loading
Loading