Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phase 0 state transition checklist—take 5 #1054

Closed
20 of 21 tasks
JustinDrake opened this issue May 6, 2019 · 8 comments
Closed
20 of 21 tasks

Phase 0 state transition checklist—take 5 #1054

JustinDrake opened this issue May 6, 2019 · 8 comments
Labels
post-freeze (substantive) Substantive consensus change non-critical for long-lived cross-client testnets

Comments

@JustinDrake
Copy link
Collaborator

JustinDrake commented May 6, 2019

(See #128, #218, #322, #675 for takes 1, 2, 3, 4.)

This issue keeps track of possible phase 0 state transition function changes.

  • 1. (post-freeze discussion) BLS12-381 standardisation: See here.
  • 2. (post-freeze discussion) Big vs little byteorder of hash_tree_root inputs: See also Little vs big endian #556.
  • 3. (post-freeze discussion) Performance parameters fine-tuning: E.g. review SLOTS_PER_EPOCH and SHARD_COUNT based on benchmarks.
  • 4. Issuance schedule: Enact schedule whereby 2**21 ETH is issued per year when 2**27 ETH is at stake.
  • 5. Better aligned micro-incentives: Make crosslink incentives proportional to number of epochs in a crosslink. Make matching head incentives proportional to head slot vs target slot.
  • 6. Stateless withdrawal credentials: Consider not storing withdrawal credentials. See Do not store withdrawal_credentials #937.
  • 7. Remove MIN_ATTESTATION_INCLUSION_DELAY: Set MIN_ATTESTATION_INCLUSION_DELAY to 1.
  • 8. (post-freeze discussion) Remove transfers: Consider completely removing the Transfer operation, going beyond MAX_TRANSFERS = 0. We want to do a practice hard fork that add a field to an SSZ object (in this case, adding the transfers field to BeaconBlockBody).
  • 9. (post-freeze discussion) Last slot vs first slot epoch transitions: See Improve epoch processing within state transition #1043.
  • 10. Merged historical stats: Consider merging latest_randao_mixes, latest_active_index_roots, latest_slashed_balances into a single SSZ object.
  • 11. More historical stats: Store the last 8 months of historical lists so that historical start shards can be recomputed.
  • 12. Crosslink lengths: Fix [Phase 1] get_custody_chunk_count is broken #1034.
  • 13. Bitfields/bigints/generalised indices: See Cleaner bitfields #1019.
  • 14 Fine-tune object field ordering: See Cleanup containers #917.
  • 15 Crosslink in AttestationData: See Crosslink in AttestationData #1044.
  • 16 (post-freeze discussion) Exit fee: See Withdrawal queue -> exit queue #850 (comment).
  • 17 Improve upon latest_active_index_roots: For more efficient light clients. See Active registry roots #1104
  • 18 (post-freeze discussion) Hard Forkability: See handling altered constants at forks #1101, also related to 8
  • 19 Fixed size state: Make BeaconState fixed size to be friendly to SSZ partials.
  • 20 Checkpoints: Refactor BeaconState to use Checkpoints.
  • 21 Slashing early exit: (bug) In some circumstances getting slashed allows for an early exit.
@vbuterin
Copy link
Contributor

vbuterin commented May 7, 2019

  1. Big-endian vs little-endian hash_tree_root: See Little vs big endian #556.

What are the places where little endian is still used in the hash tree root?

I have a strong preference toward not, for example, reversing the bytes of hashes the way bitcoin does. I had to deal with that as an implementer and it was painful. Endianness should be purely a convention about how we serialize things that are integers within the eth2 spec; we should be treating everything outside the eth2 spec proper (eg. hash algorithms, BLS signature and BLS pubkey serialization...) as black boxes that just give us bytes.

@JustinDrake
Copy link
Collaborator Author

What are the places where little endian is still used in the hash tree root?

To only place is byteorder when calling to_bytes on a uintN for N in [16, 32, 64, 128, 256]. This affects, for example, hash_tree_root of a slot number (of type uint64).

It's confusing that "endianness" is used for both bits and bytes. What about using big/little "byteorder" and "bitorder" instead?

we should be treating everything outside the eth2 spec proper (eg. hash algorithms, BLS signature and BLS pubkey serialization...) as black boxes that just give us bytes

Agreed :)

@hwwhww hwwhww pinned this issue May 7, 2019
@vbuterin
Copy link
Contributor

vbuterin commented May 7, 2019

Ah sorry, meant to ask where big endian is used in tree hash root. To me it seems obvious that if SSZ serialization uses little endian then so should SSZ tree hashing, so I don't see the issue....

Bitorder is only relevant for bitfields, correct?

@vbuterin
Copy link
Contributor

  1. Better aligned micro-incentives: Make crosslink incentives proportional to number of epochs in a crosslink. Make matching head incentives proportional to head slot vs target slot.

This is arguably a bad idea, because the total payment that validators get would potentially be larger (!!!) if they skip crosslinks. That is:

  • Honest strategy: (100% vote) (100% vote) (100% vote) (100% vote)
  • Honest reward: 1 + 1 + 1 + 1 = 4
  • Evil strategy: (60% vote) (60% vote) (60% vote) (100% vote)
  • Evil reward: 0.6**2 + 0.6**2 + 0.6**2 + (1 * 4) = 5.08 (or if we're even stupider with the implementation: 0.6**2 + (0.6**2 * 2) + (0.6**2 * 3) + (1 * 4) = 6.16)

@vbuterin
Copy link
Contributor

16 Exit fee: See #850 (comment).

Do we want an exit fee or a minimum time online? We already have this:

    # Verify the validator has been active long enough
    assert get_current_epoch(state) >= validator.activation_epoch + PERSISTENT_COMMITTEE_PERIOD

JustinDrake added a commit that referenced this issue May 21, 2019
Possible replacement of `latest_active_index_roots` with `latest_active_registry_roots` to allow for significantly more efficient light clients (see item 17 in #1054). Key changes:

* Validator information (including indices) is pre-shuffled and grouped by committee.
* Validator information relevant to light clients (`validator.effective_balance` and `validator.slashed`) is kept "close" to the validator index to avoid accessing `validator_registry`.
* Validator information (`index`, `effective_balance`, `slashed`) is compactified into a `uint64` which is friendly to SSZ packing.
* Shuffled pubkeys are available but kept separate from compact validator information. Light clients with pubkeys cached do not need to re-download and re-authenticate them.
@djrtwo
Copy link
Contributor

djrtwo commented May 21, 2019

Consider completely removing the Transfer operation, going beyond MAX_TRANSFERS = 0. We want to do a practice hard fork that add a field to an SSZ object (in this case, adding the transfers field to BeaconBlockBody).

I'm not seeing much value here especially considering clients already have this functionality built and tested. If we sequester Transfer to another fork in between 0 and 1, we would have to define a whole state transition file for the in between fork. Coordinating a production fork around a constant change is significant enough IMO

@djrtwo
Copy link
Contributor

djrtwo commented May 21, 2019

Last slot vs first slot epoch transitions

Down to get on a call to convince you that this is still not the proper path :)

JustinDrake added a commit that referenced this issue May 22, 2019
Address item 11 of #1054. This stores 8-month old historical start shards so that historical committees to be recomputed (e.g. for attester slashings).
This was referenced Jun 8, 2019
JustinDrake added a commit that referenced this issue Jun 9, 2019
See item 7 of #1054. We should consider increasing the slot duration as well.
JustinDrake added a commit that referenced this issue Jun 10, 2019
Substantive changes:

1) Split the inclusion delay reward between attester and proposer to add up to at most one base reward. This is analogous to the reward logic in `slash_validator`, and makes the `BASE_REWARDS_PER_EPOCH` constant include proposer rewards.
2) Double `BASE_REWARD_FACTOR` to 2^6 (addressing item 4 in #1054). When the total effective balance is 2^17 ETH then maximum annual issuance is a bit below 2^21 ETH. Maximum annual issuance happens when a) all validators make perfect attestations (matching source, target, head, as well as consistent crosslink data), b) all attestations are included as fast as possible (in particular, no skip blocks), and c) there are no slashings.

```python
BASE_REWARD_FACTOR = 2**6
SLOTS_PER_EPOCH = 2**6
SECONDS_PER_SLOT = 6
BASE_REWARDS_PER_EPOCH = 5
GWEI_PER_ETH = 10**9
MAX_TOTAL_EFFECTIVE_BALANCE = 2**27 * GWEI_PER_ETH
TARGET_MAX_ISSUANCE = 2**21 * GWEI_PER_ETH

def integer_squareroot(n: int) -> int:
    """
    The largest integer ``x`` such that ``x**2`` is less than or equal to ``n``.
    """
    assert n >= 0
    x = n
    y = (x + 1) // 2
    while y < x:
        x = y
        y = (x + n // x) // 2
    return x

MAX_REWARDS_PER_EPOCH = MAX_TOTAL_EFFECTIVE_BALANCE * BASE_REWARD_FACTOR // integer_squareroot(MAX_TOTAL_EFFECTIVE_BALANCE) // BASE_REWARDS_PER_EPOCH
EPOCHS_PER_YEAR = 365.25*24*60*60 / (SECONDS_PER_SLOT * SLOTS_PER_EPOCH)
MAX_REWARDS_PER_YEAR = EPOCHS_PER_YEAR * MAX_REWARDS_PER_EPOCH * BASE_REWARDS_PER_EPOCH

print(MAX_REWARDS_PER_YEAR / TARGET_MAX_ISSUANCE)
```
@JustinDrake JustinDrake added the milestone:June 30 freeze 🥶 Phase 0 spec freeze for long-lived cross-client testnet label Jun 15, 2019
@JustinDrake JustinDrake removed the milestone:June 30 freeze 🥶 Phase 0 spec freeze for long-lived cross-client testnet label Jun 29, 2019
@JustinDrake JustinDrake unpinned this issue Jun 29, 2019
@JustinDrake JustinDrake added the post-freeze (substantive) Substantive consensus change non-critical for long-lived cross-client testnets label Jul 5, 2019
@JustinDrake JustinDrake removed this from the Phase 0 Frozen milestone Jul 7, 2019
@djrtwo djrtwo mentioned this issue Dec 12, 2019
@djrtwo
Copy link
Contributor

djrtwo commented Dec 12, 2019

All items except (16) have been addressed. Closing this in favor of specific issue on exit fee #1521

@djrtwo djrtwo closed this as completed Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
post-freeze (substantive) Substantive consensus change non-critical for long-lived cross-client testnets
Projects
None yet
Development

No branches or pull requests

3 participants