Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add the ability to skip the relayer public key check #207

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ timeout_get_payload_ms = 4000
# Timeout in milliseconds for the `register_validator` call to relays.
# OPTIONAL, DEFAULT: 3000
timeout_register_validator_ms = 3000
# Whether to skip signature verification of headers against the relay pubkey
# Whether to skip signature verification of headers and pubkey matching against the relay pubkey
# OPTIONAL, DEFAULT: false
skip_sigverify = false
# Minimum bid in ETH that will be accepted from `get_header`
Expand Down
33 changes: 16 additions & 17 deletions crates/pbs/src/mev_boost/get_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,22 +398,22 @@ fn validate_header(
return Err(ValidationError::BidTooLow { min: minimum_bid_wei, got: value });
}

if expected_relay_pubkey != received_relay_pubkey {
return Err(ValidationError::PubkeyMismatch {
expected: expected_relay_pubkey,
got: received_relay_pubkey,
});
}

let expected_timestamp = timestamp_of_slot_start_sec(slot, chain);
if expected_timestamp != signed_header.message.header.timestamp {
return Err(ValidationError::TimestampMismatch {
expected: expected_timestamp,
got: signed_header.message.header.timestamp,
})
});
}

if !skip_sig_verify {
if expected_relay_pubkey != received_relay_pubkey {
return Err(ValidationError::PubkeyMismatch {
expected: expected_relay_pubkey,
got: received_relay_pubkey,
});
}

verify_signed_message(
chain,
&received_relay_pubkey,
Expand Down Expand Up @@ -545,6 +545,13 @@ mod tests {

mock_header.message.value = U256::from(11);

let expected = timestamp_of_slot_start_sec(slot, chain);
assert_eq!(
validate_header(&mock_header, chain, pubkey, parent_hash, false, min_bid, slot,),
Err(ValidationError::TimestampMismatch { expected, got: 0 })
);

mock_header.message.header.timestamp = expected;
mock_header.message.pubkey = pubkey;

assert_eq!(
Expand All @@ -560,14 +567,6 @@ mod tests {
Err(ValidationError::PubkeyMismatch { expected: BlsPublicKey::default(), got: pubkey })
);

let expected = timestamp_of_slot_start_sec(slot, chain);
assert_eq!(
validate_header(&mock_header, chain, pubkey, parent_hash, false, min_bid, slot,),
Err(ValidationError::TimestampMismatch { expected, got: 0 })
);

mock_header.message.header.timestamp = expected;

assert!(matches!(
validate_header(&mock_header, chain, pubkey, parent_hash, false, min_bid, slot),
Err(ValidationError::Sigverify(_))
Expand All @@ -580,6 +579,6 @@ mod tests {

assert!(
validate_header(&mock_header, chain, pubkey, parent_hash, false, min_bid, slot).is_ok()
)
);
}
}
Loading