Addresses clippy lints (#8723)
This commit is contained in:
parent
0fdd26431e
commit
6181ebe239
|
@ -27,6 +27,7 @@ impl Arbitrary for DateTime32 {
|
|||
/// - making durations and intervals 3 seconds or longer,
|
||||
/// - avoiding complex time-based calculations, and
|
||||
/// - avoiding relying on subsecond precision or time order.
|
||||
///
|
||||
/// When monotonic times are needed, use the opaque `std::time::Instant` type.
|
||||
///
|
||||
/// # Usage
|
||||
|
|
|
@ -97,6 +97,7 @@ pub fn difficulty_threshold_is_valid(
|
|||
/// Returns `Ok(())` if `hash` passes:
|
||||
/// - the target difficulty limit for `network` (PoWLimit), and
|
||||
/// - the difficulty filter,
|
||||
///
|
||||
/// based on the fields in `header`.
|
||||
///
|
||||
/// If the block is invalid, returns an error containing `height` and `hash`.
|
||||
|
@ -286,8 +287,8 @@ pub fn time_is_valid_at(
|
|||
/// # Consensus rules:
|
||||
///
|
||||
/// - A SHA-256d hash in internal byte order. The merkle root is derived from the
|
||||
/// hashes of all transactions included in this block, ensuring that none of
|
||||
/// those transactions can be modified without modifying the header. [7.6]
|
||||
/// hashes of all transactions included in this block, ensuring that none of
|
||||
/// those transactions can be modified without modifying the header. [7.6]
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
|
|
|
@ -49,9 +49,11 @@ use crate::error::TransactionError;
|
|||
///
|
||||
/// > the nTime field MUST represent a time strictly greater than the median of the
|
||||
/// > timestamps of the past PoWMedianBlockSpan blocks.
|
||||
///
|
||||
/// <https://zips.z.cash/protocol/protocol.pdf#blockheader>
|
||||
///
|
||||
/// > The transaction can be added to any block whose block time is greater than the locktime.
|
||||
///
|
||||
/// <https://developer.bitcoin.org/devguide/transactions.html#locktime-and-sequence-number>
|
||||
///
|
||||
/// If the transaction's lock time is less than the median-time-past,
|
||||
|
|
|
@ -275,11 +275,11 @@ fn sapling_onwards_strategy() -> impl Strategy<Value = (Network, block::Height)>
|
|||
/// # Panics
|
||||
///
|
||||
/// - if `transaction_version` is not `4` or `5` (the only transaction versions that are currently
|
||||
/// supported by the transaction verifier)
|
||||
/// supported by the transaction verifier)
|
||||
/// - if `relative_source_heights` has more than `u32::MAX` items (see
|
||||
/// [`mock_transparent_transfers`] for details)
|
||||
/// [`mock_transparent_transfers`] for details)
|
||||
/// - if any item of `relative_source_heights` is not in the range `0.0..1.0` (see
|
||||
/// [`scale_block_height`] for details)
|
||||
/// [`scale_block_height`] for details)
|
||||
fn mock_transparent_transaction(
|
||||
network: &Network,
|
||||
block_height: block::Height,
|
||||
|
|
|
@ -9,10 +9,9 @@ use crate::methods::get_block_template_rpcs::GetBlockTemplateRpc;
|
|||
/// See notes for [`GetBlockTemplateRpc::submit_block`] method
|
||||
#[derive(Clone, Debug, PartialEq, Eq, serde::Deserialize)]
|
||||
pub struct JsonParameters {
|
||||
/// The workid for the block template.
|
||||
/// The workid for the block template. Currently unused.
|
||||
///
|
||||
/// > If the server provided a workid, it MUST be included with submissions,
|
||||
/// currently unused.
|
||||
///
|
||||
/// Rationale:
|
||||
///
|
||||
|
|
|
@ -128,9 +128,9 @@ impl Runner {
|
|||
/// In this loop, get the transactions that are in the queue and:
|
||||
/// - Check if they are now in the mempool and if so, delete the transaction from the queue.
|
||||
/// - Check if the transaction is now part of a block in the state and if so,
|
||||
/// delete the transaction from the queue.
|
||||
/// delete the transaction from the queue.
|
||||
/// - With the transactions left in the queue, retry sending them to the mempool ignoring
|
||||
/// the result of this operation.
|
||||
/// the result of this operation.
|
||||
///
|
||||
/// Additionally, each iteration of the above loop, will receive and insert to the queue
|
||||
/// transactions that are pending in the channel.
|
||||
|
|
|
@ -116,12 +116,12 @@ impl FixHttpRequestMiddleware {
|
|||
/// # Security
|
||||
///
|
||||
/// - `content-type` headers exist so that applications know they are speaking the correct protocol with the correct format.
|
||||
/// We can be a bit flexible, but there are some types (such as binary) we shouldn't allow.
|
||||
/// In particular, the "application/x-www-form-urlencoded" header should be rejected, so browser forms can't be used to attack
|
||||
/// a local RPC port. See "The Role of Routers in the CSRF Attack" in
|
||||
/// <https://www.invicti.com/blog/web-security/importance-content-type-header-http-requests/>
|
||||
/// We can be a bit flexible, but there are some types (such as binary) we shouldn't allow.
|
||||
/// In particular, the "application/x-www-form-urlencoded" header should be rejected, so browser forms can't be used to attack
|
||||
/// a local RPC port. See "The Role of Routers in the CSRF Attack" in
|
||||
/// <https://www.invicti.com/blog/web-security/importance-content-type-header-http-requests/>
|
||||
/// - Checking all the headers is secure, but only because hyper has custom code that just reads the first content-type header.
|
||||
/// <https://github.com/hyperium/headers/blob/f01cc90cf8d601a716856bc9d29f47df92b779e4/src/common/content_type.rs#L102-L108>
|
||||
/// <https://github.com/hyperium/headers/blob/f01cc90cf8d601a716856bc9d29f47df92b779e4/src/common/content_type.rs#L102-L108>
|
||||
pub fn insert_or_replace_content_type_header(headers: &mut header::HeaderMap) {
|
||||
if !headers.contains_key(header::CONTENT_TYPE)
|
||||
|| headers
|
||||
|
|
|
@ -29,6 +29,7 @@ use crate::{
|
|||
/// - Returns an error, or
|
||||
/// - Returns the block hash of a block that the read state already contains,
|
||||
/// (so that there's nothing for the syncer to do except wait for the next chain tip change).
|
||||
///
|
||||
/// See the [`TrustedChainSync::wait_for_chain_tip_change()`] method documentation for more information.
|
||||
const POLL_DELAY: Duration = Duration::from_millis(200);
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ pub fn main() {
|
|||
|
||||
for txid in txids.iter() {
|
||||
let tx = Transaction::read(
|
||||
&hex::decode(&fetch_tx_via_rpc(txid.encode_hex()))
|
||||
&hex::decode(fetch_tx_via_rpc(txid.encode_hex()))
|
||||
.expect("RPC response should be decodable from hex string to bytes")[..],
|
||||
BranchId::for_height(&network, height),
|
||||
)
|
||||
|
|
|
@ -389,6 +389,7 @@ impl DiskWriteBatch {
|
|||
/// - insert created UTXOs,
|
||||
/// - insert transparent address UTXO index entries, and
|
||||
/// - insert transparent address transaction entries,
|
||||
///
|
||||
/// without actually writing anything.
|
||||
///
|
||||
/// Also modifies the `address_balances` for these new UTXOs.
|
||||
|
@ -466,6 +467,7 @@ impl DiskWriteBatch {
|
|||
/// Adds the following changes to this batch:
|
||||
/// - delete spent UTXOs, and
|
||||
/// - delete transparent address UTXO index entries,
|
||||
///
|
||||
/// without actually writing anything.
|
||||
///
|
||||
/// Also modifies the `address_balances` for these new UTXOs.
|
||||
|
@ -523,6 +525,7 @@ impl DiskWriteBatch {
|
|||
/// Adds the following changes to this batch:
|
||||
/// - index spending transactions for each spent transparent output
|
||||
/// (this is different from the transaction that created the output),
|
||||
///
|
||||
/// without actually writing anything.
|
||||
///
|
||||
/// # Errors
|
||||
|
@ -573,6 +576,7 @@ impl DiskWriteBatch {
|
|||
|
||||
/// Prepare a database batch containing `finalized.block`'s:
|
||||
/// - transparent address balance changes,
|
||||
///
|
||||
/// and return it (without actually writing anything).
|
||||
///
|
||||
/// # Errors
|
||||
|
|
|
@ -182,6 +182,7 @@ impl NonFinalizedState {
|
|||
// Chain::cmp uses the partial cumulative work, and the hash of the tip block.
|
||||
// Neither of these fields has interior mutability.
|
||||
// (And when the tip block is dropped for a chain, the chain is also dropped.)
|
||||
#[allow(clippy::mutable_key_type)]
|
||||
let chains = mem::take(&mut self.chain_set);
|
||||
let mut chains = chains.into_iter();
|
||||
|
||||
|
|
|
@ -28,9 +28,9 @@ use crate::{
|
|||
/// - `transaction_has_valid_network_upgrade`: See `LedgerState::height_strategy` for details.
|
||||
/// Note: `false` allows zero or more invalid network upgrades.
|
||||
/// - `blocks_after_nu_activation`: The number of blocks the strategy will generate
|
||||
/// after the provided `network_upgrade`.
|
||||
/// after the provided `network_upgrade`.
|
||||
/// - `network_upgrade` - The network upgrade that we are using to simulate from where the
|
||||
/// legacy chain checks should start to apply.
|
||||
/// legacy chain checks should start to apply.
|
||||
///
|
||||
/// Returns:
|
||||
/// A generated arbitrary strategy for the provided arguments.
|
||||
|
|
|
@ -126,6 +126,7 @@ pub const PEER_GOSSIP_DELAY: Duration = Duration::from_secs(7);
|
|||
/// This timeout makes sure that the syncer doesn't hang when:
|
||||
/// - the lookahead queue is full, and
|
||||
/// - we are waiting for a request that is stuck.
|
||||
///
|
||||
/// See [`BLOCK_VERIFY_TIMEOUT`] for details.
|
||||
///
|
||||
/// ## Correctness
|
||||
|
@ -149,6 +150,7 @@ pub(super) const BLOCK_DOWNLOAD_TIMEOUT: Duration = Duration::from_secs(20);
|
|||
/// - are for blocks a long way ahead of the current tip, or
|
||||
/// - are for invalid blocks which will never verify, because they depend on
|
||||
/// missing blocks or transactions.
|
||||
///
|
||||
/// These conditions can happen during normal operation - they are not bugs.
|
||||
///
|
||||
/// This timeout also mitigates or hides the following kinds of bugs:
|
||||
|
|
|
@ -21,7 +21,7 @@ pub const ESTIMATED_RELEASE_HEIGHT: u32 = 2_562_000;
|
|||
/// Notes:
|
||||
///
|
||||
/// - Zebra will exit with a panic if the current tip height is bigger than the `ESTIMATED_RELEASE_HEIGHT`
|
||||
/// plus this number of days.
|
||||
/// plus this number of days.
|
||||
/// - Currently set to 16 weeks.
|
||||
pub const EOS_PANIC_AFTER: u32 = 112;
|
||||
|
||||
|
|
|
@ -27,11 +27,11 @@
|
|||
//! Some of them require environment variables or directories to be present:
|
||||
//!
|
||||
//! - `FULL_SYNC_MAINNET_TIMEOUT_MINUTES` env variable: The total number of minutes we
|
||||
//! will allow this test to run or give up. Value for the Mainnet full sync tests.
|
||||
//! will allow this test to run or give up. Value for the Mainnet full sync tests.
|
||||
//! - `FULL_SYNC_TESTNET_TIMEOUT_MINUTES` env variable: The total number of minutes we
|
||||
//! will allow this test to run or give up. Value for the Testnet ful sync tests.
|
||||
//! will allow this test to run or give up. Value for the Testnet ful sync tests.
|
||||
//! - `/zebrad-cache` directory: For some sync tests, this needs to be created in
|
||||
//! the file system, the created directory should have write permissions.
|
||||
//! the file system, the created directory should have write permissions.
|
||||
//!
|
||||
//! Here are some examples on how to run each of the tests:
|
||||
//!
|
||||
|
@ -811,28 +811,13 @@ fn last_config_is_stored() -> Result<()> {
|
|||
\n\
|
||||
Take the missing config file logged above, \n\
|
||||
and commit it to Zebra's git repository as:\n\
|
||||
zebrad/tests/common/configs/{}<next-release-tag>.toml \n\
|
||||
zebrad/tests/common/configs/<next-release-tag>.toml \n\
|
||||
\n\
|
||||
Or run: \n\
|
||||
cargo build {}--bin zebrad && \n\
|
||||
cargo build --bin zebrad && \n\
|
||||
zebrad generate | \n\
|
||||
sed 's/cache_dir = \".*\"/cache_dir = \"cache_dir\"/' > \n\
|
||||
zebrad/tests/common/configs/{}<next-release-tag>.toml",
|
||||
if cfg!(feature = "shielded-scan") {
|
||||
SHIELDED_SCAN_CONFIG_PREFIX
|
||||
} else {
|
||||
""
|
||||
},
|
||||
if cfg!(feature = "shielded-scan") {
|
||||
"--features=shielded-scan "
|
||||
} else {
|
||||
""
|
||||
},
|
||||
if cfg!(feature = "shielded-scan") {
|
||||
SHIELDED_SCAN_CONFIG_PREFIX
|
||||
} else {
|
||||
""
|
||||
},
|
||||
zebrad/tests/common/configs/<next-release-tag>.toml",
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -963,7 +948,6 @@ fn stored_configs_parsed_correctly() -> Result<()> {
|
|||
|
||||
// ignore files starting with shieldedscan prefix
|
||||
// if we were not built with the shielded-scan feature.
|
||||
#[cfg(not(feature = "shielded-scan"))]
|
||||
if config_file_name.starts_with(SHIELDED_SCAN_CONFIG_PREFIX) {
|
||||
tracing::info!(?config_file_path, "skipping shielded-scan config file path");
|
||||
continue;
|
||||
|
@ -1021,14 +1005,6 @@ fn stored_configs_work() -> Result<()> {
|
|||
continue;
|
||||
}
|
||||
|
||||
// ignore files starting with shieldedscan prefix
|
||||
// if we were not built with the shielded-scan feature.
|
||||
#[cfg(not(feature = "shielded-scan"))]
|
||||
if config_file_name.starts_with(SHIELDED_SCAN_CONFIG_PREFIX) {
|
||||
tracing::info!(?config_file_path, "skipping shielded-scan config file path");
|
||||
continue;
|
||||
}
|
||||
|
||||
let run_dir = testdir()?;
|
||||
let stored_config_path = config_file_full_path(config_file.path());
|
||||
|
||||
|
|
|
@ -80,27 +80,6 @@ pub fn default_test_config(net: &Network) -> Result<ZebradConfig> {
|
|||
mining.miner_address = Some(miner_address.parse().expect("hard-coded address is valid"));
|
||||
}
|
||||
|
||||
#[cfg(feature = "shielded-scan")]
|
||||
{
|
||||
let mut shielded_scan = zebra_scan::Config::ephemeral();
|
||||
shielded_scan.db_config_mut().cache_dir = "zebra-scan".into();
|
||||
|
||||
let config = ZebradConfig {
|
||||
network,
|
||||
state,
|
||||
sync,
|
||||
mempool,
|
||||
consensus,
|
||||
tracing,
|
||||
mining,
|
||||
shielded_scan,
|
||||
..ZebradConfig::default()
|
||||
};
|
||||
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "shielded-scan"))]
|
||||
Ok(ZebradConfig {
|
||||
network,
|
||||
state,
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
# Default configuration for zebrad.
|
||||
#
|
||||
# This file can be used as a skeleton for custom configs.
|
||||
#
|
||||
# Unspecified fields use default values. Optional fields are Some(field) if the
|
||||
# field is present and None if it is absent.
|
||||
#
|
||||
# This file is generated as an example using zebrad's current defaults.
|
||||
# You should set only the config options you want to keep, and delete the rest.
|
||||
# Only a subset of fields are present in the skeleton, since optional values
|
||||
# whose default is None are omitted.
|
||||
#
|
||||
# The config format (including a complete list of sections and fields) is
|
||||
# documented here:
|
||||
# https://docs.rs/zebrad/latest/zebrad/config/struct.ZebradConfig.html
|
||||
#
|
||||
# zebrad attempts to load configs in the following order:
|
||||
#
|
||||
# 1. The -c flag on the command line, e.g., `zebrad -c myconfig.toml start`;
|
||||
# 2. The file `zebrad.toml` in the users's preference directory (platform-dependent);
|
||||
# 3. The default config.
|
||||
|
||||
[consensus]
|
||||
checkpoint_sync = true
|
||||
|
||||
[mempool]
|
||||
eviction_memory_time = "1h"
|
||||
tx_cost_limit = 80000000
|
||||
|
||||
[metrics]
|
||||
|
||||
[mining]
|
||||
debug_like_zcashd = true
|
||||
|
||||
[network]
|
||||
cache_dir = true
|
||||
crawl_new_peer_interval = "1m 1s"
|
||||
initial_mainnet_peers = [
|
||||
"dnsseed.z.cash:8233",
|
||||
"dnsseed.str4d.xyz:8233",
|
||||
"mainnet.seeder.zfnd.org:8233",
|
||||
"mainnet.is.yolo.money:8233",
|
||||
]
|
||||
initial_testnet_peers = [
|
||||
"dnsseed.testnet.z.cash:18233",
|
||||
"testnet.seeder.zfnd.org:18233",
|
||||
"testnet.is.yolo.money:18233",
|
||||
]
|
||||
listen_addr = "0.0.0.0:8233"
|
||||
max_connections_per_ip = 1
|
||||
network = "Mainnet"
|
||||
peerset_initial_target_size = 25
|
||||
|
||||
[rpc]
|
||||
debug_force_finished_sync = false
|
||||
parallel_cpu_threads = 0
|
||||
|
||||
[shielded_scan]
|
||||
cache_dir = "cache_dir"
|
||||
delete_old_database = true
|
||||
ephemeral = false
|
||||
|
||||
[shielded_scan.sapling_keys_to_scan]
|
||||
|
||||
[state]
|
||||
cache_dir = "cache_dir"
|
||||
delete_old_database = true
|
||||
ephemeral = false
|
||||
|
||||
[sync]
|
||||
checkpoint_verify_concurrency_limit = 1000
|
||||
download_concurrency_limit = 50
|
||||
full_verify_concurrency_limit = 20
|
||||
parallel_cpu_threads = 0
|
||||
|
||||
[tracing]
|
||||
buffer_limit = 128000
|
||||
force_use_color = false
|
||||
use_color = true
|
||||
use_journald = false
|
|
@ -1,89 +0,0 @@
|
|||
# Default configuration for zebrad.
|
||||
#
|
||||
# This file can be used as a skeleton for custom configs.
|
||||
#
|
||||
# Unspecified fields use default values. Optional fields are Some(field) if the
|
||||
# field is present and None if it is absent.
|
||||
#
|
||||
# This file is generated as an example using zebrad's current defaults.
|
||||
# You should set only the config options you want to keep, and delete the rest.
|
||||
# Only a subset of fields are present in the skeleton, since optional values
|
||||
# whose default is None are omitted.
|
||||
#
|
||||
# The config format (including a complete list of sections and fields) is
|
||||
# documented here:
|
||||
# https://docs.rs/zebrad/latest/zebrad/config/struct.ZebradConfig.html
|
||||
#
|
||||
# zebrad attempts to load configs in the following order:
|
||||
#
|
||||
# 1. The -c flag on the command line, e.g., `zebrad -c myconfig.toml start`;
|
||||
# 2. The file `zebrad.toml` in the users's preference directory (platform-dependent);
|
||||
# 3. The default config.
|
||||
#
|
||||
# The user's preference directory and the default path to the `zebrad` config are platform dependent,
|
||||
# based on `dirs::preference_dir`, see https://docs.rs/dirs/latest/dirs/fn.preference_dir.html :
|
||||
#
|
||||
# | Platform | Value | Example |
|
||||
# | -------- | ------------------------------------- | ---------------------------------------------- |
|
||||
# | Linux | `$XDG_CONFIG_HOME` or `$HOME/.config` | `/home/alice/.config/zebrad.toml` |
|
||||
# | macOS | `$HOME/Library/Preferences` | `/Users/Alice/Library/Preferences/zebrad.toml` |
|
||||
# | Windows | `{FOLDERID_RoamingAppData}` | `C:\Users\Alice\AppData\Local\zebrad.toml` |
|
||||
|
||||
[consensus]
|
||||
checkpoint_sync = true
|
||||
|
||||
[mempool]
|
||||
eviction_memory_time = "1h"
|
||||
tx_cost_limit = 80000000
|
||||
|
||||
[metrics]
|
||||
|
||||
[mining]
|
||||
debug_like_zcashd = true
|
||||
|
||||
[network]
|
||||
cache_dir = true
|
||||
crawl_new_peer_interval = "1m 1s"
|
||||
initial_mainnet_peers = [
|
||||
"dnsseed.z.cash:8233",
|
||||
"dnsseed.str4d.xyz:8233",
|
||||
"mainnet.seeder.zfnd.org:8233",
|
||||
"mainnet.is.yolo.money:8233",
|
||||
]
|
||||
initial_testnet_peers = [
|
||||
"dnsseed.testnet.z.cash:18233",
|
||||
"testnet.seeder.zfnd.org:18233",
|
||||
"testnet.is.yolo.money:18233",
|
||||
]
|
||||
listen_addr = "0.0.0.0:8233"
|
||||
max_connections_per_ip = 1
|
||||
network = "Mainnet"
|
||||
peerset_initial_target_size = 25
|
||||
|
||||
[rpc]
|
||||
debug_force_finished_sync = false
|
||||
parallel_cpu_threads = 0
|
||||
|
||||
[shielded_scan]
|
||||
cache_dir = "cache_dir"
|
||||
delete_old_database = true
|
||||
ephemeral = false
|
||||
|
||||
[shielded_scan.sapling_keys_to_scan]
|
||||
|
||||
[state]
|
||||
cache_dir = "cache_dir"
|
||||
delete_old_database = true
|
||||
ephemeral = false
|
||||
|
||||
[sync]
|
||||
checkpoint_verify_concurrency_limit = 1000
|
||||
download_concurrency_limit = 50
|
||||
full_verify_concurrency_limit = 20
|
||||
parallel_cpu_threads = 0
|
||||
|
||||
[tracing]
|
||||
buffer_limit = 128000
|
||||
force_use_color = false
|
||||
use_color = true
|
||||
use_journald = false
|
|
@ -31,8 +31,7 @@
|
|||
//!
|
||||
//! - `GetLightdInfo`: Covered.
|
||||
//!
|
||||
//! - `Ping`: Not covered and it will never be. `Ping` is only used for testing
|
||||
//! purposes.
|
||||
//! - `Ping`: Not covered and it will never be. `Ping` is only used for testing purposes.
|
||||
|
||||
use color_eyre::eyre::Result;
|
||||
use hex_literal::hex;
|
||||
|
|
Loading…
Reference in New Issue