Skip to content

Commit 5063492

Browse files
authored
Make MEV decoding less strict for Deneb encoded responses. (#7045)
* Disable strict requirement for `eth-consensus-version` header for Deneb fork. * Making it working with weird specification requirements, with `eth-consensus-version` is not required for JSON responses. * Address review comments.
1 parent 531a7c2 commit 5063492

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

beacon_chain/spec/eth2_apis/eth2_rest_serialization.nim

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3285,17 +3285,7 @@ proc decodeBytesJsonOrSsz*(
32853285
version: string
32863286
): Result[T, RestErrorMessage] =
32873287
var res {.noinit.}: T
3288-
3289-
let
3290-
typeFork = kind(typeof(res.data))
3291-
consensusFork = ConsensusFork.decodeString(version).valueOr:
3292-
return err(RestErrorMessage.init(Http400, UnableDecodeVersionError,
3293-
[version, $error]))
3294-
if typeFork != consensusFork:
3295-
return err(
3296-
RestErrorMessage.init(Http400, UnexpectedForkVersionError,
3297-
["eth-consensus-version", consensusFork.toString(),
3298-
typeFork.toString()]))
3288+
const typeFork = kind(typeof(res.data))
32993289

33003290
if contentType == ApplicationJsonMediaType:
33013291
res =
@@ -3321,6 +3311,17 @@ proc decodeBytesJsonOrSsz*(
33213311
typeFork.toString()]))
33223312
ok(res)
33233313
elif contentType == OctetStreamMediaType:
3314+
let consensusFork =
3315+
ConsensusFork.decodeString(version).valueOr:
3316+
return err(RestErrorMessage.init(Http400, UnableDecodeVersionError,
3317+
[version, $error]))
3318+
if typeFork != consensusFork:
3319+
return err(
3320+
RestErrorMessage.init(
3321+
Http400, UnexpectedForkVersionError,
3322+
["eth-consensus-version", consensusFork.toString(),
3323+
typeFork.toString()]))
3324+
33243325
ok(T(
33253326
version: newJString(typeFork.toString()),
33263327
data:

0 commit comments

Comments
 (0)