Commit f02c274
authored
snapcfg, downloader: lazy-parse registry, per-chain remote loading (#19641)
## Summary
First PR in a series to remove the need to read all chains' TOML files
at startup. Erigon only uses one chain per execution, but the current
code parses all 8 chains' snapshot hashes eagerly at init and fetches
all 8 from GitHub/R2 when loading remote preverified hashes.
This PR does not remove the registry, but makes it effectively a
registry of 1 element by:
- **Lazy-parsing the preverified registry**: store raw embedded TOML
bytes and parse on demand instead of parsing all chains at init time
- **Adding `LoadRemotePreverifiedForChain`**: fetch snapshot hashes for
a single chain from GitHub/R2 instead of all chains; use it in
`downloadercfg.LoadSnapshotsHashes`
- **Deduplicating `cdnHeaders`**: move the canonical definition +
`InsertCloudflareHeaders` to `db/snapcfg/cdn.go`; remove copies from
`db/downloader`
- **Pulling `fetchChainToml` from erigon-snapshot into this repo**
(`db/snapcfg/util.go`) with TODOs marking the copies to remove upstream
- **Extracting URL builders**: `ChainTomlR2URL` and `ChainTomlGitHubURL`
in `db/snapcfg/cdn.go` with unit tests
### Measured improvement (chiado, cold start)
| | main | this branch |
|---|---|---|
| Snapshot hash loading | ~2533ms | ~587ms |
| **Speedup** | — | **~4.3x faster** |
## Test plan
- [x] `make lint` clean
- [x] `make erigon integration` builds
- [x] Ephemeral node with `--chain=chiado` starts and loads snapshot
hashes correctly
- [x] `go test ./db/snapcfg/...` passes with new URL builder tests1 parent d73979a commit f02c274
6 files changed
Lines changed: 228 additions & 69 deletions
File tree
- db
- downloader
- downloadercfg
- snapcfg
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
| |||
64 | 63 | | |
65 | 64 | | |
66 | 65 | | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | 154 | | |
164 | 155 | | |
165 | 156 | | |
| |||
168 | 159 | | |
169 | 160 | | |
170 | 161 | | |
171 | | - | |
| 162 | + | |
172 | 163 | | |
173 | 164 | | |
174 | 165 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
331 | | - | |
| 331 | + | |
332 | 332 | | |
333 | 333 | | |
334 | 334 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
227 | 228 | | |
228 | 229 | | |
229 | 230 | | |
230 | | - | |
| 231 | + | |
231 | 232 | | |
232 | 233 | | |
233 | 234 | | |
| |||
240 | 241 | | |
241 | 242 | | |
242 | 243 | | |
243 | | - | |
| 244 | + | |
244 | 245 | | |
245 | 246 | | |
246 | 247 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
0 commit comments