From 057364a7d4552334060256679b89f43dd38dec10 Mon Sep 17 00:00:00 2001 From: vbuterin Date: Fri, 8 Feb 2019 19:37:34 -0600 Subject: [PATCH 1/3] Add mandatory deposit index ordering Co-requisite with #589 --- specs/core/0_beacon-chain.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index ebc12324c4..78388cad26 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -526,6 +526,7 @@ The following data structures are defined as [SimpleSerialize (SSZ)](https://git # Ethereum 1.0 chain data 'latest_eth1_data': Eth1Data, 'eth1_data_votes': [Eth1DataVote], + 'deposit_count': 'uint64' } ``` @@ -1717,6 +1718,7 @@ Verify that `len(block.body.deposits) <= MAX_DEPOSITS`. For each `deposit` in `block.body.deposits`: * Let `serialized_deposit_data` be the serialized form of `deposit.deposit_data`. It should be 8 bytes for `deposit_data.amount` followed by 8 bytes for `deposit_data.timestamp` and then the `DepositInput` bytes. That is, it should match `deposit_data` in the [Ethereum 1.0 deposit contract](#ethereum-10-deposit-contract) of which the hash was placed into the Merkle tree. +* Verify that `deposit.index == state.deposit_index`. * Verify that `verify_merkle_branch(hash(serialized_deposit_data), deposit.branch, DEPOSIT_CONTRACT_TREE_DEPTH, deposit.index, state.latest_eth1_data.deposit_root)` is `True`. ```python @@ -1745,6 +1747,8 @@ process_deposit( ) ``` +* Set `state.deposit_index += 1`. + ##### Exits Verify that `len(block.body.exits) <= MAX_EXITS`. From 36d5120deb20d24546c8877aea212b6e961df0e3 Mon Sep 17 00:00:00 2001 From: vbuterin Date: Fri, 8 Feb 2019 19:38:09 -0600 Subject: [PATCH 2/3] Initialize deposit index --- specs/core/0_beacon-chain.md | 1 + 1 file changed, 1 insertion(+) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 78388cad26..a7e2b62861 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -1479,6 +1479,7 @@ def get_initial_beacon_state(initial_validator_deposits: List[Deposit], # Ethereum 1.0 chain data latest_eth1_data=latest_eth1_data, eth1_data_votes=[], + deposit_index=0 ) # Process initial deposits From 019fe8953e6aabd2176f93ab00b96904966882ca Mon Sep 17 00:00:00 2001 From: vbuterin Date: Fri, 8 Feb 2019 22:02:55 -0600 Subject: [PATCH 3/3] Fixed as per @djrtwo's comments --- 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 a7e2b62861..da2cce788d 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -526,7 +526,7 @@ The following data structures are defined as [SimpleSerialize (SSZ)](https://git # Ethereum 1.0 chain data 'latest_eth1_data': Eth1Data, 'eth1_data_votes': [Eth1DataVote], - 'deposit_count': 'uint64' + 'deposit_index': 'uint64' } ``` @@ -1479,7 +1479,7 @@ def get_initial_beacon_state(initial_validator_deposits: List[Deposit], # Ethereum 1.0 chain data latest_eth1_data=latest_eth1_data, eth1_data_votes=[], - deposit_index=0 + deposit_index=len(initial_validator_deposits) ) # Process initial deposits