Rust 1.54.0 lints (#2483)

## Issue Addressed

N/A

## Proposed Changes

- Removing a bunch of unnecessary references
- Updated `Error::VariantError` to `Error::Variant`
- There were additional enum variant lints that I ignored, because I thought our variant names were fine
- removed `MonitoredValidator`'s `pubkey` field, because I couldn't find it used anywhere. It looks like we just use the string version of the pubkey (the `id` field) if there is no index

## Additional Info



Co-authored-by: realbigsean <seananderson33@gmail.com>
This commit is contained in:
realbigsean
2021-07-30 01:11:47 +00:00
parent 8efd9fc324
commit 303deb9969
104 changed files with 307 additions and 313 deletions

View File

@@ -12,7 +12,7 @@ pub enum Error {
/// Logs have to be added with monotonically-increasing block numbers.
NonConsecutive { log_index: u64, expected: usize },
/// The eth1 event log data was unable to be parsed.
LogParseError(String),
LogParse(String),
/// There are insufficient deposits in the cache to fulfil the request.
InsufficientDeposits {
known_deposits: usize,
@@ -26,9 +26,9 @@ pub enum Error {
/// E.g., you cannot request deposit 10 when the deposit count is 9.
DepositCountInvalid { deposit_count: u64, range_end: u64 },
/// Error with the merkle tree for deposits.
DepositTreeError(merkle_proof::MerkleTreeError),
DepositTree(merkle_proof::MerkleTreeError),
/// An unexpected condition was encountered.
InternalError(String),
Internal(String),
}
#[derive(Encode, Decode, Clone)]
@@ -160,7 +160,7 @@ impl DepositCache {
self.logs.push(log);
self.deposit_tree
.push_leaf(deposit)
.map_err(Error::DepositTreeError)?;
.map_err(Error::DepositTree)?;
self.deposit_roots.push(self.deposit_tree.root());
Ok(DepositCacheInsertOutcome::Inserted)
}
@@ -219,7 +219,7 @@ impl DepositCache {
let leaves = self
.leaves
.get(0..deposit_count as usize)
.ok_or_else(|| Error::InternalError("Unable to get known leaves".into()))?;
.ok_or_else(|| Error::Internal("Unable to get known leaves".into()))?;
// Note: there is likely a more optimal solution than recreating the `DepositDataTree`
// each time this function is called.
@@ -233,7 +233,7 @@ impl DepositCache {
let deposits = self
.logs
.get(start as usize..end as usize)
.ok_or_else(|| Error::InternalError("Unable to get known log".into()))?
.ok_or_else(|| Error::Internal("Unable to get known log".into()))?
.iter()
.map(|deposit_log| {
let (_leaf, proof) = tree.generate_proof(deposit_log.index as usize);

View File

@@ -378,7 +378,7 @@ pub async fn get_deposit_logs_in_range(
.ok_or("Data was not string")?;
Ok(Log {
block_number: hex_to_u64_be(&block_number)?,
block_number: hex_to_u64_be(block_number)?,
data: hex_to_bytes(data)?,
})
})
@@ -446,7 +446,7 @@ pub async fn send_rpc_request(
/// Accepts an entire HTTP body (as a string) and returns either the `result` field or the `error['message']` field, as a serde `Value`.
fn response_result_or_error(response: &str) -> Result<Value, RpcError> {
let json = serde_json::from_str::<Value>(&response)
let json = serde_json::from_str::<Value>(response)
.map_err(|e| RpcError::InvalidJson(e.to_string()))?;
if let Some(error) = json.get("error").map(|e| e.get("message")).flatten() {

View File

@@ -48,7 +48,7 @@ impl Inner {
/// Encode the eth1 block and deposit cache as bytes.
pub fn as_bytes(&self) -> Vec<u8> {
let ssz_eth1_cache = SszEth1Cache::from_inner(&self);
let ssz_eth1_cache = SszEth1Cache::from_inner(self);
ssz_eth1_cache.as_ssz_bytes()
}

View File

@@ -705,7 +705,7 @@ impl Service {
}
}
}
endpoints.fallback.map_format_error(|s| &s.endpoint, &e)
endpoints.fallback.map_format_error(|s| &s.endpoint, e)
};
let process_err = |e: Error| match &e {
@@ -716,7 +716,7 @@ impl Service {
let (remote_head_block, new_block_numbers_deposit, new_block_numbers_block_cache) =
endpoints
.first_success(|e| async move {
get_remote_head_and_new_block_ranges(e, &self, node_far_behind_seconds).await
get_remote_head_and_new_block_ranges(e, self, node_far_behind_seconds).await
})
.await
.map_err(|e| {
@@ -881,7 +881,7 @@ impl Service {
Some(range) => range,
None => endpoints
.first_success(|e| async move {
relevant_new_block_numbers_from_endpoint(e, &self, HeadType::Deposit).await
relevant_new_block_numbers_from_endpoint(e, self, HeadType::Deposit).await
})
.await
.map_err(Error::FallbackError)?,
@@ -922,7 +922,7 @@ impl Service {
.first_success(|e| async move {
get_deposit_logs_in_range(
e,
&deposit_contract_address_ref,
deposit_contract_address_ref,
block_range_ref.clone(),
Duration::from_millis(GET_DEPOSIT_LOG_TIMEOUT_MILLIS),
)
@@ -1034,7 +1034,7 @@ impl Service {
Some(range) => range,
None => endpoints
.first_success(|e| async move {
relevant_new_block_numbers_from_endpoint(e, &self, HeadType::BlockCache)
relevant_new_block_numbers_from_endpoint(e, self, HeadType::BlockCache)
.await
})
.await