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

Last minute cleanups #1244

Closed
wants to merge 10 commits into from
Closed

Last minute cleanups #1244

wants to merge 10 commits into from

Conversation

JustinDrake
Copy link
Collaborator

@JustinDrake JustinDrake commented Jun 30, 2019

  • Fix lingering BLS_WITHDRAWAL_PREFIX_BYTE (should be BLS_WITHDRAWAL_PREFIX)
  • Fix typing of fork_version: bytes=b'\x00' * 4 (should be fork_version: Version=Version())
  • Consistent naming for integer input (use n in both int_to_bytes and integer_squareroot)
  • Use uint64 over int in a few places
  • Set type for a few of the configurations
  • Make BLS_WITHDRAWAL_PREFIX a Bytes1
  • Put JUSTIFICATION_BITS_LENGTH in the constants (as opposed to configurations)
  • Remove effectively untriggerable assert index_count <= 2**40 (there for cryptographic security)

@JustinDrake JustinDrake added the milestone:June 30 freeze 🥶 Phase 0 spec freeze for long-lived cross-client testnet label Jun 30, 2019
specs/core/0_beacon-chain.md Show resolved Hide resolved
specs/core/0_beacon-chain.md Outdated Show resolved Hide resolved
| `MIN_EPOCHS_TO_INACTIVITY_PENALTY` | `2**2` (= 4) | epochs | 25.6 minutes |

* `MAX_EPOCHS_PER_CROSSLINK` should be a small constant times `SHARD_COUNT // SLOTS_PER_EPOCH`.
| `MIN_ATTESTATION_INCLUSION_DELAY` | `Slot(2**0)` (= 1) | 6 seconds |
Copy link
Contributor

@djrtwo djrtwo Jun 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of these should be typed as Slot or Epoch. "5 slots" is not actually a Slot. It's a count of something.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the thing that is being counted here not a Slot though?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slot was called SlotNumber, as the ID to identify a certain slot; Epoch and Shard are as well.

| `EPOCHS_PER_HISTORICAL_VECTOR` | `2**16` (= 65,536) | epochs | ~0.8 years |
| `EPOCHS_PER_SLASHINGS_VECTOR` | `2**13` (= 8,192) | epochs | ~36 days |
| `HISTORICAL_ROOTS_LIMIT` | `2**24` (= 16,777,216) | historical roots | ~26,131 years |
| `EPOCHS_PER_HISTORICAL_VECTOR` | `Epoch(2**16)` (= 65,536) | ~0.8 years |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I disagree:

  • The name EPOCHS_PER_... is consistent with the Epoch type.
  • EPOCHS_PER_HISTORICAL_VECTOR naturally occurs in Epoch summations such as epoch + EPOCHS_PER_HISTORICAL_VECTOR - MIN_SEED_LOOKAHEAD.
  • EPOCHS_PER_HISTORICAL_VECTOR naturally occurs in Epoch modular reductions such as epoch % EPOCHS_PER_HISTORICAL_VECTOR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in instances where there is a PER in the name, dimensional analysis dictates that they are not Epochs, but `Epochs * HistoricalVectors**(-1).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SLOTS_PER_EPOCH is defined as "the number of slots in an epoch". That's of type Slot, not Slot/Epoch.

Copy link
Contributor

@CarlBeek CarlBeek Jun 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disagree. The use of SLOTS_PER_EPOCH in slot_to_epoch and in epoch_start_slot stand counter to your argument.

If SLOTS_PER_EPOCH is a Slot then epoch_start_slot's return type is Epoch*Slot and epoch_start_slot is dimensionless.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Historical vector here doesn't represent a type, but a non-typed scalar. So you could say we are multiplying by something that doesn't change the type, only the length. Imho I think the debate is silly, and naming is consistent and clear.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum, OK. Would you agree that Epochs * HistoricalVectors**(-1) is the same as Epochs because HistoricalVectors is dimensionless? 😂

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't care too much either way. Need to go to sleep soon as I can't think straight anymore 💤

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂Fine. :) I am not entirely convinced, but I sort of agree enough on the dimensionlessness HistoricalVectors.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed the need for sleep is real.

@JustinDrake JustinDrake marked this pull request as ready for review June 30, 2019 22:37
Copy link
Contributor

@CarlBeek CarlBeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asides for the type of SLOTS_PER_EPOCH, this looks good to me.

@hwwhww
Copy link
Contributor

hwwhww commented Jul 1, 2019

Opened #1251 to get merged before the freeze. 😄

@djrtwo
Copy link
Contributor

djrtwo commented Jul 1, 2019

closing in favor of #1251. Sorry! we can debate this very aesthetic item tomorrow.

@djrtwo djrtwo closed this Jul 1, 2019
djrtwo added a commit that referenced this pull request Jul 1, 2019
@protolambda protolambda deleted the last-minute-cleanups branch November 6, 2019 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
milestone:June 30 freeze 🥶 Phase 0 spec freeze for long-lived cross-client testnet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants