remove AttestationDataAndCustodyBit
This commit is contained in:
parent
65b615a4d4
commit
600265a311
|
@ -24,14 +24,13 @@ from eth2spec.utils.ssz.ssz_impl import (
|
||||||
signing_root,
|
signing_root,
|
||||||
)
|
)
|
||||||
from eth2spec.utils.ssz.ssz_typing import (
|
from eth2spec.utils.ssz.ssz_typing import (
|
||||||
bit, boolean, Container, List, Vector, uint64,
|
boolean, Container, List, Vector, uint64,
|
||||||
Bytes1, Bytes4, Bytes8, Bytes32, Bytes48, Bytes96, Bitlist, Bitvector,
|
Bytes1, Bytes4, Bytes8, Bytes32, Bytes48, Bytes96, Bitlist, Bitvector,
|
||||||
)
|
)
|
||||||
from eth2spec.utils.bls import (
|
from eth2spec.utils.bls import (
|
||||||
bls_aggregate_signatures,
|
bls_aggregate_signatures,
|
||||||
bls_aggregate_pubkeys,
|
bls_aggregate_pubkeys,
|
||||||
bls_verify,
|
bls_verify,
|
||||||
bls_verify_multiple,
|
|
||||||
bls_sign,
|
bls_sign,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
- [`Checkpoint`](#checkpoint)
|
- [`Checkpoint`](#checkpoint)
|
||||||
- [`Validator`](#validator)
|
- [`Validator`](#validator)
|
||||||
- [`AttestationData`](#attestationdata)
|
- [`AttestationData`](#attestationdata)
|
||||||
- [`AttestationDataAndCustodyBit`](#attestationdataandcustodybit)
|
|
||||||
- [`IndexedAttestation`](#indexedattestation)
|
- [`IndexedAttestation`](#indexedattestation)
|
||||||
- [`PendingAttestation`](#pendingattestation)
|
- [`PendingAttestation`](#pendingattestation)
|
||||||
- [`Eth1Data`](#eth1data)
|
- [`Eth1Data`](#eth1data)
|
||||||
|
@ -308,14 +307,6 @@ class AttestationData(Container):
|
||||||
target: Checkpoint
|
target: Checkpoint
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `AttestationDataAndCustodyBit`
|
|
||||||
|
|
||||||
```python
|
|
||||||
class AttestationDataAndCustodyBit(Container):
|
|
||||||
data: AttestationData
|
|
||||||
custody_bit: bit # Challengeable bit (SSZ-bool, 1 byte) for the custody of shard data
|
|
||||||
```
|
|
||||||
|
|
||||||
#### `IndexedAttestation`
|
#### `IndexedAttestation`
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
@ -612,13 +603,9 @@ def is_valid_indexed_attestation(state: BeaconState, indexed_attestation: Indexe
|
||||||
if not indices == sorted(indices):
|
if not indices == sorted(indices):
|
||||||
return False
|
return False
|
||||||
# Verify aggregate signature
|
# Verify aggregate signature
|
||||||
if not bls_verify_multiple(
|
if not bls_verify(
|
||||||
pubkeys=[
|
pubkey=bls_aggregate_pubkeys([state.validators[i].pubkey for i in indices]),
|
||||||
bls_aggregate_pubkeys([state.validators[i].pubkey for i in indices]),
|
message_hash=hash_tree_root(indexed_attestation.data),
|
||||||
],
|
|
||||||
message_hashes=[
|
|
||||||
hash_tree_root(AttestationDataAndCustodyBit(data=indexed_attestation.data, custody_bit=0b0)),
|
|
||||||
],
|
|
||||||
signature=indexed_attestation.signature,
|
signature=indexed_attestation.signature,
|
||||||
domain=get_domain(state, DOMAIN_BEACON_ATTESTER, indexed_attestation.data.target.epoch),
|
domain=get_domain(state, DOMAIN_BEACON_ATTESTER, indexed_attestation.data.target.epoch),
|
||||||
):
|
):
|
||||||
|
|
|
@ -45,7 +45,6 @@
|
||||||
- [Construct attestation](#construct-attestation)
|
- [Construct attestation](#construct-attestation)
|
||||||
- [Data](#data)
|
- [Data](#data)
|
||||||
- [Aggregation bits](#aggregation-bits)
|
- [Aggregation bits](#aggregation-bits)
|
||||||
- [Custody bits](#custody-bits)
|
|
||||||
- [Aggregate signature](#aggregate-signature)
|
- [Aggregate signature](#aggregate-signature)
|
||||||
- [Broadcast attestation](#broadcast-attestation)
|
- [Broadcast attestation](#broadcast-attestation)
|
||||||
- [Attestation aggregation](#attestation-aggregation)
|
- [Attestation aggregation](#attestation-aggregation)
|
||||||
|
@ -53,7 +52,6 @@
|
||||||
- [Construct aggregate](#construct-aggregate)
|
- [Construct aggregate](#construct-aggregate)
|
||||||
- [Data](#data-1)
|
- [Data](#data-1)
|
||||||
- [Aggregation bits](#aggregation-bits-1)
|
- [Aggregation bits](#aggregation-bits-1)
|
||||||
- [Custody bits](#custody-bits-1)
|
|
||||||
- [Aggregate signature](#aggregate-signature-1)
|
- [Aggregate signature](#aggregate-signature-1)
|
||||||
- [Broadcast aggregate](#broadcast-aggregate)
|
- [Broadcast aggregate](#broadcast-aggregate)
|
||||||
- [`AggregateAndProof`](#aggregateandproof)
|
- [`AggregateAndProof`](#aggregateandproof)
|
||||||
|
@ -331,25 +329,14 @@ Set `attestation.data = attestation_data` where `attestation_data` is the `Attes
|
||||||
|
|
||||||
*Note*: Calling `get_attesting_indices(state, attestation.data, attestation.aggregation_bits)` should return a list of length equal to 1, containing `validator_index`.
|
*Note*: Calling `get_attesting_indices(state, attestation.data, attestation.aggregation_bits)` should return a list of length equal to 1, containing `validator_index`.
|
||||||
|
|
||||||
##### Custody bits
|
|
||||||
|
|
||||||
- Let `attestation.custody_bits` be a `Bitlist[MAX_VALIDATORS_PER_COMMITTEE]` filled with zeros of length `len(committee)`.
|
|
||||||
|
|
||||||
*Note*: This is a stub for Phase 0.
|
|
||||||
|
|
||||||
##### Aggregate signature
|
##### Aggregate signature
|
||||||
|
|
||||||
Set `attestation.signature = signed_attestation_data` where `signed_attestation_data` is obtained from:
|
Set `attestation.signature = signed_attestation_data` where `signed_attestation_data` is obtained from:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
def get_signed_attestation_data(state: BeaconState, attestation: IndexedAttestation, privkey: int) -> BLSSignature:
|
def get_signed_attestation_data(state: BeaconState, attestation: IndexedAttestation, privkey: int) -> BLSSignature:
|
||||||
attestation_data_and_custody_bit = AttestationDataAndCustodyBit(
|
|
||||||
data=attestation.data,
|
|
||||||
custody_bit=0b0,
|
|
||||||
)
|
|
||||||
|
|
||||||
domain = get_domain(state, DOMAIN_BEACON_ATTESTER, attestation.data.target.epoch)
|
domain = get_domain(state, DOMAIN_BEACON_ATTESTER, attestation.data.target.epoch)
|
||||||
return bls_sign(privkey, hash_tree_root(attestation_data_and_custody_bit), domain)
|
return bls_sign(privkey, hash_tree_root(attestation.data), domain)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Broadcast attestation
|
#### Broadcast attestation
|
||||||
|
@ -391,12 +378,6 @@ Set `aggregate_attestation.data = attestation_data` where `attestation_data` is
|
||||||
|
|
||||||
Let `aggregate_attestation.aggregation_bits` be a `Bitlist[MAX_VALIDATORS_PER_COMMITTEE]` of length `len(committee)`, where each bit set from each individual attestation is set to `0b1`.
|
Let `aggregate_attestation.aggregation_bits` be a `Bitlist[MAX_VALIDATORS_PER_COMMITTEE]` of length `len(committee)`, where each bit set from each individual attestation is set to `0b1`.
|
||||||
|
|
||||||
##### Custody bits
|
|
||||||
|
|
||||||
- Let `aggregate_attestation.custody_bits` be a `Bitlist[MAX_VALIDATORS_PER_COMMITTEE]` filled with zeros of length `len(committee)`.
|
|
||||||
|
|
||||||
*Note*: This is a stub for Phase 0.
|
|
||||||
|
|
||||||
##### Aggregate signature
|
##### Aggregate signature
|
||||||
|
|
||||||
Set `aggregate_attestation.signature = aggregate_signature` where `aggregate_signature` is obtained from:
|
Set `aggregate_attestation.signature = aggregate_signature` where `aggregate_signature` is obtained from:
|
||||||
|
|
|
@ -9,7 +9,7 @@ def test_decoder():
|
||||||
rng = Random(123)
|
rng = Random(123)
|
||||||
|
|
||||||
# check these types only, Block covers a lot of operation types already.
|
# check these types only, Block covers a lot of operation types already.
|
||||||
for typ in [spec.AttestationDataAndCustodyBit, spec.BeaconState, spec.BeaconBlock]:
|
for typ in [spec.Attestation, spec.BeaconState, spec.BeaconBlock]:
|
||||||
# create a random pyspec value
|
# create a random pyspec value
|
||||||
original = random_value.get_random_ssz_object(rng, typ, 100, 10,
|
original = random_value.get_random_ssz_object(rng, typ, 100, 10,
|
||||||
mode=random_value.RandomizationMode.mode_random,
|
mode=random_value.RandomizationMode.mode_random,
|
||||||
|
|
|
@ -95,14 +95,9 @@ def sign_attestation(spec, state, attestation):
|
||||||
attestation.signature = sign_aggregate_attestation(spec, state, attestation.data, participants)
|
attestation.signature = sign_aggregate_attestation(spec, state, attestation.data, participants)
|
||||||
|
|
||||||
|
|
||||||
def get_attestation_signature(spec, state, attestation_data, privkey, custody_bit=0b0):
|
def get_attestation_signature(spec, state, attestation_data, privkey):
|
||||||
message_hash = spec.AttestationDataAndCustodyBit(
|
|
||||||
data=attestation_data,
|
|
||||||
custody_bit=custody_bit,
|
|
||||||
).hash_tree_root()
|
|
||||||
|
|
||||||
return bls_sign(
|
return bls_sign(
|
||||||
message_hash=message_hash,
|
message_hash=attestation_data.hash_tree_root(),
|
||||||
privkey=privkey,
|
privkey=privkey,
|
||||||
domain=spec.get_domain(
|
domain=spec.get_domain(
|
||||||
state=state,
|
state=state,
|
||||||
|
|
|
@ -2,7 +2,7 @@ from eth2spec.test.context import (
|
||||||
spec_state_test,
|
spec_state_test,
|
||||||
expect_assertion_error,
|
expect_assertion_error,
|
||||||
always_bls, never_bls,
|
always_bls, never_bls,
|
||||||
with_all_phases, with_phases,
|
with_all_phases,
|
||||||
spec_test,
|
spec_test,
|
||||||
low_balances,
|
low_balances,
|
||||||
with_custom_state,
|
with_custom_state,
|
||||||
|
|
Loading…
Reference in New Issue