Skip to content

Commit bbf6484

Browse files
authored
Move sync queue assertions to preset loader (#6960)
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.
1 parent de2429f commit bbf6484

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

beacon_chain/spec/presets.nim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ const
3131
MESSAGE_DOMAIN_INVALID_SNAPPY*: array[4, byte] = [0x00, 0x00, 0x00, 0x00]
3232
MESSAGE_DOMAIN_VALID_SNAPPY*: array[4, byte] = [0x01, 0x00, 0x00, 0x00]
3333

34+
MAX_SUPPORTED_BLOBS_PER_BLOCK*: uint64 = 9 # revisit getShortMap(Blobs) if >9
35+
3436
type
3537
Version* = distinct array[4, byte]
3638
Eth1Address* = web3types.Address
@@ -873,6 +875,10 @@ proc readRuntimeConfig*(
873875
checkCompatibility MAX_BLOBS_PER_BLOCK_ELECTRA
874876
checkCompatibility MAX_REQUEST_BLOB_SIDECARS_ELECTRA
875877

878+
for suffix in ["", "_ELECTRA"]:
879+
checkCompatibility MAX_SUPPORTED_BLOBS_PER_BLOCK,
880+
"MAX_BLOBS_PER_BLOCK" & suffix, `<=`
881+
876882
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.0/specs/phase0/fork-choice.md#configuration
877883
# Isn't being used as a preset in the usual way: at any time, there's one correct value
878884
checkCompatibility PROPOSER_SCORE_BOOST

beacon_chain/sync/sync_queue.nim

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,6 @@ func getShortMap*[T](
143143

144144
proc getShortMap*[T](req: SyncRequest[T],
145145
data: openArray[ref BlobSidecar]): string =
146-
static:
147-
doAssert(MAX_BLOBS_PER_BLOCK <= MAX_BLOBS_PER_BLOCK_ELECTRA)
148-
doAssert(MAX_BLOBS_PER_BLOCK_ELECTRA < 10,
149-
"getShortMap(Blobs) should be revisited")
150-
151146
var
152147
res = newStringOfCap(req.data.count)
153148
slider = req.data.slot
@@ -175,11 +170,6 @@ proc getShortMap*[T](
175170
req: SyncRequest[T],
176171
blobs: openArray[BlobSidecars]
177172
): string =
178-
static:
179-
doAssert(MAX_BLOBS_PER_BLOCK <= MAX_BLOBS_PER_BLOCK_ELECTRA)
180-
doAssert(MAX_BLOBS_PER_BLOCK_ELECTRA < 10,
181-
"getShortMap(Blobs) should be revisited")
182-
183173
var
184174
res = newStringOfCap(req.data.count)
185175
slider = req.data.slot
@@ -980,9 +970,6 @@ proc checkResponse*[T](req: SyncRequest[T],
980970

981971
proc checkBlobsResponse*[T](req: SyncRequest[T],
982972
data: openArray[Slot]): Result[void, cstring] =
983-
static:
984-
doAssert(MAX_BLOBS_PER_BLOCK <= MAX_BLOBS_PER_BLOCK_ELECTRA)
985-
986973
if len(data) == 0:
987974
# Impossible to verify empty response.
988975
return ok()

0 commit comments

Comments
 (0)