Skip to content

Commit

Permalink
remove 4 more missing constants in preset handling warning (#5428)
Browse files Browse the repository at this point in the history
  • Loading branch information
tersec authored Sep 14, 2023
1 parent bb8584c commit 7a001d4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
4 changes: 1 addition & 3 deletions beacon_chain/networking/eth2_network.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2258,9 +2258,7 @@ func gossipId(
data: openArray[byte], phase0Prefix, topic: string): seq[byte] =
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#topics-and-messages
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/p2p-interface.md#topics-and-messages
const
MESSAGE_DOMAIN_INVALID_SNAPPY = [0x00'u8, 0x00, 0x00, 0x00]
MESSAGE_DOMAIN_VALID_SNAPPY = [0x01'u8, 0x00, 0x00, 0x00]
const MESSAGE_DOMAIN_VALID_SNAPPY = [0x01'u8, 0x00, 0x00, 0x00]
let messageDigest = withEth2Hash:
h.update(MESSAGE_DOMAIN_VALID_SNAPPY)

Expand Down
5 changes: 3 additions & 2 deletions beacon_chain/spec/datatypes/constants.nim
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ const

# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/p2p-interface.md#configuration
MAX_REQUEST_BLOCKS* = 1024'u64
RESP_TIMEOUT* = 10
RESP_TIMEOUT* = 10'u64

# 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
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS*: uint64 = 4096
MAX_REQUEST_BLOCKS_DENEB*: uint64 = 128 # TODO Make use of in request code
10 changes: 5 additions & 5 deletions beacon_chain/spec/network.nim
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ const
topicAggregateAndProofsSuffix* = "beacon_aggregate_and_proof/ssz_snappy"
topicBlsToExecutionChangeSuffix* = "bls_to_execution_change/ssz_snappy"

# The spec now includes this as a bare integer as `RESP_TIMEOUT`
RESP_TIMEOUT_DUR* = RESP_TIMEOUT.seconds
const
# The spec now includes this as a bare uint64 as `RESP_TIMEOUT`
RESP_TIMEOUT_DUR* = RESP_TIMEOUT.int64.seconds

# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/light-client/p2p-interface.md#configuration
MAX_REQUEST_LIGHT_CLIENT_UPDATES* = 128

# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/deneb/p2p-interface.md#configuration
MAX_REQUEST_BLOCKS_DENEB* = 128 # TODO Make use of in request code
MAX_REQUEST_BLOB_SIDECARS* = MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK
# TODO MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS
MAX_REQUEST_BLOB_SIDECARS*: uint64 =
MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK

defaultEth2TcpPort* = 9000
defaultEth2TcpPortDesc* = $defaultEth2TcpPort
Expand Down
8 changes: 8 additions & 0 deletions beacon_chain/spec/presets.nim
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ const

# Constants from `validator.md` not covered by config/presets in the spec
TARGET_AGGREGATORS_PER_COMMITTEE*: uint64 = 16

# Not used anywhere; only for network preset checking
EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION: uint64 = 256
MESSAGE_DOMAIN_INVALID_SNAPPY = 0'u64
TTFB_TIMEOUT = 5'u64

type
Version* = distinct array[4, byte]
Expand Down Expand Up @@ -591,6 +595,10 @@ proc readRuntimeConfig*(
checkCompatibility ATTESTATION_SUBNET_PREFIX_BITS
checkCompatibility BLOB_SIDECAR_SUBNET_COUNT
checkCompatibility MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS
checkCompatibility RESP_TIMEOUT
checkCompatibility TTFB_TIMEOUT
checkCompatibility MESSAGE_DOMAIN_INVALID_SNAPPY
checkCompatibility MAX_REQUEST_BLOCKS_DENEB

# Isn't being used as a preset in the usual way: at any time, there's one correct value
checkCompatibility PROPOSER_SCORE_BOOST
Expand Down

0 comments on commit 7a001d4

Please sign in to comment.