add mocked eth1data standard

This commit is contained in:
Danny Ryan 2019-08-16 14:20:35 -06:00
parent ed2057b999
commit e596c70a19
2 changed files with 22 additions and 0 deletions

View File

@ -3,4 +3,5 @@
This is a collection of standards to aid in client interoperability testing including:
* [Mocked start](./mocked_start)
* [Mocked `Eth1Data`](./mocked_eth1data)
* [Minimal hobbits network testing](./hobbits)

View File

@ -0,0 +1,21 @@
# Mocked Eth1Data votes for interop testing
Most initial interop tests will not have an associated eth1 chain to come to consensus upon via the `Eth1Data` vote mechanism. This is a quick standard on how clients should stub this vote. The goal here is to check that `eth1data` updates but to _not_ update it in such a way that new deposits must be processed.
We may come up with a more clever mechanism that can actually handles deposits in the future, but for now we just operate in such a way that disables deposits.
## Stub standard
The following stub standard allows the eth1data mechanism to update. This should be used by validators whenever they are supposed to retrieve data from the eth1 chain.
This has validators agreeing upon a stubbed `deposit_root` and `block_hash` but always keeps `deposit_count` at `state.eth1_deposit_index` so that the consensus does not force deposits even as eth1data is updated.
```python
def get_eth1data_stub(state: BeaconState, current_epoch: Epoch) -> Eth1Data:
epochs_per_period = SLOTS_PER_ETH1_VOTING_PERIOD // SLOTS_PER_EPOCH
voting_period = current_epoch // epochs_per_period
return Eth1Data(
deposit_root=hash(voting_period),
deposit_count=state.eth1_deposit_index,
block_hash=hash(hash(voting_period)),
)