treat more constants as quasi-runtime-presets per v1.4.0 consensus specs (#5335)

This commit is contained in:
tersec 2023-08-21 19:58:51 +00:00 committed by GitHub
parent 295c3e2e41
commit c08d125fe3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 8 deletions

View File

@ -23,8 +23,8 @@ const
EPOCHS_PER_SUBNET_SUBSCRIPTION* = 256'u64
SUBNETS_PER_NODE* = 2'u64
ATTESTATION_SUBNET_COUNT*: uint64 = 64
ATTESTATION_SUBNET_EXTRA_BITS* = 0
ATTESTATION_SUBNET_PREFIX_BITS* = 6 ## \
ATTESTATION_SUBNET_EXTRA_BITS* = 0'u64
ATTESTATION_SUBNET_PREFIX_BITS* = 6'u64 ## \
## int(ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS)
static: doAssert 1 shl (ATTESTATION_SUBNET_PREFIX_BITS - ATTESTATION_SUBNET_EXTRA_BITS) ==
@ -73,3 +73,6 @@ const
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/p2p-interface.md#configuration
GOSSIP_MAX_SIZE* = 10'u64 * 1024 * 1024 # bytes
MAX_CHUNK_SIZE* = 10'u64 * 1024 * 1024 # bytes
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/p2p-interface.md#configuration
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS* = 4096'u64

View File

@ -39,9 +39,6 @@ const
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/deneb/polynomial-commitments.md#constants
BLS_MODULUS* = "52435875175126190479447740508185965837690552500527637822603658699938581184513".u256
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/p2p-interface.md#configuration
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS* = 4096'u64
type
KzgCommitments* = List[KzgCommitment, Limit MAX_BLOB_COMMITMENTS_PER_BLOCK]
Blobs* = List[Blob, Limit MAX_BLOBS_PER_BLOCK]

View File

@ -581,6 +581,10 @@ proc readRuntimeConfig*(
checkCompatibility EPOCHS_PER_SUBNET_SUBSCRIPTION
checkCompatibility MAX_CHUNK_SIZE
checkCompatibility SUBNETS_PER_NODE
checkCompatibility ATTESTATION_SUBNET_EXTRA_BITS
checkCompatibility ATTESTATION_SUBNET_PREFIX_BITS
checkCompatibility BLOB_SIDECAR_SUBNET_COUNT
checkCompatibility MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS
# Never pervasively implemented, still under discussion
checkCompatibility TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH

View File

@ -471,7 +471,7 @@ func livenessFailsafeInEffect*(
false
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/p2p-interface.md#attestation-subnet-subcription
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#attestation-subnet-subscription
func compute_subscribed_subnet(node_id: UInt256, epoch: Epoch, index: uint64):
SubnetId =
# Ensure neither `truncate` loses information
@ -482,7 +482,8 @@ func compute_subscribed_subnet(node_id: UInt256, epoch: Epoch, index: uint64):
let
node_id_prefix = truncate(
node_id shr (NODE_ID_BITS - ATTESTATION_SUBNET_PREFIX_BITS), uint64)
node_id shr (
NODE_ID_BITS - static(ATTESTATION_SUBNET_PREFIX_BITS.int)), uint64)
node_offset = truncate(
node_id mod static(EPOCHS_PER_SUBNET_SUBSCRIPTION.u256), uint64)
permutation_seed = eth2digest(uint_to_bytes(
@ -494,7 +495,7 @@ func compute_subscribed_subnet(node_id: UInt256, epoch: Epoch, index: uint64):
)
SubnetId((permutated_prefix + index) mod ATTESTATION_SUBNET_COUNT)
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/p2p-interface.md#attestation-subnet-subcription
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#attestation-subnet-subscription
iterator compute_subscribed_subnets*(node_id: UInt256, epoch: Epoch): SubnetId =
for index in 0'u64 ..< SUBNETS_PER_NODE:
yield compute_subscribed_subnet(node_id, epoch, index)