# beacon_chain # Copyright (c) 2018-2024 Status Research & Development GmbH # Licensed and distributed under either of # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # at your option. This file may not be copied, modified, or distributed except according to those terms. {.push raises: [].} {.used.} # Uncategorized helper functions from the spec import unittest2, random, std/[algorithm, macros, tables, sysrand], stew/results, stint, kzg4844/[kzg_abi, kzg_ex], ssz_serialization/proofs, chronicles, ../beacon_chain/spec/beacon_time, eth/p2p/discoveryv5/[node], ./consensus_spec/[os_ops, fixtures_utils], ../beacon_chain/spec/[helpers, eip7594_helpers], ../beacon_chain/spec/datatypes/[eip7594, deneb] from std/sequtils import anyIt, mapIt, toSeq from std/strutils import rsplit block: template sourceDir: string = currentSourcePath.rsplit(DirSep, 1)[0] doAssert Kzg.loadTrustedSetup( sourceDir & "/../vendor/nim-kzg4844/kzg4844/csources/src/trusted_setup.txt").isOk const MAX_TOP_BYTE = 114 proc createSampleKzgBlobs(n: int): Result[seq[KzgBlob], cstring] = var blob: KzgBlob var blobs: seq[KzgBlob] for i in 0.. MAX_TOP_BYTE and i %% kzg_abi.BYTES_PER_FIELD_ELEMENT == 0: blob[i] = MAX_TOP_BYTE blobs.add(blob) ok(blobs) suite "EIP-7594 Unit Tests": test "EIP-7594: Compute Extended Matrix": proc testComputeExtendedMatrix() = let blob_count = 2 let input_blobs = createSampleKzgBlobs(blob_count) let extended_matrix = compute_extended_matrix(input_blobs.get) doAssert extended_matrix.get.len == kzg_abi.CELLS_PER_EXT_BLOB * blob_count testComputeExtendedMatrix()