Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: enforce warnings as errors #1783

Merged
merged 4 commits into from
Mar 16, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/tests-rs-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ jobs:
set -ex
features="${{ steps.crate_info.outputs.features }}"
fails=""
RUSTFLAGS="-D warnings"
cargo check --no-default-features --package "${{ inputs.package }}" --locked
for feature in $features ; do
echo " ============== Verify feature $feature =============="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use std::collections::HashSet;
use std::collections::{BTreeMap, BTreeSet};
use std::convert::TryInto;

#[cfg(feature = "validation")]
use crate::consensus::basic::data_contract::InvalidDocumentTypeRequiredSecurityLevelError;
#[cfg(feature = "validation")]
use crate::consensus::basic::document::MissingPositionsInDocumentTypePropertiesError;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::data_contract::document_type::DocumentTypeRef;
#[cfg(feature = "validation")]
use crate::validation::ConsensusValidationResult;
use crate::version::PlatformVersion;
use crate::ProtocolError;
Expand Down
2 changes: 2 additions & 0 deletions packages/rs-dpp/src/document/v0/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ use platform_version::version::FeatureVersion;
use std::collections::BTreeMap;

use crate::consensus::basic::decode::DecodingError;
#[cfg(feature = "validation")]
use crate::consensus::basic::BasicError;
#[cfg(feature = "validation")]
use crate::consensus::ConsensusError;
use std::io::{BufReader, Read};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use crate::document::Document;
use crate::identity::signer::Signer;
#[cfg(feature = "state-transition-signing")]
use crate::identity::IdentityPublicKey;
use crate::prelude::{IdentityNonce, UserFeeIncrease};
use crate::prelude::IdentityNonce;
#[cfg(feature = "state-transition-signing")]
use crate::prelude::UserFeeIncrease;
use crate::state_transition::documents_batch_transition::document_transition::DocumentTransition;
use crate::state_transition::documents_batch_transition::methods::v0::DocumentsBatchTransitionMethodsV0;
use crate::state_transition::documents_batch_transition::DocumentsBatchTransition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use crate::identity::signer::Signer;
#[cfg(feature = "state-transition-signing")]
use crate::identity::IdentityPublicKey;
use crate::identity::SecurityLevel;
use crate::prelude::{IdentityNonce, UserFeeIncrease};
use crate::prelude::IdentityNonce;
#[cfg(feature = "state-transition-signing")]
use crate::prelude::UserFeeIncrease;
use crate::state_transition::documents_batch_transition::accessors::DocumentsBatchTransitionAccessorsV0;
use crate::state_transition::documents_batch_transition::document_base_transition::v0::v0_methods::DocumentBaseTransitionV0Methods;
use crate::state_transition::documents_batch_transition::document_transition::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use crate::identity::signer::Signer;
use crate::identity::SecurityLevel;
#[cfg(feature = "state-transition-signing")]
use crate::prelude::IdentityPublicKey;
use crate::prelude::{IdentityNonce, UserFeeIncrease};
use crate::prelude::IdentityNonce;
#[cfg(feature = "state-transition-signing")]
use crate::prelude::UserFeeIncrease;
use crate::state_transition::documents_batch_transition::accessors::DocumentsBatchTransitionAccessorsV0;
#[cfg(feature = "state-transition-signing")]
use crate::state_transition::documents_batch_transition::document_create_transition::DocumentCreateTransition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ use crate::identity::{Identity, IdentityPublicKey};
use crate::identity::accessors::IdentityGettersV0;
#[cfg(feature = "state-transition-signing")]
use crate::identity::identity_public_key::accessors::v0::IdentityPublicKeyGettersV0;
use crate::prelude::{IdentityNonce, UserFeeIncrease};
use crate::prelude::IdentityNonce;
#[cfg(feature = "state-transition-signing")]
use crate::prelude::UserFeeIncrease;
use crate::state_transition::identity_update_transition::accessors::IdentityUpdateTransitionAccessorsV0;
use crate::state_transition::identity_update_transition::methods::IdentityUpdateTransitionMethodsV0;
use crate::state_transition::identity_update_transition::v0::IdentityUpdateTransitionV0;
Expand Down
45 changes: 25 additions & 20 deletions packages/rs-drive-abci/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use drive_abci::rpc::core::DefaultCoreRPC;
use drive_abci::{logging, server};
use itertools::Itertools;
use std::fs::remove_file;
#[cfg(tokio_unstable)]
use std::net::SocketAddr;
use std::path::PathBuf;
use std::process::ExitCode;
Expand All @@ -20,7 +21,9 @@ use tokio::runtime::{Builder, Runtime};
use tokio::signal::unix::{signal, SignalKind};
use tokio::time::Duration;
use tokio_util::sync::CancellationToken;
#[cfg(tokio_unstable)]
use tracing_subscriber::layer::SubscriberExt;
#[cfg(tokio_unstable)]
use tracing_subscriber::util::SubscriberInitExt;

const SHUTDOWN_TIMEOUT_MILIS: u64 = 5000; // 5s; Docker defaults to 10s
Expand Down Expand Up @@ -165,26 +168,28 @@ fn main() -> Result<(), ExitCode> {
panic!("tokio_unstable flag should be set");

// Initialize Tokio console subscriber

let socket_addr: SocketAddr = config
.tokio_console_address
.parse()
.expect("cannot parse tokio console address");

let console_layer = console_subscriber::ConsoleLayer::builder()
.retention(Duration::from_secs(config.tokio_console_retention_secs))
.server_addr(socket_addr)
.spawn();

tracing_subscriber::registry()
.with(
loggers
.tracing_subscriber_layers()
.expect("should return layers"),
)
.with(console_layer)
.try_init()
.expect("can't init tracing subscribers");
#[cfg(tokio_unstable)]
{
let socket_addr: SocketAddr = config
.tokio_console_address
.parse()
.expect("cannot parse tokio console address");

let console_layer = console_subscriber::ConsoleLayer::builder()
.retention(Duration::from_secs(config.tokio_console_retention_secs))
.server_addr(socket_addr)
.spawn();

tracing_subscriber::registry()
.with(
loggers
.tracing_subscriber_layers()
.expect("should return layers"),
)
.with(console_layer)
.try_init()
.expect("can't init tracing subscribers");
}
} else {
loggers.install();
}
Expand Down
4 changes: 2 additions & 2 deletions packages/rs-drive-abci/src/utils/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use tokio::task::JoinHandle;

/// Spawn a blocking tokio task with name if tokio_unstable flag is set
pub fn spawn_blocking_task_with_name_if_supported<Function, Output>(
name: &str,
_sometimes_used_name: &str,
function: Function,
) -> io::Result<JoinHandle<Output>>
where
Expand All @@ -13,7 +13,7 @@ where
#[cfg(all(tokio_unstable, feature = "console"))]
{
tokio::task::Builder::new()
.name(name)
.name(_sometimes_used_name)
.spawn_blocking(function)
}

Expand Down
1 change: 1 addition & 0 deletions packages/rs-drive-abci/tests/strategy_tests/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ pub enum CoreHeightIncrease {
#[default]
NoCoreHeightIncrease,
RandomCoreHeightIncrease(Frequency),
#[allow(dead_code)] // TODO investigate why this is never constructed according to compiler
KnownCoreHeightIncreases(Vec<u32>),
}

Expand Down
2 changes: 2 additions & 0 deletions packages/rs-drive/src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ use dpp::data_contract::DataContract;

#[cfg(feature = "full")]
use dpp::block::block_info::BlockInfo;
#[cfg(feature = "fixtures-and-mocks")]
use dpp::prelude::Identifier;

#[cfg(feature = "fixtures-and-mocks")]
use dpp::tests::json_document::json_document_to_contract_with_ids;
#[cfg(feature = "fixtures-and-mocks")]
use dpp::version::PlatformVersion;

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl DriveHighLevelOperationConverter for DataContractCreateTransitionAction {
_epoch: &Epoch,
_platform_version: &PlatformVersion,
) -> Result<Vec<DriveOperation<'a>>, Error> {
let operations = vec![
Ok(vec![
IdentityOperation(IdentityOperationType::UpdateIdentityNonce {
identity_id: self.data_contract_ref().owner_id().into_buffer(),
nonce: self.identity_nonce(),
Expand All @@ -31,8 +31,6 @@ impl DriveHighLevelOperationConverter for DataContractCreateTransitionAction {
contract: Cow::Owned(self.data_contract()),
storage_flags: None,
}),
];

Ok(operations)
])
}
}
3 changes: 3 additions & 0 deletions packages/rs-drive/src/drive/contract/contract_fetch_info.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::drive::flags::StorageFlags;
use dpp::data_contract::DataContract;
#[cfg(feature = "fixtures-and-mocks")]
use dpp::data_contracts;
use dpp::fee::fee_result::FeeResult;
#[cfg(feature = "fixtures-and-mocks")]
use dpp::system_data_contracts::load_system_data_contract;
#[cfg(feature = "fixtures-and-mocks")]
use dpp::tests::fixtures::get_dashpay_contract_fixture;
Expand All @@ -10,6 +12,7 @@ use dpp::tests::fixtures::get_dpns_data_contract_fixture;
#[cfg(feature = "fixtures-and-mocks")]
use dpp::tests::fixtures::get_masternode_reward_shares_data_contract_fixture;
use grovedb_costs::OperationCost;
#[cfg(feature = "fixtures-and-mocks")]
use platform_version::version::PlatformVersion;

#[cfg(any(feature = "full", feature = "verify"))]
Expand Down
1 change: 1 addition & 0 deletions packages/rs-drive/src/drive/credit_pools/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ use crate::fee_pools::epochs::paths::EpochProposers;
use dpp::block::epoch::{Epoch, EpochIndex};
#[cfg(feature = "full")]
use dpp::fee::epoch::SignedCreditsPerEpoch;
#[cfg(feature = "full")]
use dpp::fee::SignedCredits;
#[cfg(feature = "full")]
use grovedb::query_result_type::QueryResultType;
Expand Down
2 changes: 1 addition & 1 deletion packages/rs-drive/src/drive/document/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@
//! Namely functions to return the paths to certain objects and the path sizes.
//!

#[cfg(any(feature = "full", feature = "verify"))]
#[cfg(feature = "full")]
use crate::drive::defaults::DEFAULT_HASH_SIZE_U8;
#[cfg(feature = "full")]
use crate::drive::flags::StorageFlags;
#[cfg(any(feature = "full", feature = "verify"))]
use crate::drive::{defaults, RootTree};
use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters;

Check warning on line 42 in packages/rs-drive/src/drive/document/mod.rs

View workflow job for this annotation

GitHub Actions / Rust packages (rs-sdk) / Linting

unused import: `dpp::data_contract::document_type::accessors::DocumentTypeV0Getters`

warning: unused import: `dpp::data_contract::document_type::accessors::DocumentTypeV0Getters` --> packages/rs-drive/src/drive/document/mod.rs:42:5 | 42 | use dpp::data_contract::document_type::accessors::DocumentTypeV0Getters; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default
use dpp::data_contract::document_type::methods::DocumentTypeV0Methods;

Check warning on line 43 in packages/rs-drive/src/drive/document/mod.rs

View workflow job for this annotation

GitHub Actions / Rust packages (rs-sdk) / Linting

unused import: `dpp::data_contract::document_type::methods::DocumentTypeV0Methods`

warning: unused import: `dpp::data_contract::document_type::methods::DocumentTypeV0Methods` --> packages/rs-drive/src/drive/document/mod.rs:43:5 | 43 | use dpp::data_contract::document_type::methods::DocumentTypeV0Methods; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#[cfg(any(feature = "full", feature = "verify"))]
use dpp::data_contract::document_type::DocumentTypeRef;

Check warning on line 45 in packages/rs-drive/src/drive/document/mod.rs

View workflow job for this annotation

GitHub Actions / Rust packages (rs-sdk) / Linting

unused import: `dpp::data_contract::document_type::DocumentTypeRef`

warning: unused import: `dpp::data_contract::document_type::DocumentTypeRef` --> packages/rs-drive/src/drive/document/mod.rs:45:5 | 45 | use dpp::data_contract::document_type::DocumentTypeRef; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#[cfg(feature = "full")]
use dpp::document::Document;
use dpp::document::DocumentV0Getters;

Check warning on line 48 in packages/rs-drive/src/drive/document/mod.rs

View workflow job for this annotation

GitHub Actions / Rust packages (rs-sdk) / Linting

unused import: `dpp::document::DocumentV0Getters`

warning: unused import: `dpp::document::DocumentV0Getters` --> packages/rs-drive/src/drive/document/mod.rs:48:5 | 48 | use dpp::document::DocumentV0Getters; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#[cfg(feature = "full")]
use grovedb::batch::key_info::KeyInfo;
#[cfg(feature = "full")]
Expand Down Expand Up @@ -84,7 +84,7 @@

#[cfg(any(feature = "full", feature = "verify"))]
/// Returns the path to a contract document type.
pub(crate) fn contract_document_type_path_vec(

Check warning on line 87 in packages/rs-drive/src/drive/document/mod.rs

View workflow job for this annotation

GitHub Actions / Rust packages (rs-sdk) / Linting

function `contract_document_type_path_vec` is never used

warning: function `contract_document_type_path_vec` is never used --> packages/rs-drive/src/drive/document/mod.rs:87:15 | 87 | pub(crate) fn contract_document_type_path_vec( | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default
contract_id: &[u8],
document_type_name: &str,
) -> Vec<Vec<u8>> {
Expand All @@ -98,7 +98,7 @@

#[cfg(any(feature = "full", feature = "verify"))]
/// Returns the path to the primary keys of a contract document type.
pub(crate) fn contract_documents_primary_key_path<'a>(

Check warning on line 101 in packages/rs-drive/src/drive/document/mod.rs

View workflow job for this annotation

GitHub Actions / Rust packages (rs-sdk) / Linting

function `contract_documents_primary_key_path` is never used

warning: function `contract_documents_primary_key_path` is never used --> packages/rs-drive/src/drive/document/mod.rs:101:15 | 101 | pub(crate) fn contract_documents_primary_key_path<'a>( | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
contract_id: &'a [u8],
document_type_name: &'a str,
) -> [&'a [u8]; 5] {
Expand All @@ -113,7 +113,7 @@

#[cfg(any(feature = "full", feature = "verify"))]
/// Returns the path to a contract document.
fn contract_documents_keeping_history_primary_key_path_for_document_id<'a>(

Check warning on line 116 in packages/rs-drive/src/drive/document/mod.rs

View workflow job for this annotation

GitHub Actions / Rust packages (rs-sdk) / Linting

function `contract_documents_keeping_history_primary_key_path_for_document_id` is never used

warning: function `contract_documents_keeping_history_primary_key_path_for_document_id` is never used --> packages/rs-drive/src/drive/document/mod.rs:116:4 | 116 | fn contract_documents_keeping_history_primary_key_path_for_document_id<'a>( | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
contract_id: &'a [u8],
document_type_name: &'a str,
document_id: &'a [u8],
Expand Down Expand Up @@ -159,7 +159,7 @@

#[cfg(any(feature = "full", feature = "verify"))]
/// Returns the size of the path to the time at which a document type was stored.
fn contract_documents_keeping_history_storage_time_reference_path_size(

Check warning on line 162 in packages/rs-drive/src/drive/document/mod.rs

View workflow job for this annotation

GitHub Actions / Rust packages (rs-sdk) / Linting

function `contract_documents_keeping_history_storage_time_reference_path_size` is never used

warning: function `contract_documents_keeping_history_storage_time_reference_path_size` is never used --> packages/rs-drive/src/drive/document/mod.rs:162:4 | 162 | fn contract_documents_keeping_history_storage_time_reference_path_size( | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
document_type_name_len: u32,
) -> u32 {
defaults::BASE_CONTRACT_DOCUMENTS_KEEPING_HISTORY_STORAGE_TIME_REFERENCE_PATH
Expand Down
Loading