Repository navigation
Conversation
…eamLabs#1105) - Implement get_extended_sample_count adhering to Ethereum Fulu peer-sampling spec - Implement math_comb and hypergeom_cdf helpers - Add unit tests covering spec test vectors, monotonicity, zero-failures, and panic on invalid bounds Resolves ReamLabs#1105
|
Same for this one, |
|
Thanks for pointing this out @perfogic! I verified that upstream consensus-specs#4393 indeed dropped The implementation here ( Given that peer sampling is no longer part of the official Fulu consensus specification:
@shariqnaiyer @perfogic please let me know your preferred direction and I can close or adapt accordingly! |
There was a problem hiding this comment.
I don't think we should be using shorthands, can you make the code more readable and reduce the comments
There was a problem hiding this comment.
Thanks for the feedback @KolbyML! I've addressed this in commit 2f714f5:
- Eliminated shorthands: Renamed
math_combtocombinationsandhypergeom_cdftohypergeometric_cdf. Replaced single-letter and abbreviated variable names with self-documenting ones (total_items,chosen_items,result,index,population_size,sample_size,success_states,denominator,numerator,cumulative_probability, etc.). - Aligned parameter ordering: Reordered
hypergeometric_cdfparameters to match the canonical Python consensus-specs order:(allowed_successes, success_states, population_size, sample_size). - Reduced comment density: Lowered comment ratio, removing redundant inline comments in tests while preserving essential specification references and doc comments.
- All 6 unit tests,
cargo fmt, andcargo clippypass cleanly.
…ments - Rename math_comb to combinations and hypergeom_cdf to hypergeometric_cdf - Replace shorthand variable names with self-documenting identifiers - Reorder hypergeometric_cdf parameters to match Python consensus-specs reference - Reduce comment density to under 8% while preserving core spec references - Tighten hypergeometric_cdf loop bound
What was wrong?
Issue #1105 requested implementing
get_extended_sample_countfrom the Ethereum Fulu specification draft (peer-sampling.md). The codebase lacked the hypergeometric cumulative distribution functions and sample-count calculation routines for peer sampling.How was it fixed?
math_comb(binomial coefficient combinationsn choose k) matching Python'smath.comb.hypergeom_cdfcomputing hypergeometric distribution CDF matching consensus-specs reference.get_extended_sample_countmatching the Fulu peer sampling specification.0..=64Note: As noted in discussions, upstream Ethereum consensus-specs PR #4393 removed peer sampling in favor of custody sampling.
Closes #1105
To-Do