Fix nrpc edge cases (#2692)

* fix: engineAPI unable to connect

* fix: pre-merge situation
This commit is contained in:
Advaita Saha 2024-10-04 07:07:24 +05:30 committed by GitHub
parent d6eb8c36f5
commit e3b0edd397
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 18 additions and 16 deletions

View File

@ -130,20 +130,18 @@ proc syncToEngineApi(conf: NRpcConf) {.async.} =
# And exchange the capabilities for a test communication
web3 = await engineUrl.newWeb3()
rpcClient = web3.provider
data =
try:
await rpcClient.exchangeCapabilities(
@[
"engine_forkchoiceUpdatedV1",
"engine_getPayloadBodiesByHash", "engine_getPayloadBodiesByRangeV1",
"engine_getPayloadV1", "engine_newPayloadV1",
]
)
except CatchableError as exc:
error "Error Connecting to the EL Engine API", error = exc.msg
@[]
notice "Communication with the EL Success", data = data
try:
let data = await rpcClient.exchangeCapabilities(
@[
"engine_forkchoiceUpdatedV1", "engine_getPayloadBodiesByHash",
"engine_getPayloadBodiesByRangeV1", "engine_getPayloadV1", "engine_newPayloadV1",
]
)
notice "Communication with the EL Success", data = data
except CatchableError as exc:
error "Error Connecting to the EL Engine API", error = exc.msg
quit(QuitFailure)
# Get the latest block number from the EL rest api
template elBlockNumber(): uint64 =
@ -163,6 +161,12 @@ proc syncToEngineApi(conf: NRpcConf) {.async.} =
notice "Current block number", number = currentBlockNumber
# Check for pre-merge situation
if currentBlockNumber <= lastEra1Block:
notice "Pre-merge, nrpc syncer works post-merge",
blocknumber = currentBlockNumber, lastPoWBlock = lastEra1Block
quit(QuitSuccess)
# Load the latest state from the CL
var
(finalizedBlck, _) = client.getELBlockFromBeaconChain(
@ -216,9 +220,7 @@ proc syncToEngineApi(conf: NRpcConf) {.async.} =
)
debug "Making new payload call for Deneb"
payloadResponse = await rpcClient.newPayload(
payload,
versioned_hashes,
forkyBlck.message.parent_root.to(Hash32),
payload, versioned_hashes, forkyBlck.message.parent_root.to(Hash32)
)
notice "Payload status", response = payloadResponse