Fix assertion crash when posting block via REST API.

This commit is contained in:
cheatfate 2021-05-27 14:53:53 +03:00 committed by zah
parent ab70f371e1
commit 90e3fb246f
1 changed files with 6 additions and 1 deletions

View File

@ -614,7 +614,12 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
if dres.isErr(): if dres.isErr():
return RestApiResponse.jsonError(Http400, InvalidBlockObjectError, return RestApiResponse.jsonError(Http400, InvalidBlockObjectError,
$dres.error()) $dres.error())
dres.get() var res = dres.get()
# `SignedBeaconBlock` deserialization do not update `root` field, so we
# need to calculate it.
res.root = hash_tree_root(res.message)
res
let head = node.chainDag.head let head = node.chainDag.head
if not(node.isSynced(head)): if not(node.isSynced(head)):
return RestApiResponse.jsonError(Http503, BeaconNodeInSyncError) return RestApiResponse.jsonError(Http503, BeaconNodeInSyncError)