Page MenuHomePhabricator

[avalanche] Add a way to get pollable contenders from contender cache
AcceptedPublic

Authored by roqqit on Mon, Jan 6, 22:57.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Summary

This provides an easy way to determine all of the contenders that should be polled without introducing deduping logic in Processor to account for the local winner(s). getPollableContenders() will be used in a future patch to reconcile stake contenders.

Test Plan
ninja check-avalanche

Diff Detail

Event Timeline

roqqit requested review of this revision.Mon, Jan 6, 22:57

Tail of the build log:

/work /work/abc-ci-builds/lint-circular-dependencies
A new circular dependency in the form of "avalanche/processor -> avalanche/stakecontendercache -> avalanche/processor" appears to have been introduced.

/work/abc-ci-builds/lint-circular-dependencies
Build lint-circular-dependencies failed with exit code 1

Move static_assert to processor.h in order to avoid circular dependency

This comment was removed by Fabien.
Fabien requested changes to this revision.Tue, Jan 7, 10:20
Fabien added inline comments.
src/avalanche/stakecontendercache.cpp
180 ↗(On Diff #51999)

It's unlikely but the rank could be equal; you should handle the case or the comparison is not deterministic

190 ↗(On Diff #51999)

I think you can make this more effective by taking the max number as a parameter. This can also help moving the assertion out of the processor.

197 ↗(On Diff #51999)

You'd better directly return the size here imo

This revision now requires changes to proceed.Tue, Jan 7, 10:20
  • Fix rare sorting case where two proofs have the same rank.
  • Make num pollable a parameter so the processor will have control over how many contenders to poll for.
  • Return number of contenders instead of bool.
  • Fix test not actually checking the contender order.

Cleanup unnecessary nesting when sorting contenders and make the sorting work the same as staking rewards selection.

This revision is now accepted and ready to land.Wed, Jan 8, 08:19