Skip to content

Commit c08d125

Browse files
authored
treat more constants as quasi-runtime-presets per v1.4.0 consensus specs (#5335)
1 parent 295c3e2 commit c08d125

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

beacon_chain/spec/datatypes/constants.nim

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ const
2323
EPOCHS_PER_SUBNET_SUBSCRIPTION* = 256'u64
2424
SUBNETS_PER_NODE* = 2'u64
2525
ATTESTATION_SUBNET_COUNT*: uint64 = 64
26-
ATTESTATION_SUBNET_EXTRA_BITS* = 0
27-
ATTESTATION_SUBNET_PREFIX_BITS* = 6 ## \
26+
ATTESTATION_SUBNET_EXTRA_BITS* = 0'u64
27+
ATTESTATION_SUBNET_PREFIX_BITS* = 6'u64 ## \
2828
## int(ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS)
2929

3030
static: doAssert 1 shl (ATTESTATION_SUBNET_PREFIX_BITS - ATTESTATION_SUBNET_EXTRA_BITS) ==
@@ -73,3 +73,6 @@ const
7373
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/p2p-interface.md#configuration
7474
GOSSIP_MAX_SIZE* = 10'u64 * 1024 * 1024 # bytes
7575
MAX_CHUNK_SIZE* = 10'u64 * 1024 * 1024 # bytes
76+
77+
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/p2p-interface.md#configuration
78+
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS* = 4096'u64

beacon_chain/spec/datatypes/deneb.nim

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ const
3939
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/deneb/polynomial-commitments.md#constants
4040
BLS_MODULUS* = "52435875175126190479447740508185965837690552500527637822603658699938581184513".u256
4141

42-
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/p2p-interface.md#configuration
43-
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS* = 4096'u64
44-
4542
type
4643
KzgCommitments* = List[KzgCommitment, Limit MAX_BLOB_COMMITMENTS_PER_BLOCK]
4744
Blobs* = List[Blob, Limit MAX_BLOBS_PER_BLOCK]

beacon_chain/spec/presets.nim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,10 @@ proc readRuntimeConfig*(
581581
checkCompatibility EPOCHS_PER_SUBNET_SUBSCRIPTION
582582
checkCompatibility MAX_CHUNK_SIZE
583583
checkCompatibility SUBNETS_PER_NODE
584+
checkCompatibility ATTESTATION_SUBNET_EXTRA_BITS
585+
checkCompatibility ATTESTATION_SUBNET_PREFIX_BITS
586+
checkCompatibility BLOB_SIDECAR_SUBNET_COUNT
587+
checkCompatibility MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS
584588

585589
# Never pervasively implemented, still under discussion
586590
checkCompatibility TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH

beacon_chain/spec/validator.nim

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ func livenessFailsafeInEffect*(
471471

472472
false
473473

474-
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/p2p-interface.md#attestation-subnet-subcription
474+
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#attestation-subnet-subscription
475475
func compute_subscribed_subnet(node_id: UInt256, epoch: Epoch, index: uint64):
476476
SubnetId =
477477
# Ensure neither `truncate` loses information
@@ -482,7 +482,8 @@ func compute_subscribed_subnet(node_id: UInt256, epoch: Epoch, index: uint64):
482482

483483
let
484484
node_id_prefix = truncate(
485-
node_id shr (NODE_ID_BITS - ATTESTATION_SUBNET_PREFIX_BITS), uint64)
485+
node_id shr (
486+
NODE_ID_BITS - static(ATTESTATION_SUBNET_PREFIX_BITS.int)), uint64)
486487
node_offset = truncate(
487488
node_id mod static(EPOCHS_PER_SUBNET_SUBSCRIPTION.u256), uint64)
488489
permutation_seed = eth2digest(uint_to_bytes(
@@ -494,7 +495,7 @@ func compute_subscribed_subnet(node_id: UInt256, epoch: Epoch, index: uint64):
494495
)
495496
SubnetId((permutated_prefix + index) mod ATTESTATION_SUBNET_COUNT)
496497

497-
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/p2p-interface.md#attestation-subnet-subcription
498+
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#attestation-subnet-subscription
498499
iterator compute_subscribed_subnets*(node_id: UInt256, epoch: Epoch): SubnetId =
499500
for index in 0'u64 ..< SUBNETS_PER_NODE:
500501
yield compute_subscribed_subnet(node_id, epoch, index)

0 commit comments

Comments
 (0)