add chunk challenge and response to block and operations

This commit is contained in:
Danny Ryan 2020-05-19 07:50:05 -06:00
parent 3851a26a0f
commit 3f0e58a8ed
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A
4 changed files with 10 additions and 5 deletions

View File

@ -214,6 +214,8 @@ MAX_REVEAL_LATENESS_DECREMENT: 128
# 2**8 (= 256) # 2**8 (= 256)
MAX_CUSTODY_KEY_REVEALS: 256 MAX_CUSTODY_KEY_REVEALS: 256
MAX_EARLY_DERIVED_SECRET_REVEALS: 1 MAX_EARLY_DERIVED_SECRET_REVEALS: 1
MAX_CUSTODY_CHUNK_CHALLENGES: 4
MAX_CUSTODY_CHUNK_CHALLENGE_RESP: 16
MAX_CUSTODY_SLASHINGS: 1 MAX_CUSTODY_SLASHINGS: 1
# Reward and penalty quotients # Reward and penalty quotients

View File

@ -215,6 +215,8 @@ CUSTODY_PERIOD_TO_RANDAO_PADDING: 8
# 2**8 (= 256) # 2**8 (= 256)
MAX_CUSTODY_KEY_REVEALS: 256 MAX_CUSTODY_KEY_REVEALS: 256
MAX_EARLY_DERIVED_SECRET_REVEALS: 1 MAX_EARLY_DERIVED_SECRET_REVEALS: 1
MAX_CUSTODY_CHUNK_CHALLENGES: 2
MAX_CUSTODY_CHUNK_CHALLENGE_RESP: 8
MAX_CUSTODY_SLASHINGS: 1 MAX_CUSTODY_SLASHINGS: 1
# Reward and penalty quotients # Reward and penalty quotients

View File

@ -215,9 +215,11 @@ class BeaconBlockBody(Container):
deposits: List[Deposit, MAX_DEPOSITS] deposits: List[Deposit, MAX_DEPOSITS]
voluntary_exits: List[SignedVoluntaryExit, MAX_VOLUNTARY_EXITS] voluntary_exits: List[SignedVoluntaryExit, MAX_VOLUNTARY_EXITS]
# Custody game # Custody game
custody_slashings: List[SignedCustodySlashing, MAX_CUSTODY_SLASHINGS] chunk_challenges: List[CustodyChunkResponse, MAX_CUSTODY_CHUNK_CHALLENGES]
chunk_challenge_responses: List[CustodyChunkResponse, MAX_CUSTODY_CHUNK_CHALLENGE_RESPONSES]
custody_key_reveals: List[CustodyKeyReveal, MAX_CUSTODY_KEY_REVEALS] custody_key_reveals: List[CustodyKeyReveal, MAX_CUSTODY_KEY_REVEALS]
early_derived_secret_reveals: List[EarlyDerivedSecretReveal, MAX_EARLY_DERIVED_SECRET_REVEALS] early_derived_secret_reveals: List[EarlyDerivedSecretReveal, MAX_EARLY_DERIVED_SECRET_REVEALS]
custody_slashings: List[SignedCustodySlashing, MAX_CUSTODY_SLASHINGS]
# Shards # Shards
shard_transitions: Vector[ShardTransition, MAX_SHARDS] shard_transitions: Vector[ShardTransition, MAX_SHARDS]
# Light clients # Light clients

View File

@ -81,6 +81,7 @@ This document details the beacon chain additions and changes in Phase 1 of Ether
| `MAX_CUSTODY_KEY_REVEALS` | `2**8` (= 256) | | `MAX_CUSTODY_KEY_REVEALS` | `2**8` (= 256) |
| `MAX_EARLY_DERIVED_SECRET_REVEALS` | `1` | | `MAX_EARLY_DERIVED_SECRET_REVEALS` | `1` |
| `MAX_CUSTODY_CHUNK_CHALLENGES` | `2**2` (= 4) | | `MAX_CUSTODY_CHUNK_CHALLENGES` | `2**2` (= 4) |
| `MAX_CUSTODY_CHUNK_CHALLENGE_RESPONSES` | `2**4` (= 16) |
| `MAX_CUSTODY_SLASHINGS` | `1` | | `MAX_CUSTODY_SLASHINGS` | `1` |
### Reward and penalty quotients ### Reward and penalty quotients
@ -297,6 +298,8 @@ def process_custody_game_operations(state: BeaconState, body: BeaconBlockBody) -
for operation in operations: for operation in operations:
fn(state, operation) fn(state, operation)
for_ops(body.chunk_challenges, process_chunk_challenge)
for_ops(body.chunk_challenge_responses, process_chunk_challenge)
for_ops(body.custody_key_reveals, process_custody_key_reveal) for_ops(body.custody_key_reveals, process_custody_key_reveal)
for_ops(body.early_derived_secret_reveals, process_early_derived_secret_reveal) for_ops(body.early_derived_secret_reveals, process_early_derived_secret_reveal)
for_ops(body.custody_slashings, process_custody_slashing) for_ops(body.custody_slashings, process_custody_slashing)
@ -304,10 +307,6 @@ def process_custody_game_operations(state: BeaconState, body: BeaconBlockBody) -
#### Chunk challenges #### Chunk challenges
Verify that `len(block.body.custody_chunk_challenges) <= MAX_CUSTODY_CHUNK_CHALLENGES`.
For each `challenge` in `block.body.custody_chunk_challenges`, run the following function:
```python ```python
def process_chunk_challenge(state: BeaconState, challenge: CustodyChunkChallenge) -> None: def process_chunk_challenge(state: BeaconState, challenge: CustodyChunkChallenge) -> None:
# Verify the attestation # Verify the attestation