@@ -57,6 +57,17 @@ pub struct Eip1559Config {
5757 pub minimum_base_fee : u64 ,
5858}
5959
60+ impl Eip1559Config {
61+ pub fn validate ( & self ) -> Result < ( ) > {
62+ require ! ( self . denominator > 0 , BridgeError :: InvalidDenominator ) ;
63+ require ! (
64+ self . window_duration_seconds > 0 ,
65+ BridgeError :: InvalidWindowDurationSeconds
66+ ) ;
67+ Ok ( ( ) )
68+ }
69+ }
70+
6071impl Eip1559 {
6172 /// Refresh the base fee if window has expired, reset window tracking
6273 /// Handles multiple expired windows by processing each empty window
@@ -159,13 +170,38 @@ pub struct GasConfig {
159170 pub gas_per_call : u64 ,
160171}
161172
173+ impl GasConfig {
174+ pub fn validate ( & self ) -> Result < ( ) > {
175+ require ! (
176+ self . gas_cost_scaler_dp > 0 ,
177+ BridgeError :: InvalidGasCostScalerDp
178+ ) ;
179+ Ok ( ( ) )
180+ }
181+ }
182+
162183#[ derive( Debug , Clone , PartialEq , Eq , InitSpace , AnchorSerialize , AnchorDeserialize ) ]
163184pub struct ProtocolConfig {
164185 /// Block interval requirement for output root registration. Every Base block associated with a
165186 /// submitted output root must be a multiple of this number.
166187 pub block_interval_requirement : u64 ,
167188}
168189
190+ impl ProtocolConfig {
191+ pub fn validate ( & self ) -> Result < ( ) > {
192+ require ! (
193+ self . block_interval_requirement > 0 ,
194+ BridgeError :: InvalidBlockIntervalRequirement
195+ ) ;
196+
197+ require ! (
198+ self . block_interval_requirement <= 1000 ,
199+ BridgeError :: InvalidBlockIntervalRequirement
200+ ) ;
201+ Ok ( ( ) )
202+ }
203+ }
204+
169205#[ derive( Debug , Clone , PartialEq , Eq , InitSpace , AnchorSerialize , AnchorDeserialize ) ]
170206pub struct BufferConfig {
171207 /// Maximum call buffer size. This caps the max size of a Solana → Base message.
@@ -247,6 +283,14 @@ pub enum BridgeError {
247283 DuplicateSigner ,
248284 #[ msg( "Invalid partner threshold" ) ]
249285 InvalidPartnerThreshold ,
286+ #[ msg( "Invalid denominator" ) ]
287+ InvalidDenominator ,
288+ #[ msg( "Invalid window duration seconds" ) ]
289+ InvalidWindowDurationSeconds ,
290+ #[ msg( "Invalid gas cost scaler dp" ) ]
291+ InvalidGasCostScalerDp ,
292+ #[ msg( "Invalid block interval requirement" ) ]
293+ InvalidBlockIntervalRequirement ,
250294}
251295
252296#[ cfg( test) ]
0 commit comments