Fix /api/eth/v1/validator/aggregate_and_proofs call
This commit is contained in:
parent
6869a1ad33
commit
be5661eebc
|
@ -288,26 +288,28 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||||
# https://ethereum.github.io/eth2.0-APIs/#/Validator/publishAggregateAndProofs
|
# https://ethereum.github.io/eth2.0-APIs/#/Validator/publishAggregateAndProofs
|
||||||
router.api(MethodPost, "/api/eth/v1/validator/aggregate_and_proofs") do (
|
router.api(MethodPost, "/api/eth/v1/validator/aggregate_and_proofs") do (
|
||||||
contentBody: Option[ContentBody]) -> RestApiResponse:
|
contentBody: Option[ContentBody]) -> RestApiResponse:
|
||||||
let payload =
|
let proofs =
|
||||||
block:
|
block:
|
||||||
if contentBody.isNone():
|
if contentBody.isNone():
|
||||||
return RestApiResponse.jsonError(Http400, EmptyRequestBodyError)
|
return RestApiResponse.jsonError(Http400, EmptyRequestBodyError)
|
||||||
let dres = decodeBody(SignedAggregateAndProof, contentBody.get())
|
let dres = decodeBody(seq[SignedAggregateAndProof], contentBody.get())
|
||||||
if dres.isErr():
|
if dres.isErr():
|
||||||
return RestApiResponse.jsonError(Http400,
|
return RestApiResponse.jsonError(Http400,
|
||||||
InvalidAggregateAndProofObjectError,
|
InvalidAggregateAndProofObjectError,
|
||||||
$dres.error())
|
$dres.error())
|
||||||
dres.get()
|
dres.get()
|
||||||
|
|
||||||
let wallTime = node.processor.getWallTime()
|
for item in proofs:
|
||||||
let res = await node.attestationPool.validateAggregate(
|
let wallTime = node.processor.getWallTime()
|
||||||
node.processor.batchCrypto, payload, wallTime
|
let res = await node.attestationPool.validateAggregate(
|
||||||
)
|
node.processor.batchCrypto, item, wallTime
|
||||||
if res.isErr():
|
)
|
||||||
return RestApiResponse.jsonError(Http400,
|
if res.isErr():
|
||||||
AggregateAndProofValidationError,
|
return RestApiResponse.jsonError(Http400,
|
||||||
$res.error())
|
AggregateAndProofValidationError,
|
||||||
node.network.broadcast(node.topicAggregateAndProofs, payload)
|
$res.error())
|
||||||
|
node.network.broadcast(node.topicAggregateAndProofs, item)
|
||||||
|
|
||||||
return RestApiResponse.jsonError(Http200,
|
return RestApiResponse.jsonError(Http200,
|
||||||
AggregateAndProofValidationSuccess)
|
AggregateAndProofValidationSuccess)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue