From 0513773d87906e42858eb9449060888fe1538438 Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Tue, 25 Feb 2025 10:43:04 +0100 Subject: [PATCH] Move sync queue assertions to preset loader MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We already check in `presets.nim`: - `MAX_BLOBS_PER_BLOCK_ELECTRA` ≥ `MAX_BLOBS_PER_BLOCK` - Config values match preset constant values until constants phased out The ≤ 9 check can be moved over, then sync queue no longer depends on the deprecated preset constant values and it remains a one-time check. --- beacon_chain/spec/presets.nim | 6 ++++++ beacon_chain/sync/sync_queue.nim | 13 ------------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/beacon_chain/spec/presets.nim b/beacon_chain/spec/presets.nim index d97c3c5ab3..183d64c16e 100644 --- a/beacon_chain/spec/presets.nim +++ b/beacon_chain/spec/presets.nim @@ -31,6 +31,8 @@ const MESSAGE_DOMAIN_INVALID_SNAPPY*: array[4, byte] = [0x00, 0x00, 0x00, 0x00] MESSAGE_DOMAIN_VALID_SNAPPY*: array[4, byte] = [0x01, 0x00, 0x00, 0x00] + MAX_SUPPORTED_BLOBS_PER_BLOCK*: uint64 = 9 # revisit getShortMap(Blobs) if >9 + type Version* = distinct array[4, byte] Eth1Address* = web3types.Address @@ -873,6 +875,10 @@ proc readRuntimeConfig*( checkCompatibility MAX_BLOBS_PER_BLOCK_ELECTRA checkCompatibility MAX_REQUEST_BLOB_SIDECARS_ELECTRA + for suffix in ["", "_ELECTRA"]: + checkCompatibility MAX_SUPPORTED_BLOBS_PER_BLOCK, + "MAX_BLOBS_PER_BLOCK" & suffix, `<=` + # https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.0/specs/phase0/fork-choice.md#configuration # Isn't being used as a preset in the usual way: at any time, there's one correct value checkCompatibility PROPOSER_SCORE_BOOST diff --git a/beacon_chain/sync/sync_queue.nim b/beacon_chain/sync/sync_queue.nim index d7f5bf281b..5c4934a274 100644 --- a/beacon_chain/sync/sync_queue.nim +++ b/beacon_chain/sync/sync_queue.nim @@ -143,11 +143,6 @@ func getShortMap*[T]( proc getShortMap*[T](req: SyncRequest[T], data: openArray[ref BlobSidecar]): string = - static: - doAssert(MAX_BLOBS_PER_BLOCK <= MAX_BLOBS_PER_BLOCK_ELECTRA) - doAssert(MAX_BLOBS_PER_BLOCK_ELECTRA < 10, - "getShortMap(Blobs) should be revisited") - var res = newStringOfCap(req.data.count) slider = req.data.slot @@ -175,11 +170,6 @@ proc getShortMap*[T]( req: SyncRequest[T], blobs: openArray[BlobSidecars] ): string = - static: - doAssert(MAX_BLOBS_PER_BLOCK <= MAX_BLOBS_PER_BLOCK_ELECTRA) - doAssert(MAX_BLOBS_PER_BLOCK_ELECTRA < 10, - "getShortMap(Blobs) should be revisited") - var res = newStringOfCap(req.data.count) slider = req.data.slot @@ -980,9 +970,6 @@ proc checkResponse*[T](req: SyncRequest[T], proc checkBlobsResponse*[T](req: SyncRequest[T], data: openArray[Slot]): Result[void, cstring] = - static: - doAssert(MAX_BLOBS_PER_BLOCK <= MAX_BLOBS_PER_BLOCK_ELECTRA) - if len(data) == 0: # Impossible to verify empty response. return ok()