File tree Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -157,9 +157,41 @@ type
157
157
158
158
ValidationRes* = Result[void , ValidationError]
159
159
160
+
160
161
func toValidationResult* (res: ValidationRes): ValidationResult =
161
162
if res.isOk(): ValidationResult.Accept else : res.error()[0 ]
162
163
164
+ proc toValidationRace* (
165
+ f1, f2: Future[ValidationRes]
166
+ ) : Future[ValidationResult] {.async: (raises: [CancelledError]) .} =
167
+ let
168
+ f1b = noCancel(f1)
169
+ f2b = noCancel(f2)
170
+
171
+ var raced: FutureBase
172
+ try :
173
+ raced = await race([f1b, f2b])
174
+ except ValueError:
175
+ # This shouldn't normally happen with 2 futures
176
+ return ValidationResult.Ignore
177
+
178
+ let
179
+ first = if raced == f1b: f1 else : f2
180
+ second = if raced == f1b: f2 else : f1
181
+
182
+ try :
183
+ let res1 = await first
184
+ if res1.isOk():
185
+ return ValidationResult.Accept
186
+ except CatchableError:
187
+ discard
188
+
189
+ try :
190
+ let res2 = await second
191
+ return toValidationResult(res2)
192
+ except CatchableError:
193
+ return ValidationResult.Ignore
194
+
163
195
# Initialization
164
196
# ------------------------------------------------------------------------------
165
197
Original file line number Diff line number Diff line change @@ -2115,8 +2115,15 @@ proc installMessageValidators(node: BeaconNode) =
2115
2115
getBlobSidecarTopic(digest, subnet_id), proc (
2116
2116
blobSidecar: deneb.BlobSidecar
2117
2117
): Future[ValidationResult] {.async: (raises: [CancelledError]) .} =
2118
- return toValidationResult(
2119
- await node.processor.processBlobSidecarFromEL(blobSidecar)))
2118
+ let
2119
+ fut1 =
2120
+ (node.processor.processBlobSidecarFromEL(blobSidecar))
2121
+ fut2 =
2122
+ (node.processor.processBlobSidecar(MsgSource.gossip,
2123
+ blobSidecar,
2124
+ subnet_id))
2125
+
2126
+ return waitFor toValidationRace(fut1, fut2))
2120
2127
2121
2128
when consensusFork >= ConsensusFork.Deneb:
2122
2129
# blob_sidecar_{subnet_id}
You can’t perform that action at this time.
0 commit comments