22
33use std:: { collections:: HashMap , sync:: Arc } ;
44
5- use alloy:: primitives:: U256 ;
6- use eyre:: Result ;
5+ use alloy:: primitives:: { utils :: format_ether , U256 } ;
6+ use eyre:: { ensure , Result } ;
77use serde:: { de:: DeserializeOwned , Deserialize , Serialize } ;
88use url:: Url ;
99
@@ -13,7 +13,7 @@ use crate::{
1313 config:: { load_env_var, load_file_from_env, CONFIG_ENV , MODULE_JWT_ENV , SIGNER_URL_ENV } ,
1414 pbs:: { BuilderEventPublisher , DefaultTimeout , RelayClient , RelayEntry , LATE_IN_SLOT_TIME_MS } ,
1515 types:: Chain ,
16- utils:: { as_eth_str, default_bool, default_u256, default_u64} ,
16+ utils:: { as_eth_str, default_bool, default_u256, default_u64, WEI_PER_ETH } ,
1717} ;
1818
1919#[ derive( Debug , Clone , Deserialize , Serialize ) ]
@@ -70,6 +70,25 @@ pub struct PbsConfig {
7070impl PbsConfig {
7171 /// Validate PBS config parameters
7272 pub fn validate ( & self ) -> Result < ( ) > {
73+ // timeouts must be positive
74+ ensure ! ( self . timeout_get_header_ms > 0 , "timeout_get_header_ms must be greater than 0" ) ;
75+ ensure ! ( self . timeout_get_payload_ms > 0 , "timeout_get_payload_ms must be greater than 0" ) ;
76+ ensure ! (
77+ self . timeout_register_validator_ms > 0 ,
78+ "timeout_register_validator_ms must be greater than 0"
79+ ) ;
80+ ensure ! ( self . late_in_slot_time_ms > 0 , "late_in_slot_time_ms must be greater than 0" ) ;
81+
82+ ensure ! (
83+ self . timeout_get_header_ms < self . late_in_slot_time_ms,
84+ "timeout_get_header_ms must be less than late_in_slot_time_ms"
85+ ) ;
86+
87+ ensure ! (
88+ self . min_bid_wei < U256 :: from( WEI_PER_ETH ) ,
89+ format!( "min bid is too high: {} ETH" , format_ether( self . min_bid_wei) )
90+ ) ;
91+
7392 Ok ( ( ) )
7493 }
7594}
0 commit comments