modify phase 1 to use new signature (no signing_root) pattern

This commit is contained in:
Danny Ryan 2019-12-05 13:49:52 -07:00
parent a32b0100ff
commit e31f17f037
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A
3 changed files with 23 additions and 8 deletions

View File

@ -51,10 +51,7 @@ from dataclasses import (
field,
)
from eth2spec.utils.ssz.ssz_impl import (
hash_tree_root,
is_zero,
)
from eth2spec.utils.ssz.ssz_impl import hash_tree_root
from eth2spec.utils.ssz.ssz_typing import (
BasicValue, Elements, BaseBytes, BaseList, SSZType,
Container, List, Vector, ByteList, ByteVector, Bitlist, Bitvector, Bits,

View File

@ -128,9 +128,9 @@ class BeaconBlockBody(Container):
attestations: List[Attestation, MAX_ATTESTATIONS]
# Entry & exit
deposits: List[Deposit, MAX_DEPOSITS]
voluntary_exits: List[VoluntaryExit, MAX_VOLUNTARY_EXITS]
voluntary_exits: List[SignedVoluntaryExit, MAX_VOLUNTARY_EXITS]
# Custody game
custody_slashings: List[CustodySlashing, MAX_CUSTODY_SLASHINGS]
custody_slashings: List[SignedCustodySlashing, MAX_CUSTODY_SLASHINGS]
custody_key_reveals: List[CustodyKeyReveal, MAX_CUSTODY_KEY_REVEALS]
early_derived_secret_reveals: List[EarlyDerivedSecretReveal, MAX_EARLY_DERIVED_SECRET_REVEALS]
# Shards
@ -150,6 +150,15 @@ class BeaconBlock(Container):
parent_root: Root
state_root: Root
body: BeaconBlockBody
```
#### Extended `SignedBeaconBlock`
Note that the `message` has a new `BeaconBlock` definition.
```python
class SignedBeaconBlock(Container):
message: BeaconBlock
signature: BLSSignature
```

View File

@ -101,9 +101,17 @@ class CustodySlashing(Container):
shard_transition: ShardTransition
attestation: Attestation
data: ByteList[MAX_SHARD_BLOCK_CHUNKS * SHARD_BLOCK_CHUNK_SIZE]
```
#### `SignedCustodySlashing`
```python
class SignedCustodySlashing(Container):
message: CustodySlashing
signature: BLSSignature
```
#### `CustodyKeyReveal`
```python
@ -347,7 +355,8 @@ def process_early_derived_secret_reveal(state: BeaconState, reveal: EarlyDerived
#### Custody Slashings
```python
def process_custody_slashing(state: BeaconState, custody_slashing: CustodySlashing) -> None:
def process_custody_slashing(state: BeaconState, signed_custody_slashing: SignedCustodySlashing) -> None:
custody_slashing = signed_custody_slashing.message
attestation = custody_slashing.attestation
# Any signed custody-slashing should result in at least one slashing.
@ -355,7 +364,7 @@ def process_custody_slashing(state: BeaconState, custody_slashing: CustodySlashi
malefactor = state.validators[custody_slashing.malefactor_index]
whistleblower = state.validators[custody_slashing.whistleblower_index]
domain = get_domain(state, DOMAIN_CUSTODY_BIT_SLASHING, get_current_epoch(state))
assert bls_verify(whistleblower.pubkey, signing_root(custody_slashing), custody_slashing.signature, domain)
assert bls_verify(whistleblower.pubkey, hash_tree_root(custody_slashing), signed_custody_slashing.signature, domain)
# Verify that the whistleblower is slashable
assert is_slashable_validator(whistleblower, get_current_epoch(state))
# Verify that the claimed malefactor is slashable