Skip to content

Commit 9dbbabc

Browse files
committed
formatting fix
1 parent 654817b commit 9dbbabc

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

nrpc/nrpc.nim

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Nimbus
2-
# Copyright (c) 2024 Status Research & Development GmbH
2+
# Copyright (c) 2024-2025 Status Research & Development GmbH
33
# Licensed under either of
44
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
55
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
@@ -199,11 +199,11 @@ proc syncToEngineApi(conf: NRpcConf) {.async.} =
199199
elif consensusFork == ConsensusFork.Capella:
200200
Opt.none(PayloadAttributesV2)
201201
elif consensusFork == ConsensusFork.Deneb or
202-
consensusFork == ConsensusFork.Electra or
203-
consensusFork == ConsensusFork.Fulu:
202+
consensusFork == ConsensusFork.Electra or consensusFork == ConsensusFork.Fulu:
204203
Opt.none(PayloadAttributesV3)
205204
else:
206-
static: doAssert(false, "Unsupported consensus fork")
205+
static:
206+
doAssert(false, "Unsupported consensus fork")
207207
Opt.none(PayloadAttributesV3)
208208

209209
# Make the forkchoiceUpdated call based, after loading attributes based on the consensus fork
@@ -249,18 +249,19 @@ proc syncToEngineApi(conf: NRpcConf) {.async.} =
249249
payload = payload,
250250
versionedHashes = versioned_hashes
251251
elif consensusFork == ConsensusFork.Electra or
252-
consensusFork == ConsensusFork.Fulu:
252+
consensusFork == ConsensusFork.Fulu:
253253
# Calculate the versioned hashes from the kzg commitments
254254
let versioned_hashes = mapIt(
255255
forkyBlck.message.body.blob_kzg_commitments,
256256
engine_api.VersionedHash(kzg_commitment_to_versioned_hash(it)),
257257
)
258258
# Execution Requests for Electra
259-
let execution_requests = @[
260-
SSZ.encode(forkyBlck.message.body.execution_requests.deposits),
261-
SSZ.encode(forkyBlck.message.body.execution_requests.withdrawals),
262-
SSZ.encode(forkyBlck.message.body.execution_requests.consolidations),
263-
]
259+
let execution_requests =
260+
@[
261+
SSZ.encode(forkyBlck.message.body.execution_requests.deposits),
262+
SSZ.encode(forkyBlck.message.body.execution_requests.withdrawals),
263+
SSZ.encode(forkyBlck.message.body.execution_requests.consolidations),
264+
]
264265
# TODO: Update to `newPayload()` once nim-web3 is updated
265266
payloadResponse = await rpcClient.engine_newPayloadV4(
266267
payload,
@@ -274,15 +275,15 @@ proc syncToEngineApi(conf: NRpcConf) {.async.} =
274275
versionedHashes = versioned_hashes,
275276
executionRequests = execution_requests
276277
else:
277-
static: doAssert(false, "Unsupported consensus fork")
278+
static:
279+
doAssert(false, "Unsupported consensus fork")
278280

279281
info "newPayload Request sent",
280282
blockNumber = int(payload.blockNumber), response = payloadResponse.status
281283

282284
if payloadResponse.status != PayloadExecutionStatus.accepted:
283-
error "Payload not accepted",
284-
blockNumber = int(payload.blockNumber),
285-
status = payloadResponse.status
285+
error "Payload not accepted",
286+
blockNumber = int(payload.blockNumber), status = payloadResponse.status
286287
quit(QuitFailure)
287288

288289
# Load the head hash from the execution payload, for forkchoice
@@ -315,22 +316,21 @@ proc syncToEngineApi(conf: NRpcConf) {.async.} =
315316

316317
# Check for reorg
317318
# No need to check for reorg if the EL head is behind the finalized block
318-
if currentBlockNumber > finalizedBlck.header.number and oldHeadBlockNumber > headBlck.header.number:
319-
warn "Head moved backwards : Possible reorg detected",
320-
oldHead = oldHeadBlockNumber,
321-
newHead = headBlck.header.number
322-
323-
let (headClBlck, isAvailable) = client.getCLBlockFromBeaconChain(
324-
BlockIdent.init(BlockIdentType.Head), clConfig
325-
)
319+
if currentBlockNumber > finalizedBlck.header.number and
320+
oldHeadBlockNumber > headBlck.header.number:
321+
warn "Head moved backwards : Possible reorg detected",
322+
oldHead = oldHeadBlockNumber, newHead = headBlck.header.number
323+
324+
let (headClBlck, isAvailable) =
325+
client.getCLBlockFromBeaconChain(BlockIdent.init(BlockIdentType.Head), clConfig)
326326

327327
# move back the importedSlot to the finalized block
328328
if isAvailable:
329329
withBlck(headClBlck.asTrusted()):
330330
when consensusFork >= ConsensusFork.Bellatrix:
331331
importedSlot = forkyBlck.message.slot.uint64 + 1
332332
currentBlockNumber = forkyBlck.message.body.execution_payload.block_number
333-
333+
334334
# Load this head to the `headBlck`
335335
if not getEthBlock(forkyBlck.message, headBlck):
336336
error "Failed to get EL block from CL head"
@@ -345,7 +345,6 @@ proc syncToEngineApi(conf: NRpcConf) {.async.} =
345345
error "Failed to get CL head"
346346
quit(QuitFailure)
347347

348-
349348
# fcU call for the last remaining payloads
350349
sendFCU(curBlck)
351350

0 commit comments

Comments
 (0)