Commit 9de8203
authored
hotfix: get_first_subscribed_slot and add logs (#538)
<!-- greptile_comment -->
## Greptile Summary
Updated On: 2025-09-11 11:55:03 UTC
This PR fixes a critical bug in the account cloning system's slot
validation logic and adds enhanced error logging. The primary change
modifies the fallback value in `get_first_subscribed_slot()` from
`u64::MAX` to `u64::MIN` in the `RemoteAccountClonerWorker`.
The core issue was in the slot comparison logic where account snapshots
were being validated against subscription slots. When
`get_first_subscribed_slot(pubkey)` returned `None`, the previous code
would fall back to `u64::MAX`, making the condition
`account_chain_snapshot.at_slot >= u64::MAX` virtually impossible to
satisfy since no reasonable slot number would ever reach the maximum u64
value. This caused legitimate account snapshots to be rejected, leading
to excessive retries and eventual failures in the account cloning
process.
By changing the fallback to `u64::MIN` (0), the validation becomes much
more permissive - any account snapshot with a reasonable slot number
will pass the comparison. This aligns with the expected behavior when
there's no specific subscription slot requirement.
The PR also adds comprehensive error logging that captures key debugging
information including the account pubkey, number of fetch attempts,
current snapshot slot, and the first subscribed slot value. This
enhanced logging will help diagnose future issues in the account cloning
pipeline.
This change integrates with the broader account management system where
`RemoteAccountClonerWorker` collaborates with account update services to
ensure account data consistency across different validator instances.
## Confidence score: 4/5
- This PR addresses a clear logical bug with a straightforward fix that
makes the slot validation behavior more sensible
- Score reflects the focused nature of the change and clear improvement
in the logic, though the lack of tests and potential edge cases prevent
a perfect score
- Pay close attention to the slot comparison logic to ensure the new
permissive behavior doesn't introduce unintended side effects
<!-- /greptile_comment -->1 parent 141d6a5 commit 9de8203
File tree
2 files changed
+12
-1
lines changed- magicblock-account-cloner
- src
- tests
2 files changed
+12
-1
lines changedLines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
523 | 523 | | |
524 | 524 | | |
525 | 525 | | |
526 | | - | |
| 526 | + | |
527 | 527 | | |
528 | 528 | | |
529 | 529 | | |
530 | 530 | | |
531 | 531 | | |
532 | 532 | | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
533 | 538 | | |
534 | 539 | | |
535 | 540 | | |
536 | 541 | | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
537 | 547 | | |
538 | 548 | | |
539 | 549 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
| 275 | + | |
275 | 276 | | |
276 | 277 | | |
277 | 278 | | |
| |||
0 commit comments