Fixed Clippy Complaints & Some Failing Tests (#3791)

* Fixed Clippy Complaints & Some Failing Tests
* Update Dockerfile to Rust-1.65
* EF test file renamed
* Touch up comments based on feedback
This commit is contained in:
ethDreamer
2022-12-13 10:50:24 -06:00
committed by GitHub
parent 173a0abab4
commit b1c33361ea
15 changed files with 79 additions and 49 deletions
+6 -4
View File
@@ -2205,8 +2205,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.verify_and_observe(bls_to_execution_change, &wall_clock_state, &self.spec)?)
}
// TODO: remove this whole block once withdrawals-processing is removed
#[cfg(not(feature = "withdrawals-processing"))]
{
#[allow(clippy::drop_non_drop)]
drop(bls_to_execution_change);
Ok(ObservationOutcome::AlreadyKnown)
}
@@ -4342,17 +4344,17 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
// Might implement caching here in the future..
let prepare_state = self
.state_at_slot(prepare_slot, StateSkipConfig::WithoutStateRoots)
.or_else(|e| {
.map_err(|e| {
error!(self.log, "State advance for withdrawals failed"; "error" => ?e);
Err(e)
e
})?;
Some(get_expected_withdrawals(&prepare_state, &self.spec))
}
}
.transpose()
.or_else(|e| {
.map_err(|e| {
error!(self.log, "Error preparing beacon proposer"; "error" => ?e);
Err(e)
e
})
.map(|withdrawals_opt| withdrawals_opt.map(|w| w.into()))
.map_err(Error::PrepareProposerFailed)?;
@@ -176,7 +176,7 @@ impl<T: EthSpec> JsonExecutionPayload<T> {
.collect::<Vec<_>>()
.into()
})
.ok_or(Error::BadConversion("Null withdrawal field converting JsonExecutionPayloadV2 -> ExecutionPayloadCapella".to_string()))?
.ok_or_else(|| Error::BadConversion("Null withdrawal field converting JsonExecutionPayloadV2 -> ExecutionPayloadCapella".to_string()))?
})),
ForkName::Eip4844 => Ok(ExecutionPayload::Eip4844(ExecutionPayloadEip4844 {
parent_hash: v2.parent_hash,
@@ -191,7 +191,7 @@ impl<T: EthSpec> JsonExecutionPayload<T> {
timestamp: v2.timestamp,
extra_data: v2.extra_data,
base_fee_per_gas: v2.base_fee_per_gas,
excess_data_gas: v2.excess_data_gas.ok_or(Error::BadConversion("Null `excess_data_gas` field converting JsonExecutionPayloadV2 -> ExecutionPayloadEip4844".to_string()))?,
excess_data_gas: v2.excess_data_gas.ok_or_else(|| Error::BadConversion("Null `excess_data_gas` field converting JsonExecutionPayloadV2 -> ExecutionPayloadEip4844".to_string()))?,
block_hash: v2.block_hash,
transactions: v2.transactions,
#[cfg(feature = "withdrawals")]
@@ -204,7 +204,7 @@ impl<T: EthSpec> JsonExecutionPayload<T> {
.collect::<Vec<_>>()
.into()
})
.ok_or(Error::BadConversion("Null withdrawal field converting JsonExecutionPayloadV2 -> ExecutionPayloadEip4844".to_string()))?
.ok_or_else(|| Error::BadConversion("Null withdrawal field converting JsonExecutionPayloadV2 -> ExecutionPayloadEip4844".to_string()))?
})),
_ => Err(Error::UnsupportedForkVariant(format!("Unsupported conversion from JsonExecutionPayloadV2 for {}", fork_name))),
}
+1 -1
View File
@@ -342,7 +342,7 @@ impl Engine {
impl PayloadIdCacheKey {
fn new(head_block_hash: &ExecutionBlockHash, attributes: &PayloadAttributes) -> Self {
Self {
head_block_hash: head_block_hash.clone(),
head_block_hash: *head_block_hash,
payload_attributes: attributes.clone(),
}
}
+1 -1
View File
@@ -1582,7 +1582,7 @@ impl<T: EthSpec> ExecutionLayer<T> {
let transactions = VariableList::new(
block
.transactions()
.into_iter()
.iter()
.map(|transaction| VariableList::new(transaction.rlp().to_vec()))
.collect::<Result<_, _>>()
.map_err(ApiError::DeserializeTransaction)?,
@@ -74,11 +74,29 @@ pub async fn handle_rpc<T: EthSpec>(
.unwrap())
}
}
ENGINE_NEW_PAYLOAD_V1 => {
let request: JsonExecutionPayload<T> = get_param(params, 0)?;
ENGINE_NEW_PAYLOAD_V1 | ENGINE_NEW_PAYLOAD_V2 => {
let request = match method {
ENGINE_NEW_PAYLOAD_V1 => {
JsonExecutionPayload::V1(get_param::<JsonExecutionPayloadV1<T>>(params, 0)?)
}
ENGINE_NEW_PAYLOAD_V2 => {
JsonExecutionPayload::V2(get_param::<JsonExecutionPayloadV2<T>>(params, 0)?)
}
_ => unreachable!(),
};
let fork = match request {
JsonExecutionPayload::V1(_) => ForkName::Merge,
JsonExecutionPayload::V2(ref payload) => {
if payload.withdrawals.is_none() {
ForkName::Merge
} else {
ForkName::Capella
}
}
};
// Canned responses set by block hash take priority.
if let Some(status) = ctx.get_new_payload_status(&request.block_hash()) {
if let Some(status) = ctx.get_new_payload_status(request.block_hash()) {
return Ok(serde_json::to_value(JsonPayloadStatusV1::from(status)).unwrap());
}
@@ -97,8 +115,7 @@ pub async fn handle_rpc<T: EthSpec>(
Some(
ctx.execution_block_generator
.write()
// FIXME: should this worry about other forks?
.new_payload(request.try_into_execution_payload(ForkName::Merge).unwrap()),
.new_payload(request.try_into_execution_payload(fork).unwrap()),
)
} else {
None
+1 -1
View File
@@ -41,7 +41,7 @@ pub async fn publish_block<T: BeaconChainTypes>(
))
} else {
//TODO(pawan): return an empty sidecar instead
return Err(warp_utils::reject::broadcast_without_import(format!("")));
return Err(warp_utils::reject::broadcast_without_import(String::new()));
}
}
_ => PubsubMessage::BeaconBlock(block.clone()),
@@ -224,12 +224,10 @@ impl<T: EthSpec> PubsubMessage<T> {
| ForkName::Merge
| ForkName::Capella,
)
| None => {
return Err(format!(
| None => Err(format!(
"beacon_blobs_and_sidecar topic invalid for given fork digest {:?}",
gossip_topic.fork_digest
))
}
)),
}
}
GossipKind::VoluntaryExit => {
+4
View File
@@ -558,8 +558,10 @@ impl<T: EthSpec> OperationPool<T> {
)
}
// TODO: remove this whole block once withdrwals-processing is removed
#[cfg(not(feature = "withdrawals-processing"))]
{
#[allow(clippy::drop_copy)]
drop((state, spec));
vec![]
}
@@ -597,8 +599,10 @@ impl<T: EthSpec> OperationPool<T> {
);
}
// TODO: remove this whole block once withdrwals-processing is removed
#[cfg(not(feature = "withdrawals-processing"))]
{
#[allow(clippy::drop_copy)]
drop((head_block, head_state, spec));
}
}