From 985c8a2c3066bb98c84c92f0a66bd7c297440abe Mon Sep 17 00:00:00 2001 From: vbuterin Date: Thu, 20 Dec 2018 16:01:00 -0500 Subject: [PATCH 1/5] Proof of custody placeholders Replacing #145 --- specs/core/0_beacon-chain.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 91c1aecf8..ee5f16dd9 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -418,11 +418,16 @@ Unless otherwise indicated, code appearing in `this style` is to be interpreted #### `BeaconBlockBody` +`ProofOfCustodySeedChange`, `ProofOfCustodyChallenge`, `ProofOfCustodyResponse` defined in phase 1; for now put dummy classes as these lists will remain empty throughout phase 0. + ```python { 'proposer_slashings': [ProposerSlashing], 'casper_slashings': [CasperSlashing], 'attestations': [Attestation], + 'poc_seed_changes': [ProofOfCustodySeedChange], + 'poc_challenges': [ProofOfCustodyChallenge], + 'poc_responses': [ProofOfCustodyResponse], 'deposits': [Deposit], 'exits': [Exit], } @@ -465,6 +470,16 @@ Unless otherwise indicated, code appearing in `this style` is to be interpreted 'persistent_committees': [['uint24']], '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], + # 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', + # Finality 'previous_justified_slot': 'uint64', 'justified_slot': 'uint64', @@ -1533,6 +1548,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))`. * 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 The steps below happen when `state.slot % EPOCH_LENGTH == 0`. From ac0b8aac074cc2710f3c0aa07773cc516f4ea949 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Fri, 21 Dec 2018 16:41:48 +0800 Subject: [PATCH 2/5] Add initial setting of proof of custody placeholders --- specs/core/0_beacon-chain.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index ee5f16dd9..049e513b6 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -100,6 +100,7 @@ - [Attestations](#attestations-1) - [Deposits](#deposits-1) - [Exits](#exits-1) + - [Miscellaneous](#miscellaneous) - [Per-epoch processing](#per-epoch-processing) - [Helpers](#helpers) - [Receipt roots](#receipt-roots) @@ -418,7 +419,7 @@ Unless otherwise indicated, code appearing in `this style` is to be interpreted #### `BeaconBlockBody` -`ProofOfCustodySeedChange`, `ProofOfCustodyChallenge`, `ProofOfCustodyResponse` defined in phase 1; for now put dummy classes as these lists will remain empty throughout phase 0. +`ProofOfCustodySeedChange`, `ProofOfCustodyChallenge`, and `ProofOfCustodyResponse` will be defined in phase 1; for now put dummy classes as these lists will remain empty throughout phase 0. ```python { @@ -1130,6 +1131,9 @@ A valid block with slot `INITIAL_SLOT_NUMBER` (a "genesis block") has the follow proposer_slashings=[], casper_slashings=[], attestations=[], + poc_seed_changes=[], + poc_challenges=[], + poc_responses=[], deposits=[], exits=[] ), @@ -1165,6 +1169,12 @@ def get_initial_beacon_state(initial_validator_deposits: List[Deposit], persistent_committees=[], persistent_committee_reassignments=[], + # Proof of custody + poc_challenges=[], + poc_commitment=ZERO_HASH, + last_poc_change_slot=0, + second_last_poc_change_slot=0, + # Finality previous_justified_slot=INITIAL_SLOT_NUMBER, justified_slot=INITIAL_SLOT_NUMBER, From 1d1db908e2665f9e8f44d73e04579aa20f7d98d5 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Fri, 21 Dec 2018 16:43:59 +0800 Subject: [PATCH 3/5] Fix grammar --- specs/core/0_beacon-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 049e513b6..48425183c 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -419,7 +419,7 @@ Unless otherwise indicated, code appearing in `this style` is to be interpreted #### `BeaconBlockBody` -`ProofOfCustodySeedChange`, `ProofOfCustodyChallenge`, and `ProofOfCustodyResponse` will be defined in phase 1; for now put dummy classes as these lists will remain empty throughout phase 0. +`ProofOfCustodySeedChange`, `ProofOfCustodyChallenge`, and `ProofOfCustodyResponse` will be defined in phase 1; for now, put dummy classes as these lists will remain empty throughout phase 0. ```python { From 5fc8f6cfcaa8c08863009734e2f2a9a4ac1d05fc Mon Sep 17 00:00:00 2001 From: vbuterin Date: Fri, 21 Dec 2018 11:26:40 -0500 Subject: [PATCH 4/5] Fixed deposit inclusion and positioning of state variables --- specs/core/0_beacon-chain.md | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 48425183c..5aa9f1aea 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -378,6 +378,8 @@ Unless otherwise indicated, code appearing in `this style` is to be interpreted 'withdrawal_credentials': 'hash32', # Initial RANDAO commitment 'randao_commitment': 'hash32', + # Initial proof of custody commitment + 'poc_commitment': 'hash32', # a BLS signature of this ``DepositInput`` 'proof_of_possession': ['uint384'], } @@ -475,11 +477,6 @@ Unless otherwise indicated, code appearing in `this style` is to be interpreted # 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], - # 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', # Finality 'previous_justified_slot': 'uint64', @@ -518,6 +515,11 @@ Unless otherwise indicated, code appearing in `this style` is to be interpreted 'latest_status_change_slot': 'uint64', # Exit counter when validator exited (or 0) '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', } ``` @@ -1171,9 +1173,6 @@ def get_initial_beacon_state(initial_validator_deposits: List[Deposit], # Proof of custody poc_challenges=[], - poc_commitment=ZERO_HASH, - last_poc_change_slot=0, - second_last_poc_change_slot=0, # Finality previous_justified_slot=INITIAL_SLOT_NUMBER, @@ -1264,6 +1263,7 @@ def process_deposit(state: BeaconState, deposit: int, proof_of_possession: bytes, withdrawal_credentials: Hash32, + poc_commitment: Hash32, randao_commitment: Hash32) -> int: """ Process a deposit from Ethereum 1.0. @@ -1289,7 +1289,10 @@ def process_deposit(state: BeaconState, randao_layers=0, status=PENDING_ACTIVATION, 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) @@ -1541,7 +1544,9 @@ process_deposit( deposit=deposit.deposit_data.value, proof_of_possession=deposit.deposit_data.deposit_input.proof_of_possession, 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, + ) ``` From 4f94f7579c7d3571570aa8a703b13e64345f512d Mon Sep 17 00:00:00 2001 From: vbuterin Date: Fri, 21 Dec 2018 11:29:15 -0500 Subject: [PATCH 5/5] Moved notes to the end of the section to make Danny happy --- specs/core/0_beacon-chain.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 5aa9f1aea..9e466ba0d 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -421,8 +421,6 @@ Unless otherwise indicated, code appearing in `this style` is to be interpreted #### `BeaconBlockBody` -`ProofOfCustodySeedChange`, `ProofOfCustodyChallenge`, and `ProofOfCustodyResponse` will be defined in phase 1; for now, put dummy classes as these lists will remain empty throughout phase 0. - ```python { 'proposer_slashings': [ProposerSlashing], @@ -436,6 +434,8 @@ Unless otherwise indicated, code appearing in `this style` is to be interpreted } ``` +`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` ```python