@@ -78,9 +78,48 @@ pub(crate) struct ConfigFlashblocks {
7878 help_heading = "flashblocks" ,
7979 env = "RPROXY_FLASHBLOCKS_LOG_SANITISE" ,
8080 long( "flashblocks-log-sanitise" ) ,
81- name( "flashblocks-log_sanitise " )
81+ name( "flashblocks_log_sanitise " )
8282 ) ]
8383 pub ( crate ) log_sanitise : bool ,
84+
85+ /// the chance (between 0.0 and 1.0) that pings received from
86+ /// flashblocks backend would be ignored (no pong sent)
87+ #[ arg(
88+ default_value = "0.0" ,
89+ help_heading = "chaos" ,
90+ env = "RPROXY_CHAOS_PROBABILITY_FLASHBLOCKS_BACKEND_PING_IGNORED" ,
91+ long( "chaos-probability-flashblocks-backend-ping-ignored" ) ,
92+ name( "chaos_probability_flashblocks_backend_ping_ignored" ) ,
93+ value_name = "probability"
94+ ) ]
95+ #[ cfg( feature = "chaos" ) ]
96+ pub ( crate ) chaos_probability_backend_ping_ignored : f64 ,
97+
98+ /// the chance (between 0.0 and 1.0) that pings received from
99+ /// flashblocks client would be ignored (no pong sent)
100+ #[ arg(
101+ default_value = "0.0" ,
102+ help_heading = "chaos" ,
103+ env = "RPROXY_CHAOS_PROBABILITY_FLASHBLOCKS_CLIENT_PING_IGNORED" ,
104+ long( "chaos-probability-flashblocks-client-ping-ignored" ) ,
105+ name( "chaos_probability_flashblocks_client_ping_ignored" ) ,
106+ value_name = "probability"
107+ ) ]
108+ #[ cfg( feature = "chaos" ) ]
109+ pub ( crate ) chaos_probability_client_ping_ignored : f64 ,
110+
111+ /// the chance (between 0.0 and 1.0) that client's flashblocks stream
112+ /// would block (no more messages sent)
113+ #[ arg(
114+ default_value = "0.0" ,
115+ help_heading = "chaos" ,
116+ env = "RPROXY_CHAOS_PROBABILITY_FLASHBLOCKS_STREAM_BLOCKED" ,
117+ long( "chaos-probability-flashblocks-stream-blocked" ) ,
118+ name( "chaos_probability_flashblocks_stream_blocked" ) ,
119+ value_name = "probability"
120+ ) ]
121+ #[ cfg( feature = "chaos" ) ]
122+ pub ( crate ) chaos_probability_stream_blocked : f64 ,
84123}
85124
86125impl ConfigFlashblocks {
@@ -119,6 +158,42 @@ impl ConfigFlashblocks {
119158 } )
120159 } ) ;
121160
161+ #[ cfg( feature = "chaos" ) ]
162+ {
163+ // chaos_probability_flashblocks_backend_ping_ignored
164+ if self . chaos_probability_backend_ping_ignored < 0.0 ||
165+ self . chaos_probability_backend_ping_ignored > 1.0
166+ {
167+ errs. push (
168+ ConfigFlashblocksError :: ChaosProbabilityFlashblocksBackendPingIgnoredInvalid {
169+ probability : self . chaos_probability_backend_ping_ignored ,
170+ } ,
171+ ) ;
172+ }
173+
174+ // chaos_probability_flashblocks_client_ping_ignored
175+ if self . chaos_probability_client_ping_ignored < 0.0 ||
176+ self . chaos_probability_client_ping_ignored > 1.0
177+ {
178+ errs. push (
179+ ConfigFlashblocksError :: ChaosProbabilityFlashblocksClientPingIgnoredInvalid {
180+ probability : self . chaos_probability_client_ping_ignored ,
181+ } ,
182+ ) ;
183+ }
184+
185+ // chaos_probability_flashblocks_stream_blocked
186+ if self . chaos_probability_stream_blocked < 0.0 ||
187+ self . chaos_probability_stream_blocked > 1.0
188+ {
189+ errs. push (
190+ ConfigFlashblocksError :: ChaosProbabilityFlashblocksStreamBlockedInvalid {
191+ probability : self . chaos_probability_stream_blocked ,
192+ } ,
193+ ) ;
194+ }
195+ }
196+
122197 match errs. len ( ) {
123198 0 => None ,
124199 _ => Some ( errs) ,
@@ -156,6 +231,24 @@ impl ConfigProxyWs for ConfigFlashblocks {
156231 fn log_sanitise ( & self ) -> bool {
157232 self . log_sanitise
158233 }
234+
235+ #[ inline]
236+ #[ cfg( feature = "chaos" ) ]
237+ fn chaos_probability_backend_ping_ignored ( & self ) -> f64 {
238+ self . chaos_probability_backend_ping_ignored
239+ }
240+
241+ #[ inline]
242+ #[ cfg( feature = "chaos" ) ]
243+ fn chaos_probability_client_ping_ignored ( & self ) -> f64 {
244+ self . chaos_probability_client_ping_ignored
245+ }
246+
247+ #[ inline]
248+ #[ cfg( feature = "chaos" ) ]
249+ fn chaos_probability_stream_blocked ( & self ) -> f64 {
250+ self . chaos_probability_stream_blocked
251+ }
159252}
160253
161254// ConfigFlashblocksError ----------------------------------------------
@@ -170,4 +263,22 @@ pub(crate) enum ConfigFlashblocksError {
170263
171264 #[ error( "invalid flashblocks proxy listen address '{addr}': {err}" ) ]
172265 ListenAddressInvalid { addr : String , err : std:: net:: AddrParseError } ,
266+
267+ #[ error(
268+ "invalid flashblocks backend ping ignore probability (must be within [0.0 .. 1.0]: {probability}"
269+ ) ]
270+ #[ cfg( feature = "chaos" ) ]
271+ ChaosProbabilityFlashblocksBackendPingIgnoredInvalid { probability : f64 } ,
272+
273+ #[ error(
274+ "invalid flashblocks client ping ignore probability (must be within [0.0 .. 1.0]: {probability}"
275+ ) ]
276+ #[ cfg( feature = "chaos" ) ]
277+ ChaosProbabilityFlashblocksClientPingIgnoredInvalid { probability : f64 } ,
278+
279+ #[ error(
280+ "invalid flashblocks stream block probability (must be within [0.0 .. 1.0]: {probability}"
281+ ) ]
282+ #[ cfg( feature = "chaos" ) ]
283+ ChaosProbabilityFlashblocksStreamBlockedInvalid { probability : f64 } ,
173284}
0 commit comments