From df78af9b936bc46dc30d91bcf4940799249e798b Mon Sep 17 00:00:00 2001 From: "s. rannou" Date: Wed, 11 Dec 2024 12:08:48 +0100 Subject: [PATCH 1/2] feat: add the ability to skip the relayer public key check --- crates/pbs/src/mev_boost/get_header.rs | 33 +++++++++++++------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/crates/pbs/src/mev_boost/get_header.rs b/crates/pbs/src/mev_boost/get_header.rs index 04485119..315752a1 100644 --- a/crates/pbs/src/mev_boost/get_header.rs +++ b/crates/pbs/src/mev_boost/get_header.rs @@ -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, @@ -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!( @@ -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(_)) @@ -580,6 +579,6 @@ mod tests { assert!( validate_header(&mock_header, chain, pubkey, parent_hash, false, min_bid, slot).is_ok() - ) + ); } } From 3f0161ccea6ffbe9cfc6dabbd21030882f525e03 Mon Sep 17 00:00:00 2001 From: "s. rannou" Date: Wed, 11 Dec 2024 15:47:45 +0100 Subject: [PATCH 2/2] fix: nit --- config.example.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.example.toml b/config.example.toml index 138876d9..66e3d47e 100644 --- a/config.example.toml +++ b/config.example.toml @@ -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`