lambdaclass / lambdaclass/lambda_ethereum_consensus

Use `shuffle_list` instead of `compute_shuffled_index` when possible.

Open
#752 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

perf
Dominant language
Elixir
Stars
109
Forks
41
PR merge metrics
No merged PRs in 30d

Description

Preliminary read: https://eth2book.info/capella/part2/building_blocks/shuffling/#a-full-shuffle
Full shuffle implementation: https://github.com/lambdaclass/lambda_ethereum_consensus/issues/467

Using compute_shuffled_index is quite slow, so instead of computing it for every index that we care about. Instead we should shuffle the whole list once and then query each index. Maybe we'll need some type of cache for this.

Some places where this function is used
https://github.com/lambdaclass/lambda_ethereum_consensus/blob/e01f27594b370f850ae5480566168d200958a430/lib/lambda_ethereum_consensus/state_transition/misc.ex#L207
https://github.com/lambdaclass/lambda_ethereum_consensus/blob/e01f27594b370f850ae5480566168d200958a430/lib/lambda_ethereum_consensus/state_transition/misc.ex#L135
https://github.com/lambdaclass/lambda_ethereum_consensus/blob/3da8c9eccbef54a56722829fc86e6389cc602689/lib/lambda_ethereum_consensus/state_transition/accessors.ex#L88

Acceptance criteria:

  • There should be some type of benchmark that shows the improvement of performance from using one function vs the other

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the shuffle_list and compute_shuffled_index implementations, then inspect the call sites in lib/lambda_ethereum_consensus/state_transition/misc.ex at lines 135 and 207 and accessors.ex at line 88. Review issue #467 for the full shuffle implementation. Done means using the full-list approach where possible and adding a benchmark that compares both functions' performance.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
backend, performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.