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

feat: shed: FIP0036 post poll result processing #9387

Merged
merged 9 commits into from
Oct 13, 2022
Merged

Conversation

arajasek
Copy link
Contributor

@arajasek arajasek commented Sep 28, 2022

Related Issues and Proposed Changes

This is a shed command that tabulates the results of FIP-0036. It is fed in votes from FilPoll, along with the state root and height (for this poll bafy2bzacebdnzh43hw66bmvguk65wiwr5ssaejlq44fpdei2ysfh3eefpdlqs and 2162760). See #9375 for more, this is a slight reworking of that.

Additional Info

lotus-shed fip36poll results --repo=/mnt/oldnet bafy2bzacebdnzh43hw66bmvguk65wiwr5ssaejlq44fpdei2ysfh3eefpdlqs 2162760 ~/Downloads/votes.json

Sample output:

Total acceptance token:  3641447073483215769868470
Total rejection token:  4546494321191196771637925
Total acceptance SP deal power:  20666424631525888
Total rejection SP deal power:  141508413655663360
Total acceptance SP rb power:  3486069098389962752
Total rejection SP rb power:  2454514779633483776
Total acceptance Client rb power:  15715869958078464
Total rejection Client rb power:  29557281734075904


Final results **drumroll**
token holders REJECT FIP-0036 :(
SPs by deal data stored VETO FIP-0036!!!
SPs by total raw byte power ACCEPT FIP-0036 :)
Storage Clients REJECT FIP-0036 :(

Checklist

Before you mark the PR ready for review, please make sure that:

  • All commits have a clear commit message.
  • The PR title is in the form of of <PR type>: <area>: <change being made>
    • example: fix: mempool: Introduce a cache for valid signatures
    • PR type: fix, feat, INTERFACE BREAKING CHANGE, CONSENSUS BREAKING, build, chore, ci, docs,perf, refactor, revert, style, test
    • area: api, chain, state, vm, data transfer, market, mempool, message, block production, multisig, networking, paychan, proving, sealing, wallet, deps
  • This PR has tests for new functionality or change in behaviour
  • If new user-facing features are introduced, clear usage guidelines and / or documentation updates should be included in https://lotus.filecoin.io or Discussion Tutorials.
  • CI is green

@arajasek arajasek requested a review from a team as a code owner September 28, 2022 01:12
@arajasek arajasek changed the title Asr/fip0036 feat: shed: FIP0036 post poll result processing Sep 28, 2022
@arajasek arajasek force-pushed the asr/fip0036 branch 2 times, most recently from e303661 to 7f1302a Compare September 28, 2022 01:24
@jennijuju
Copy link
Member

jennijuju commented Sep 28, 2022

Take out the emoji please 😜😜 let’s not make sentimental suggestion a😜😜

}

//process msigs
// TODO: Oh god, oh god, there's a possibility that a multisig has voted in both directions
Copy link
Member

Choose a reason for hiding this comment

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

lets add the ID from https://api.filpoll.io/api/polls/16/view-votes to Vote - and which can be used to indicate which option reaches threshold first


if v == APPROVE {
approveBalance = types.BigAdd(approveBalance, accountActor.Balance)
votesIncludingMsigs[signerId] = APPROVE
Copy link
Member

Choose a reason for hiding this comment

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

why adding here?

Copy link
Member

Choose a reason for hiding this comment

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

oka after figuring out the intention of this map I think this should be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jennijuju You're gonna have to say more than that :P

Why should it be removed?

(The purpose is just to have a map that includes votes from msigs for the purpose of checking owner addresses in the next loop)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe answer to my q is here: #9387 (comment)?

clientApproveBytes = big.Add(clientApproveBytes, clientBytes)
} else {
rejectionBalance = types.BigAdd(rejectionBalance, accountActor.Balance)
votesIncludingMsigs[signerId] = Reject
Copy link
Member

Choose a reason for hiding this comment

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

why adding here?

minerVotes := make(map[address.Address]uint64)
fmt.Println("counting miner votes")
for s, v := range votes {
if minerInfos, found := ownerMap[s]; found {
Copy link
Member

Choose a reason for hiding this comment

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

for s is msig - this is not checking against whether the music mets the threshold, add a voteMsig found check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops! that's supposed to be iterating over votesIncludingMsigs -- are you proposing just doing this loop twice, once for votes and once for votedMsigs? I do like that more.

Copy link
Member

Choose a reason for hiding this comment

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

im confused - then where is the miner balance when the owner is not msig accounted?

Copy link
Member

Choose a reason for hiding this comment

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

oh here

if minerInfos, found := ownerMap[signerId]; found {
..

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

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

Initial pass. Mostly nits but it would be easier to review if we reduced code duplication and added some comments on the vote tallying strategy.

cmd/lotus-shed/fip-0036.go Outdated Show resolved Hide resolved
return idAddr
}

panic("didn't find addr")
Copy link
Member

Choose a reason for hiding this comment

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

Can someone not vote with a bogus ID? (I assume we should just skip here)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't believe FilPoll allows that (with the possible exception of certain Core Devs who submitted newly created IDs for the core devs portion of the vote).

Copy link
Collaborator

Choose a reason for hiding this comment

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

You already have an instance:

2022/09/28 22:01:40 ignoring ballot {49 t1giru42mia2x27svolr3n7vth7byb77eshpc77iq 2022-09-28 18:12:09.179 +0000 UTC}: unknown robust address

This one was ID-ed way after 2162760

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah i wound up having to handle it lol -- only for vote signer resolution, though, the rest are panics.

cmd/lotus-shed/fip-0036.go Outdated Show resolved Hide resolved
workerMap := make(map[address.Address][]address.Address)
// a map of miners to some info aboout them for quick lookup
minerActorsInfo := make(map[address.Address]minerBriefInfo)
// a map of client addresses to deal data stored in proposals
Copy link
Member

Choose a reason for hiding this comment

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

multisigs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For which one? I don't think so? Workers are BLS addresses, clients are either secp or bls?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, sorry, I forgot that these needed to be key addresses.

Technically, we also need to handle the case where a multisig owns a multisig, which requires either multiple passes or a dependency graph. But I'm not sure how important that is.

cmd/lotus-shed/fip-0036.go Show resolved Hide resolved
cmd/lotus-shed/fip-0036.go Outdated Show resolved Hide resolved
cmd/lotus-shed/fip-0036.go Outdated Show resolved Hide resolved
cmd/lotus-shed/fip-0036.go Outdated Show resolved Hide resolved
//process msigs
// TODO: Oh god, oh god, there's a possibility that a multisig has voted in both directions
// and we'll pick a winner non-deterministically as we iterate...
// We need to factor in vote time if that happens and pick whoever went first
Copy link
Member

Choose a reason for hiding this comment

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

(IMO, just pick the direction with more votes and drop the vote on tie)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do think it's correcter to pick the first vote that crossed the threshold -- that's how msigs operate on chain.

(gonna do that for now, and log how many instances of this we have... @ribasushi already has this info too).

Copy link
Collaborator

Choose a reason for hiding this comment

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

@arajasek on my side I am not coming up with any instances of this, aside from the mega-msig

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't agree that it's correcter to pick the first vote that crosses the threshold. That incentivizes a race as soon as the poll opens. We should want people to take as much time as they need before the poll closes to gather and weigh information.

I agree with @Stebalien's idea as the most straightforward solution.

// msig has already voted, skip
continue
}
if mpv, found := msigPendingVotes[ms]; found { //other signers of the multisig have voted, yet the threshold has not met
Copy link
Member

Choose a reason for hiding this comment

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

So... we can simplify this code by always incrementing, then checking. I.e., don't special-case a threshold of one, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, i'll maybe get to that ;P

Copy link
Member

Choose a reason for hiding this comment

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

NOT YOUR PRIO

Copy link
Member

Choose a reason for hiding this comment

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

It'll make it a lot easier to reason about and review.

cmd/lotus-shed/fip-0036.go Outdated Show resolved Hide resolved
cmd/lotus-shed/fip-0036.go Show resolved Hide resolved
cmd/lotus-shed/fip-0036.go Outdated Show resolved Hide resolved
cmd/lotus-shed/fip-0036.go Outdated Show resolved Hide resolved

fmt.Println("iterating over proposals")
dps, _ := marketState.Proposals()
if err := dps.ForEach(func(dealID abi.DealID, d market.DealProposal) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@arajasek considering every deal as "legit" is not accurate. This is the filtering I do on my end:
... d.sector_activation_epoch IS NOT NULL AND d.deal_slash_epoch IS NULL and d.end_epoch > 2162760

It doesn't affect the result much at all, but still...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, there's some nitpicking to do here. I'm not convinced that your approach is correcter (we should clarify all of this for future polls).

  • A Deal in the Proposals already has is "accepted" by both parties and has collateral locked, so I'm not sure we should check d.sector_activation_epoch IS NOT NULL?
  • A slashed deal is still a deal that a client made (and SP accepted) and both put up collateral for, so should it not be counted?
  • d.end_epoch > 2162760 excludes deals that have expired but cron hasn't GCed yet...that's probably a better definition of "active deals" but it's a narrow boundary?

I definitely don't think any of your suggestions are "wrong", just...not clearly correcter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(would be easy to adopt any subset of your suggestions, though)

Copy link
Collaborator

Choose a reason for hiding this comment

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

@arajasek answering in the same order

  • The reason I always do this when parsing the state, is because we have deal Proposals that are slated to start far in the future, some in the next millennium
Expand for urgh
 deal_id  |  status   |    deal_start_time     | start_epoch 
----------+-----------+------------------------+-------------
   311683 | published | 3534-01-31 14:40:00+00 |  1591979600
   219097 | published | 3390-03-05 22:00:00+00 |  1440604800
   218449 | published | 3389-10-06 22:00:00+00 |  1440172800
   166347 | published | 3279-01-31 22:00:00+00 |  1323748800
   165999 | published | 3272-04-27 22:00:00+00 |  1316635200
   165922 | published | 3270-07-02 22:00:00+00 |  1314720000
   165919 | published | 3270-06-27 22:00:00+00 |  1314705600
   165917 | published | 3270-06-27 22:00:00+00 |  1314705600
   165921 | published | 3270-06-27 22:00:00+00 |  1314705600
   165918 | published | 3270-06-27 22:00:00+00 |  1314705600
   165912 | published | 3270-06-22 22:00:00+00 |  1314691200
   165916 | published | 3270-06-22 22:00:00+00 |  1314691200
   165911 | published | 3270-06-22 22:00:00+00 |  1314691200
   165915 | published | 3270-06-22 22:00:00+00 |  1314691200
   165914 | published | 3270-06-22 22:00:00+00 |  1314691200
   165908 | published | 3270-06-17 22:00:00+00 |  1314676800
   165909 | published | 3270-06-17 22:00:00+00 |  1314676800
   165905 | published | 3270-06-17 22:00:00+00 |  1314676800
   165910 | published | 3270-06-17 22:00:00+00 |  1314676800
   165907 | published | 3270-06-17 22:00:00+00 |  1314676800
   165904 | published | 3270-06-12 22:00:00+00 |  1314662400
   165903 | published | 3270-06-12 22:00:00+00 |  1314662400
   165902 | published | 3270-06-12 22:00:00+00 |  1314662400
   159205 | published | 3240-01-31 22:00:00+00 |  1282723200
   159203 | published | 3240-01-26 22:00:00+00 |  1282708800
   159200 | published | 3240-01-26 22:00:00+00 |  1282708800
   159204 | published | 3240-01-26 22:00:00+00 |  1282708800
   159202 | published | 3240-01-26 22:00:00+00 |  1282708800
   159201 | published | 3240-01-26 22:00:00+00 |  1282708800
   159197 | published | 3240-01-21 22:00:00+00 |  1282694400
   159195 | published | 3240-01-21 22:00:00+00 |  1282694400
   159196 | published | 3240-01-21 22:00:00+00 |  1282694400
   159193 | published | 3240-01-21 22:00:00+00 |  1282694400
   159194 | published | 3240-01-21 22:00:00+00 |  1282694400
   159190 | published | 3240-01-16 22:00:00+00 |  1282680000
   159191 | published | 3240-01-16 22:00:00+00 |  1282680000
   159192 | published | 3240-01-16 22:00:00+00 |  1282680000
   159188 | published | 3240-01-16 22:00:00+00 |  1282680000
   159189 | published | 3240-01-16 22:00:00+00 |  1282680000
   159183 | published | 3239-12-22 22:00:00+00 |  1282608000
   159181 | published | 3239-12-22 22:00:00+00 |  1282608000
   159170 | published | 3239-06-10 22:00:00+00 |  1282046400
   159155 | published | 3239-01-21 22:00:00+00 |  1281643200
   192728 | published | 2959-10-11 20:08:30+00 |   987868577
  2768016 | published | 2033-01-30 16:31:30+00 |    13080303
  2768015 | published | 2033-01-30 16:31:00+00 |    13080302
  2768014 | published | 2033-01-30 16:30:30+00 |    13080301
 11512152 | published | 2022-10-16 09:14:00+00 |     2253508
 11458042 | published | 2022-10-16 09:13:30+00 |     2253507
 11464093 | published | 2022-10-16 09:13:30+00 |     2253507
 11512158 | published | 2022-10-16 09:13:00+00 |     2253506
...
  • "Slashed deal" is a misnomer: it means the underlying sector is gone for good and the deal has entered cron cleanup. I did confirm this with @ZenGround0 at multiple points.

  • No strong feelings about this one, though note that cron cleanup is sometimes up to 24h

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I always do this when parsing the state, is because we have deal Proposals that are slated to start far in the future, some in the next millennium

Persuaded, adding that check.

"Slashed deal" is a misnomer: it means the underlying sector is gone for good and the deal has entered cron cleanup. I did confirm this with @ZenGround0 at multiple points.

Yeah, you're right, but it's another 24 hour issue...I don't care enough for that ;)

@arajasek arajasek merged commit 4d28bde into master Oct 13, 2022
@arajasek arajasek deleted the asr/fip0036 branch October 13, 2022 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants