Commit 6533dba
Anchor expansion on the case, and measure what log scanning actually costs
Expanding a counterparty has a cheaper question available than "everything
this address ever did", and the case already contains it: when a seed's
transfers span 113.61M to 113.92M, its counterparties are interesting around
*that*. `_known_range` reads the oldest block the case knows and starts there,
less a margin --- the margin because what a counterparty did *before* the
money arrived is frequently the point, and the LpdFi attacker's funding sat
two thousand blocks ahead of the exploit.
`_fetch_into` and `_fetch_page` take `start_block`; `expand` passes it.
**And the measurement that says this is not enough.** The endpoint costs about
a millisecond per block scanned, flat, whatever the chunk width --- 500 blocks
in 1.0s, 5,000 in 5.2s, 20,000 in 20.7s. Widening buys fewer requests and no
time at all, so the only lever is scanning fewer blocks, and anchoring saved
10%: the case's oldest block already sat near the window start.
seed, 400,000 blocks, two directions 828s of server time, 207s at 4 concurrent
anchored expansion, 358,466 blocks 742s, 186s
three addresses 9.3 minutes
That is the honest cost of reconstructing transfers from `eth_getLogs` on a
free public node, and it is not a bug to be tuned away. A log scan is the
fallback that makes an unindexed chain readable at all; it is not a substitute
for an indexer, and multi-address expansion is where the difference stops
being academic. Recorded here so the next person does not spend an afternoon
rediscovering it.
`_known_range` degrades to None on a store that cannot answer, because it is
an optimisation and must not break a fetch for the sake of making it cheaper.
Two test doubles caught that and the argument being threaded through.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FXWQ25VgFeMuuMhGWjvdof1 parent 2a3fec8 commit 6533dba
2 files changed
Lines changed: 77 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
499 | 499 | | |
500 | 500 | | |
501 | 501 | | |
502 | | - | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
503 | 508 | | |
504 | 509 | | |
505 | 510 | | |
| |||
1202 | 1207 | | |
1203 | 1208 | | |
1204 | 1209 | | |
1205 | | - | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
1206 | 1216 | | |
1207 | 1217 | | |
1208 | 1218 | | |
| |||
1248 | 1258 | | |
1249 | 1259 | | |
1250 | 1260 | | |
1251 | | - | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
1252 | 1269 | | |
1253 | 1270 | | |
1254 | 1271 | | |
| |||
1281 | 1298 | | |
1282 | 1299 | | |
1283 | 1300 | | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
1284 | 1342 | | |
1285 | | - | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
1286 | 1350 | | |
1287 | 1351 | | |
1288 | 1352 | | |
| |||
1341 | 1405 | | |
1342 | 1406 | | |
1343 | 1407 | | |
1344 | | - | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
1345 | 1411 | | |
1346 | 1412 | | |
1347 | 1413 | | |
| |||
1368 | 1434 | | |
1369 | 1435 | | |
1370 | 1436 | | |
1371 | | - | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
1372 | 1441 | | |
1373 | 1442 | | |
1374 | 1443 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
| 118 | + | |
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| |||
0 commit comments