fix(rpc): report correct sync status in pruned mode - #3864
Conversation
|
Claude finished @cicr99's task in 4m 50s —— View job Review:
|
| func (s *Sequencer) StartingBlockHeader() (*core.Header, error) { | ||
| return nil, nil // Not relevant for Sequencer. Todo: clean Reader | ||
| } |
There was a problem hiding this comment.
(nil, nil) is a nil-deref landmine. The sequencer is wired in as the RPC syncReader (rpc.New(chain, &seq, ...) in node/node.go:339), and Handler.Syncing() now does startingBlockHeader.Hash / &startingBlockHeader.Number with no nil check after a nil error.
Today this happens to be safe only because Sequencer.HighestBlockHeader() returns nil and the handler bails out at the highestBlockHeader == nil check before the deref. That's an accidental ordering dependency: reorder the checks in Syncing(), or ever make HighestBlockHeader() return non-nil for the sequencer, and starknet_syncing panics.
Mirror what NoopSynchronizer does and return an error instead:
| func (s *Sequencer) StartingBlockHeader() (*core.Header, error) { | |
| return nil, nil // Not relevant for Sequencer. Todo: clean Reader | |
| } | |
| func (s *Sequencer) StartingBlockHeader() (*core.Header, error) { | |
| // Not relevant for Sequencer. Todo: clean Reader | |
| return nil, errors.New("StartingBlockHeader() not implemented") | |
| } |
Same applies to the three fakeSyncer.StartingBlockHeader() implementations added in rpc/v{8,9,10}/subscriptions_test.go. Independently, I'd add a defensive if err != nil || startingBlockHeader == nil guard in each Syncing() handler so a misbehaving Reader can't panic an RPC handler.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3864 +/- ##
==========================================
- Coverage 75.43% 75.31% -0.12%
==========================================
Files 442 442
Lines 39862 39920 +58
==========================================
- Hits 30068 30065 -3
- Misses 7713 7760 +47
- Partials 2081 2095 +14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
a7e941f to
b426e1f
Compare
|
Claude finished @cicr99's task in 6m 35s —— View job Review:
|
|
Claude finished @cicr99's task in 5m 51s —— View job Review:
|
|
Claude finished @cicr99's task in 5m 16s —— View job Review:
|
Fixes #3791
starknet_syncingpreviously read the starting block hash from blockchain storage using the sync start block number. In pruned mode, that starting block header may have already been removed, causing the RPC method to returnfalseeven while the node is still syncing.This PR stores the starting block header in the synchronizer once the starting block is successfully stored, and updates RPC v8/v9/v10 to read the starting block metadata from the synchronizer instead of prunable chain history.
Changes
StartingBlockHeader()to the sync reader interface.Synchronizerwhen the sync start block is stored.starknet_syncingin RPC v8/v9/v10 to use the synchronizer’s cached start header.