Commit eef02af
authored
Fix data availability checker race condition causing partial data columns to be served over RPC (#7961)
Partially resolves #6439, an simpler alternative to #7931.
Race condition occurs when RPC data columns arrives after a block has been imported and removed from the DA checker:
1. Block becomes available via gossip
2. RPC columns arrive and pass fork choice check (block hasn't been imported)
3. Block import completes (removing block from DA checker)
4. RPC data columns finish verification and get imported into DA checker
This causes two issues:
1. **Partial data serving**: Already imported components get re-inserted, potentially causing LH to serve incomplete data
2. **State cache misses**: Leads to state reconstruction, holding the availability cache write lock longer and increasing race likelihood
### Proposed Changes
1. Never manually remove pending components from DA checker. Components are only removed via LRU eviction as finality advances. This makes sure we don't run into the issue described above.
2. Use `get` instead of `pop` when recovering the executed block, this prevents cache misses in race condition. This should reduce the likelihood of the race condition
3. Refactor DA checker to drop write lock as soon as components are added. This should also reduce the likelihood of the race condition
**Trade-offs:**
This solution eliminates a few nasty race conditions while allowing simplicity, with the cost of allowing block re-import (already existing).
The increase in memory in DA checker can be partially offset by a reduction in block cache size if this really comes an issue (as we now serve recent blocks from DA checker).1 parent 979ed25 commit eef02af
File tree
4 files changed
+132
-176
lines changed- beacon_node/beacon_chain/src
- data_availability_checker
4 files changed
+132
-176
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3815 | 3815 | | |
3816 | 3816 | | |
3817 | 3817 | | |
3818 | | - | |
3819 | | - | |
3820 | | - | |
3821 | | - | |
3822 | | - | |
3823 | | - | |
3824 | | - | |
3825 | | - | |
3826 | | - | |
3827 | | - | |
3828 | | - | |
3829 | | - | |
3830 | | - | |
3831 | 3818 | | |
3832 | 3819 | | |
3833 | 3820 | | |
| |||
Lines changed: 8 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
48 | | - | |
| 47 | + | |
| 48 | + | |
49 | 49 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
54 | 53 | | |
55 | 54 | | |
56 | 55 | | |
| |||
346 | 345 | | |
347 | 346 | | |
348 | 347 | | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | 348 | | |
355 | 349 | | |
356 | 350 | | |
| |||
589 | 583 | | |
590 | 584 | | |
591 | 585 | | |
592 | | - | |
593 | | - | |
| 586 | + | |
| 587 | + | |
594 | 588 | | |
595 | 589 | | |
596 | 590 | | |
| |||
0 commit comments