Commit 5da9093
fix(core): address PR #451 review feedback
Bug fixes (must-fix per review):
- attestation_data: wrap MemDB::await_attestation in tokio::time::timeout
(24s) so a request for a slot that never produces consensus output
cannot hold a handler task indefinitely. delete_duty now records
evicted keys per duty type and notifies waiters, so await_data returns
Error::AwaitDutyExpired immediately when the awaited duty is gone
instead of spinning until the timeout fires. Maps to 408 on the wire.
- Stop leaking upstream BlindedBlock400Response Debug output (incl.
stacktraces) into the client-visible ApiError.message. The variant
payload is now attached as `source` for debug logs; the message stays
generic.
Hardening:
- new_insecure is gated behind #[cfg(test)] so the insecure_test flag
cannot reach production builds.
- new_router applies DefaultBodyLimit::max(64 KiB) on the two
POST /duties/{attester,sync}/{epoch} routes — defends against the
Vec<u64> parse amplification on the ValIndexes deserializer.
- All upstream eth2_cl calls are wrapped in tokio::time::timeout(12s)
so a hanging beacon node cannot stall handler tasks.
- proposer_duties / attester_duties / sync_committee_duties propagate
upstream BadRequest as 400 and ServiceUnavailable as 503 instead of
collapsing every non-Ok variant to 502 — the VC can now back off on
upstream syncing instead of treating it as a gateway failure.
- swap_attester_pubshares / swap_sync_committee_pubshares now return
500 (cluster misconfig) instead of 502 when a pubshare is missing —
the upstream returned well-formed data, the failure is local.
ValIndexes:
- Replace #[serde(untagged)] with a streaming Visitor that validates
each element via SeqAccess::next_element. Avoids the speculative
Vec<u64> parse and the serde Content cache. Now accepts mixed
numeric/string elements and rejects negative integers.
- Hard cap at 8192 indices per request.
ApiError:
- with_boxed_source for sources that aren't std::error::Error (e.g.
anyhow::Error from auto-gen request builders).
Router:
- attestation_data uses Result<Query<...>, QueryRejection> so 4xx
responses from missing/malformed query params share the same
{ code, message } envelope as the rest of the router.
Tests (+13):
- attestation_data: timeout when data never arrives; 408 when duty is
evicted while a waiter is parked; cancellation cleanup when the
handler future is dropped; negative lookup on wrong committee_index.
- Status-mapping helpers: confirm upstream Debug output is never
serialized into the message.
- Router: ApiError envelope on bad query; oversized body rejection;
ValIndexes empty/mixed/oversized/negative cases.
Co-Authored-By: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com>1 parent 26675fe commit 5da9093
8 files changed
Lines changed: 834 additions & 156 deletions
File tree
- crates/core
- src
- dutydb
- validatorapi
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
52 | 58 | | |
53 | 59 | | |
54 | 60 | | |
| |||
177 | 183 | | |
178 | 184 | | |
179 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
180 | 197 | | |
181 | 198 | | |
182 | 199 | | |
| |||
190 | 207 | | |
191 | 208 | | |
192 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
193 | 222 | | |
194 | 223 | | |
195 | 224 | | |
| |||
225 | 254 | | |
226 | 255 | | |
227 | 256 | | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
228 | 261 | | |
229 | 262 | | |
230 | 263 | | |
| |||
272 | 305 | | |
273 | 306 | | |
274 | 307 | | |
275 | | - | |
276 | 308 | | |
277 | 309 | | |
278 | 310 | | |
| |||
282 | 314 | | |
283 | 315 | | |
284 | 316 | | |
285 | | - | |
286 | 317 | | |
287 | 318 | | |
288 | 319 | | |
| |||
292 | 323 | | |
293 | 324 | | |
294 | 325 | | |
295 | | - | |
296 | 326 | | |
297 | 327 | | |
298 | 328 | | |
| |||
302 | 332 | | |
303 | 333 | | |
304 | 334 | | |
305 | | - | |
306 | 335 | | |
307 | 336 | | |
308 | 337 | | |
309 | | - | |
310 | | - | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
311 | 348 | | |
| 349 | + | |
312 | 350 | | |
| 351 | + | |
313 | 352 | | |
314 | 353 | | |
315 | 354 | | |
316 | 355 | | |
317 | 356 | | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
318 | 370 | | |
319 | 371 | | |
320 | 372 | | |
321 | | - | |
322 | | - | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
323 | 383 | | |
324 | 384 | | |
325 | 385 | | |
| |||
333 | 393 | | |
334 | 394 | | |
335 | 395 | | |
336 | | - | |
337 | | - | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
338 | 406 | | |
339 | 407 | | |
340 | 408 | | |
| |||
347 | 415 | | |
348 | 416 | | |
349 | 417 | | |
350 | | - | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
351 | 425 | | |
352 | 426 | | |
353 | 427 | | |
| |||
365 | 439 | | |
366 | 440 | | |
367 | 441 | | |
368 | | - | |
369 | | - | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
370 | 452 | | |
371 | 453 | | |
372 | 454 | | |
373 | 455 | | |
374 | 456 | | |
375 | 457 | | |
376 | 458 | | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
377 | 464 | | |
378 | 465 | | |
379 | 466 | | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
| 467 | + | |
| 468 | + | |
385 | 469 | | |
386 | 470 | | |
387 | 471 | | |
388 | 472 | | |
389 | 473 | | |
390 | 474 | | |
391 | | - | |
392 | | - | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
393 | 479 | | |
394 | 480 | | |
395 | 481 | | |
| |||
577 | 663 | | |
578 | 664 | | |
579 | 665 | | |
| 666 | + | |
580 | 667 | | |
581 | 668 | | |
582 | 669 | | |
| |||
589 | 676 | | |
590 | 677 | | |
591 | 678 | | |
| 679 | + | |
592 | 680 | | |
593 | 681 | | |
594 | 682 | | |
595 | | - | |
596 | | - | |
| 683 | + | |
| 684 | + | |
597 | 685 | | |
| 686 | + | |
598 | 687 | | |
599 | 688 | | |
600 | 689 | | |
601 | 690 | | |
602 | | - | |
603 | | - | |
| 691 | + | |
| 692 | + | |
604 | 693 | | |
| 694 | + | |
605 | 695 | | |
606 | 696 | | |
607 | 697 | | |
| |||
0 commit comments