Skip to content
Open
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
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ RUST_BACKTRACE = "1"
# workaround for dependency `leveldb-sys v2.0.9`
CMAKE_POLICY_VERSION_MINIMUM = "3.5"
CC = "clang"
CXX = "clang++"
CXX = "clang++"
15 changes: 7 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: clean help stats bench all install run test build doc check format bench-no-run pretty-log ensure-clang

prog :=neptune-core
prog :=nyks-node

# Passive dependency-checker. Informs and exits.
check-clang:
Expand Down Expand Up @@ -41,7 +41,7 @@ build: ensure-clang

doc:
cargo doc --no-deps
xdg-open "target/doc/neptune-core/index.html"
xdg-open "target/doc/nyks_node/index.html"

check: check-clang
cargo check
Expand All @@ -59,12 +59,11 @@ happy: clippy format
cargo test --doc

install: ensure-clang
cargo install --force --locked --path neptune-core/
cargo install --force --locked --path neptune-core-cli/
cargo install --force --locked --path neptune-dashboard/

install-linux: install
@echo "\n\nPlease run:\n./scripts/linux/install-bash-completions.sh\nto install bash-completions for Neptune-core's CLI."
cargo install --force --locked --path nyks-node/
cargo install --force --locked --path nyks-prover/
cargo install --force --locked --path nyks-wallet/
cargo install --force --locked --path nyks-composer/
cargo install --force --locked --path nyks-upgrader/

clippy:
cargo clippy --all-targets -- -D warnings
Expand Down
1 change: 0 additions & 1 deletion composer/src/composer/prover/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ impl TransactionProver {
rng.random(),
consensus_rule_set,
)
.await
.unwrap()
.into();

Expand Down
2 changes: 1 addition & 1 deletion consensus/src/block/block_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl BlockTransaction {
/// See also: [`Transaction::merge_with`], which should be used if
/// - a) the arguments are two regular [`Transaction`]s; and
/// - b) the result must be a regular [`Transaction`] as well.
pub async fn merge(
pub fn merge(
coinbase: BlockOrRegularTransaction,
other: Transaction,
shuffle_seed: [u8; 32],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,10 +564,10 @@ impl RemovalRecordList {
{
if *tree_height < Self::ENCODING_TREE_HEIGHT_OFFSET {
// Verify that tree heights are sorted correctly
if let Some(previous) = tree_heights.last() {
if *previous > *tree_height {
return Err(RemovalRecordListUnpackError::IncorrectlySortedTreeHeights);
}
if let Some(previous) = tree_heights.last()
&& *previous > *tree_height
{
return Err(RemovalRecordListUnpackError::IncorrectlySortedTreeHeights);
}

// use both authentication structure and chunk
Expand Down
2 changes: 1 addition & 1 deletion consensus/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl Transaction {
/// set hashes are not the same, if both transactions have coinbase a
/// coinbase UTXO, if either of the transactions are *not* a single
/// proof, or if the RHS (`other`) has a negative fee.
pub async fn merge_with(
pub fn merge_with(
self,
other: Transaction,
shuffle_seed: [u8; 32],
Expand Down
1 change: 1 addition & 0 deletions consensus/src/transaction/transaction_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl TransactionProofType {

/// represents a transaction proof, which can be of different types.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, GetSize, BFieldCodec)]
#[allow(clippy::large_enum_variant)]
pub enum TransactionProof {
/// a strong proof. required for confirming a transaction into a block.
SingleProof(NyksProof),
Expand Down
15 changes: 1 addition & 14 deletions node/src/application/config/cli_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use clap::builder::TypedValueParser;
use clap::Parser;
use libp2p::multiaddr::Protocol;
use libp2p::Multiaddr;
use nyks_consensus::transaction::transaction_proof::TransactionProofQuality;
use nyks_consensus::network::Network;
use nyks_consensus::transaction::transaction_proof::TransactionProofQuality;
use nyks_consensus::type_scripts::native_currency_amount::NativeCurrencyAmount;
use nyks_rpc_core::api::ops::Namespace;
use tracing::error;
Expand Down Expand Up @@ -271,19 +271,6 @@ pub struct Args {
#[clap(long, default_value = "1800", value_parser = duration_from_seconds_str)]
pub reconnect_cooldown: Duration,

/// Construct and maintain a UTXO index
///
/// If set, all announcements and inputs in all processed blocks will be
/// indexed in a database that enables a fast rescan for the discovery of
/// all balance-affecting inputs and outputs of blocks.
///
/// If blocks have already been processed without this flag active, and the
/// flag is later activated, all blocks up to the current tip will be
/// indexed, when a new block is set as tip. This process might take some
/// time (tens of minutes).
#[clap(long)]
pub utxo_index: bool,

/// Enable JSON/HTTP RPC.
/// You can optionally specify an address and port (default: 127.0.0.1:9797).
/// If not given, RPC is disabled.
Expand Down
24 changes: 0 additions & 24 deletions node/src/application/config/data_directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use serde::Serialize;
use crate::state::archival_state::ARCHIVAL_BLOCK_MMR_DIRECTORY_NAME;
use crate::state::archival_state::BLOCK_INDEX_DB_NAME;
use crate::state::archival_state::MUTATOR_SET_DIRECTORY_NAME;
use crate::state::archival_state::UTXO_INDEX_DIRECTORY_NAME;
use crate::state::database::DATABASE_DIRECTORY_ROOT_NAME;
use crate::state::networking_state::BANNED_IPS_DB_NAME;
use crate::state::shared::BLOCK_FILENAME_EXTENSION;
Expand Down Expand Up @@ -74,15 +73,11 @@ impl DataDirectory {
.context("open_ensure_parent_dir_exists")
}

///////////////////////////////////////////////////////////////////////////
///
/// The root data directory path
pub fn root_dir_path(&self) -> PathBuf {
self.data_dir.clone()
}

///////////////////////////////////////////////////////////////////////////
///
/// The block database directory path
pub fn database_dir_path(&self) -> PathBuf {
self.data_dir.join(Path::new(DATABASE_DIRECTORY_ROOT_NAME))
Expand All @@ -92,24 +87,19 @@ impl DataDirectory {
self.data_dir.join(Path::new(NETWORK_SUBDIRECTORY_NAME))
}

///////////////////////////////////////////////////////////////////////////
///
/// The banned IPs database directory path.
///
/// This directory lives within `DataDirectory::database_dir_path()`.
pub fn banned_ips_database_dir_path(&self) -> PathBuf {
self.database_dir_path().join(Path::new(BANNED_IPS_DB_NAME))
}

///////////////////////////////////////////////////////////////////////////
/// directory for storing database backups before migrating schema to newer version
pub fn db_migration_backups_dir_path(&self) -> PathBuf {
self.database_dir_path()
.join(Path::new(DB_MIGRATION_BACKUPS_DIR))
}

///////////////////////////////////////////////////////////////////////////
///
/// The mutator set database directory path.
///
/// This directory lives within `DataDirectory::database_dir_path()`.
Expand All @@ -118,8 +108,6 @@ impl DataDirectory {
.join(Path::new(MUTATOR_SET_DIRECTORY_NAME))
}

///////////////////////////////////////////////////////////////////////////
///
/// The archival block MMR database directory path
///
/// This directory lives within `DataDirectory::database_dir_path()`.
Expand All @@ -128,18 +116,6 @@ impl DataDirectory {
.join(Path::new(ARCHIVAL_BLOCK_MMR_DIRECTORY_NAME))
}

///////////////////////////////////////////////////////////////////////////
///
/// The UTXO index database directory path
///
/// This directory lives within `DataDirectory::database_dir_path()`.
pub(crate) fn utxo_index_dir_path(&self) -> PathBuf {
self.database_dir_path()
.join(Path::new(UTXO_INDEX_DIRECTORY_NAME))
}

///////////////////////////////////////////////////////////////////////////
///
/// The block body directory.
///
/// This directory lives within `DataDirectory::root_dir_path()`.
Expand Down
10 changes: 0 additions & 10 deletions node/src/application/rpc/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,6 @@ impl RpcServer {
}
}

if namespaces.contains(&Namespace::Utxoindex) {
let has_utxo_index =
state.chain.is_archival_node() && state.chain.archival_state().utxo_index.is_some();

if !has_utxo_index {
namespaces.remove(&Namespace::Utxoindex);
error!("Node does not maintain a UTXO index, cannot enable utxoindex namespace.");
}
}

if !self.unrestricted && namespaces.contains(&Namespace::Network) {
warn!("Networking module is enabled without unsafe mode - this may expose sensitive data.")
}
Expand Down
110 changes: 0 additions & 110 deletions node/src/application/rpc/service.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
use std::collections::HashSet;

use async_trait::async_trait;
use itertools::Itertools;
use nyks_consensus::block::Block;
use nyks_consensus::block::FUTUREDATING_LIMIT;
use nyks_consensus::mutator_set::addition_record::AdditionRecord;
use nyks_consensus::mutator_set::removal_record::absolute_index_set::AbsoluteIndexSet;
use nyks_consensus::proof_abstractions::timestamp::Timestamp;
use nyks_consensus::transaction::Transaction;
use nyks_rpc_core::api::rpc::*;
Expand Down Expand Up @@ -650,112 +646,6 @@ impl RpcApi for RpcServer {
Ok(SubmitBlockResponse { success })
}

/* Utxoindex */

async fn block_heights_by_flags_call(
&self,
request: BlockHeightsByFlagsRequest,
) -> RpcResult<BlockHeightsByFlagsResponse> {
let announcement_flags: HashSet<_> = request.announcement_flags.into_iter().collect();
let heights = self
.state
.lock_guard()
.await
.chain
.archival_state()
.utxo_index
.as_ref()
.expect("Utxo index namespace can only be active when UTXO index is present")
.blocks_by_announcement_flags(&announcement_flags)
.await;

let block_heights = BlockHeightsByFlagsResponse {
block_heights: heights.into_iter().collect(),
};

Ok(block_heights)
}

async fn block_heights_by_addition_records_call(
&self,
request: BlockHeightsByAdditionRecordsRequest,
) -> RpcResult<BlockHeightsByAdditionRecordsResponse> {
let addition_records: HashSet<AdditionRecord> = request
.addition_records
.into_iter()
.map(|x| x.into())
.collect();

let block_heights = self
.state
.lock_guard()
.await
.chain
.archival_state()
.addition_records_to_block_height(addition_records)
.await
.expect("Utxo index namespace can only be active when UTXO index is present");

let block_heights = BlockHeightsByAdditionRecordsResponse {
block_heights: block_heights.into_iter().collect(),
};

Ok(block_heights)
}

async fn block_heights_by_absolute_index_sets_call(
&self,
request: BlockHeightsByAbsoluteIndexSetsRequest,
) -> RpcResult<BlockHeightsByAbsoluteIndexSetsResponse> {
let absolute_index_sets: HashSet<AbsoluteIndexSet> =
request.absolute_index_sets.into_iter().collect();

let block_heights = self
.state
.lock_guard()
.await
.chain
.archival_state()
.absolute_index_sets_to_block_heights(absolute_index_sets)
.await
.expect("Utxo index namespace can only be active when UTXO index is present");

let block_heights = BlockHeightsByAbsoluteIndexSetsResponse {
block_heights: block_heights.into_iter().collect(),
};

Ok(block_heights)
}

async fn was_mined_call(&self, request: WasMinedRequest) -> RpcResult<WasMinedResponse> {
if request.addition_records.is_empty() && request.absolute_index_sets.is_empty() {
return Err(RpcError::EmptyFilteringConditions);
}

let addition_records = request
.addition_records
.into_iter()
.map(|x| x.into())
.collect();
let absolute_index_sets = request.absolute_index_sets.into_iter().collect();

let blocks = self
.state
.lock_guard()
.await
.chain
.archival_state()
.canonical_block_heights_with_puts(absolute_index_sets, addition_records)
.await
.expect("UTXO index namespace is only active if UTXO index is maintained");

let res = WasMinedResponse {
block_heights: blocks.into_iter().collect(),
};

Ok(res)
}

/* Mempool */

async fn transactions_call(&self, _: TransactionsRequest) -> RpcResult<TransactionsResponse> {
Expand Down
Loading
Loading