21
21
../ eth_data_exporter/ cl_data_exporter,
22
22
./ [portal_bridge_conf, portal_bridge_common]
23
23
24
- const
25
- largeRequestsTimeout = 120 .seconds # For downloading large items such as states.
26
- restRequestsTimeout = 30 .seconds
24
+ const restRequestsTimeout = 30 .seconds
27
25
28
26
# TODO : From nimbus_binary_common, but we don't want to import that.
29
27
proc sleepAsync(t: TimeDiff): Future[void ] =
@@ -236,32 +234,36 @@ proc gossipHistoricalSummaries(
236
234
portalRpcClient: RpcClient,
237
235
cfg: RuntimeConfig,
238
236
forkDigests: ref ForkDigests,
239
- ): Future[Result[void , string ]] {.async.} =
240
- let state =
237
+ ): Future[Result[void , string ]] {.async: (raises: [CancelledError] ) .} =
238
+ let summariesOpt =
241
239
try :
242
- notice " Downloading beacon state "
240
+ notice " Downloading beacon historical_summaries "
243
241
awaitWithTimeout(
244
- restClient.getStateV2(StateIdent.init(StateIdentType.Finalized), cfg),
245
- largeRequestsTimeout,
242
+ restClient.getHistoricalSummariesV1(
243
+ StateIdent.init(StateIdentType.Finalized), cfg
244
+ ),
245
+ restRequestsTimeout,
246
246
):
247
- return err(" Attempt to download beacon state timed out" )
248
- except CatchableError as exc:
249
- return err(" Unable to download beacon state: " & exc.msg)
250
-
251
- if state == nil :
252
- return err(" No beacon state found" )
253
-
254
- withState(state[]):
255
- when consensusFork >= ConsensusFork.Capella:
247
+ return err(" Attempt to download historical_summaries timed out" )
248
+ except RestError as exc:
249
+ return err(" Unable to download historical_summaries: " & exc.msg)
250
+
251
+ if summariesOpt.isNone():
252
+ return err(" No historical_summaries found" )
253
+
254
+ let summariesForked = summariesOpt.get()
255
+ withForkyHistoricalSummariesWithProof(summariesForked):
256
+ when consensusFork >= ConsensusFork.Electra:
257
+ err(" Historical summaries not yet supported for Electra and later forks" )
258
+ elif consensusFork >= ConsensusFork.Capella:
256
259
let
257
- historical_summaries = forkyState.data.historical_summaries
258
- proof = ? buildProof(state[])
259
- epoch = forkyState.data.slot.epoch()
260
+ epoch = forkySummaries.slot.epoch()
260
261
forkDigest = forkDigestAtEpoch(forkDigests[], epoch, cfg)
261
262
summariesWithProof = HistoricalSummariesWithProof(
262
- epoch: epoch, historical_summaries: historical_summaries, proof: proof
263
+ epoch: epoch,
264
+ historical_summaries: forkySummaries.historical_summaries,
265
+ proof: forkySummaries.proof,
263
266
)
264
-
265
267
contentKey = encode(historicalSummariesContentKey(epoch.uint64 ))
266
268
content = encodeSsz(summariesWithProof, forkDigest)
267
269
@@ -271,11 +273,11 @@ proc gossipHistoricalSummaries(
271
273
)
272
274
info " Beacon historical_summaries gossiped" , peers, epoch
273
275
274
- return ok()
276
+ ok()
275
277
except CatchableError as e:
276
- return err(" JSON-RPC error: " & $ e.msg)
278
+ err(" JSON-RPC error: " & $ e.msg)
277
279
else :
278
- return err(" No historical_summaries pre Capella" )
280
+ err(" No historical summaries pre- Capella" )
279
281
280
282
proc runBeacon* (config: PortalBridgeConf) {.raises: [CatchableError].} =
281
283
notice " Launching Fluffy beacon chain bridge" , cmdParams = commandLineParams()
0 commit comments