mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-11 22:16:53 +00:00
add support for Electra blob subnets and IDs (#6806)
* add support for Electra blob subnets and IDs * fix tests
This commit is contained in:
parent
e29ef244ed
commit
fb1c3ba718
@ -144,7 +144,7 @@ template ethAmountUnit*(typ: type) {.dirty.} =
|
|||||||
|
|
||||||
func u256*(n: typ): UInt256 {.borrow.}
|
func u256*(n: typ): UInt256 {.borrow.}
|
||||||
|
|
||||||
proc toString*(B: typedesc[Base10], value: typ): string {.borrow.}
|
func toString*(B: typedesc[Base10], value: typ): string {.borrow.}
|
||||||
|
|
||||||
proc writeValue*(writer: var JsonWriter, value: typ) {.raises: [IOError].} =
|
proc writeValue*(writer: var JsonWriter, value: typ) {.raises: [IOError].} =
|
||||||
writer.writeValue(distinctBase(value))
|
writer.writeValue(distinctBase(value))
|
||||||
@ -204,7 +204,7 @@ type
|
|||||||
## blob sidecar - it is distinct from the CommitteeIndex in particular
|
## blob sidecar - it is distinct from the CommitteeIndex in particular
|
||||||
##
|
##
|
||||||
## The `BlobId` type is constrained to values in the range
|
## The `BlobId` type is constrained to values in the range
|
||||||
## `[0, BLOB_SIDECAR_SUBNET_COUNT)` during initialization.
|
## `[0, MAX_BLOBS_PER_BLOCK_ELECTRA)` during initialization.
|
||||||
|
|
||||||
# BitVector[4] in the spec, ie 4 bits which end up encoded as a byte for
|
# BitVector[4] in the spec, ie 4 bits which end up encoded as a byte for
|
||||||
# SSZ / hashing purposes
|
# SSZ / hashing purposes
|
||||||
@ -612,7 +612,9 @@ template makeLimitedU64*(T: untyped, limit: uint64) =
|
|||||||
|
|
||||||
makeLimitedU64(CommitteeIndex, MAX_COMMITTEES_PER_SLOT)
|
makeLimitedU64(CommitteeIndex, MAX_COMMITTEES_PER_SLOT)
|
||||||
makeLimitedU64(SubnetId, ATTESTATION_SUBNET_COUNT)
|
makeLimitedU64(SubnetId, ATTESTATION_SUBNET_COUNT)
|
||||||
makeLimitedU64(BlobId, BLOB_SIDECAR_SUBNET_COUNT)
|
|
||||||
|
static: doAssert MAX_BLOBS_PER_BLOCK_ELECTRA >= BLOB_SIDECAR_SUBNET_COUNT
|
||||||
|
makeLimitedU64(BlobId, MAX_BLOBS_PER_BLOCK_ELECTRA)
|
||||||
|
|
||||||
const
|
const
|
||||||
validatorIndexLimit = min(uint64(int32.high), VALIDATOR_REGISTRY_LIMIT)
|
validatorIndexLimit = min(uint64(int32.high), VALIDATOR_REGISTRY_LIMIT)
|
||||||
|
@ -16,12 +16,12 @@ export base
|
|||||||
const
|
const
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.8/specs/phase0/p2p-interface.md#topics-and-messages
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.8/specs/phase0/p2p-interface.md#topics-and-messages
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.9/specs/capella/p2p-interface.md#topics-and-messages
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.9/specs/capella/p2p-interface.md#topics-and-messages
|
||||||
topicBeaconBlocksSuffix* = "beacon_block/ssz_snappy"
|
topicBeaconBlocksSuffix = "beacon_block/ssz_snappy"
|
||||||
topicVoluntaryExitsSuffix* = "voluntary_exit/ssz_snappy"
|
topicVoluntaryExitsSuffix = "voluntary_exit/ssz_snappy"
|
||||||
topicProposerSlashingsSuffix* = "proposer_slashing/ssz_snappy"
|
topicProposerSlashingsSuffix = "proposer_slashing/ssz_snappy"
|
||||||
topicAttesterSlashingsSuffix* = "attester_slashing/ssz_snappy"
|
topicAttesterSlashingsSuffix = "attester_slashing/ssz_snappy"
|
||||||
topicAggregateAndProofsSuffix* = "beacon_aggregate_and_proof/ssz_snappy"
|
topicAggregateAndProofsSuffix = "beacon_aggregate_and_proof/ssz_snappy"
|
||||||
topicBlsToExecutionChangeSuffix* = "bls_to_execution_change/ssz_snappy"
|
topicBlsToExecutionChangeSuffix = "bls_to_execution_change/ssz_snappy"
|
||||||
|
|
||||||
const
|
const
|
||||||
# The spec now includes this as a bare uint64 as `RESP_TIMEOUT`
|
# The spec now includes this as a bare uint64 as `RESP_TIMEOUT`
|
||||||
@ -112,7 +112,7 @@ func getBlobSidecarTopic*(forkDigest: ForkDigest,
|
|||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/validator.md#sidecar
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/validator.md#sidecar
|
||||||
func compute_subnet_for_blob_sidecar*(blob_index: BlobIndex): BlobId =
|
func compute_subnet_for_blob_sidecar*(blob_index: BlobIndex): BlobId =
|
||||||
BlobId(blob_index mod BLOB_SIDECAR_SUBNET_COUNT)
|
BlobId(blob_index mod MAX_BLOBS_PER_BLOCK_ELECTRA)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.8/specs/_features/eip7594/p2p-interface.md#compute_subnet_for_data_column_sidecar
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.8/specs/_features/eip7594/p2p-interface.md#compute_subnet_for_data_column_sidecar
|
||||||
func compute_subnet_for_data_column_sidecar*(column_index: ColumnIndex): uint64 =
|
func compute_subnet_for_data_column_sidecar*(column_index: ColumnIndex): uint64 =
|
||||||
|
@ -86,7 +86,10 @@ suite "Honest validator":
|
|||||||
"/eth2/00000000/blob_sidecar_2/ssz_snappy",
|
"/eth2/00000000/blob_sidecar_2/ssz_snappy",
|
||||||
"/eth2/00000000/blob_sidecar_3/ssz_snappy",
|
"/eth2/00000000/blob_sidecar_3/ssz_snappy",
|
||||||
"/eth2/00000000/blob_sidecar_4/ssz_snappy",
|
"/eth2/00000000/blob_sidecar_4/ssz_snappy",
|
||||||
"/eth2/00000000/blob_sidecar_5/ssz_snappy"]
|
"/eth2/00000000/blob_sidecar_5/ssz_snappy",
|
||||||
|
"/eth2/00000000/blob_sidecar_6/ssz_snappy",
|
||||||
|
"/eth2/00000000/blob_sidecar_7/ssz_snappy",
|
||||||
|
"/eth2/00000000/blob_sidecar_8/ssz_snappy"]
|
||||||
|
|
||||||
test "is_aggregator":
|
test "is_aggregator":
|
||||||
check:
|
check:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user