Commit f91f0c9
authored
Fix Blockfrost Chain Synchronization from Genesis and Optimize API Calls (#2300)
Problem:
- When starting from ChainPointAtGenesis, the node would fail to
properly initialize and synchronize with the chain. Additionally, the
continuous polling approach was making excessive API calls to
Blockfrost.
Solution:
- Improved Genesis Handling: Added proper error handling for genesis
block retrieval. When block 0 (genesis) is not available via Blockfrost
API, the system now gracefully falls back to block 1. (Block 0 is not
available in pre-prod)
<img width="1084" height="460" alt="image"
src="https://github.com/user-attachments/assets/d665a24f-c7b4-4eb3-ab3e-61f11326cb6e"
/>
- Two-Phase Synchronization:
- Phase 1 - Catch-up: New catchUpToLatest function rapidly syncs from
the starting point to the latest block without delays
- Phase 2 - Polling: New pollForNewBlocks function polls for new blocks
at intervals based on the actual blockchain's blockTime parameter
- Optimized API Usage: Replaced the tight loop with threadDelay 1 with
intelligent polling that respects the blockchain's slot timing,
significantly reducing unnecessary API calls to Blockfrost
- Better Error Handling: Added specific handling for
MissingNextBlockHash exceptions during polling (expected when waiting
for new blocks)
---
<!-- Consider each and tick it off one way or the other -->
* [X] CHANGELOG updated or not needed
* [X] Documentation updated or not needed
* [X] Haddocks updated or not needed
* [X] No new TODOs introduced or explained herafterFile tree
2 files changed
+54
-18
lines changed- .github/workflows
- hydra-node/src/Hydra/Chain
2 files changed
+54
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
205 | 206 | | |
206 | 207 | | |
207 | 208 | | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
| 209 | + | |
| 210 | + | |
212 | 211 | | |
213 | 212 | | |
214 | 213 | | |
215 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
216 | 226 | | |
217 | 227 | | |
218 | 228 | | |
| 229 | + | |
| 230 | + | |
219 | 231 | | |
220 | 232 | | |
221 | | - | |
| 233 | + | |
222 | 234 | | |
223 | 235 | | |
224 | 236 | | |
| |||
230 | 242 | | |
231 | 243 | | |
232 | 244 | | |
233 | | - | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
234 | 266 | | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
239 | 279 | | |
240 | 280 | | |
241 | 281 | | |
| |||
348 | 388 | | |
349 | 389 | | |
350 | 390 | | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
| |||
0 commit comments