From e31f17f03700da5c5edf3a555c4951ee8ee1059f Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Thu, 5 Dec 2019 13:49:52 -0700 Subject: [PATCH] modify phase 1 to use new signature (no signing_root) pattern --- scripts/build_spec.py | 5 +---- specs/core/1_beacon-chain.md | 13 +++++++++++-- specs/core/1_custody-game.md | 13 +++++++++++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/scripts/build_spec.py b/scripts/build_spec.py index b88104140..b1a8b3485 100644 --- a/scripts/build_spec.py +++ b/scripts/build_spec.py @@ -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, diff --git a/specs/core/1_beacon-chain.md b/specs/core/1_beacon-chain.md index 6837987b1..3e88d01da 100644 --- a/specs/core/1_beacon-chain.md +++ b/specs/core/1_beacon-chain.md @@ -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 ``` diff --git a/specs/core/1_custody-game.md b/specs/core/1_custody-game.md index aa96b387f..60d63db03 100644 --- a/specs/core/1_custody-game.md +++ b/specs/core/1_custody-game.md @@ -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