From 06e4ad5faaedcb8c769b8ae6099b62941f317537 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Mon, 27 May 2024 13:42:24 +0200 Subject: [PATCH] move `KzgCommitments` to `base` Preparation for EIP-7495 SSZ `StableContainer` which can only contain immutable types in their fields. --- beacon_chain/spec/datatypes/base.nim | 7 ++++++- beacon_chain/spec/datatypes/deneb.nim | 8 +++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/beacon_chain/spec/datatypes/base.nim b/beacon_chain/spec/datatypes/base.nim index 2a955e472..0a210d3ed 100644 --- a/beacon_chain/spec/datatypes/base.nim +++ b/beacon_chain/spec/datatypes/base.nim @@ -70,9 +70,11 @@ import ../../version, ".."/[beacon_time, crypto, digest, presets] +from kzg4844 import KzgCommitment + export tables, results, endians2, json_serialization, sszTypes, beacon_time, crypto, - digest, presets + digest, presets, kzg4844 const SPEC_VERSION* = "1.5.0-alpha.2" ## Spec version we're aiming to be compatible with, right now @@ -422,6 +424,9 @@ type SignedBLSToExecutionChangeList* = List[SignedBLSToExecutionChange, Limit MAX_BLS_TO_EXECUTION_CHANGES] + # https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#beaconblockbody + KzgCommitments* = List[KzgCommitment, Limit MAX_BLOB_COMMITMENTS_PER_BLOCK] + # https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.2/specs/capella/beacon-chain.md#historicalsummary HistoricalSummary* = object # `HistoricalSummary` matches the components of the phase0 diff --git a/beacon_chain/spec/datatypes/deneb.nim b/beacon_chain/spec/datatypes/deneb.nim index 248ae5b99..41ecce517 100644 --- a/beacon_chain/spec/datatypes/deneb.nim +++ b/beacon_chain/spec/datatypes/deneb.nim @@ -36,9 +36,6 @@ const BLS_MODULUS* = "52435875175126190479447740508185965837690552500527637822603658699938581184513".u256 type - # https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#beaconblockbody - KzgCommitments* = List[KzgCommitment, Limit MAX_BLOB_COMMITMENTS_PER_BLOCK] - # TODO this apparently is suppposed to be SSZ-equivalent to Bytes32, but # current spec doesn't ever SSZ-serialize it or hash_tree_root it # TODO make `distinct` then add a REST serialization for it specifically, via @@ -51,7 +48,8 @@ type BlobIndex* = uint64 # https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/deneb/polynomial-commitments.md#custom-types - Blob* = array[BYTES_PER_FIELD_ELEMENT * FIELD_ELEMENTS_PER_BLOB, byte] + Blob* = array[ + BYTES_PER_FIELD_ELEMENT * deneb_preset.FIELD_ELEMENTS_PER_BLOB, byte] # https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/p2p-interface.md#blobsidecar BlobSidecar* = object @@ -616,7 +614,7 @@ func kzg_commitment_inclusion_proof_gindex*( (BLOB_KZG_COMMITMENTS_GINDEX shl 1) + 0 # List depth BLOB_KZG_COMMITMENTS_PROOF_DEPTH = - log2trunc(nextPow2(deneb.KzgCommitments.maxLen.uint64)) + log2trunc(nextPow2(KzgCommitments.maxLen.uint64)) # First item BLOB_KZG_COMMITMENTS_FIRST_GINDEX = (BLOB_KZG_COMMITMENTS_BASE_GINDEX shl BLOB_KZG_COMMITMENTS_PROOF_DEPTH)