Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
chirag-bgh committed Sep 7, 2023
1 parent e3be6f9 commit 4afadff
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions mev-relay-rs/src/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use ethereum_consensus::{
builder::ValidatorRegistration,
clock::get_current_unix_time_in_secs,
crypto::SecretKey,
primitives::{BlsPublicKey, Hash32, Root, Slot, U256},
primitives::{BlsPublicKey, Root, Slot, U256},
state_transition::Context,
};
use mev_build_rs::NullBuilder;
Expand Down Expand Up @@ -34,17 +34,19 @@ fn validate_bid_request(
// TDOD: take this as input
let fork = "Bellatrix";
// Check if the slot is timely
if !is_slot_timely(&bid_request.slot, &fork, &context) {
if !is_slot_timely(&bid_request.slot, fork, context) {
return Err(Error::InvalidSlot)
}

// Check if the parent_hash is on a chain tip
if !is_parent_hash_on_chain_tip(&bid_request.parent_hash, &context) {
let chain_tip = &context.terminal_block_hash;
if bid_request.parent_hash != *chain_tip {
return Err(Error::InvalidParentHash)
}

// Check if public_key is one of the possible proposers
if !is_valid_proposer(&bid_request.public_key, &validator_registry) {
let validator_index = validator_registry.get_validator_index(&bid_request.public_key);
if validator_index.is_some() {
return Err(Error::ValidatorNotRegistered(bid_request.public_key.clone()))
}

Expand All @@ -60,17 +62,6 @@ fn is_slot_timely(slot: &Slot, fork: &str, context: &Context) -> bool {
slot + PROPOSAL_TOLERANCE_DELAY >= current_slot
}

fn is_parent_hash_on_chain_tip(parent_hash: &Hash32, context: &Context) -> bool {
let chain_tip = &context.terminal_block_hash;
parent_hash == chain_tip
}

fn is_valid_proposer(public_key: &BlsPublicKey, validator_registry: &ValidatorRegistry) -> bool {
// check if validator is in the current validator set\
let validator_index = validator_registry.get_validator_index(public_key);
validator_index.is_some()
}

fn validate_execution_payload(
execution_payload: &ExecutionPayload,
_value: &U256,
Expand Down

0 comments on commit 4afadff

Please sign in to comment.