Skip to content

Commit

Permalink
make MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS configurable (#5582)
Browse files Browse the repository at this point in the history
* make `MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS` configurable

Gnosis uses custom `MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS` to account
for the faster slot timing, so that blobs still remain available for
roughly the same amount of real time.

Also extend REST config endpoint with full config form `v1.4.0-beta.4`,
and extend compatibility checks when loading configs to reduce warnings.
  • Loading branch information
etan-status authored Nov 9, 2023
1 parent 68a7792 commit 101b723
Show file tree
Hide file tree
Showing 8 changed files with 268 additions and 55 deletions.
10 changes: 7 additions & 3 deletions beacon_chain/nimbus_beacon_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,15 @@ proc initFullNode(
validatorChangePool, node.attachedValidators, syncCommitteeMsgPool,
lightClientPool, quarantine, blobQuarantine, rng, getBeaconTime, taskpool)
syncManager = newSyncManager[Peer, PeerId](
node.network.peerPool, dag.cfg.DENEB_FORK_EPOCH, SyncQueueKind.Forward, getLocalHeadSlot,
node.network.peerPool,
dag.cfg.DENEB_FORK_EPOCH, dag.cfg.MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS,
SyncQueueKind.Forward, getLocalHeadSlot,
getLocalWallSlot, getFirstSlotAtFinalizedEpoch, getBackfillSlot,
getFrontfillSlot, dag.tail.slot, blockVerifier)
backfiller = newSyncManager[Peer, PeerId](
node.network.peerPool, dag.cfg.DENEB_FORK_EPOCH, SyncQueueKind.Backward, getLocalHeadSlot,
node.network.peerPool,
dag.cfg.DENEB_FORK_EPOCH, dag.cfg.MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS,
SyncQueueKind.Backward, getLocalHeadSlot,
getLocalWallSlot, getFirstSlotAtFinalizedEpoch, getBackfillSlot,
getFrontfillSlot, dag.backfill.slot, blockVerifier,
maxHeadAge = 0)
Expand Down Expand Up @@ -1326,7 +1330,7 @@ proc updateGossipStatus(node: BeaconNode, slot: Slot) {.async.} =

proc pruneBlobs(node: BeaconNode, slot: Slot) =
let blobPruneEpoch = (slot.epoch -
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS - 1)
node.dag.cfg.MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS - 1)
if slot.is_epoch() and blobPruneEpoch >= node.dag.cfg.DENEB_FORK_EPOCH:
var blocks: array[SLOTS_PER_EPOCH.int, BlockId]
var count = 0
Expand Down
48 changes: 45 additions & 3 deletions beacon_chain/rpc/rest_config_api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
KZG_COMMITMENT_INCLUSION_PROOF_DEPTH:
Base10.toString(uint64(KZG_COMMITMENT_INCLUSION_PROOF_DEPTH)),

# https://github.com/ethereum/consensus-specs/blob/v1.3.0/configs/mainnet.yaml
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/configs/mainnet.yaml
PRESET_BASE:
cfg.PRESET_BASE,
CONFIG_NAME:
Expand Down Expand Up @@ -197,12 +197,56 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
Base10.toString(cfg.MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT),
PROPOSER_SCORE_BOOST:
Base10.toString(PROPOSER_SCORE_BOOST),
REORG_HEAD_WEIGHT_THRESHOLD:
Base10.toString(REORG_HEAD_WEIGHT_THRESHOLD),
REORG_PARENT_WEIGHT_THRESHOLD:
Base10.toString(REORG_PARENT_WEIGHT_THRESHOLD),
REORG_MAX_EPOCHS_SINCE_FINALIZATION:
Base10.toString(uint64(REORG_MAX_EPOCHS_SINCE_FINALIZATION)),
DEPOSIT_CHAIN_ID:
Base10.toString(cfg.DEPOSIT_CHAIN_ID),
DEPOSIT_NETWORK_ID:
Base10.toString(cfg.DEPOSIT_NETWORK_ID),
DEPOSIT_CONTRACT_ADDRESS:
$cfg.DEPOSIT_CONTRACT_ADDRESS,
GOSSIP_MAX_SIZE:
Base10.toString(GOSSIP_MAX_SIZE),
MAX_REQUEST_BLOCKS:
Base10.toString(MAX_REQUEST_BLOCKS),
EPOCHS_PER_SUBNET_SUBSCRIPTION:
Base10.toString(EPOCHS_PER_SUBNET_SUBSCRIPTION),
MIN_EPOCHS_FOR_BLOCK_REQUESTS:
Base10.toString(cfg.MIN_EPOCHS_FOR_BLOCK_REQUESTS),
MAX_CHUNK_SIZE:
Base10.toString(MAX_CHUNK_SIZE),
TTFB_TIMEOUT:
Base10.toString(TTFB_TIMEOUT),
RESP_TIMEOUT:
Base10.toString(RESP_TIMEOUT),
ATTESTATION_PROPAGATION_SLOT_RANGE:
Base10.toString(ATTESTATION_PROPAGATION_SLOT_RANGE),
MAXIMUM_GOSSIP_CLOCK_DISPARITY:
Base10.toString(MAXIMUM_GOSSIP_CLOCK_DISPARITY.milliseconds.uint64),
MESSAGE_DOMAIN_INVALID_SNAPPY:
to0xHex(MESSAGE_DOMAIN_INVALID_SNAPPY),
MESSAGE_DOMAIN_VALID_SNAPPY:
to0xHex(MESSAGE_DOMAIN_VALID_SNAPPY),
SUBNETS_PER_NODE:
Base10.toString(SUBNETS_PER_NODE),
ATTESTATION_SUBNET_COUNT:
Base10.toString(ATTESTATION_SUBNET_COUNT),
ATTESTATION_SUBNET_EXTRA_BITS:
Base10.toString(ATTESTATION_SUBNET_EXTRA_BITS),
ATTESTATION_SUBNET_PREFIX_BITS:
Base10.toString(ATTESTATION_SUBNET_PREFIX_BITS),
MAX_REQUEST_BLOCKS_DENEB:
Base10.toString(MAX_REQUEST_BLOCKS_DENEB),
MAX_REQUEST_BLOB_SIDECARS:
Base10.toString(MAX_REQUEST_BLOB_SIDECARS),
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS:
Base10.toString(cfg.MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS),
BLOB_SIDECAR_SUBNET_COUNT:
Base10.toString(BLOB_SIDECAR_SUBNET_COUNT),

# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/beacon-chain.md#constants
# GENESIS_SLOT
Expand Down Expand Up @@ -265,8 +309,6 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/validator.md#constants
TARGET_AGGREGATORS_PER_COMMITTEE:
Base10.toString(TARGET_AGGREGATORS_PER_COMMITTEE),
ATTESTATION_SUBNET_COUNT:
Base10.toString(ATTESTATION_SUBNET_COUNT),

# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/altair/validator.md#constants
TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE:
Expand Down
6 changes: 1 addition & 5 deletions beacon_chain/spec/datatypes/base.nim
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,12 @@ import
stew/[assign2, byteutils, results],
chronicles,
json_serialization,
chronos/timer,
ssz_serialization/types as sszTypes,
../../version,
".."/[beacon_time, crypto, digest, presets]

export
tables, results, json_serialization, timer, sszTypes, beacon_time, crypto,
tables, results, json_serialization, sszTypes, beacon_time, crypto,
digest, presets

const SPEC_VERSION* = "1.4.0-beta.4"
Expand All @@ -82,9 +81,6 @@ const
ZERO_HASH* = Eth2Digest()
MAX_GRAFFITI_SIZE* = 32

# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#configuration
MAXIMUM_GOSSIP_CLOCK_DISPARITY* = 500.millis

SLOTS_PER_ETH1_VOTING_PERIOD* =
EPOCHS_PER_ETH1_VOTING_PERIOD * SLOTS_PER_EPOCH

Expand Down
9 changes: 7 additions & 2 deletions beacon_chain/spec/datatypes/constants.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.

import chronos/timer

type
Slot* = distinct uint64
Epoch* = distinct uint64
Expand Down Expand Up @@ -54,8 +56,11 @@ const
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/capella/beacon-chain.md#domain-types
DOMAIN_BLS_TO_EXECUTION_CHANGE* = DomainType([byte 0x0a, 0x00, 0x00, 0x00])

# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/fork-choice.md#configuration
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/phase0/fork-choice.md#configuration
PROPOSER_SCORE_BOOST*: uint64 = 40
REORG_HEAD_WEIGHT_THRESHOLD*: uint64 = 20
REORG_PARENT_WEIGHT_THRESHOLD*: uint64 = 160
REORG_MAX_EPOCHS_SINCE_FINALIZATION* = Epoch(2)

# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.2/specs/deneb/p2p-interface.md#configuration
BLOB_SIDECAR_SUBNET_COUNT*: uint64 = 6
Expand All @@ -64,11 +69,11 @@ const
MAX_REQUEST_BLOCKS* = 1024'u64
RESP_TIMEOUT* = 10'u64
ATTESTATION_PROPAGATION_SLOT_RANGE*: uint64 = 32
MAXIMUM_GOSSIP_CLOCK_DISPARITY* = 500.millis

# 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.2/specs/deneb/p2p-interface.md#configuration
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS*: uint64 = 4096
MAX_REQUEST_BLOCKS_DENEB*: uint64 = 128 # TODO Make use of in request code
Loading

0 comments on commit 101b723

Please sign in to comment.