Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Rework election eligibilty predicates #1122

Merged
merged 2 commits into from
Sep 9, 2020
Merged

Rework election eligibilty predicates #1122

merged 2 commits into from
Sep 9, 2020

Conversation

anorth
Copy link
Member

@anorth anorth commented Sep 8, 2020

The miner election eligibility predicates need to be split into one that operates on the parent state, and one at the Winning PoSt lookback.

  • Move the predicates into a new states package intended for use from outside the actors themselves
  • In MinerEligibleForElection change the consensus min power check to a non-zero claim check
  • Add MinerEligibleForElectionAtPoStLookback which checks for consensus min power
  • Rework tests to not use the mock runtime or other higher level stuff

Closes #1102
FYI @nicola @whyrusleeping @magik6k

Copy link
Contributor

@ZenGround0 ZenGround0 left a comment

Choose a reason for hiding this comment

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

LGTM

actors/states/election_test.go Outdated Show resolved Hide resolved
t.Run("miner eligible", func(t *testing.T) {
mstate := constructMinerState(ctx, t, store, owner)
pstate := constructPowerStateWithMiner(t, store, maddr, pwr, proofType)
rstate := constructRewardState(t, tenFIL)
Copy link
Contributor

Choose a reason for hiding this comment

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

love it

actors/states/election_test.go Outdated Show resolved Hide resolved
}

// Tests whether a miner is eligible for election given a Winning PoSt lookback state.
func MinerEligibleForElectionAtPoStLookback(store adt.Store, pstate *power.State, mAddr addr.Address) (bool, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit. This function returning true doesn't imply the miner was eligible at PoSt lookback. Also this method doesn't deal with lookback directly. MinerMeetsConsensusMinimumAtPoStLookbackwould be more accurate. MinerMeetsPoStLookbackEligibilityRequirement? I'm not convinced this function adds much over calling pstate.MinerNominalPowerMeetsConsensusMinimum(store, mAddr) directly.

The comment kind of gets at it, but it would be better to to directly call out "pstate must be the prior state of the power actor at the PoSt lookback epoch". This is an unusual thing in the actor code.

Copy link
Member Author

Choose a reason for hiding this comment

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

What this adds is that when the eligibility requirements change, we can encapsulate that change here (or at least force downstream ack of it through a type signature change). Such a change is likely to be accompanied by other actor changes so we can cover the whole thing and reduce coordination with Lotus.

Thanks for the name suggestion.

@codecov-commenter
Copy link

Codecov Report

Merging #1122 into master will decrease coverage by 0.0%.
The diff coverage is 57.8%.

@@           Coverage Diff            @@
##           master   #1122     +/-   ##
========================================
- Coverage    75.9%   75.9%   -0.1%     
========================================
  Files          49      50      +1     
  Lines        6282    6284      +2     
========================================
- Hits         4772    4770      -2     
- Misses        894     895      +1     
- Partials      616     619      +3     

@anorth anorth merged commit d6b1190 into master Sep 9, 2020
@anorth anorth deleted the anorth/eligibilty branch September 9, 2020 07:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Miner eligibility check does not check for min miner size
4 participants