From 620ca103f977b779ccca2786d8861b5973ccfccc Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Fri, 27 Sep 2024 16:40:53 -0700 Subject: [PATCH] Fix warnings --- .../src/engine_api/json_structures.rs | 29 +++---------------- .../src/test_utils/handle_rpc.rs | 2 +- .../src/test_utils/mock_builder.rs | 6 ++-- consensus/types/src/execution_requests.rs | 4 ++- 4 files changed, 12 insertions(+), 29 deletions(-) diff --git a/beacon_node/execution_layer/src/engine_api/json_structures.rs b/beacon_node/execution_layer/src/engine_api/json_structures.rs index 285c01c81b9..b0ff6f5236d 100644 --- a/beacon_node/execution_layer/src/engine_api/json_structures.rs +++ b/beacon_node/execution_layer/src/engine_api/json_structures.rs @@ -1,13 +1,13 @@ use super::*; use alloy_rlp::RlpEncodable; -use bytes::{BufMut, Bytes, BytesMut}; +use bytes::Bytes; use serde::{Deserialize, Serialize}; -use ssz::{Decode, Encode}; +use ssz::Decode; use strum::EnumString; use superstruct::superstruct; use types::beacon_block_body::KzgCommitments; use types::blob_sidecar::BlobsList; -use types::{DepositRequest, FixedVector, PublicKeyBytes, Signature, Unsigned, WithdrawalRequest}; +use types::{DepositRequest, FixedVector, Unsigned, WithdrawalRequest}; #[derive(Debug, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] @@ -191,15 +191,6 @@ enum RequestPrefix { } impl RequestPrefix { - // TODO(pawan): get the final values from the spec - pub fn to_prefix(&self) -> u8 { - match self { - Self::Deposit => 0, - Self::Withdrawal => 1, - Self::Consolidation => 2, - } - } - pub fn from_prefix(prefix: u8) -> Option { match prefix { 0 => Some(Self::Deposit), @@ -210,13 +201,6 @@ impl RequestPrefix { } } -fn prefix_and_bytes(request: &T, prefix: u8, max_size: usize) -> Bytes { - let mut bytes: Vec = Vec::with_capacity(max_size); - bytes.push(prefix); - bytes.append(&mut request.as_ssz_bytes()); - Bytes::from(bytes) -} - impl From> for JsonExecutionPayloadV4 { fn from(payload: ExecutionPayloadElectra) -> Self { JsonExecutionPayloadV4 { @@ -828,12 +812,7 @@ impl From> for JsonExecutionPayloadBodyV1< Self { transactions: value.transactions, withdrawals: value.withdrawals.map(|withdrawals| { - VariableList::from( - withdrawals - .into_iter() - .map(Into::into) - .collect::>(), - ) + VariableList::from(withdrawals.into_iter().map(Into::into).collect::>()) }), } } diff --git a/beacon_node/execution_layer/src/test_utils/handle_rpc.rs b/beacon_node/execution_layer/src/test_utils/handle_rpc.rs index 127460b19f9..8f8ac87b9a7 100644 --- a/beacon_node/execution_layer/src/test_utils/handle_rpc.rs +++ b/beacon_node/execution_layer/src/test_utils/handle_rpc.rs @@ -247,7 +247,7 @@ pub async fn handle_rpc( Some( ctx.execution_block_generator .write() - .new_payload(request.try_into().unwrap()), + .new_payload(request.into()), ) } else { None diff --git a/beacon_node/execution_layer/src/test_utils/mock_builder.rs b/beacon_node/execution_layer/src/test_utils/mock_builder.rs index e86a1e97f05..f9815393f6a 100644 --- a/beacon_node/execution_layer/src/test_utils/mock_builder.rs +++ b/beacon_node/execution_layer/src/test_utils/mock_builder.rs @@ -540,7 +540,8 @@ pub fn serve( let mut message = match payload_response_type { crate::GetPayloadResponseType::Full(payload_response) => { - let (payload, _block_value, maybe_blobs_bundle, maybe_requests): ( + #[allow(clippy::type_complexity)] + let (payload, _block_value, maybe_blobs_bundle, _maybe_requests): ( ExecutionPayload, Uint256, Option>, @@ -592,7 +593,8 @@ pub fn serve( } } crate::GetPayloadResponseType::Blinded(payload_response) => { - let (payload, _block_value, maybe_blobs_bundle, maybe_requests): ( + #[allow(clippy::type_complexity)] + let (payload, _block_value, maybe_blobs_bundle, _maybe_requests): ( ExecutionPayload, Uint256, Option>, diff --git a/consensus/types/src/execution_requests.rs b/consensus/types/src/execution_requests.rs index 46f313f933f..c0f6bac06d7 100644 --- a/consensus/types/src/execution_requests.rs +++ b/consensus/types/src/execution_requests.rs @@ -38,7 +38,9 @@ pub struct ExecutionRequests { #[cfg(test)] mod tests { + use crate::MainnetEthSpec; + use super::*; - ssz_and_tree_hash_tests!(ExecutionRequests); + ssz_and_tree_hash_tests!(ExecutionRequests); }