2023-08-27 01:23:45 +00:00
|
|
|
# Nimbus
|
|
|
|
# Copyright (c) 2023 Status Research & Development GmbH
|
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
|
|
|
|
# at your option.
|
|
|
|
# This file may not be copied, modified, or distributed except according to
|
|
|
|
# those terms.
|
|
|
|
|
|
|
|
import
|
|
|
|
std/[options, typetraits],
|
|
|
|
eth/common,
|
|
|
|
./web3_eth_conv,
|
|
|
|
./beacon_engine,
|
2023-12-08 09:35:50 +00:00
|
|
|
web3/execution_types,
|
2023-08-27 01:23:45 +00:00
|
|
|
./api_handler/api_utils,
|
|
|
|
./api_handler/api_getpayload,
|
|
|
|
./api_handler/api_getbodies,
|
|
|
|
./api_handler/api_exchangeconf,
|
|
|
|
./api_handler/api_newpayload,
|
|
|
|
./api_handler/api_forkchoice
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Public functions
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
{.push gcsafe, raises:[CatchableError].}
|
|
|
|
|
|
|
|
func validateVersionedHashed*(payload: ExecutionPayload,
|
|
|
|
expected: openArray[Web3Hash]): bool =
|
|
|
|
var versionedHashes: seq[common.Hash256]
|
|
|
|
for x in payload.transactions:
|
|
|
|
let tx = rlp.decode(distinctBase(x), Transaction)
|
|
|
|
versionedHashes.add tx.versionedHashes
|
2023-10-20 14:02:22 +00:00
|
|
|
|
|
|
|
if versionedHashes.len != expected.len:
|
|
|
|
return false
|
|
|
|
|
2023-08-27 01:23:45 +00:00
|
|
|
for i, x in expected:
|
|
|
|
if distinctBase(x) != versionedHashes[i].data:
|
|
|
|
return false
|
|
|
|
true
|
|
|
|
|
|
|
|
{.pop.}
|
|
|
|
|
|
|
|
export
|
|
|
|
invalidStatus,
|
|
|
|
getPayload,
|
|
|
|
getPayloadV3,
|
|
|
|
getPayloadBodiesByHash,
|
|
|
|
getPayloadBodiesByRange,
|
|
|
|
exchangeConf,
|
|
|
|
newPayload,
|
|
|
|
forkchoiceUpdated
|