1.57.0 lints (#2850)

## Issue Addressed

New rust lints

## Proposed Changes

- Boxing some enum variants
- removing some unused fields (is the validator lockfile unused? seemed so to me)

## Additional Info

- some error fields were marked as dead code but are logged out in areas
- left some dead fields in our ef test code because I assume they are useful for debugging?

Co-authored-by: realbigsean <seananderson33@gmail.com>
This commit is contained in:
realbigsean
2021-12-03 04:44:30 +00:00
parent f3c237cfa0
commit a80ccc3a33
22 changed files with 64 additions and 56 deletions

View File

@@ -187,14 +187,13 @@ fn valid_4_deposits() {
let harness = get_harness::<MainnetEthSpec>(EPOCH_OFFSET, VALIDATOR_COUNT);
let mut state = harness.get_current_state();
let (deposits, mut state) = harness.make_deposits(&mut state, 4, None, None);
let (deposits, state) = harness.make_deposits(&mut state, 4, None, None);
let deposits = VariableList::from(deposits);
let mut head_block = harness.chain.head_beacon_block().unwrap().deconstruct().0;
*head_block.to_mut().body_mut().deposits_mut() = deposits;
let result =
process_operations::process_deposits(&mut state, head_block.body().deposits(), &spec);
let result = process_operations::process_deposits(state, head_block.body().deposits(), &spec);
// Expecting Ok because these are valid deposits.
assert_eq!(result, Ok(()));
@@ -206,7 +205,7 @@ fn invalid_deposit_deposit_count_too_big() {
let harness = get_harness::<MainnetEthSpec>(EPOCH_OFFSET, VALIDATOR_COUNT);
let mut state = harness.get_current_state();
let (deposits, mut state) = harness.make_deposits(&mut state, 1, None, None);
let (deposits, state) = harness.make_deposits(&mut state, 1, None, None);
let deposits = VariableList::from(deposits);
let mut head_block = harness.chain.head_beacon_block().unwrap().deconstruct().0;
@@ -214,8 +213,7 @@ fn invalid_deposit_deposit_count_too_big() {
let big_deposit_count = NUM_DEPOSITS + 1;
state.eth1_data_mut().deposit_count = big_deposit_count;
let result =
process_operations::process_deposits(&mut state, head_block.body().deposits(), &spec);
let result = process_operations::process_deposits(state, head_block.body().deposits(), &spec);
// Expecting DepositCountInvalid because we incremented the deposit_count
assert_eq!(
@@ -233,7 +231,7 @@ fn invalid_deposit_count_too_small() {
let harness = get_harness::<MainnetEthSpec>(EPOCH_OFFSET, VALIDATOR_COUNT);
let mut state = harness.get_current_state();
let (deposits, mut state) = harness.make_deposits(&mut state, 1, None, None);
let (deposits, state) = harness.make_deposits(&mut state, 1, None, None);
let deposits = VariableList::from(deposits);
let mut head_block = harness.chain.head_beacon_block().unwrap().deconstruct().0;
@@ -241,8 +239,7 @@ fn invalid_deposit_count_too_small() {
let small_deposit_count = NUM_DEPOSITS - 1;
state.eth1_data_mut().deposit_count = small_deposit_count;
let result =
process_operations::process_deposits(&mut state, head_block.body().deposits(), &spec);
let result = process_operations::process_deposits(state, head_block.body().deposits(), &spec);
// Expecting DepositCountInvalid because we decremented the deposit_count
assert_eq!(
@@ -260,7 +257,7 @@ fn invalid_deposit_bad_merkle_proof() {
let harness = get_harness::<MainnetEthSpec>(EPOCH_OFFSET, VALIDATOR_COUNT);
let mut state = harness.get_current_state();
let (deposits, mut state) = harness.make_deposits(&mut state, 1, None, None);
let (deposits, state) = harness.make_deposits(&mut state, 1, None, None);
let deposits = VariableList::from(deposits);
let mut head_block = harness.chain.head_beacon_block().unwrap().deconstruct().0;
@@ -270,8 +267,7 @@ fn invalid_deposit_bad_merkle_proof() {
// Manually offsetting deposit count and index to trigger bad merkle proof
state.eth1_data_mut().deposit_count += 1;
*state.eth1_deposit_index_mut() += 1;
let result =
process_operations::process_deposits(&mut state, head_block.body().deposits(), &spec);
let result = process_operations::process_deposits(state, head_block.body().deposits(), &spec);
// Expecting BadMerkleProof because the proofs were created with different indices
assert_eq!(
@@ -289,15 +285,14 @@ fn invalid_deposit_wrong_sig() {
let harness = get_harness::<MainnetEthSpec>(EPOCH_OFFSET, VALIDATOR_COUNT);
let mut state = harness.get_current_state();
let (deposits, mut state) =
let (deposits, state) =
harness.make_deposits(&mut state, 1, None, Some(SignatureBytes::empty()));
let deposits = VariableList::from(deposits);
let mut head_block = harness.chain.head_beacon_block().unwrap().deconstruct().0;
*head_block.to_mut().body_mut().deposits_mut() = deposits;
let result =
process_operations::process_deposits(&mut state, head_block.body().deposits(), &spec);
let result = process_operations::process_deposits(state, head_block.body().deposits(), &spec);
// Expecting Ok(()) even though the block signature does not correspond to the correct public key
assert_eq!(result, Ok(()));
}
@@ -308,15 +303,14 @@ fn invalid_deposit_invalid_pub_key() {
let harness = get_harness::<MainnetEthSpec>(EPOCH_OFFSET, VALIDATOR_COUNT);
let mut state = harness.get_current_state();
let (deposits, mut state) =
let (deposits, state) =
harness.make_deposits(&mut state, 1, Some(PublicKeyBytes::empty()), None);
let deposits = VariableList::from(deposits);
let mut head_block = harness.chain.head_beacon_block().unwrap().deconstruct().0;
*head_block.to_mut().body_mut().deposits_mut() = deposits;
let result =
process_operations::process_deposits(&mut state, head_block.body().deposits(), &spec);
let result = process_operations::process_deposits(state, head_block.body().deposits(), &spec);
// Expecting Ok(()) even though we passed in invalid publickeybytes in the public key field of the deposit data.
assert_eq!(result, Ok(()));