Skip to content

Commit 5b63e7a

Browse files
committed
feat: add the ability to skip the relayer public key check
1 parent 7a22028 commit 5b63e7a

File tree

4 files changed

+52
-9
lines changed

4 files changed

+52
-9
lines changed

config.example.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ timeout_register_validator_ms = 3000
4040
# Whether to skip signature verification of headers against the relay pubkey
4141
# OPTIONAL, DEFAULT: false
4242
skip_sigverify = false
43+
# Whether to skip the public key of the PBS relayer. Useful if the relayer is a local pre-confirmation module.
44+
# OPTIONAL, DEFAULT: false
45+
skip_relayer_pubkey_check = false
4346
# Minimum bid in ETH that will be accepted from `get_header`
4447
# Can be specified as a float or a string for extra precision (e.g. "0.01")
4548
# OPTIONAL, DEFAULT: 0.0

crates/common/src/config/pbs.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ pub struct PbsConfig {
8383
/// Whether to skip the relay signature verification
8484
#[serde(default = "default_bool::<false>")]
8585
pub skip_sigverify: bool,
86+
/// Whether to skip the relay pubkey verification
87+
pub skip_relayer_pubkey_check: bool,
8688
/// Minimum bid that will be accepted from get_header
8789
#[serde(rename = "min_bid_eth", with = "as_eth_str", default = "default_u256")]
8890
pub min_bid_wei: U256,

crates/pbs/src/mev_boost/get_header.rs

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ pub async fn get_header<S: BuilderApiState>(
9191
max_timeout_ms,
9292
ValidationContext {
9393
skip_sigverify: state.pbs_config().skip_sigverify,
94+
skip_relayer_pubkey_check: state.pbs_config().skip_relayer_pubkey_check,
9495
min_bid_wei: state.pbs_config().min_bid_wei,
9596
extra_validation_enabled: state.extra_validation_enabled(),
9697
parent_block: parent_block.clone(),
@@ -265,6 +266,7 @@ struct RequestContext {
265266
#[derive(Clone)]
266267
struct ValidationContext {
267268
skip_sigverify: bool,
269+
skip_relayer_pubkey_check: bool,
268270
min_bid_wei: U256,
269271
extra_validation_enabled: bool,
270272
parent_block: Arc<RwLock<Option<Block>>>,
@@ -349,6 +351,7 @@ async fn send_one_get_header(
349351
relay.pubkey(),
350352
params.parent_hash,
351353
validation.skip_sigverify,
354+
validation.skip_relayer_pubkey_check,
352355
validation.min_bid_wei,
353356
params.slot,
354357
)?;
@@ -371,6 +374,7 @@ fn validate_header(
371374
expected_relay_pubkey: BlsPublicKey,
372375
parent_hash: B256,
373376
skip_sig_verify: bool,
377+
skip_relayer_pubkey_check: bool,
374378
minimum_bid_wei: U256,
375379
slot: u64,
376380
) -> Result<(), ValidationError> {
@@ -398,7 +402,7 @@ fn validate_header(
398402
return Err(ValidationError::BidTooLow { min: minimum_bid_wei, got: value });
399403
}
400404

401-
if expected_relay_pubkey != received_relay_pubkey {
405+
if !skip_relayer_pubkey_check && expected_relay_pubkey != received_relay_pubkey {
402406
return Err(ValidationError::PubkeyMismatch {
403407
expected: expected_relay_pubkey,
404408
got: received_relay_pubkey,
@@ -410,7 +414,7 @@ fn validate_header(
410414
return Err(ValidationError::TimestampMismatch {
411415
expected: expected_timestamp,
412416
got: signed_header.message.header.timestamp,
413-
})
417+
});
414418
}
415419

416420
if !skip_sig_verify {
@@ -489,6 +493,7 @@ mod tests {
489493
BlsPublicKey::default(),
490494
parent_hash,
491495
false,
496+
false,
492497
min_bid,
493498
slot,
494499
),
@@ -504,6 +509,7 @@ mod tests {
504509
BlsPublicKey::default(),
505510
parent_hash,
506511
false,
512+
false,
507513
min_bid,
508514
slot,
509515
),
@@ -522,6 +528,7 @@ mod tests {
522528
BlsPublicKey::default(),
523529
parent_hash,
524530
false,
531+
false,
525532
min_bid,
526533
slot,
527534
),
@@ -537,6 +544,7 @@ mod tests {
537544
BlsPublicKey::default(),
538545
parent_hash,
539546
false,
547+
false,
540548
min_bid,
541549
slot,
542550
),
@@ -554,6 +562,7 @@ mod tests {
554562
BlsPublicKey::default(),
555563
parent_hash,
556564
false,
565+
false,
557566
min_bid,
558567
slot,
559568
),
@@ -562,24 +571,52 @@ mod tests {
562571

563572
let expected = timestamp_of_slot_start_sec(slot, chain);
564573
assert_eq!(
565-
validate_header(&mock_header, chain, pubkey, parent_hash, false, min_bid, slot,),
574+
validate_header(&mock_header, chain, pubkey, parent_hash, false, false, min_bid, slot,),
566575
Err(ValidationError::TimestampMismatch { expected, got: 0 })
567576
);
568577

569578
mock_header.message.header.timestamp = expected;
570579

571580
assert!(matches!(
572-
validate_header(&mock_header, chain, pubkey, parent_hash, false, min_bid, slot),
581+
validate_header(&mock_header, chain, pubkey, parent_hash, false, false, min_bid, slot),
573582
Err(ValidationError::Sigverify(_))
574583
));
575-
assert!(
576-
validate_header(&mock_header, chain, pubkey, parent_hash, true, min_bid, slot).is_ok()
577-
);
584+
assert!(validate_header(
585+
&mock_header,
586+
chain,
587+
pubkey,
588+
parent_hash,
589+
true,
590+
false,
591+
min_bid,
592+
slot
593+
)
594+
.is_ok());
595+
596+
assert!(validate_header(
597+
&mock_header,
598+
chain,
599+
BlsPublicKey::default(),
600+
parent_hash,
601+
true,
602+
true,
603+
min_bid,
604+
slot
605+
)
606+
.is_ok());
578607

579608
mock_header.signature = sign_builder_message(chain, &secret_key, &mock_header.message);
580609

581-
assert!(
582-
validate_header(&mock_header, chain, pubkey, parent_hash, false, min_bid, slot).is_ok()
610+
assert!(validate_header(
611+
&mock_header,
612+
chain,
613+
pubkey,
614+
parent_hash,
615+
false,
616+
false,
617+
min_bid,
618+
slot
583619
)
620+
.is_ok());
584621
}
585622
}

tests/tests/pbs_integration.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ fn get_pbs_static_config(port: u16) -> PbsConfig {
3333
timeout_get_payload_ms: u64::MAX,
3434
timeout_register_validator_ms: u64::MAX,
3535
skip_sigverify: false,
36+
skip_relayer_pubkey_check: false,
3637
min_bid_wei: U256::ZERO,
3738
late_in_slot_time_ms: u64::MAX,
3839
relay_monitors: vec![],

0 commit comments

Comments
 (0)