@@ -130,9 +130,9 @@ impl SubmitTask {
130
130
retry_limit : usize ,
131
131
) -> eyre:: Result < ControlFlow > {
132
132
let submitting_start_time = Instant :: now ( ) ;
133
-
134
- let ( current_slot , start, end) = self . calculate_slot_window ( ) ;
135
- debug ! ( current_slot , start, end, "calculating target slot window" ) ;
133
+ let now = utils :: now ( ) ;
134
+ let ( initial_slot , start, end) = self . calculate_slot_window ( ) ;
135
+ debug ! ( initial_slot , start, end, now , "calculating target slot window" ) ;
136
136
137
137
let mut req = bumpable. req ( ) . clone ( ) ;
138
138
@@ -147,6 +147,9 @@ impl SubmitTask {
147
147
let inbound_result = match self . send_transaction ( req) . instrument ( span. clone ( ) ) . await {
148
148
Ok ( control_flow) => control_flow,
149
149
Err ( error) => {
150
+ if let Some ( value) = self . slot_still_valid ( initial_slot) {
151
+ return value;
152
+ }
150
153
// Log error and retry
151
154
error ! ( %error, "error handling inbound block" ) ;
152
155
ControlFlow :: Retry
@@ -157,6 +160,9 @@ impl SubmitTask {
157
160
158
161
match inbound_result {
159
162
ControlFlow :: Retry => {
163
+ if let Some ( value) = self . slot_still_valid ( initial_slot) {
164
+ return value;
165
+ }
160
166
// bump the req
161
167
req = bumpable. bumped ( ) ;
162
168
if bumpable. bump_count ( ) > retry_limit {
@@ -192,6 +198,19 @@ impl SubmitTask {
192
198
Ok ( result)
193
199
}
194
200
201
+ /// Checks if a slot is still valid during submission retries.
202
+ fn slot_still_valid ( & self , initial_slot : u64 ) -> Option < Result < ControlFlow , eyre:: Error > > {
203
+ let ( current_slot, _, _) = self . calculate_slot_window ( ) ;
204
+ if current_slot != initial_slot {
205
+ // If the slot has changed, skip the block
206
+ debug ! ( current_slot, initial_slot, "slot changed before submission - skipping block" ) ;
207
+ counter ! ( "builder.slot_missed" ) . increment ( 1 ) ;
208
+ return Some ( Ok ( ControlFlow :: Skip ) ) ;
209
+ }
210
+ debug ! ( current_slot, "slot still valid - continuing submission" ) ;
211
+ None
212
+ }
213
+
195
214
/// Calculates and returns the slot number and its start and end timestamps for the current instant.
196
215
fn calculate_slot_window ( & self ) -> ( u64 , u64 , u64 ) {
197
216
let now_ts = utils:: now ( ) ;
@@ -243,6 +262,12 @@ impl SubmitTask {
243
262
{
244
263
Ok ( bumpable) => bumpable,
245
264
Err ( error) => {
265
+ if error. to_string ( ) . contains ( "403 Forbidden" ) {
266
+ // Don't error as this is expected behavior
267
+ warn ! ( %error, "403 Forbidden detected - skipping block" ) ;
268
+ continue
269
+ }
270
+
246
271
error ! ( %error, "failed to prepare transaction for submission" ) ;
247
272
continue ;
248
273
}
0 commit comments