Skip to content

Commit

Permalink
chore: fix ci (#49)
Browse files Browse the repository at this point in the history
Description
---
fixes fmt
fixes ci profiles
  • Loading branch information
SWvheerden authored Sep 19, 2024
1 parent e9b6f0a commit 38ee3bd
Show file tree
Hide file tree
Showing 25 changed files with 329 additions and 223 deletions.
14 changes: 14 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[profile.ci]
slow-timeout = { period = "60s", terminate-after=2}

[profile.ci.junit] # this can be some other profile, too
path = "junit.xml"

[profile.intellij]
retries = 0
slow-timeout = { period = "30s" }
failure-output = "immediate-final"
fail-fast = false

[profile.intellij.junit] # this can be some other profile, too
path = "junit.xml"
13 changes: 9 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ name: CI
merge_group:

env:
toolchain: nightly-2024-03-01
toolchain: nightly-2024-09-19
CARGO_HTTP_MULTIPLEXING: false
CARGO_TERM_COLOR: always
CARGO_UNSTABLE_SPARSE_REGISTRY: true
Expand All @@ -26,7 +26,7 @@ concurrency:
jobs:
clippy:
name: clippy
runs-on: [ ubuntu-20.04 ]
runs-on: [ ubuntu-latest ]
steps:
- name: checkout
uses: actions/checkout@v4
Expand All @@ -39,7 +39,11 @@ jobs:
run: |
sudo apt-get update
sudo bash scripts/install_ubuntu_dependencies.sh
- name: Cache cargo files and outputs
if: startsWith(runner.environment,'github-hosted')
uses: Swatinem/rust-cache@v2
- name: caching (nightly)
if: startsWith(runner.environment,'self-hosted')
# Don't use rust-cache.
# Rust-cache disables a key feature of actions/cache: restoreKeys.
# Without restore keys, we lose the ability to get partial matches on caches, and end
Expand All @@ -59,11 +63,12 @@ jobs:
tari-${{ runner.os }}-${{ runner.cpu-model }}-${{ env.toolchain }}-nightly-${{ hashFiles('**/Cargo.lock') }}
tari-${{ runner.os }}-${{ runner.cpu-model }}-${{ env.toolchain }}-nightly
- name: cargo format
run: cargo fmt --all -- --check
run: cargo +${{ env.toolchain }} fmt --all -- --check
- name: Install cargo-lints
run: cargo install cargo-lints
- name: Clippy check (with lints)
run: cargo lints clippy --all-targets --all-features
run: cargo +${{ env.toolchain }} lints clippy --all-targets --all-features

machete:
# Checks for unused dependencies.
name: machete
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ target/

# Ignore OS files
.DS_Store

.idea/
10 changes: 5 additions & 5 deletions src/cli/args.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Copyright 2024 The Tari Project
// SPDX-License-Identifier: BSD-3-Clause

use std::path::PathBuf;
use std::sync::Arc;
use std::{path::PathBuf, sync::Arc};

use clap::{Parser, Subcommand};
use tari_shutdown::ShutdownSignal;

use crate::cli::commands;
use crate::cli::util::cli_styles;
use crate::cli::util::validate_tribe;
use crate::cli::{
commands,
util::{cli_styles, validate_tribe},
};

#[allow(clippy::struct_excessive_bools)]
#[derive(Clone, Parser, Debug)]
Expand Down
17 changes: 9 additions & 8 deletions src/cli/commands/list_tribes.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
// Copyright 2024 The Tari Project
// SPDX-License-Identifier: BSD-3-Clause

use std::sync::Arc;
use std::time::Duration;
use std::{sync::Arc, time::Duration};

use anyhow::anyhow;
use itertools::Itertools;
use tari_shutdown::{Shutdown, ShutdownSignal};
use tokio::sync::oneshot;
use tokio::task::JoinHandle;
use tokio::{select, time};
use tokio::{select, sync::oneshot, task::JoinHandle, time};

use crate::cli::args::{Cli, ListTribeArgs, StartArgs};
use crate::cli::commands::util;
use crate::server::p2p::peer_store::PeerStore;
use crate::{
cli::{
args::{Cli, ListTribeArgs, StartArgs},
commands::util,
},
server::p2p::peer_store::PeerStore,
};

pub async fn handle_list_tribes(
cli: Arc<Cli>,
Expand Down
6 changes: 4 additions & 2 deletions src/cli/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ use std::sync::Arc;

use tari_shutdown::ShutdownSignal;

use crate::cli::args::{Cli, StartArgs};
use crate::cli::commands::util;
use crate::cli::{
args::{Cli, StartArgs},
commands::util,
};

pub async fn handle_start(cli: Arc<Cli>, args: &StartArgs, cli_shutdown_signal: ShutdownSignal) -> anyhow::Result<()> {
util::server(cli, args, cli_shutdown_signal, true)
Expand Down
25 changes: 12 additions & 13 deletions src/cli/commands/util.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
// Copyright 2024 The Tari Project
// SPDX-License-Identifier: BSD-3-Clause

use std::env;
use std::sync::Arc;
use std::{env, sync::Arc};

use libp2p::identity::Keypair;
use tari_common::configuration::Network;
use tari_common::initialize_logging;
use tari_core::consensus::ConsensusManager;
use tari_core::proof_of_work::randomx_factory::RandomXFactory;
use tari_core::proof_of_work::PowAlgorithm;
use tari_common::{configuration::Network, initialize_logging};
use tari_core::{
consensus::ConsensusManager,
proof_of_work::{randomx_factory::RandomXFactory, PowAlgorithm},
};
use tari_shutdown::ShutdownSignal;

use crate::cli::args::{Cli, StartArgs};
use crate::server as main_server;
use crate::server::p2p::Tribe;
use crate::server::Server;
use crate::sharechain::in_memory::InMemoryShareChain;
use crate::sharechain::{BlockValidationParams, MAX_BLOCKS_COUNT};
use crate::{
cli::args::{Cli, StartArgs},
server as main_server,
server::{p2p::Tribe, Server},
sharechain::{in_memory::InMemoryShareChain, BlockValidationParams, MAX_BLOCKS_COUNT},
};

pub async fn server(
cli: Arc<Cli>,
Expand Down
3 changes: 1 addition & 2 deletions src/cli/util.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright 2024 The Tari Project
// SPDX-License-Identifier: BSD-3-Clause

use clap::builder::styling::AnsiColor;
use clap::builder::Styles;
use clap::builder::{styling::AnsiColor, Styles};

pub fn cli_styles() -> Styles {
Styles::styled()
Expand Down
7 changes: 5 additions & 2 deletions src/server/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ use std::{path::PathBuf, time::Duration};

use libp2p::identity::Keypair;

use crate::server::p2p::Tribe;
use crate::server::{http, p2p, p2p::peer_store::PeerStoreConfig};
use crate::server::{
http,
p2p,
p2p::{peer_store::PeerStoreConfig, Tribe},
};

/// Config is the server configuration struct.
#[derive(Clone)]
Expand Down
96 changes: 66 additions & 30 deletions src/server/grpc/base_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,52 @@ use log::error;
use minotari_app_grpc::{
tari_rpc,
tari_rpc::{
base_node_client::BaseNodeClient, Block, BlockBlobRequest, BlockGroupRequest, BlockGroupResponse,
BlockHeaderResponse, BlockHeight, BlockTimingResponse, ConsensusConstants, Empty, FetchMatchingUtxosRequest,
GetActiveValidatorNodesRequest, GetBlocksRequest, GetHeaderByHashRequest, GetMempoolTransactionsRequest,
GetNewBlockBlobResult, GetNewBlockResult, GetNewBlockTemplateWithCoinbasesRequest,
GetNewBlockWithCoinbasesRequest, GetPeersRequest, GetShardKeyRequest, GetShardKeyResponse,
GetSideChainUtxosRequest, GetTemplateRegistrationsRequest, HeightRequest, HistoricalBlock,
ListConnectedPeersResponse, ListHeadersRequest, MempoolStatsResponse, NetworkStatusResponse, NewBlockTemplate,
NewBlockTemplateRequest, NewBlockTemplateResponse, NodeIdentity, SearchKernelsRequest, SearchUtxosRequest,
SoftwareUpdate, StringValue, SubmitBlockResponse, SubmitTransactionRequest, SubmitTransactionResponse,
SyncInfoResponse, SyncProgressResponse, TipInfoResponse, TransactionStateRequest, TransactionStateResponse,
base_node_client::BaseNodeClient,
Block,
BlockBlobRequest,
BlockGroupRequest,
BlockGroupResponse,
BlockHeaderResponse,
BlockHeight,
BlockTimingResponse,
ConsensusConstants,
Empty,
FetchMatchingUtxosRequest,
GetActiveValidatorNodesRequest,
GetBlocksRequest,
GetHeaderByHashRequest,
GetMempoolTransactionsRequest,
GetNewBlockBlobResult,
GetNewBlockResult,
GetNewBlockTemplateWithCoinbasesRequest,
GetNewBlockWithCoinbasesRequest,
GetPeersRequest,
GetShardKeyRequest,
GetShardKeyResponse,
GetSideChainUtxosRequest,
GetTemplateRegistrationsRequest,
HeightRequest,
HistoricalBlock,
ListConnectedPeersResponse,
ListHeadersRequest,
MempoolStatsResponse,
NetworkStatusResponse,
NewBlockTemplate,
NewBlockTemplateRequest,
NewBlockTemplateResponse,
NodeIdentity,
SearchKernelsRequest,
SearchUtxosRequest,
SoftwareUpdate,
StringValue,
SubmitBlockResponse,
SubmitTransactionRequest,
SubmitTransactionResponse,
SyncInfoResponse,
SyncProgressResponse,
TipInfoResponse,
TransactionStateRequest,
TransactionStateResponse,
ValueAtHeightResponse,
},
};
Expand Down Expand Up @@ -112,48 +148,66 @@ impl TariBaseNodeGrpc {

#[tonic::async_trait]
impl tari_rpc::base_node_server::BaseNode for TariBaseNodeGrpc {
type FetchMatchingUtxosStream = mpsc::Receiver<Result<tari_rpc::FetchMatchingUtxosResponse, Status>>;
type GetActiveValidatorNodesStream = mpsc::Receiver<Result<tari_rpc::GetActiveValidatorNodesResponse, Status>>;
type GetBlocksStream = mpsc::Receiver<Result<HistoricalBlock, Status>>;
type GetMempoolTransactionsStream = mpsc::Receiver<Result<tari_rpc::GetMempoolTransactionsResponse, Status>>;
type GetNetworkDifficultyStream = mpsc::Receiver<Result<tari_rpc::NetworkDifficultyResponse, Status>>;
type GetPeersStream = mpsc::Receiver<Result<tari_rpc::GetPeersResponse, Status>>;
type GetSideChainUtxosStream = mpsc::Receiver<Result<tari_rpc::GetSideChainUtxosResponse, Status>>;
type GetTemplateRegistrationsStream = mpsc::Receiver<Result<tari_rpc::GetTemplateRegistrationResponse, Status>>;
type GetTokensInCirculationStream = mpsc::Receiver<Result<ValueAtHeightResponse, Status>>;
type ListHeadersStream = mpsc::Receiver<Result<BlockHeaderResponse, Status>>;
type SearchKernelsStream = mpsc::Receiver<Result<HistoricalBlock, Status>>;
type SearchUtxosStream = mpsc::Receiver<Result<HistoricalBlock, Status>>;

async fn list_headers(
&self,
request: Request<ListHeadersRequest>,
) -> Result<Response<Self::ListHeadersStream>, Status> {
proxy_stream_result!(self, list_headers, request, LIST_HEADERS_PAGE_SIZE)
}

async fn get_header_by_hash(
&self,
request: Request<GetHeaderByHashRequest>,
) -> Result<Response<BlockHeaderResponse>, Status> {
proxy_simple_result!(self, get_header_by_hash, request)
}
type GetBlocksStream = mpsc::Receiver<Result<HistoricalBlock, Status>>;

async fn get_blocks(&self, request: Request<GetBlocksRequest>) -> Result<Response<Self::GetBlocksStream>, Status> {
proxy_stream_result!(self, get_blocks, request, GET_BLOCKS_PAGE_SIZE)
}

async fn get_block_timing(&self, request: Request<HeightRequest>) -> Result<Response<BlockTimingResponse>, Status> {
proxy_simple_result!(self, get_block_timing, request)
}

async fn get_constants(&self, request: Request<BlockHeight>) -> Result<Response<ConsensusConstants>, Status> {
proxy_simple_result!(self, get_constants, request)
}

async fn get_block_size(
&self,
request: Request<BlockGroupRequest>,
) -> Result<Response<BlockGroupResponse>, Status> {
proxy_simple_result!(self, get_block_size, request)
}

async fn get_block_fees(
&self,
request: Request<BlockGroupRequest>,
) -> Result<Response<BlockGroupResponse>, Status> {
proxy_simple_result!(self, get_block_fees, request)
}

async fn get_version(&self, request: Request<Empty>) -> Result<Response<StringValue>, Status> {
proxy_simple_result!(self, get_version, request)
}

async fn check_for_updates(&self, request: Request<Empty>) -> Result<Response<SoftwareUpdate>, Status> {
proxy_simple_result!(self, check_for_updates, request)
}
type GetTokensInCirculationStream = mpsc::Receiver<Result<ValueAtHeightResponse, Status>>;

async fn get_tokens_in_circulation(
&self,
Expand All @@ -167,8 +221,6 @@ impl tari_rpc::base_node_server::BaseNode for TariBaseNodeGrpc {
)
}

type GetNetworkDifficultyStream = mpsc::Receiver<Result<tari_rpc::NetworkDifficultyResponse, Status>>;

async fn get_network_difficulty(
&self,
request: Request<HeightRequest>,
Expand Down Expand Up @@ -238,41 +290,31 @@ impl tari_rpc::base_node_server::BaseNode for TariBaseNodeGrpc {
proxy_simple_result!(self, get_tip_info, request)
}

type SearchKernelsStream = mpsc::Receiver<Result<HistoricalBlock, Status>>;

async fn search_kernels(
&self,
request: Request<SearchKernelsRequest>,
) -> Result<Response<Self::SearchKernelsStream>, Status> {
proxy_stream_result!(self, search_kernels, request, GET_BLOCKS_PAGE_SIZE)
}

type SearchUtxosStream = mpsc::Receiver<Result<HistoricalBlock, Status>>;

async fn search_utxos(
&self,
request: Request<SearchUtxosRequest>,
) -> Result<Response<Self::SearchUtxosStream>, Status> {
proxy_stream_result!(self, search_utxos, request, GET_BLOCKS_PAGE_SIZE)
}

type FetchMatchingUtxosStream = mpsc::Receiver<Result<tari_rpc::FetchMatchingUtxosResponse, Status>>;

async fn fetch_matching_utxos(
&self,
request: Request<FetchMatchingUtxosRequest>,
) -> Result<Response<Self::FetchMatchingUtxosStream>, Status> {
proxy_stream_result!(self, fetch_matching_utxos, request, GET_BLOCKS_PAGE_SIZE)
}

type GetPeersStream = mpsc::Receiver<Result<tari_rpc::GetPeersResponse, Status>>;

async fn get_peers(&self, request: Request<GetPeersRequest>) -> Result<Response<Self::GetPeersStream>, Status> {
proxy_stream_result!(self, get_peers, request, GET_BLOCKS_PAGE_SIZE)
}

type GetMempoolTransactionsStream = mpsc::Receiver<Result<tari_rpc::GetMempoolTransactionsResponse, Status>>;

async fn get_mempool_transactions(
&self,
request: Request<GetMempoolTransactionsRequest>,
Expand Down Expand Up @@ -306,8 +348,6 @@ impl tari_rpc::base_node_server::BaseNode for TariBaseNodeGrpc {
proxy_simple_result!(self, get_mempool_stats, request)
}

type GetActiveValidatorNodesStream = mpsc::Receiver<Result<tari_rpc::GetActiveValidatorNodesResponse, Status>>;

async fn get_active_validator_nodes(
&self,
request: Request<GetActiveValidatorNodesRequest>,
Expand All @@ -322,17 +362,13 @@ impl tari_rpc::base_node_server::BaseNode for TariBaseNodeGrpc {
proxy_simple_result!(self, get_shard_key, request)
}

type GetTemplateRegistrationsStream = mpsc::Receiver<Result<tari_rpc::GetTemplateRegistrationResponse, Status>>;

async fn get_template_registrations(
&self,
request: Request<GetTemplateRegistrationsRequest>,
) -> Result<Response<Self::GetTemplateRegistrationsStream>, Status> {
proxy_stream_result!(self, get_template_registrations, request, 10)
}

type GetSideChainUtxosStream = mpsc::Receiver<Result<tari_rpc::GetSideChainUtxosResponse, Status>>;

async fn get_side_chain_utxos(
&self,
request: Request<GetSideChainUtxosRequest>,
Expand Down
Loading

0 comments on commit 38ee3bd

Please sign in to comment.