This reverts commit c5326619a4
.
This commit is contained in:
parent
05d2271a9f
commit
a93ab7cf3b
|
@ -491,11 +491,9 @@ func asConsensusType*(payload: engine_api.GetPayloadV3Response):
|
|||
# Both are defined as `array[N, byte]` under the hood.
|
||||
blobsBundle: deneb.BlobsBundle(
|
||||
commitments: KzgCommitments.init(
|
||||
payload.blobsBundle.commitments.mapIt(
|
||||
kzg_abi.KzgCommitment(bytes: it.bytes))),
|
||||
payload.blobsBundle.commitments.mapIt(it.bytes)),
|
||||
proofs: KzgProofs.init(
|
||||
payload.blobsBundle.proofs.mapIt(
|
||||
kzg_abi.KzgProof(bytes: it.bytes))),
|
||||
payload.blobsBundle.proofs.mapIt(it.bytes)),
|
||||
blobs: Blobs.init(
|
||||
payload.blobsBundle.blobs.mapIt(it.bytes))))
|
||||
|
||||
|
@ -562,11 +560,9 @@ func asConsensusType*(payload: engine_api.GetPayloadV4Response):
|
|||
# Both are defined as `array[N, byte]` under the hood.
|
||||
blobsBundle: deneb.BlobsBundle(
|
||||
commitments: KzgCommitments.init(
|
||||
payload.blobsBundle.commitments.mapIt(
|
||||
kzg_abi.KzgCommitment(bytes: it.bytes))),
|
||||
payload.blobsBundle.commitments.mapIt(it.bytes)),
|
||||
proofs: KzgProofs.init(
|
||||
payload.blobsBundle.proofs.mapIt(
|
||||
kzg_abi.KzgProof(bytes: it.bytes))),
|
||||
payload.blobsBundle.proofs.mapIt(it.bytes)),
|
||||
blobs: Blobs.init(
|
||||
payload.blobsBundle.blobs.mapIt(it.bytes))))
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ proc storeBackfillBlock(
|
|||
let blobs = blobsOpt.get()
|
||||
let kzgCommits = signedBlock.message.body.blob_kzg_commitments.asSeq
|
||||
if blobs.len > 0 or kzgCommits.len > 0:
|
||||
let r = validate_blobs(kzgCommits, blobs.mapIt(KzgBlob(bytes: it.blob)),
|
||||
let r = validate_blobs(kzgCommits, blobs.mapIt(it.blob),
|
||||
blobs.mapIt(it.kzg_proof))
|
||||
if r.isErr():
|
||||
debug "backfill blob validation failed",
|
||||
|
@ -575,7 +575,7 @@ proc storeBlock(
|
|||
let blobs = blobsOpt.get()
|
||||
let kzgCommits = signedBlock.message.body.blob_kzg_commitments.asSeq
|
||||
if blobs.len > 0 or kzgCommits.len > 0:
|
||||
let r = validate_blobs(kzgCommits, blobs.mapIt(KzgBlob(bytes: it.blob)),
|
||||
let r = validate_blobs(kzgCommits, blobs.mapIt(it.blob),
|
||||
blobs.mapIt(it.kzg_proof))
|
||||
if r.isErr():
|
||||
debug "blob validation failed",
|
||||
|
|
|
@ -458,7 +458,7 @@ proc validateBlobSidecar*(
|
|||
# blob_sidecar.blob, blob_sidecar.kzg_commitment, blob_sidecar.kzg_proof)`.
|
||||
block:
|
||||
let ok = verifyProof(
|
||||
KzgBlob(bytes: blob_sidecar.blob),
|
||||
blob_sidecar.blob,
|
||||
blob_sidecar.kzg_commitment,
|
||||
blob_sidecar.kzg_proof).valueOr:
|
||||
return dag.checkedReject("BlobSidecar: blob verify failed")
|
||||
|
|
|
@ -528,7 +528,7 @@ func initHashedBeaconState*(s: BeaconState): HashedBeaconState =
|
|||
HashedBeaconState(data: s)
|
||||
|
||||
func shortLog*(v: KzgCommitment | KzgProof): auto =
|
||||
to0xHex(v.bytes)
|
||||
to0xHex(v)
|
||||
|
||||
func shortLog*(v: Blob): auto =
|
||||
to0xHex(v.toOpenArray(0, 31))
|
||||
|
|
|
@ -1358,7 +1358,7 @@ proc readValue*(reader: var JsonReader[RestJson],
|
|||
value: var (KzgCommitment|KzgProof)) {.
|
||||
raises: [IOError, SerializationError].} =
|
||||
try:
|
||||
hexToByteArray(reader.readValue(string), distinctBase(value.bytes))
|
||||
hexToByteArray(reader.readValue(string), distinctBase(value))
|
||||
except ValueError:
|
||||
raiseUnexpectedValue(reader,
|
||||
"KzgCommitment value should be a valid hex string")
|
||||
|
@ -1366,7 +1366,7 @@ proc readValue*(reader: var JsonReader[RestJson],
|
|||
proc writeValue*(
|
||||
writer: var JsonWriter[RestJson], value: KzgCommitment | KzgProof
|
||||
) {.raises: [IOError].} =
|
||||
writeValue(writer, hexOriginal(distinctBase(value.bytes)))
|
||||
writeValue(writer, hexOriginal(distinctBase(value)))
|
||||
|
||||
## GraffitiBytes
|
||||
proc writeValue*(
|
||||
|
|
|
@ -1076,7 +1076,7 @@ func kzg_commitment_to_versioned_hash*(
|
|||
|
||||
var res: VersionedHash
|
||||
res[0] = VERSIONED_HASH_VERSION_KZG
|
||||
res[1 .. 31] = eth2digest(kzg_commitment.bytes).data.toOpenArray(1, 31)
|
||||
res[1 .. 31] = eth2digest(kzg_commitment).data.toOpenArray(1, 31)
|
||||
res
|
||||
|
||||
proc validate_blobs*(
|
||||
|
|
|
@ -117,10 +117,8 @@ proc routeSignedBeaconBlock*(
|
|||
let blobs = blobsOpt.get()
|
||||
let kzgCommits = blck.message.body.blob_kzg_commitments.asSeq
|
||||
if blobs.len > 0 or kzgCommits.len > 0:
|
||||
let res = validate_blobs(
|
||||
kzgCommits,
|
||||
blobs.mapIt(KzgBlob(bytes: it.blob)),
|
||||
blobs.mapIt(it.kzg_proof))
|
||||
let res = validate_blobs(kzgCommits, blobs.mapIt(it.blob),
|
||||
blobs.mapIt(it.kzg_proof))
|
||||
if res.isErr():
|
||||
warn "blobs failed validation",
|
||||
blockRoot = shortLog(blck.root),
|
||||
|
|
|
@ -128,7 +128,7 @@ proc unblindAndRouteBlockMEV*(
|
|||
bundle.data.blobs_bundle.commitments:
|
||||
return err("unblinded blobs bundle has unexpected commitments")
|
||||
let ok = verifyProofs(
|
||||
blobs_bundle.blobs.mapIt(KzgBlob(bytes: it)),
|
||||
asSeq blobs_bundle.blobs,
|
||||
asSeq blobs_bundle.commitments,
|
||||
asSeq blobs_bundle.proofs).valueOr:
|
||||
return err("unblinded blobs bundle fails verification")
|
||||
|
|
|
@ -136,8 +136,7 @@ proc loadOps(
|
|||
blobs: distinctBase(parseTest(
|
||||
path/(step["blobs"].getStr()) & ".ssz_snappy",
|
||||
SSZ, List[KzgBlob, Limit MAX_BLOBS_PER_BLOCK])),
|
||||
proofs: step["proofs"].mapIt(
|
||||
KzgProof(bytes: fromHex(array[48, byte], it.getStr()))))
|
||||
proofs: step["proofs"].mapIt(KzgProof.fromHex(it.getStr())))
|
||||
else:
|
||||
Opt.none(BlobData)
|
||||
else:
|
||||
|
@ -408,4 +407,4 @@ from ../../beacon_chain/conf import loadKzgTrustedSetup
|
|||
discard loadKzgTrustedSetup() # Required for Deneb tests
|
||||
|
||||
fcSuite("ForkChoice", "fork_choice")
|
||||
fcSuite("Sync", "sync")
|
||||
fcSuite("Sync", "sync")
|
|
@ -50,12 +50,12 @@ proc runBlobToKzgCommitmentTest(suiteName, suitePath, path: string) =
|
|||
if blob.isNone:
|
||||
check output.kind == JNull
|
||||
else:
|
||||
let commitment = blobToKzgCommitment(KzgBlob(bytes: blob.get))
|
||||
let commitment = blobToKzgCommitment(blob.get)
|
||||
check:
|
||||
if commitment.isErr:
|
||||
output.kind == JNull
|
||||
else:
|
||||
commitment.get().bytes == fromHex[48](output.getStr).get
|
||||
commitment.get == fromHex[48](output.getStr).get
|
||||
|
||||
proc runVerifyKzgProofTest(suiteName, suitePath, path: string) =
|
||||
let relativePathComponent = path.relativeTestPathComponent(suitePath)
|
||||
|
@ -75,10 +75,7 @@ proc runVerifyKzgProofTest(suiteName, suitePath, path: string) =
|
|||
if commitment.isNone or z.isNone or y.isNone or proof.isNone:
|
||||
check output.kind == JNull
|
||||
else:
|
||||
let v = verifyProof(
|
||||
KzgCommitment(bytes: commitment.get),
|
||||
KzgBytes32(bytes: z.get), KzgBytes32(bytes: y.get),
|
||||
KzgBytes48(bytes: proof.get))
|
||||
let v = verifyProof(commitment.get, z.get, y.get, proof.get)
|
||||
check:
|
||||
if v.isErr:
|
||||
output.kind == JNull
|
||||
|
@ -103,10 +100,7 @@ proc runVerifyBlobKzgProofTest(suiteName, suitePath, path: string) =
|
|||
if blob.isNone or commitment.isNone or proof.isNone:
|
||||
check output.kind == JNull
|
||||
else:
|
||||
let v = verifyBlobKzgProof(
|
||||
KzgBlob(bytes: blob.get),
|
||||
KzgBytes48(bytes: commitment.get),
|
||||
KzgBytes48(bytes: proof.get))
|
||||
let v = verifyBlobKzgProof(blob.get, commitment.get, proof.get)
|
||||
check:
|
||||
if v.isErr:
|
||||
output.kind == JNull
|
||||
|
@ -133,9 +127,7 @@ proc runVerifyBlobKzgProofBatchTest(suiteName, suitePath, path: string) =
|
|||
check output.kind == JNull
|
||||
else:
|
||||
let v = verifyBlobKzgProofBatch(
|
||||
blobs.mapIt(KzgBlob(bytes: it.get)),
|
||||
commitments.mapIt(KzgCommitment(bytes: it.get)),
|
||||
proofs.mapIt(KzgProof(bytes: it.get)))
|
||||
blobs.mapIt(it.get), commitments.mapIt(it.get), proofs.mapIt(it.get))
|
||||
check:
|
||||
if v.isErr:
|
||||
output.kind == JNull
|
||||
|
@ -158,8 +150,7 @@ proc runComputeKzgProofTest(suiteName, suitePath, path: string) =
|
|||
if blob.isNone or z.isNone:
|
||||
check output.kind == JNull
|
||||
else:
|
||||
let p = computeKzgProof(
|
||||
KzgBlob(bytes: blob.get), KzgBytes32(bytes: z.get))
|
||||
let p = computeKzgProof(blob.get, z.get)
|
||||
if p.isErr:
|
||||
check output.kind == JNull
|
||||
else:
|
||||
|
@ -167,8 +158,8 @@ proc runComputeKzgProofTest(suiteName, suitePath, path: string) =
|
|||
proof = fromHex[48](output[0].getStr)
|
||||
y = fromHex[32](output[1].getStr)
|
||||
check:
|
||||
p.get.proof.bytes == proof.get
|
||||
p.get.y.bytes == y.get
|
||||
p.get.proof == proof.get
|
||||
p.get.y == y.get
|
||||
|
||||
proc runComputeBlobKzgProofTest(suiteName, suitePath, path: string) =
|
||||
let relativePathComponent = path.relativeTestPathComponent(suitePath)
|
||||
|
@ -186,12 +177,11 @@ proc runComputeBlobKzgProofTest(suiteName, suitePath, path: string) =
|
|||
if blob.isNone or commitment.isNone:
|
||||
check output.kind == JNull
|
||||
else:
|
||||
let p = computeBlobKzgProof(
|
||||
KzgBlob(bytes: blob.get), KzgBytes48(bytes: commitment.get))
|
||||
let p = computeBlobKzgProof(blob.get, commitment.get)
|
||||
if p.isErr:
|
||||
check output.kind == JNull
|
||||
else:
|
||||
check p.get.bytes == fromHex[48](output.getStr).get
|
||||
check p.get == fromHex[48](output.getStr).get
|
||||
|
||||
from std/algorithm import sorted
|
||||
|
||||
|
@ -237,4 +227,4 @@ suite suiteName:
|
|||
for kind, path in walkDir(testsDir, relative = true, checkDir = true):
|
||||
runComputeBlobKzgProofTest(suiteName, testsDir, testsDir / path)
|
||||
|
||||
doAssert Kzg.freeTrustedSetup().isOk
|
||||
doAssert Kzg.freeTrustedSetup().isOk
|
|
@ -213,7 +213,7 @@ from stew/byteutils import hexToByteArray
|
|||
func fromHex(T: typedesc[KzgCommitment], s: string): T {.
|
||||
raises: [ValueError].} =
|
||||
var res: T
|
||||
hexToByteArray(s, res.bytes)
|
||||
hexToByteArray(s, res)
|
||||
res
|
||||
|
||||
suite "REST JSON encoding and decoding":
|
||||
|
@ -353,4 +353,4 @@ suite "REST JSON encoding and decoding":
|
|||
check:
|
||||
validator.pubkey == ValidatorPubKey.fromHex(
|
||||
"0x933ad9491b62059dd065b560d256d8957a8c402cc6e8d8ee7290ae11e8f7329267a8811c397529dac52ae1342ba58c95")[]
|
||||
validator.exit_epoch == FAR_FUTURE_EPOCH
|
||||
validator.exit_epoch == FAR_FUTURE_EPOCH
|
|
@ -1 +1 @@
|
|||
Subproject commit 2f5cee7bea0d62e2b502ff668f752bda7f3eb0c4
|
||||
Subproject commit f12616d0675d9f6346141ca95f0840ab227eb213
|
Loading…
Reference in New Issue