Correct subnet subscription duration variable
This commit is contained in:
parent
0dd8db76cd
commit
a0d03378fa
|
@ -94,7 +94,6 @@ All terminology, constants, functions, and protocol mechanics defined in the [Ph
|
||||||
| `ATTESTATION_SUBNET_EXTRA_BITS` | `0` | The number of extra bits of a NodeId to use when mapping to a subscribed subnet |
|
| `ATTESTATION_SUBNET_EXTRA_BITS` | `0` | The number of extra bits of a NodeId to use when mapping to a subscribed subnet |
|
||||||
| `SUBNETS_PER_NODE` | `2` | The number of long-lived subnets a beacon node should be subscribed to. |
|
| `SUBNETS_PER_NODE` | `2` | The number of long-lived subnets a beacon node should be subscribed to. |
|
||||||
| `ATTESTATION_SUBNET_PREFIX_BITS` | `(ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS)` | |
|
| `ATTESTATION_SUBNET_PREFIX_BITS` | `(ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS)` | |
|
||||||
| `SUBNET_DURATION_IN_EPOCHS` | `2` | |
|
|
||||||
|
|
||||||
## Containers
|
## Containers
|
||||||
|
|
||||||
|
@ -611,14 +610,14 @@ def get_aggregate_and_proof_signature(state: BeaconState,
|
||||||
|
|
||||||
Because Phase 0 does not have shards and thus does not have Shard Committees, there is no stable backbone to the attestation subnets (`beacon_attestation_{subnet_id}`). To provide this stability, each beacon node should:
|
Because Phase 0 does not have shards and thus does not have Shard Committees, there is no stable backbone to the attestation subnets (`beacon_attestation_{subnet_id}`). To provide this stability, each beacon node should:
|
||||||
|
|
||||||
* Remain subscribed to `SUBNETS_PER_NODE` for `SUBNET_DURATION_IN_EPOCHS` epochs.
|
* Remain subscribed to `SUBNETS_PER_NODE` for `EPOCHS_PER_SUBNET_SUBSCRIPTION` epochs.
|
||||||
* Maintain advertisement of the selected subnets in their node's ENR `attnets` entry by setting the selected `subnet_id` bits to `True` (e.g. `ENR["attnets"][subnet_id] = True`) for all persistent attestation subnets.
|
* Maintain advertisement of the selected subnets in their node's ENR `attnets` entry by setting the selected `subnet_id` bits to `True` (e.g. `ENR["attnets"][subnet_id] = True`) for all persistent attestation subnets.
|
||||||
* Select these subnets based on their node-id as specified by the following `compute_subnets(node_id,epoch)` function.
|
* Select these subnets based on their node-id as specified by the following `compute_subnets(node_id,epoch)` function.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def compute_subnet(node_id: int, epoch: Epoch, index: int) -> int:
|
def compute_subnet(node_id: int, epoch: Epoch, index: int) -> int:
|
||||||
node_id_prefix = node_id >> (256 - ATTESTATION_SUBNET_PREFIX_BITS)
|
node_id_prefix = node_id >> (256 - ATTESTATION_SUBNET_PREFIX_BITS)
|
||||||
permutation_seed = hash(uint_to_bytes(epoch // SUBNET_DURATION_IN_EPOCHS))
|
permutation_seed = hash(uint_to_bytes(epoch // EPOCHS_PER_SUBNET_SUBSCRIPTION))
|
||||||
permutated_prefix = compute_shuffled_index(node_id_prefix, 1 << ATTESTATION_SUBNET_PREFIX_BITS, permutation_seed)
|
permutated_prefix = compute_shuffled_index(node_id_prefix, 1 << ATTESTATION_SUBNET_PREFIX_BITS, permutation_seed)
|
||||||
return (permutated_prefix + index) % ATTESTATION_SUBNET_COUNT
|
return (permutated_prefix + index) % ATTESTATION_SUBNET_COUNT
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue