Fix publishBlockV1() and publishBlockV2() SSZ decoding process. (#6408)

This commit is contained in:
Eugene Kabanov 2024-07-04 04:08:07 +03:00 committed by GitHub
parent 0dc2447a58
commit 85c2850971
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 18 additions and 6 deletions

View File

@ -3536,7 +3536,9 @@ proc decodeBody*(
of ConsensusFork.Phase0:
let blck =
try:
SSZ.decode(body.data, phase0.SignedBeaconBlock)
var res = SSZ.decode(body.data, phase0.SignedBeaconBlock)
res.root = hash_tree_root(res.message)
res
except SerializationError as exc:
return err(RestErrorMessage.init(Http400, UnableDecodeError,
[version, exc.formatMsg("<data>")]))
@ -3548,7 +3550,9 @@ proc decodeBody*(
of ConsensusFork.Altair:
let blck =
try:
SSZ.decode(body.data, altair.SignedBeaconBlock)
var res = SSZ.decode(body.data, altair.SignedBeaconBlock)
res.root = hash_tree_root(res.message)
res
except SerializationError as exc:
return err(RestErrorMessage.init(Http400, UnableDecodeError,
[version, exc.formatMsg("<data>")]))
@ -3560,7 +3564,9 @@ proc decodeBody*(
of ConsensusFork.Bellatrix:
let blck =
try:
SSZ.decode(body.data, bellatrix.SignedBeaconBlock)
var res = SSZ.decode(body.data, bellatrix.SignedBeaconBlock)
res.root = hash_tree_root(res.message)
res
except SerializationError as exc:
return err(RestErrorMessage.init(Http400, UnableDecodeError,
[version, exc.formatMsg("<data>")]))
@ -3572,7 +3578,9 @@ proc decodeBody*(
of ConsensusFork.Capella:
let blck =
try:
SSZ.decode(body.data, capella.SignedBeaconBlock)
var res = SSZ.decode(body.data, capella.SignedBeaconBlock)
res.root = hash_tree_root(res.message)
res
except SerializationError as exc:
return err(RestErrorMessage.init(Http400, UnableDecodeError,
[version, exc.formatMsg("<data>")]))
@ -3584,7 +3592,9 @@ proc decodeBody*(
of ConsensusFork.Deneb:
let blckContents =
try:
SSZ.decode(body.data, DenebSignedBlockContents)
var res = SSZ.decode(body.data, DenebSignedBlockContents)
res.signed_block.root = hash_tree_root(res.signed_block.message)
res
except SerializationError as exc:
return err(RestErrorMessage.init(Http400, UnableDecodeError,
[version, exc.formatMsg("<data>")]))
@ -3596,7 +3606,9 @@ proc decodeBody*(
of ConsensusFork.Electra:
let blckContents =
try:
SSZ.decode(body.data, ElectraSignedBlockContents)
var res = SSZ.decode(body.data, ElectraSignedBlockContents)
res.signed_block.root = hash_tree_root(res.signed_block.message)
res
except SerializationError as exc:
return err(RestErrorMessage.init(Http400, UnableDecodeError,
[version, exc.formatMsg("<data>")]))