Commit afc238d
authored
test(slash): attest eagerly when skipping checkpoint validation (#23722)
Slashing e2e tests that relied on `skipCheckpointProposalValidation`
were flakey when a previous block in the checkpoint was invalid. Reason
is that a checkpoint proposal usually carries a last block, which was
validated, but required the previous invalid block to be found. Since it
wasn't, the block proposal validation was timing out at the end of the
slot, then yielding to the checkpoint validation, which immediately
produced the attestation. This attestation only made it because of the
500ms grace period we give to them after the slot end.
This PR changes the flow when `skipCheckpointProposalValidation` is set,
so we attest immediately, and then we try processing the last block.
## Motivation
The `e2e_slashing_attested_invalid_proposal` test flakes: a "lazy"
validator (`skipCheckpointProposalValidation`) is supposed to attest to
a bad checkpoint proposal so an honest node records the offense, but it
sometimes attests ~24s late and peers reject the attestation as stale
(`Checkpoint attestation slot N is not current or next slot`), so the
offense is never recorded and the test times out. The root cause is a
real liveness issue, not just a test artifact: a skip-validation node's
attestation was serialized behind processing the last block embedded in
the checkpoint proposal, and that block's re-execution blocks until the
re-execution deadline (~a full slot) when its parent is unavailable —
which is guaranteed here, since the parent is the deliberately-invalid
block. Whether the resulting late attestation lands inside the slot's
acceptance window then comes down to timing jitter.
## Approach
When a node skips checkpoint proposal validation, its attestation needs
nothing from the embedded block, so create and broadcast it before
processing that block instead of after. Nodes that validate checkpoints
keep the original order (block first), because their checkpoint
validation depends on the last block. The decision is gated on the
`skipCheckpointProposalValidation` flag, mirrored into `P2PConfig` next
to its sibling `skipProposalSlotValidation`; the default is `false`, so
all production nodes are byte-for-byte unchanged.
## Changes
- **p2p (`libp2p_service.ts`)**: In `handleGossipedCheckpointProposal`,
process the checkpoint proposal before the embedded block when
`skipCheckpointProposalValidation` is set; otherwise keep the existing
block-then-checkpoint order. Single shared closure, no duplication.
- **p2p (`config.ts`)**: Mirror `skipCheckpointProposalValidation` into
`P2PConfig` (interface + mapping, no env var, default `false`).
- **validator-client (`proposal_handler.ts`)**: Remove a redundant
second `skipCheckpointProposalValidation` early-return in the all-nodes
checkpoint handler (dead code; the first early-return already covers
it).
- **p2p (tests)**: Add a test that a skip-mode node attests without
waiting for stalled block processing, and a complementary test that the
default node still processes the block first.1 parent 34134bb commit afc238d
4 files changed
Lines changed: 123 additions & 14 deletions
File tree
- yarn-project
- p2p/src
- services/libp2p
- validator-client/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
249 | 256 | | |
250 | 257 | | |
251 | 258 | | |
| |||
580 | 587 | | |
581 | 588 | | |
582 | 589 | | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
583 | 595 | | |
584 | 596 | | |
585 | 597 | | |
| |||
Lines changed: 89 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
955 | 955 | | |
956 | 956 | | |
957 | 957 | | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
958 | 1045 | | |
959 | 1046 | | |
960 | 1047 | | |
| |||
1525 | 1612 | | |
1526 | 1613 | | |
1527 | 1614 | | |
| 1615 | + | |
1528 | 1616 | | |
1529 | 1617 | | |
1530 | 1618 | | |
| |||
1539 | 1627 | | |
1540 | 1628 | | |
1541 | 1629 | | |
| 1630 | + | |
1542 | 1631 | | |
1543 | 1632 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1342 | 1342 | | |
1343 | 1343 | | |
1344 | 1344 | | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
1345 | 1351 | | |
1346 | 1352 | | |
1347 | | - | |
1348 | | - | |
1349 | | - | |
1350 | | - | |
1351 | | - | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
1352 | 1366 | | |
1353 | 1367 | | |
1354 | 1368 | | |
1355 | | - | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
1356 | 1372 | | |
1357 | 1373 | | |
1358 | 1374 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | 314 | | |
323 | 315 | | |
324 | 316 | | |
| |||
0 commit comments