move spec constants to spec (#4825)
* move spec constants to spec quite funny, this removes >_1000_ transitive imports when building `nimbus_validator_client`. `genDepend`: ```sh [arnetheduck@praeceps beacon_chain]$ diff -u nimbus_validator_client.dot.pre nimbus_validator_client.dot | wc 1167 3507 103822 ``` * imports * better constants * oops * too many blobs * reorder spec constants in fork order * cleanup
This commit is contained in:
parent
176c80a3d5
commit
7df75d77fa
|
@ -195,7 +195,7 @@ proc getLightClientBootstrap*(
|
||||||
contentType: resp.contentType,
|
contentType: resp.contentType,
|
||||||
data: data))
|
data: data))
|
||||||
|
|
||||||
from ../../networking/eth2_network import MAX_REQUEST_LIGHT_CLIENT_UPDATES
|
from ../../spec/network import MAX_REQUEST_LIGHT_CLIENT_UPDATES
|
||||||
export MAX_REQUEST_LIGHT_CLIENT_UPDATES
|
export MAX_REQUEST_LIGHT_CLIENT_UPDATES
|
||||||
|
|
||||||
proc getLightClientUpdatesByRangePlain(
|
proc getLightClientUpdatesByRangePlain(
|
||||||
|
|
|
@ -25,12 +25,21 @@ const
|
||||||
topicBlsToExecutionChangeSuffix* = "bls_to_execution_change/ssz_snappy"
|
topicBlsToExecutionChangeSuffix* = "bls_to_execution_change/ssz_snappy"
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.5/specs/phase0/p2p-interface.md#configuration
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.5/specs/phase0/p2p-interface.md#configuration
|
||||||
|
MAX_REQUEST_BLOCKS* = 1024
|
||||||
RESP_TIMEOUT* = 10.seconds
|
RESP_TIMEOUT* = 10.seconds
|
||||||
|
|
||||||
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.5/specs/altair/light-client/p2p-interface.md#configuration
|
||||||
|
MAX_REQUEST_LIGHT_CLIENT_UPDATES* = 128
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.5/specs/bellatrix/p2p-interface.md#configuration
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.5/specs/bellatrix/p2p-interface.md#configuration
|
||||||
GOSSIP_MAX_SIZE_BELLATRIX* = 10 * 1024 * 1024 # bytes
|
GOSSIP_MAX_SIZE_BELLATRIX* = 10 * 1024 * 1024 # bytes
|
||||||
MAX_CHUNK_SIZE_BELLATRIX* = 10 * 1024 * 1024 # bytes
|
MAX_CHUNK_SIZE_BELLATRIX* = 10 * 1024 * 1024 # bytes
|
||||||
|
|
||||||
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.5/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
|
||||||
|
|
||||||
defaultEth2TcpPort* = 9000
|
defaultEth2TcpPort* = 9000
|
||||||
defaultEth2TcpPortDesc* = $defaultEth2TcpPort
|
defaultEth2TcpPortDesc* = $defaultEth2TcpPort
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
import chronos, chronicles, stew/base10
|
import chronos, chronicles, stew/base10
|
||||||
import
|
import
|
||||||
eth/p2p/discoveryv5/random2,
|
eth/p2p/discoveryv5/random2,
|
||||||
|
../spec/network,
|
||||||
../networking/eth2_network,
|
../networking/eth2_network,
|
||||||
../beacon_clock,
|
../beacon_clock,
|
||||||
"."/sync_protocol, "."/sync_manager
|
"."/sync_protocol, "."/sync_manager
|
||||||
|
|
|
@ -78,7 +78,7 @@ type
|
||||||
slots*: uint64
|
slots*: uint64
|
||||||
|
|
||||||
BeaconBlocksRes = NetRes[List[ref ForkedSignedBeaconBlock, MAX_REQUEST_BLOCKS]]
|
BeaconBlocksRes = NetRes[List[ref ForkedSignedBeaconBlock, MAX_REQUEST_BLOCKS]]
|
||||||
BlobSidecarsRes = NetRes[List[ref BlobSidecar, Limit(MAX_REQUEST_BLOBS_SIDECARS * MAX_BLOBS_PER_BLOCK)]]
|
BlobSidecarsRes = NetRes[List[ref BlobSidecar, Limit(MAX_REQUEST_BLOB_SIDECARS)]]
|
||||||
|
|
||||||
proc now*(sm: typedesc[SyncMoment], slots: uint64): SyncMoment {.inline.} =
|
proc now*(sm: typedesc[SyncMoment], slots: uint64): SyncMoment {.inline.} =
|
||||||
SyncMoment(stamp: now(chronos.Moment), slots: slots)
|
SyncMoment(stamp: now(chronos.Moment), slots: slots)
|
||||||
|
|
|
@ -22,13 +22,8 @@ logScope:
|
||||||
topics = "sync"
|
topics = "sync"
|
||||||
|
|
||||||
const
|
const
|
||||||
MAX_REQUEST_BLOCKS* = 1024
|
|
||||||
MAX_REQUEST_BLOBS_SIDECARS* = 128
|
|
||||||
|
|
||||||
blockResponseCost = allowedOpsPerSecondCost(64) # Allow syncing ~64 blocks/sec (minus request costs)
|
blockResponseCost = allowedOpsPerSecondCost(64) # Allow syncing ~64 blocks/sec (minus request costs)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-rc.5/specs/altair/light-client/p2p-interface.md#configuration
|
|
||||||
MAX_REQUEST_LIGHT_CLIENT_UPDATES* = 128
|
|
||||||
lightClientBootstrapResponseCost = allowedOpsPerSecondCost(1)
|
lightClientBootstrapResponseCost = allowedOpsPerSecondCost(1)
|
||||||
## Only one bootstrap per peer should ever be needed - no need to allow more
|
## Only one bootstrap per peer should ever be needed - no need to allow more
|
||||||
lightClientUpdateResponseCost = allowedOpsPerSecondCost(1000)
|
lightClientUpdateResponseCost = allowedOpsPerSecondCost(1000)
|
||||||
|
@ -71,7 +66,7 @@ type
|
||||||
slot: Slot
|
slot: Slot
|
||||||
|
|
||||||
BlockRootsList* = List[Eth2Digest, Limit MAX_REQUEST_BLOCKS]
|
BlockRootsList* = List[Eth2Digest, Limit MAX_REQUEST_BLOCKS]
|
||||||
BlobIdentifierList* = List[BlobIdentifier, Limit (MAX_REQUEST_BLOBS_SIDECARS * MAX_BLOBS_PER_BLOCK)]
|
BlobIdentifierList* = List[BlobIdentifier, Limit (MAX_REQUEST_BLOB_SIDECARS)]
|
||||||
|
|
||||||
template readChunkPayload*(
|
template readChunkPayload*(
|
||||||
conn: Connection, peer: Peer, MsgType: type ForkySignedBeaconBlock):
|
conn: Connection, peer: Peer, MsgType: type ForkySignedBeaconBlock):
|
||||||
|
@ -434,7 +429,7 @@ p2pProtocol BeaconSync(version = 1,
|
||||||
peer: Peer,
|
peer: Peer,
|
||||||
blobIds: BlobIdentifierList,
|
blobIds: BlobIdentifierList,
|
||||||
response: MultipleChunksResponse[
|
response: MultipleChunksResponse[
|
||||||
ref BlobSidecar, Limit(MAX_REQUEST_BLOBS_SIDECARS * MAX_BLOBS_PER_BLOCK)])
|
ref BlobSidecar, Limit(MAX_REQUEST_BLOB_SIDECARS)])
|
||||||
{.async, libp2pProtocol("blob_sidecars_by_root", 1).} =
|
{.async, libp2pProtocol("blob_sidecars_by_root", 1).} =
|
||||||
# TODO Semantically, this request should return a non-ref, but doing so
|
# TODO Semantically, this request should return a non-ref, but doing so
|
||||||
# runs into extreme inefficiency due to the compiler introducing
|
# runs into extreme inefficiency due to the compiler introducing
|
||||||
|
@ -486,7 +481,7 @@ p2pProtocol BeaconSync(version = 1,
|
||||||
peer: Peer,
|
peer: Peer,
|
||||||
startSlot: Slot,
|
startSlot: Slot,
|
||||||
reqCount: uint64,
|
reqCount: uint64,
|
||||||
response: MultipleChunksResponse[ref BlobSidecar, Limit(MAX_REQUEST_BLOBS_SIDECARS * MAX_BLOBS_PER_BLOCK)])
|
response: MultipleChunksResponse[ref BlobSidecar, Limit(MAX_REQUEST_BLOB_SIDECARS)])
|
||||||
{.async, libp2pProtocol("blob_sidecars_by_range", 1).} =
|
{.async, libp2pProtocol("blob_sidecars_by_range", 1).} =
|
||||||
# TODO This code is more complicated than it needs to be, since the type
|
# TODO This code is more complicated than it needs to be, since the type
|
||||||
# of the multiple chunks response is not actually used in this server
|
# of the multiple chunks response is not actually used in this server
|
||||||
|
@ -512,7 +507,7 @@ p2pProtocol BeaconSync(version = 1,
|
||||||
if startSlot.epoch < epochBoundary:
|
if startSlot.epoch < epochBoundary:
|
||||||
raise newException(ResourceUnavailableError, BlobsOutOfRange)
|
raise newException(ResourceUnavailableError, BlobsOutOfRange)
|
||||||
|
|
||||||
var blockIds: array[MAX_REQUEST_BLOBS_SIDECARS, BlockId]
|
var blockIds: array[int(MAX_REQUEST_BLOB_SIDECARS), BlockId]
|
||||||
let
|
let
|
||||||
count = int min(reqCount, blockIds.lenu64)
|
count = int min(reqCount, blockIds.lenu64)
|
||||||
endIndex = count - 1
|
endIndex = count - 1
|
||||||
|
|
|
@ -12,7 +12,8 @@ import
|
||||||
./sync/sync_manager,
|
./sync/sync_manager,
|
||||||
./consensus_object_pools/[block_clearance, blockchain_dag],
|
./consensus_object_pools/[block_clearance, blockchain_dag],
|
||||||
./spec/eth2_apis/rest_beacon_client,
|
./spec/eth2_apis/rest_beacon_client,
|
||||||
./spec/[beaconstate, eth2_merkleization, forks, light_client_sync, presets,
|
./spec/[beaconstate, eth2_merkleization, forks, light_client_sync,
|
||||||
|
network, presets,
|
||||||
state_transition, deposit_snapshots],
|
state_transition, deposit_snapshots],
|
||||||
"."/[beacon_clock, beacon_chain_db, era_db]
|
"."/[beacon_clock, beacon_chain_db, era_db]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue