Merge pull request #349 from ethereum/vbuterin-patch-17

Proof of custody placeholders
This commit is contained in:
Danny Ryan 2018-12-22 07:08:18 -06:00 committed by GitHub
commit d0b5133912
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 36 additions and 2 deletions

View File

@ -100,6 +100,7 @@
- [Attestations](#attestations-1) - [Attestations](#attestations-1)
- [Deposits](#deposits-1) - [Deposits](#deposits-1)
- [Exits](#exits-1) - [Exits](#exits-1)
- [Miscellaneous](#miscellaneous)
- [Per-epoch processing](#per-epoch-processing) - [Per-epoch processing](#per-epoch-processing)
- [Helpers](#helpers) - [Helpers](#helpers)
- [Receipt roots](#receipt-roots) - [Receipt roots](#receipt-roots)
@ -377,6 +378,8 @@ Unless otherwise indicated, code appearing in `this style` is to be interpreted
'withdrawal_credentials': 'hash32', 'withdrawal_credentials': 'hash32',
# Initial RANDAO commitment # Initial RANDAO commitment
'randao_commitment': 'hash32', 'randao_commitment': 'hash32',
# Initial proof of custody commitment
'poc_commitment': 'hash32',
# a BLS signature of this ``DepositInput`` # a BLS signature of this ``DepositInput``
'proof_of_possession': ['uint384'], 'proof_of_possession': ['uint384'],
} }
@ -423,11 +426,16 @@ Unless otherwise indicated, code appearing in `this style` is to be interpreted
'proposer_slashings': [ProposerSlashing], 'proposer_slashings': [ProposerSlashing],
'casper_slashings': [CasperSlashing], 'casper_slashings': [CasperSlashing],
'attestations': [Attestation], 'attestations': [Attestation],
'poc_seed_changes': [ProofOfCustodySeedChange],
'poc_challenges': [ProofOfCustodyChallenge],
'poc_responses': [ProofOfCustodyResponse],
'deposits': [Deposit], 'deposits': [Deposit],
'exits': [Exit], 'exits': [Exit],
} }
``` ```
`ProofOfCustodySeedChange`, `ProofOfCustodyChallenge`, and `ProofOfCustodyResponse` will be defined in phase 1; for now, put dummy classes as these lists will remain empty throughout phase 0.
#### `ProposalSignedData` #### `ProposalSignedData`
```python ```python
@ -466,6 +474,11 @@ Unless otherwise indicated, code appearing in `this style` is to be interpreted
'persistent_committees': [['uint24']], 'persistent_committees': [['uint24']],
'persistent_committee_reassignments': [ShardReassignmentRecord], 'persistent_committee_reassignments': [ShardReassignmentRecord],
# Proof of custody
# Placeholders for now; ProofOfCustodyChallenge is defined in phase 1, implementers can
# put a dummy class in for now, as the list will remain empty throughout phase 0
'poc_challenges': [ProofOfCustodyChallenge],
# Finality # Finality
'previous_justified_slot': 'uint64', 'previous_justified_slot': 'uint64',
'justified_slot': 'uint64', 'justified_slot': 'uint64',
@ -503,6 +516,11 @@ Unless otherwise indicated, code appearing in `this style` is to be interpreted
'latest_status_change_slot': 'uint64', 'latest_status_change_slot': 'uint64',
# Exit counter when validator exited (or 0) # Exit counter when validator exited (or 0)
'exit_count': 'uint64', 'exit_count': 'uint64',
# Proof of custody commitment
'poc_commitment': 'hash32',
# Slot the proof of custody seed was last changed
'last_poc_change_slot': 'uint64',
'second_last_poc_change_slot': 'uint64',
} }
``` ```
@ -1116,6 +1134,9 @@ A valid block with slot `INITIAL_SLOT_NUMBER` (a "genesis block") has the follow
proposer_slashings=[], proposer_slashings=[],
casper_slashings=[], casper_slashings=[],
attestations=[], attestations=[],
poc_seed_changes=[],
poc_challenges=[],
poc_responses=[],
deposits=[], deposits=[],
exits=[] exits=[]
), ),
@ -1152,6 +1173,9 @@ def get_initial_beacon_state(initial_validator_deposits: List[Deposit],
persistent_committees=[], persistent_committees=[],
persistent_committee_reassignments=[], persistent_committee_reassignments=[],
# Proof of custody
poc_challenges=[],
# Finality # Finality
previous_justified_slot=INITIAL_SLOT_NUMBER, previous_justified_slot=INITIAL_SLOT_NUMBER,
justified_slot=INITIAL_SLOT_NUMBER, justified_slot=INITIAL_SLOT_NUMBER,
@ -1241,6 +1265,7 @@ def process_deposit(state: BeaconState,
deposit: int, deposit: int,
proof_of_possession: bytes, proof_of_possession: bytes,
withdrawal_credentials: Hash32, withdrawal_credentials: Hash32,
poc_commitment: Hash32,
randao_commitment: Hash32) -> int: randao_commitment: Hash32) -> int:
""" """
Process a deposit from Ethereum 1.0. Process a deposit from Ethereum 1.0.
@ -1266,7 +1291,10 @@ def process_deposit(state: BeaconState,
randao_layers=0, randao_layers=0,
status=PENDING_ACTIVATION, status=PENDING_ACTIVATION,
latest_status_change_slot=state.slot, latest_status_change_slot=state.slot,
exit_count=0 exit_count=0,
poc_commitment=poc_commitment,
last_poc_change_slot=0,
second_last_poc_change_slot=0,
) )
index = min_empty_validator_index(state.validator_registry, state.validator_balances, state.slot) index = min_empty_validator_index(state.validator_registry, state.validator_balances, state.slot)
@ -1518,7 +1546,9 @@ process_deposit(
deposit=deposit.deposit_data.value, deposit=deposit.deposit_data.value,
proof_of_possession=deposit.deposit_data.deposit_input.proof_of_possession, proof_of_possession=deposit.deposit_data.deposit_input.proof_of_possession,
withdrawal_credentials=deposit.deposit_data.deposit_input.withdrawal_credentials, withdrawal_credentials=deposit.deposit_data.deposit_input.withdrawal_credentials,
randao_commitment=deposit.deposit_data.deposit_input.randao_commitment poc_commitment=deposit.deposit_data.deposit_input.poc_commitment,
randao_commitment=deposit.deposit_data.deposit_input.randao_commitment,
) )
``` ```
@ -1535,6 +1565,10 @@ For each `exit` in `block.body.exits`:
* Verify that `bls_verify(pubkey=validator.pubkey, message=ZERO_HASH, signature=exit.signature, domain=get_domain(state.fork_data, exit.slot, DOMAIN_EXIT))`. * Verify that `bls_verify(pubkey=validator.pubkey, message=ZERO_HASH, signature=exit.signature, domain=get_domain(state.fork_data, exit.slot, DOMAIN_EXIT))`.
* Run `update_validator_status(state, validator_index, new_status=ACTIVE_PENDING_EXIT)`. * Run `update_validator_status(state, validator_index, new_status=ACTIVE_PENDING_EXIT)`.
#### Miscellaneous
[TO BE REMOVED IN PHASE 1] Verify that `len(block.body.poc_seed_changes) == len(block.body.poc_challenges) == len(block.body.poc_responses) == 0`.
## Per-epoch processing ## Per-epoch processing
The steps below happen when `state.slot % EPOCH_LENGTH == 0`. The steps below happen when `state.slot % EPOCH_LENGTH == 0`.