fixed all clippy errors
This commit is contained in:
parent
31ea1358c9
commit
17ea4979a3
|
@ -45,7 +45,7 @@ impl NetworkChainTipHeightEstimator {
|
|||
current_height: block::Height,
|
||||
network: &Network,
|
||||
) -> Self {
|
||||
let mut target_spacings = NetworkUpgrade::target_spacings(&network);
|
||||
let mut target_spacings = NetworkUpgrade::target_spacings(network);
|
||||
let (_genesis_height, initial_target_spacing) =
|
||||
target_spacings.next().expect("No target spacings were set");
|
||||
|
||||
|
|
|
@ -473,8 +473,8 @@ impl HistoryTree {
|
|||
let tree = Some(NonEmptyHistoryTree::from_block(
|
||||
network,
|
||||
block,
|
||||
&sapling_root,
|
||||
&orchard_root,
|
||||
sapling_root,
|
||||
orchard_root,
|
||||
)?);
|
||||
// Replace the current object with the new tree
|
||||
*self = HistoryTree(tree);
|
||||
|
@ -483,7 +483,7 @@ impl HistoryTree {
|
|||
self.0
|
||||
.as_mut()
|
||||
.expect("history tree must exist Heartwood-onward")
|
||||
.push(block.clone(), &sapling_root, &orchard_root)?;
|
||||
.push(block.clone(), sapling_root, orchard_root)?;
|
||||
}
|
||||
};
|
||||
Ok(())
|
||||
|
|
|
@ -363,9 +363,9 @@ impl NetworkUpgrade {
|
|||
}
|
||||
|
||||
/// Returns all the target block spacings for `network` and the heights where they start.
|
||||
pub fn target_spacings<'a>(
|
||||
network: &'a Network,
|
||||
) -> impl Iterator<Item = (block::Height, Duration)> + 'a {
|
||||
pub fn target_spacings(
|
||||
network: &Network,
|
||||
) -> impl Iterator<Item = (block::Height, Duration)> + '_ {
|
||||
[
|
||||
(NetworkUpgrade::Genesis, PRE_BLOSSOM_POW_TARGET_SPACING),
|
||||
(
|
||||
|
|
|
@ -132,10 +132,10 @@ impl zcash_address::TryFromAddress for Address {
|
|||
}
|
||||
}
|
||||
unified::Receiver::P2pkh(data) => {
|
||||
transparent = Some(transparent::Address::from_pub_key_hash(&network, data));
|
||||
transparent = Some(transparent::Address::from_pub_key_hash(network, data));
|
||||
}
|
||||
unified::Receiver::P2sh(data) => {
|
||||
transparent = Some(transparent::Address::from_script_hash(&network, data));
|
||||
transparent = Some(transparent::Address::from_script_hash(network, data));
|
||||
}
|
||||
unified::Receiver::Unknown { .. } => {
|
||||
return Err(BoxError::from("Unsupported receiver in a Unified Address.").into());
|
||||
|
|
|
@ -78,7 +78,7 @@ impl Transaction {
|
|||
// > MUST be 0x26A7270A.
|
||||
// > If effectiveVersion ≥ 5, the nConsensusBranchId field MUST match the consensus
|
||||
// > branch ID used for SIGHASH transaction hashes, as specified in [ZIP-244].
|
||||
network_upgrade: NetworkUpgrade::current(&network, height),
|
||||
network_upgrade: NetworkUpgrade::current(network, height),
|
||||
|
||||
// There is no documented consensus rule for the lock time field in coinbase
|
||||
// transactions, so we just leave it unlocked. (We could also set it to `height`.)
|
||||
|
|
|
@ -29,7 +29,7 @@ pub fn funding_stream_values(
|
|||
let mut results = HashMap::new();
|
||||
|
||||
if height >= canopy_height {
|
||||
let range = FUNDING_STREAM_HEIGHT_RANGES.get(&network).unwrap();
|
||||
let range = FUNDING_STREAM_HEIGHT_RANGES.get(network).unwrap();
|
||||
if range.contains(&height) {
|
||||
let block_subsidy = block_subsidy(height, network)?;
|
||||
for (&receiver, &numerator) in FUNDING_STREAM_RECEIVER_NUMERATORS.iter() {
|
||||
|
@ -83,7 +83,7 @@ fn funding_stream_address_index(height: Height, network: &Network) -> usize {
|
|||
.checked_add(funding_stream_address_period(height, network))
|
||||
.expect("no overflow should happen in this sum")
|
||||
.checked_sub(funding_stream_address_period(
|
||||
FUNDING_STREAM_HEIGHT_RANGES.get(&network).unwrap().start,
|
||||
FUNDING_STREAM_HEIGHT_RANGES.get(network).unwrap().start,
|
||||
network,
|
||||
))
|
||||
.expect("no overflow should happen in this sub") as usize;
|
||||
|
@ -105,7 +105,7 @@ pub fn funding_stream_address(
|
|||
) -> transparent::Address {
|
||||
let index = funding_stream_address_index(height, network);
|
||||
let address = &FUNDING_STREAM_ADDRESSES
|
||||
.get(&network)
|
||||
.get(network)
|
||||
.expect("there is always another hash map as value for a given valid network")
|
||||
.get(&receiver)
|
||||
.expect("in the inner hash map there is always a vector of strings with addresses")[index];
|
||||
|
|
|
@ -22,7 +22,7 @@ use crate::{funding_stream_values, parameters::subsidy::*};
|
|||
/// Returns `None` if the divisor would overflow a `u64`.
|
||||
pub fn halving_divisor(height: Height, network: &Network) -> Option<u64> {
|
||||
let blossom_height = Blossom
|
||||
.activation_height(&network)
|
||||
.activation_height(network)
|
||||
.expect("blossom activation height should be available");
|
||||
|
||||
if height < SLOW_START_SHIFT {
|
||||
|
|
|
@ -324,11 +324,11 @@ where
|
|||
|
||||
// transaction verification
|
||||
|
||||
let transaction = transaction::Verifier::new(&network, state_service.clone());
|
||||
let transaction = transaction::Verifier::new(network, state_service.clone());
|
||||
let transaction = Buffer::new(BoxService::new(transaction), VERIFIER_BUFFER_BOUND);
|
||||
|
||||
// block verification
|
||||
let (list, max_checkpoint_height) = init_checkpoint_list(config, &network);
|
||||
let (list, max_checkpoint_height) = init_checkpoint_list(config, network);
|
||||
|
||||
let tip = match state_service
|
||||
.ready()
|
||||
|
@ -347,8 +347,8 @@ where
|
|||
"initializing block verifier router"
|
||||
);
|
||||
|
||||
let block = SemanticBlockVerifier::new(&network, state_service.clone(), transaction.clone());
|
||||
let checkpoint = CheckpointVerifier::from_checkpoint_list(list, &network, tip, state_service);
|
||||
let block = SemanticBlockVerifier::new(network, state_service.clone(), transaction.clone());
|
||||
let checkpoint = CheckpointVerifier::from_checkpoint_list(list, network, tip, state_service);
|
||||
let router = BlockVerifierRouter {
|
||||
checkpoint,
|
||||
max_checkpoint_height,
|
||||
|
|
|
@ -215,7 +215,7 @@ pub fn disabled_add_to_sprout_pool(
|
|||
network: &Network,
|
||||
) -> Result<(), TransactionError> {
|
||||
let canopy_activation_height = NetworkUpgrade::Canopy
|
||||
.activation_height(&network)
|
||||
.activation_height(network)
|
||||
.expect("Canopy activation height must be present for both networks");
|
||||
|
||||
// # Consensus
|
||||
|
@ -331,13 +331,13 @@ pub fn coinbase_outputs_are_decryptable(
|
|||
// The consensus rule only applies to Heartwood onward.
|
||||
if height
|
||||
< NetworkUpgrade::Heartwood
|
||||
.activation_height(&network)
|
||||
.activation_height(network)
|
||||
.expect("Heartwood height is known")
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if !zcash_note_encryption::decrypts_successfully(transaction, &network, height) {
|
||||
if !zcash_note_encryption::decrypts_successfully(transaction, network, height) {
|
||||
return Err(TransactionError::CoinbaseOutputsNotDecryptable);
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ pub fn coinbase_expiry_height(
|
|||
let expiry_height = coinbase.expiry_height();
|
||||
|
||||
// TODO: replace `if let` with `expect` after NU5 mainnet activation
|
||||
if let Some(nu5_activation_height) = NetworkUpgrade::Nu5.activation_height(&network) {
|
||||
if let Some(nu5_activation_height) = NetworkUpgrade::Nu5.activation_height(network) {
|
||||
// # Consensus
|
||||
//
|
||||
// > [NU5 onward] The nExpiryHeight field of a coinbase transaction
|
||||
|
|
|
@ -334,7 +334,7 @@ fn sanitize_transaction_version(
|
|||
transaction_version: u8,
|
||||
block_height: block::Height,
|
||||
) -> (u8, NetworkUpgrade) {
|
||||
let network_upgrade = NetworkUpgrade::current(&network, block_height);
|
||||
let network_upgrade = NetworkUpgrade::current(network, block_height);
|
||||
|
||||
let max_version = {
|
||||
use NetworkUpgrade::*;
|
||||
|
|
|
@ -64,7 +64,7 @@ impl Version {
|
|||
assert!(
|
||||
constants::CURRENT_NETWORK_PROTOCOL_VERSION >= min_spec,
|
||||
"Zebra does not implement the minimum specified {:?} protocol version for {:?} at {:?}",
|
||||
NetworkUpgrade::current(&network, height),
|
||||
NetworkUpgrade::current(network, height),
|
||||
network,
|
||||
height,
|
||||
);
|
||||
|
@ -80,7 +80,7 @@ impl Version {
|
|||
/// - after Zebra's local network is slow or shut down.
|
||||
fn initial_min_for_network(network: &Network) -> Version {
|
||||
*constants::INITIAL_MIN_NETWORK_PROTOCOL_VERSION
|
||||
.get(&network)
|
||||
.get(network)
|
||||
.expect("We always have a value for testnet or mainnet")
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ impl Version {
|
|||
///
|
||||
/// This is the minimum peer version when Zebra is close to the current tip.
|
||||
fn min_specified_for_height(network: &Network, height: block::Height) -> Version {
|
||||
let network_upgrade = NetworkUpgrade::current(&network, height);
|
||||
let network_upgrade = NetworkUpgrade::current(network, height);
|
||||
Version::min_specified_for_upgrade(network, network_upgrade)
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ mod test {
|
|||
fn version_consistent(network: &Network) {
|
||||
let _init_guard = zebra_test::init();
|
||||
|
||||
let highest_network_upgrade = NetworkUpgrade::current(&network, block::Height::MAX);
|
||||
let highest_network_upgrade = NetworkUpgrade::current(network, block::Height::MAX);
|
||||
assert!(highest_network_upgrade == Nu5 || highest_network_upgrade == Canopy,
|
||||
"expected coverage of all network upgrades: add the new network upgrade to the list in this test");
|
||||
|
||||
|
@ -250,7 +250,7 @@ mod test {
|
|||
Canopy,
|
||||
Nu5,
|
||||
] {
|
||||
let height = network_upgrade.activation_height(&network);
|
||||
let height = network_upgrade.activation_height(network);
|
||||
if let Some(height) = height {
|
||||
assert_eq!(
|
||||
Version::min_specified_for_upgrade(network, network_upgrade),
|
||||
|
|
|
@ -568,12 +568,12 @@ where
|
|||
(tip_height + 1).expect("valid chain tips are a lot less than Height::MAX");
|
||||
let consensus = TipConsensusBranch {
|
||||
chain_tip: ConsensusBranchIdHex(
|
||||
NetworkUpgrade::current(&network, tip_height)
|
||||
NetworkUpgrade::current(network, tip_height)
|
||||
.branch_id()
|
||||
.unwrap_or(ConsensusBranchId::RPC_MISSING_ID),
|
||||
),
|
||||
next_block: ConsensusBranchIdHex(
|
||||
NetworkUpgrade::current(&network, next_block_height)
|
||||
NetworkUpgrade::current(network, next_block_height)
|
||||
.branch_id()
|
||||
.unwrap_or(ConsensusBranchId::RPC_MISSING_ID),
|
||||
),
|
||||
|
|
|
@ -361,7 +361,7 @@ pub fn standard_coinbase_outputs(
|
|||
miner_fee: Amount<NonNegative>,
|
||||
like_zcashd: bool,
|
||||
) -> Vec<(Amount<NonNegative>, transparent::Script)> {
|
||||
let funding_streams = funding_stream_values(height, &network)
|
||||
let funding_streams = funding_stream_values(height, network)
|
||||
.expect("funding stream value calculations are valid for reasonable chain heights");
|
||||
|
||||
// Optional TODO: move this into a zebra_consensus function?
|
||||
|
@ -373,12 +373,12 @@ pub fn standard_coinbase_outputs(
|
|||
.map(|(receiver, amount)| {
|
||||
(
|
||||
receiver,
|
||||
(amount, funding_stream_address(height, &network, receiver)),
|
||||
(amount, funding_stream_address(height, network, receiver)),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
let miner_reward = miner_subsidy(height, &network)
|
||||
let miner_reward = miner_subsidy(height, network)
|
||||
.expect("reward calculations are valid for reasonable chain heights")
|
||||
+ miner_fee;
|
||||
let miner_reward =
|
||||
|
|
|
@ -56,7 +56,7 @@ async fn test_rpc_response_data_for_network(network: &Network) {
|
|||
// Create a populated state service
|
||||
#[cfg_attr(not(feature = "getblocktemplate-rpcs"), allow(unused_variables))]
|
||||
let (state, read_state, latest_chain_tip, _chain_tip_change) =
|
||||
zebra_state::populated_state(blocks.clone(), &network).await;
|
||||
zebra_state::populated_state(blocks.clone(), network).await;
|
||||
|
||||
// Start snapshots of RPC responses.
|
||||
let mut settings = insta::Settings::clone_current();
|
||||
|
@ -65,7 +65,7 @@ async fn test_rpc_response_data_for_network(network: &Network) {
|
|||
// Test getblocktemplate-rpcs snapshots
|
||||
#[cfg(feature = "getblocktemplate-rpcs")]
|
||||
get_block_template_rpcs::test_responses(
|
||||
&network,
|
||||
network,
|
||||
mempool.clone(),
|
||||
state,
|
||||
read_state.clone(),
|
||||
|
@ -100,7 +100,7 @@ async fn test_rpc_response_data_for_network(network: &Network) {
|
|||
|
||||
// build addresses
|
||||
let address = &first_block_first_transaction.outputs()[1]
|
||||
.address(&network)
|
||||
.address(network)
|
||||
.unwrap();
|
||||
let addresses = vec![address.to_string()];
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ pub async fn test_responses<State, ReadState>(
|
|||
_transaction_verifier,
|
||||
_parameter_download_task_handle,
|
||||
_max_checkpoint_height,
|
||||
) = zebra_consensus::router::init(zebra_consensus::Config::default(), &network, state.clone())
|
||||
) = zebra_consensus::router::init(zebra_consensus::Config::default(), network, state.clone())
|
||||
.await;
|
||||
|
||||
let mut mock_sync_status = MockSyncStatus::default();
|
||||
|
@ -94,7 +94,7 @@ pub async fn test_responses<State, ReadState>(
|
|||
|
||||
#[allow(clippy::unnecessary_struct_initialization)]
|
||||
let mining_config = crate::config::mining::Config {
|
||||
miner_address: Some(transparent::Address::from_script_hash(&network, [0xad; 20])),
|
||||
miner_address: Some(transparent::Address::from_script_hash(network, [0xad; 20])),
|
||||
extra_coinbase_data: None,
|
||||
debug_like_zcashd: true,
|
||||
// TODO: Use default field values when optional features are enabled in tests #8183
|
||||
|
@ -102,7 +102,7 @@ pub async fn test_responses<State, ReadState>(
|
|||
};
|
||||
|
||||
// nu5 block height
|
||||
let fake_tip_height = NetworkUpgrade::Nu5.activation_height(&network).unwrap();
|
||||
let fake_tip_height = NetworkUpgrade::Nu5.activation_height(network).unwrap();
|
||||
// nu5 block hash
|
||||
let fake_tip_hash =
|
||||
Hash::from_hex("0000000000d723156d9b65ffcf4984da7a19675ed7e2f06d9e5d5188af087bf8").unwrap();
|
||||
|
|
|
@ -28,7 +28,7 @@ async fn scan_task_processes_messages_correctly() -> Result<(), Report> {
|
|||
mock_scan_task.register_keys(sapling_keys_with_birth_heights.clone())?;
|
||||
|
||||
let (new_keys, _new_results_senders, _new_results_receivers) =
|
||||
ScanTask::process_messages(&mut cmd_receiver, &mut parsed_keys, &network)?;
|
||||
ScanTask::process_messages(&mut cmd_receiver, &mut parsed_keys, network)?;
|
||||
|
||||
// Check that it updated parsed_keys correctly and returned the right new keys when starting with an empty state
|
||||
|
||||
|
@ -49,7 +49,7 @@ async fn scan_task_processes_messages_correctly() -> Result<(), Report> {
|
|||
// Check that no key should be added if they are all already known and the heights are the same
|
||||
|
||||
let (new_keys, _new_results_senders, _new_results_receivers) =
|
||||
ScanTask::process_messages(&mut cmd_receiver, &mut parsed_keys, &network)?;
|
||||
ScanTask::process_messages(&mut cmd_receiver, &mut parsed_keys, network)?;
|
||||
|
||||
assert_eq!(
|
||||
parsed_keys.len(),
|
||||
|
@ -75,7 +75,7 @@ async fn scan_task_processes_messages_correctly() -> Result<(), Report> {
|
|||
mock_scan_task.register_keys(sapling_keys_with_birth_heights[10..15].to_vec())?;
|
||||
|
||||
let (new_keys, _new_results_senders, _new_results_receivers) =
|
||||
ScanTask::process_messages(&mut cmd_receiver, &mut parsed_keys, &network)?;
|
||||
ScanTask::process_messages(&mut cmd_receiver, &mut parsed_keys, network)?;
|
||||
|
||||
assert_eq!(
|
||||
parsed_keys.len(),
|
||||
|
@ -95,7 +95,7 @@ async fn scan_task_processes_messages_correctly() -> Result<(), Report> {
|
|||
let done_rx = mock_scan_task.remove_keys(sapling_keys.clone())?;
|
||||
|
||||
let (new_keys, _new_results_senders, _new_results_receivers) =
|
||||
ScanTask::process_messages(&mut cmd_receiver, &mut parsed_keys, &network)?;
|
||||
ScanTask::process_messages(&mut cmd_receiver, &mut parsed_keys, network)?;
|
||||
|
||||
// Check that it sends the done notification successfully before returning and dropping `done_tx`
|
||||
done_rx.await?;
|
||||
|
@ -114,7 +114,7 @@ async fn scan_task_processes_messages_correctly() -> Result<(), Report> {
|
|||
mock_scan_task.remove_keys(sapling_keys.clone())?;
|
||||
|
||||
let (new_keys, _new_results_senders, _new_results_receivers) =
|
||||
ScanTask::process_messages(&mut cmd_receiver, &mut parsed_keys, &network)?;
|
||||
ScanTask::process_messages(&mut cmd_receiver, &mut parsed_keys, network)?;
|
||||
|
||||
assert!(
|
||||
new_keys.is_empty(),
|
||||
|
@ -130,7 +130,7 @@ async fn scan_task_processes_messages_correctly() -> Result<(), Report> {
|
|||
mock_scan_task.register_keys(sapling_keys_with_birth_heights[..2].to_vec())?;
|
||||
|
||||
let (new_keys, _new_results_senders, _new_results_receivers) =
|
||||
ScanTask::process_messages(&mut cmd_receiver, &mut parsed_keys, &network)?;
|
||||
ScanTask::process_messages(&mut cmd_receiver, &mut parsed_keys, network)?;
|
||||
|
||||
assert_eq!(
|
||||
new_keys.len(),
|
||||
|
@ -159,7 +159,7 @@ async fn scan_task_processes_messages_correctly() -> Result<(), Report> {
|
|||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
|
||||
let (_new_keys, new_results_senders, new_results_receivers) =
|
||||
ScanTask::process_messages(&mut cmd_receiver, &mut parsed_keys, &network)?;
|
||||
ScanTask::process_messages(&mut cmd_receiver, &mut parsed_keys, network)?;
|
||||
|
||||
let (result_receiver, rsp_tx) = new_results_receivers
|
||||
.into_iter()
|
||||
|
|
|
@ -50,7 +50,7 @@ impl Storage {
|
|||
/// New keys in `config` are not inserted into the database.
|
||||
pub(crate) fn new_db(config: &Config, network: &Network, read_only: bool) -> Self {
|
||||
Self::new_with_debug(
|
||||
config, &network,
|
||||
config, network,
|
||||
// TODO: make format upgrades work with any database, then change debug_skip_format_upgrades to `false`
|
||||
true, read_only,
|
||||
)
|
||||
|
|
|
@ -420,7 +420,7 @@ impl StateService {
|
|||
|
||||
if let Some(tip) = state.best_tip() {
|
||||
let nu5_activation_height = NetworkUpgrade::Nu5
|
||||
.activation_height(&network)
|
||||
.activation_height(network)
|
||||
.expect("NU5 activation height is set");
|
||||
|
||||
if let Err(error) = check::legacy_chain(
|
||||
|
|
|
@ -124,7 +124,7 @@ pub(crate) fn block_commitment_is_valid_for_chain_history(
|
|||
network: &Network,
|
||||
history_tree: &HistoryTree,
|
||||
) -> Result<(), ValidateContextError> {
|
||||
match block.commitment(&network)? {
|
||||
match block.commitment(network)? {
|
||||
block::Commitment::PreSaplingReserved(_)
|
||||
| block::Commitment::FinalSaplingRoot(_)
|
||||
| block::Commitment::ChainHistoryActivationReserved => {
|
||||
|
@ -346,7 +346,7 @@ where
|
|||
// using our activation heights, the Zebra instance that verified those blocks had different
|
||||
// network upgrade heights.
|
||||
block
|
||||
.check_transaction_network_upgrade_consistency(&network)
|
||||
.check_transaction_network_upgrade_consistency(network)
|
||||
.map_err(|error| {
|
||||
format!("inconsistent network upgrade found in transaction: {error:?}")
|
||||
})?;
|
||||
|
|
|
@ -368,7 +368,7 @@ impl ZebraDb {
|
|||
.values()
|
||||
.map(|ordered_utxo| &ordered_utxo.utxo),
|
||||
)
|
||||
.filter_map(|utxo| utxo.output.address(&network))
|
||||
.filter_map(|utxo| utxo.output.address(network))
|
||||
.unique()
|
||||
.collect();
|
||||
|
||||
|
|
|
@ -413,7 +413,7 @@ impl DiskWriteBatch {
|
|||
// Index all new transparent outputs
|
||||
for (new_output_location, utxo) in new_outputs_by_out_loc {
|
||||
let unspent_output = &utxo.output;
|
||||
let receiving_address = unspent_output.address(&network);
|
||||
let receiving_address = unspent_output.address(network);
|
||||
|
||||
// Update the address balance by adding this UTXO's value
|
||||
if let Some(receiving_address) = receiving_address {
|
||||
|
@ -490,7 +490,7 @@ impl DiskWriteBatch {
|
|||
// Coinbase inputs represent new coins, so there are no UTXOs to mark as spent.
|
||||
for (spent_output_location, utxo) in spent_utxos_by_out_loc {
|
||||
let spent_output = &utxo.output;
|
||||
let sending_address = spent_output.address(&network);
|
||||
let sending_address = spent_output.address(network);
|
||||
|
||||
// Fetch the balance, and the link from the address to the AddressLocation, from memory.
|
||||
if let Some(sending_address) = sending_address {
|
||||
|
@ -548,7 +548,7 @@ impl DiskWriteBatch {
|
|||
let spent_utxo = spent_utxos_by_outpoint
|
||||
.get(&spent_outpoint)
|
||||
.expect("unexpected missing spent output");
|
||||
let sending_address = spent_utxo.output.address(&network);
|
||||
let sending_address = spent_utxo.output.address(network);
|
||||
|
||||
// Fetch the balance, and the link from the address to the AddressLocation, from memory.
|
||||
if let Some(sending_address) = sending_address {
|
||||
|
|
|
@ -1270,7 +1270,7 @@ impl Chain {
|
|||
) -> impl Iterator<Item = &TransparentTransfers> {
|
||||
addresses
|
||||
.iter()
|
||||
.flat_map(|address| self.partial_transparent_transfers.get(&address))
|
||||
.flat_map(|address| self.partial_transparent_transfers.get(address))
|
||||
}
|
||||
|
||||
/// Returns the transparent balance change for `addresses` in this non-finalized chain.
|
||||
|
|
|
@ -150,7 +150,7 @@ where
|
|||
"full address UTXO response",
|
||||
);
|
||||
|
||||
return Ok(AddressUtxos::new(&network, utxos, tx_ids));
|
||||
return Ok(AddressUtxos::new(network, utxos, tx_ids));
|
||||
}
|
||||
|
||||
Err(chain_utxo_error) => {
|
||||
|
|
|
@ -247,7 +247,7 @@ fn difficulty_time_and_history_tree(
|
|||
let difficulty_adjustment = AdjustedDifficulty::new_from_header_time(
|
||||
cur_time.into(),
|
||||
tip_height,
|
||||
&network,
|
||||
network,
|
||||
relevant_data.iter().cloned(),
|
||||
);
|
||||
let expected_difficulty = difficulty_adjustment.expected_difficulty_threshold();
|
||||
|
@ -308,7 +308,7 @@ fn adjust_difficulty_and_time_for_testnet(
|
|||
.expect("valid blocks have in-range times");
|
||||
|
||||
let minimum_difficulty_spacing =
|
||||
NetworkUpgrade::minimum_difficulty_spacing_for_height(&network, previous_block_height)
|
||||
NetworkUpgrade::minimum_difficulty_spacing_for_height(network, previous_block_height)
|
||||
.expect("just checked testnet, and the RPC returns an error for low heights");
|
||||
let minimum_difficulty_spacing: Duration32 = minimum_difficulty_spacing
|
||||
.try_into()
|
||||
|
@ -360,7 +360,7 @@ fn adjust_difficulty_and_time_for_testnet(
|
|||
result.expected_difficulty = AdjustedDifficulty::new_from_header_time(
|
||||
result.cur_time.into(),
|
||||
previous_block_height,
|
||||
&network,
|
||||
network,
|
||||
relevant_data.iter().cloned(),
|
||||
)
|
||||
.expected_difficulty_threshold();
|
||||
|
|
|
@ -42,12 +42,13 @@ use zebra_scan::{storage::Storage, Config};
|
|||
#[allow(clippy::print_stdout)]
|
||||
pub fn main() {
|
||||
let network = zcash_primitives::consensus::Network::MainNetwork;
|
||||
let storage = Storage::new(&Config::default(), network.into(), true);
|
||||
let zebra_network: zebra_chain::parameters::Network = network.into();
|
||||
let storage = Storage::new(&Config::default(), &zebra_network, true);
|
||||
// If the first memo is empty, it doesn't get printed. But we never print empty memos anyway.
|
||||
let mut prev_memo = "".to_owned();
|
||||
|
||||
for (key, _) in storage.sapling_keys_last_heights().iter() {
|
||||
let dfvk = sapling_key_to_scan_block_keys(key, network.into())
|
||||
let dfvk = sapling_key_to_scan_block_keys(key, &zebra_network)
|
||||
.expect("Scanning key from the storage should be valid")
|
||||
.0
|
||||
.into_iter()
|
||||
|
|
|
@ -306,7 +306,7 @@ impl StartCmd {
|
|||
info!("spawning shielded scanner with configured viewing keys");
|
||||
zebra_scan::spawn_init(
|
||||
config.shielded_scan.clone(),
|
||||
config.network.network,
|
||||
config.network.network.clone(),
|
||||
state,
|
||||
chain_tip_change,
|
||||
)
|
||||
|
@ -324,7 +324,7 @@ impl StartCmd {
|
|||
let miner_task_handle = if config.mining.is_internal_miner_enabled() {
|
||||
info!("spawning Zcash miner");
|
||||
let rpc = zebra_rpc::methods::get_block_template_rpcs::GetBlockTemplateRpcImpl::new(
|
||||
config.network.network,
|
||||
&config.network.network,
|
||||
config.mining.clone(),
|
||||
mempool,
|
||||
read_only_state_service,
|
||||
|
|
|
@ -323,7 +323,7 @@ impl FakeChainTip {
|
|||
match self {
|
||||
Self::Grow(chain_tip_block) => {
|
||||
let height = block::Height(previous.height.0 + 1);
|
||||
let target_spacing = NetworkUpgrade::target_spacing_for_height(&network, height);
|
||||
let target_spacing = NetworkUpgrade::target_spacing_for_height(network, height);
|
||||
|
||||
let mock_block_time_delta = Duration::seconds(
|
||||
previous.time.timestamp() % (2 * target_spacing.num_seconds()),
|
||||
|
|
|
@ -65,7 +65,7 @@ pub fn check(tip_height: Height, network: &Network) {
|
|||
info!("Checking if Zebra release is inside support range ...");
|
||||
|
||||
// Get the current block spacing
|
||||
let target_block_spacing = NetworkUpgrade::target_spacing_for_height(&network, tip_height);
|
||||
let target_block_spacing = NetworkUpgrade::target_spacing_for_height(network, tip_height);
|
||||
|
||||
// Get the number of blocks per day
|
||||
let estimated_blocks_per_day =
|
||||
|
|
|
@ -1338,7 +1338,7 @@ async fn metrics_endpoint() -> Result<()> {
|
|||
let url = format!("http://{endpoint}");
|
||||
|
||||
// Write a configuration that has metrics endpoint_addr set
|
||||
let mut config = default_test_config(Mainnet)?;
|
||||
let mut config = default_test_config(&Mainnet)?;
|
||||
config.metrics.endpoint_addr = Some(endpoint.parse().unwrap());
|
||||
|
||||
let dir = testdir()?.with_config(&mut config)?;
|
||||
|
@ -1395,7 +1395,7 @@ async fn tracing_endpoint() -> Result<()> {
|
|||
let url_filter = format!("{url_default}/filter");
|
||||
|
||||
// Write a configuration that has tracing endpoint_addr option set
|
||||
let mut config = default_test_config(Mainnet)?;
|
||||
let mut config = default_test_config(&Mainnet)?;
|
||||
config.tracing.endpoint_addr = Some(endpoint.parse().unwrap());
|
||||
|
||||
let dir = testdir()?.with_config(&mut config)?;
|
||||
|
@ -2115,7 +2115,7 @@ fn zebra_metrics_conflict() -> Result<()> {
|
|||
let listen_addr = format!("127.0.0.1:{port}");
|
||||
|
||||
// Write a configuration that has our created metrics endpoint_addr
|
||||
let mut config = default_test_config(Mainnet)?;
|
||||
let mut config = default_test_config(&Mainnet)?;
|
||||
config.metrics.endpoint_addr = Some(listen_addr.parse().unwrap());
|
||||
let dir1 = testdir()?.with_config(&mut config)?;
|
||||
let regex1 = regex::escape(&format!(r"Opened metrics endpoint at {listen_addr}"));
|
||||
|
@ -2144,7 +2144,7 @@ fn zebra_tracing_conflict() -> Result<()> {
|
|||
let listen_addr = format!("127.0.0.1:{port}");
|
||||
|
||||
// Write a configuration that has our created tracing endpoint_addr
|
||||
let mut config = default_test_config(Mainnet)?;
|
||||
let mut config = default_test_config(&Mainnet)?;
|
||||
config.tracing.endpoint_addr = Some(listen_addr.parse().unwrap());
|
||||
let dir1 = testdir()?.with_config(&mut config)?;
|
||||
let regex1 = regex::escape(&format!(r"Opened tracing endpoint at {listen_addr}"));
|
||||
|
@ -2646,7 +2646,7 @@ async fn state_format_test(
|
|||
tracing::info!(?network, "running {test_name} using zebra-state");
|
||||
|
||||
let config = UseAnyState
|
||||
.zebrad_config(test_name, false, Some(dir.path()), &network)
|
||||
.zebrad_config(test_name, false, Some(dir.path()), network)
|
||||
.expect("already checked config")?;
|
||||
|
||||
zebra_state::write_state_database_format_version_to_disk(
|
||||
|
@ -2841,7 +2841,7 @@ fn scan_task_starts() -> Result<()> {
|
|||
let test_type = TestType::LaunchWithEmptyState {
|
||||
launches_lightwalletd: false,
|
||||
};
|
||||
let mut config = default_test_config(Mainnet)?;
|
||||
let mut config = default_test_config(&Mainnet)?;
|
||||
let mut keys = IndexMap::new();
|
||||
keys.insert(ZECPAGES_SAPLING_VIEWING_KEY.to_string(), 1);
|
||||
config.shielded_scan.sapling_keys_to_scan = keys;
|
||||
|
@ -2886,7 +2886,7 @@ async fn scan_rpc_server_starts() -> Result<()> {
|
|||
|
||||
let port = random_known_port();
|
||||
let listen_addr = format!("127.0.0.1:{port}");
|
||||
let mut config = default_test_config(Mainnet)?;
|
||||
let mut config = default_test_config(&Mainnet)?;
|
||||
config.shielded_scan.listen_addr = Some(listen_addr.parse()?);
|
||||
|
||||
// Start zebra with the config.
|
||||
|
@ -2944,7 +2944,7 @@ fn scan_start_where_left() -> Result<()> {
|
|||
let test_type = TestType::UpdateZebraCachedStateNoRpc;
|
||||
if let Some(cache_dir) = test_type.zebrad_state_path("scan test") {
|
||||
// Add a key to the config
|
||||
let mut config = default_test_config(Mainnet)?;
|
||||
let mut config = default_test_config(&Mainnet)?;
|
||||
let mut keys = IndexMap::new();
|
||||
keys.insert(ZECPAGES_SAPLING_VIEWING_KEY.to_string(), 1);
|
||||
config.shielded_scan.sapling_keys_to_scan = keys;
|
||||
|
|
|
@ -71,7 +71,7 @@ pub async fn run(network: Network) -> Result<()> {
|
|||
|
||||
// Sync zebrad to the network chain tip
|
||||
let (mut zebrad, zebra_rpc_address) = if let Some(zebrad_and_address) =
|
||||
spawn_zebrad_for_rpc(network, test_name, test_type, true)?
|
||||
spawn_zebrad_for_rpc(network.clone(), test_name, test_type, true)?
|
||||
{
|
||||
zebrad_and_address
|
||||
} else {
|
||||
|
@ -155,8 +155,12 @@ pub async fn run(network: Network) -> Result<()> {
|
|||
"zebrad synced to the tip, launching zebra-checkpoints...",
|
||||
);
|
||||
|
||||
let zebra_checkpoints =
|
||||
spawn_zebra_checkpoints_direct(network, test_type, zebra_rpc_address, last_checkpoint)?;
|
||||
let zebra_checkpoints = spawn_zebra_checkpoints_direct(
|
||||
network.clone(),
|
||||
test_type,
|
||||
zebra_rpc_address,
|
||||
last_checkpoint,
|
||||
)?;
|
||||
|
||||
let show_zebrad_logs = env::var(LOG_ZEBRAD_CHECKPOINTS).is_ok();
|
||||
if !show_zebrad_logs {
|
||||
|
|
|
@ -85,7 +85,8 @@ pub async fn run() -> Result<()> {
|
|||
"running gRPC send transaction test using lightwalletd & zebrad",
|
||||
);
|
||||
|
||||
let transactions = load_transactions_from_future_blocks(network, test_type, test_name).await?;
|
||||
let transactions =
|
||||
load_transactions_from_future_blocks(network.clone(), test_type, test_name).await?;
|
||||
|
||||
tracing::info!(
|
||||
transaction_count = ?transactions.len(),
|
||||
|
@ -98,9 +99,12 @@ pub async fn run() -> Result<()> {
|
|||
|
||||
// Start zebrad with no peers, we want to send transactions without blocks coming in. If `wallet_grpc_test`
|
||||
// runs before this test (as it does in `lightwalletd_test_suite`), then we are the most up to date with tip we can.
|
||||
let (mut zebrad, zebra_rpc_address) = if let Some(zebrad_and_address) =
|
||||
spawn_zebrad_for_rpc(network, test_name, test_type, use_internet_connection)?
|
||||
{
|
||||
let (mut zebrad, zebra_rpc_address) = if let Some(zebrad_and_address) = spawn_zebrad_for_rpc(
|
||||
network.clone(),
|
||||
test_name,
|
||||
test_type,
|
||||
use_internet_connection,
|
||||
)? {
|
||||
zebrad_and_address
|
||||
} else {
|
||||
// Skip the test, we don't have the required cached state
|
||||
|
@ -283,7 +287,7 @@ async fn load_transactions_from_future_blocks(
|
|||
test_type: TestType,
|
||||
test_name: &str,
|
||||
) -> Result<Vec<Arc<Transaction>>> {
|
||||
let transactions = get_future_blocks(network, test_type, test_name, MAX_NUM_FUTURE_BLOCKS)
|
||||
let transactions = get_future_blocks(&network, test_type, test_name, MAX_NUM_FUTURE_BLOCKS)
|
||||
.await?
|
||||
.into_iter()
|
||||
.flat_map(|block| block.transactions)
|
||||
|
|
|
@ -85,9 +85,12 @@ pub async fn run() -> Result<()> {
|
|||
|
||||
// Launch zebra with peers and using a predefined zebrad state path.
|
||||
// As this tests are just queries we can have a live chain where blocks are coming.
|
||||
let (mut zebrad, zebra_rpc_address) = if let Some(zebrad_and_address) =
|
||||
spawn_zebrad_for_rpc(network, test_name, test_type, use_internet_connection)?
|
||||
{
|
||||
let (mut zebrad, zebra_rpc_address) = if let Some(zebrad_and_address) = spawn_zebrad_for_rpc(
|
||||
network.clone(),
|
||||
test_name,
|
||||
test_type,
|
||||
use_internet_connection,
|
||||
)? {
|
||||
tracing::info!(
|
||||
?network,
|
||||
?test_type,
|
||||
|
@ -134,7 +137,7 @@ pub async fn run() -> Result<()> {
|
|||
|
||||
// Launch lightwalletd
|
||||
let (lightwalletd, lightwalletd_rpc_port) =
|
||||
spawn_lightwalletd_for_rpc(network, test_name, test_type, zebra_rpc_address)?
|
||||
spawn_lightwalletd_for_rpc(network.clone(), test_name, test_type, zebra_rpc_address)?
|
||||
.expect("already checked cached state and network requirements");
|
||||
|
||||
tracing::info!(
|
||||
|
@ -182,10 +185,10 @@ pub async fn run() -> Result<()> {
|
|||
.into_inner();
|
||||
|
||||
// Get `Sapling` activation height.
|
||||
let sapling_activation_height = Sapling.activation_height(network).unwrap().0 as u64;
|
||||
let sapling_activation_height = Sapling.activation_height(&network).unwrap().0 as u64;
|
||||
|
||||
// As we are using a pretty much synchronized blockchain, we can assume the tip is above the Nu5 network upgrade
|
||||
assert!(block_tip.height > Nu5.activation_height(network).unwrap().0 as u64);
|
||||
assert!(block_tip.height > Nu5.activation_height(&network).unwrap().0 as u64);
|
||||
|
||||
// The first block in the mainnet that has sapling and orchard information.
|
||||
let block_with_trees = 1687107;
|
||||
|
|
|
@ -80,14 +80,14 @@ pub(crate) async fn run() -> Result<()> {
|
|||
fs::remove_dir_all(std::path::Path::new(&scan_db_path)).ok();
|
||||
|
||||
let (state_service, _read_state_service, latest_chain_tip, chain_tip_change) =
|
||||
start_state_service_with_cache_dir(network, zebrad_state_path.clone()).await?;
|
||||
start_state_service_with_cache_dir(&network, zebrad_state_path.clone()).await?;
|
||||
|
||||
let chain_tip_height = latest_chain_tip
|
||||
.best_tip_height()
|
||||
.ok_or_else(|| eyre!("State directory doesn't have a chain tip block"))?;
|
||||
|
||||
let sapling_activation_height = NetworkUpgrade::Sapling
|
||||
.activation_height(network)
|
||||
.activation_height(&network)
|
||||
.expect("there should be an activation height for Mainnet");
|
||||
|
||||
assert!(
|
||||
|
@ -105,7 +105,7 @@ pub(crate) async fn run() -> Result<()> {
|
|||
let state = ServiceBuilder::new().buffer(10).service(state_service);
|
||||
|
||||
// Create an ephemeral `Storage` instance
|
||||
let storage = Storage::new(&scan_config, network, false);
|
||||
let storage = Storage::new(&scan_config, &network, false);
|
||||
let mut scan_task = ScanTask::spawn(storage, state, chain_tip_change);
|
||||
|
||||
tracing::info!("started scan task, sending register/subscribe keys messages with zecpages key to start scanning for a new key",);
|
||||
|
|
Loading…
Reference in New Issue