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

Group helper functions by type #918

Closed
JustinDrake opened this issue Apr 14, 2019 · 3 comments
Closed

Group helper functions by type #918

JustinDrake opened this issue Apr 14, 2019 · 3 comments
Assignees
Labels
general:presentation Presentation (as opposed to content) milestone:June 30 freeze 🥶 Phase 0 spec freeze for long-lived cross-client testnet

Comments

@JustinDrake
Copy link
Contributor

JustinDrake commented Apr 14, 2019

Suggest grouping helpers in four categories:

  1. Math and crypto
  2. Non-boolean pure functions (get_...)
  3. Boolean pure functions (is_...)
  4. State-modifying functions

I have done the following renamings:

  • get_epoch_start_slot => get_start_slot
  • get_beacon_proposer_index => get_proposer_index
  • bls_domain => get_bls_domain
  • generate_seed => get_seed
  • compute_committee => get_committee
  • convert_to_indexed => get_indexed_attestation
  • slot_to_epoch => get_epoch_from_slot
  • verify_bitfield => is_valid_bitfield
  • validate_indexed_attestation => is_valid_indexed_attestation
  • get_shuffled_index => shuffle_index

Math

int_to_bytes
bytes_to_int
integer_squareroot
xor

Crypto

hash
hash_tree_root
signing_root
verify_merkle_branch
bls_verify
bls_verify_multiple
bls_aggregate_pubkeys

Non-boolean pure functions (get_...)

get_previous_epoch
get_current_epoch
get_start_slot
get_start_shard
get_epoch_from_slot
get_active_validator_indices
get_epoch_committee_count
get_shard_delta
get_crosslink_committee
get_block_root
get_randao_mix
get_seed
get_proposer_index
get_total_balance
get_churn_limit
get_delayed_activation_exit_epoch
get_crosslink_committee_for_attestation
get_attestation_participants
get_domain

Boolean pure functions (is_...)

is_active_validator
is_slashable_validator
is_double_vote
is_surround_vote
is_valid_bitfield
is_valid_indexed_attestation

State-modifying functions

activate_validator
initiate_validator_exit
slash_validator
set_balance
increase_balance
decrease_balance

@JustinDrake JustinDrake added the general:presentation Presentation (as opposed to content) label Apr 14, 2019
@djrtwo
Copy link
Contributor

djrtwo commented Apr 17, 2019

I think this is reasonable.

@ralexstokes
Copy link
Member

my two dai:

  1. a nicer name for boolean pure functions could be predicates
  2. consider the cost of losing semantic intent while pursuing uniformity, cf. compute_committee => get_committee, generate_seed => get_seed

i could easily be out-weighed here but ime get_foo has the connotation that you are just "chasing pointers" to get to some other data, with less, rather than more, computation along the way

@JustinDrake JustinDrake added the milestone:June 30 freeze 🥶 Phase 0 spec freeze for long-lived cross-client testnet label Jun 29, 2019
@JustinDrake JustinDrake self-assigned this Jun 29, 2019
@JustinDrake
Copy link
Contributor Author

Mostly addressed in #1237 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
general:presentation Presentation (as opposed to content) milestone:June 30 freeze 🥶 Phase 0 spec freeze for long-lived cross-client testnet
Projects
None yet
Development

No branches or pull requests

3 participants