From e596c70a19e22c7def4fd3519e20ae4022349390 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Fri, 16 Aug 2019 14:20:35 -0600 Subject: [PATCH] add mocked eth1data standard --- interop/README.md | 1 + interop/mocked_eth1data/README.md | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 interop/mocked_eth1data/README.md diff --git a/interop/README.md b/interop/README.md index 77a81c4..5967081 100644 --- a/interop/README.md +++ b/interop/README.md @@ -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) \ No newline at end of file diff --git a/interop/mocked_eth1data/README.md b/interop/mocked_eth1data/README.md new file mode 100644 index 0000000..d6c910a --- /dev/null +++ b/interop/mocked_eth1data/README.md @@ -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)), + )