From 3851a26a0fa1e8c860956ba4da893608a3126752 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Tue, 19 May 2020 07:33:07 -0600 Subject: [PATCH] add phase 1 custody objects to custody-game.md --- specs/phase1/beacon-chain.md | 99 +----------------------------------- specs/phase1/custody-game.md | 92 +++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 98 deletions(-) diff --git a/specs/phase1/beacon-chain.md b/specs/phase1/beacon-chain.md index 278efda28..27a9229dd 100644 --- a/specs/phase1/beacon-chain.md +++ b/specs/phase1/beacon-chain.md @@ -12,14 +12,6 @@ - [Custom types](#custom-types) - [Configuration](#configuration) - [Misc](#misc) -- [New containers](#new-containers) - - [`CustodyChunkChallenge`](#custodychunkchallenge) - - [`CustodyChunkChallengeRecord`](#custodychunkchallengerecord) - - [`CustodyChunkResponse`](#custodychunkresponse) - - [`CustodySlashing`](#custodyslashing) - - [`SignedCustodySlashing`](#signedcustodyslashing) - - [`CustodyKeyReveal`](#custodykeyreveal) - - [`EarlyDerivedSecretReveal`](#earlyderivedsecretreveal) - [Updated containers](#updated-containers) - [Extended `AttestationData`](#extended-attestationdata) - [Extended `Attestation`](#extended-attestation) @@ -31,7 +23,7 @@ - [Extended `BeaconBlock`](#extended-beaconblock) - [Extended `SignedBeaconBlock`](#extended-signedbeaconblock) - [Extended `BeaconState`](#extended-beaconstate) -- [New containers](#new-containers-1) +- [New containers](#new-containers) - [`ShardBlock`](#shardblock) - [`SignedShardBlock`](#signedshardblock) - [`ShardBlockHeader`](#shardblockheader) @@ -124,95 +116,6 @@ Configuration is not namespaced. Instead it is strictly an extension; | `BYTES_PER_CUSTODY_CHUNK` | `2**12` | bytes | | `CUSTODY_RESPONSE_DEPTH` | `ceillog2(MAX_SHARD_BLOCK_SIZE // BYTES_PER_CUSTODY_CHUNK) | - | - | - - -## New containers - -### `CustodyChunkChallenge` - -```python -class CustodyChunkChallenge(Container): - responder_index: ValidatorIndex - shard_transition: ShardTransition - attestation: Attestation - data_index: uint64 - chunk_index: uint64 -``` - -### `CustodyChunkChallengeRecord` - -```python -class CustodyChunkChallengeRecord(Container): - challenge_index: uint64 - challenger_index: ValidatorIndex - responder_index: ValidatorIndex - inclusion_epoch: Epoch - data_root: Root - chunk_index: uint64 -``` - -#### `CustodyChunkResponse` - -```python -class CustodyChunkResponse(Container): - challenge_index: uint64 - chunk_index: uint64 - chunk: ByteVector[BYTES_PER_CUSTODY_CHUNK] - branch: Vector[Root, CUSTODY_RESPONSE_DEPTH] -``` - -#### `CustodySlashing` - -```python -class CustodySlashing(Container): - # Attestation.custody_bits_blocks[data_index][committee.index(malefactor_index)] is the target custody bit to check. - # (Attestation.data.shard_transition_root as ShardTransition).shard_data_roots[data_index] is the root of the data. - data_index: uint64 - malefactor_index: ValidatorIndex - malefactor_secret: BLSSignature - whistleblower_index: ValidatorIndex - shard_transition: ShardTransition - attestation: Attestation - data: ByteList[MAX_SHARD_BLOCK_SIZE] -``` - -#### `SignedCustodySlashing` - -```python -class SignedCustodySlashing(Container): - message: CustodySlashing - signature: BLSSignature -``` - - -#### `CustodyKeyReveal` - -```python -class CustodyKeyReveal(Container): - # Index of the validator whose key is being revealed - revealer_index: ValidatorIndex - # Reveal (masked signature) - reveal: BLSSignature -``` - -#### `EarlyDerivedSecretReveal` - -Represents an early (punishable) reveal of one of the derived secrets, where derived secrets are RANDAO reveals and custody reveals (both are part of the same domain). - -```python -class EarlyDerivedSecretReveal(Container): - # Index of the validator whose key is being revealed - revealed_index: ValidatorIndex - # RANDAO epoch of the key that is being revealed - epoch: Epoch - # Reveal (masked signature) - reveal: BLSSignature - # Index of the validator who revealed (whistleblower) - masker_index: ValidatorIndex - # Mask used to hide the actual reveal signature (prevent reveal from being stolen) - mask: Bytes32 -``` - ## Updated containers The following containers have updated definitions in Phase 1. diff --git a/specs/phase1/custody-game.md b/specs/phase1/custody-game.md index c81c6a17b..96a7f5616 100644 --- a/specs/phase1/custody-game.md +++ b/specs/phase1/custody-game.md @@ -18,6 +18,13 @@ - [Signature domain types](#signature-domain-types) - [Data structures](#data-structures) - [New Beacon Chain operations](#new-beacon-chain-operations) + - [`CustodyChunkChallenge`](#custodychunkchallenge) + - [`CustodyChunkChallengeRecord`](#custodychunkchallengerecord) + - [`CustodyChunkResponse`](#custodychunkresponse) + - [`CustodySlashing`](#custodyslashing) + - [`SignedCustodySlashing`](#signedcustodyslashing) + - [`CustodyKeyReveal`](#custodykeyreveal) + - [`EarlyDerivedSecretReveal`](#earlyderivedsecretreveal) - [Helpers](#helpers) - [`replace_empty_or_append`](#replace_empty_or_append) - [`legendre_bit`](#legendre_bit) @@ -95,6 +102,91 @@ The following types are defined, mapping into `DomainType` (little endian): ### New Beacon Chain operations +#### `CustodyChunkChallenge` + +```python +class CustodyChunkChallenge(Container): + responder_index: ValidatorIndex + shard_transition: ShardTransition + attestation: Attestation + data_index: uint64 + chunk_index: uint64 +``` + +#### `CustodyChunkChallengeRecord` + +```python +class CustodyChunkChallengeRecord(Container): + challenge_index: uint64 + challenger_index: ValidatorIndex + responder_index: ValidatorIndex + inclusion_epoch: Epoch + data_root: Root + chunk_index: uint64 +``` + +#### `CustodyChunkResponse` + +```python +class CustodyChunkResponse(Container): + challenge_index: uint64 + chunk_index: uint64 + chunk: ByteVector[BYTES_PER_CUSTODY_CHUNK] + branch: Vector[Root, CUSTODY_RESPONSE_DEPTH] +``` + +#### `CustodySlashing` + +```python +class CustodySlashing(Container): + # Attestation.custody_bits_blocks[data_index][committee.index(malefactor_index)] is the target custody bit to check. + # (Attestation.data.shard_transition_root as ShardTransition).shard_data_roots[data_index] is the root of the data. + data_index: uint64 + malefactor_index: ValidatorIndex + malefactor_secret: BLSSignature + whistleblower_index: ValidatorIndex + shard_transition: ShardTransition + attestation: Attestation + data: ByteList[MAX_SHARD_BLOCK_SIZE] +``` + +#### `SignedCustodySlashing` + +```python +class SignedCustodySlashing(Container): + message: CustodySlashing + signature: BLSSignature +``` + +#### `CustodyKeyReveal` + +```python +class CustodyKeyReveal(Container): + # Index of the validator whose key is being revealed + revealer_index: ValidatorIndex + # Reveal (masked signature) + reveal: BLSSignature +``` + +#### `EarlyDerivedSecretReveal` + +Represents an early (punishable) reveal of one of the derived secrets, where derived secrets are RANDAO reveals and custody reveals (both are part of the same domain). + +```python +class EarlyDerivedSecretReveal(Container): + # Index of the validator whose key is being revealed + revealed_index: ValidatorIndex + # RANDAO epoch of the key that is being revealed + epoch: Epoch + # Reveal (masked signature) + reveal: BLSSignature + # Index of the validator who revealed (whistleblower) + masker_index: ValidatorIndex + # Mask used to hide the actual reveal signature (prevent reveal from being stolen) + mask: Bytes32 +``` + + ## Helpers ### `replace_empty_or_append`