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

Fix past councils spending amounts #4554

Merged
merged 11 commits into from
Nov 15, 2023
Merged

Fix past councils spending amounts #4554

merged 11 commits into from
Nov 15, 2023

Conversation

mkbeefcake
Copy link
Contributor

Fix the #4121 (wrong values in Councils and past councils)
image

@vercel
Copy link

vercel bot commented Sep 26, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
dao ✅ Ready (Inspect) Visit Preview Nov 10, 2023 10:49am
pioneer-2 ✅ Ready (Inspect) Visit Preview Nov 10, 2023 10:49am
pioneer-2-storybook ✅ Ready (Inspect) Visit Preview Nov 10, 2023 10:49am

@chrlschwb
Copy link
Contributor

"total spent" column should include the total of councilor reward + WG budget updates + funding proposals + channel payout rewards

Copy link
Contributor

@chrlschwb chrlschwb left a comment

Choose a reason for hiding this comment

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

once the CI error is fixed, I believe the PR is good

proposalsApproved: data?.proposalsApproved?.totalCount ?? 0,
proposalsRejected: (data?.proposalsRejected?.totalCount || 0) + (data?.proposalsSlashed?.totalCount || 0),
totalSpent: data && getTotalSpent(data.budgetSpendingEvents),
// totalSpent: data && getTotalSpent(data.budgetSpendingEvents),
Copy link
Contributor

Choose a reason for hiding this comment

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

please remove unnecessary line

@ivanturlakov
Copy link

Tested on https://dao-h1gyak8tv-joystream.vercel.app/#/council/past-councils
Mainnet

@chrlschwb I couldn't find the numbers that correspond to the total spent... this is term 19

Screenshot 2023-10-12 at 20 25 05 Screenshot 2023-10-12 at 20 24 27 Screenshot 2023-10-12 at 20 24 43

Comment on lines 58 to 63
// totalSpent: getTotalSpent(spendingEvents),
totalSpent: councilFields.councilMembers
.reduce((a, b) => a.add(new BN(b.accumulatedReward)), BN_ZERO)
.add(workingGroupBudgets.reduce((a, b) => a.add(new BN(b.budgetChangeAmount)), BN_ZERO))
.add(getSpentOnProposals(fundingRequestsApproved))
.add(workingGroupRewardPaidEvents.reduce((a, b) => a.add(new BN(b.amount)), BN_ZERO)),
Copy link
Member

Choose a reason for hiding this comment

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

Because this code will probably have to be updated in the furture I think it's worth makin it a bit clearer so please remove the export from getTotalSpent and update it's definition to something like:

const getTotalSpent = (
  councilMembers: ...,
  workingGroupBudgets: ...,
  workingGroupRewardPaidEvents: ...,
  fundingRequestsApproved: ...,
) => {
  const totalAccumulatedReward = councilMembers
    .reduce((a, b) => a.add(new BN(b.accumulatedReward)), BN_ZERO)
  const totalBudgetChange = workingGroupBudgets
    .reduce((a, b) => a.add(new BN(b.budgetChangeAmount)), BN_ZERO)
  const totalRewardPaid = workingGroupRewardPaidEvents
    .reduce((a, b) => a.add(new BN(b.amount)), BN_ZERO)
  const spentOnProposal = getSpentOnProposals(fundingRequestsApproved)

  return totalAccumulatedReward
    .add(totalBudgetChange)
    .add(totalRewardPaid)
    .add(spentOnProposal)
}

Then:

Suggested change
// totalSpent: getTotalSpent(spendingEvents),
totalSpent: councilFields.councilMembers
.reduce((a, b) => a.add(new BN(b.accumulatedReward)), BN_ZERO)
.add(workingGroupBudgets.reduce((a, b) => a.add(new BN(b.budgetChangeAmount)), BN_ZERO))
.add(getSpentOnProposals(fundingRequestsApproved))
.add(workingGroupRewardPaidEvents.reduce((a, b) => a.add(new BN(b.amount)), BN_ZERO)),
totalSpent: getTotalSpent(councilFields.councilMembers, workingGroupBudgets, workingGroupRewardPaidEvents, spentOnProposal),

Also @chrlschwb should channel payout be included here ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I believe channel payout should be included

@chrlschwb
Copy link
Contributor

chrlschwb commented Oct 13, 2023

@ivanturlakov thanks for the test.
total spent includes council rewards, working group spending, funding proposals and creator payouts.
So if you substract validator rewards from grand total of council report, you should get total spent

can you please check with other council term reports?

@ivanturlakov
Copy link

ivanturlakov commented Oct 13, 2023

Tested on https://dao-h1gyak8tv-joystream.vercel.app/#/council/past-councils
Mainnet

@chrlschwb Seems that the amount of validator rewards is not the cause

I tried playing with numbers yesterday but it didn't help me find the cause

TOTAL_SPENT Council Report(w/o validator rewards)
Term 19 1 378 733 1 367 796
Term 18 1 302 162 892 115
Term 17 1 081 875 1 249 522
Term 16 26 935 787 ⚠️ 1 687 568

@chrlschwb
Copy link
Contributor

@ivanturlakov
For term 16, there was 25 MJOY burned right after minting, which was not included in the overall council spending report
image

I think council reports could contain some errors since they are amalgamation of WG reports and WG reports can contain slight errors due to unpaid rewards at the time of writing them, etc. However, this will require a more detailed analysis.

@mkbeefcake
Copy link
Contributor Author

@thesan @chrlschwb I have added channelPaymentMadeEvent for calculating

Copy link
Member

@thesan thesan left a comment

Choose a reason for hiding this comment

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

LGTM!

Some more in depth QA is probably needed but since these are currently wrong in produciton anyway I'll merge this PR right now.

@thesan thesan changed the title Fix 4121: migrated proposalExecutedEvent to Proposals Fix past council spending amounts Nov 15, 2023
@thesan thesan changed the title Fix past council spending amounts Fix past councils spending amounts Nov 15, 2023
@thesan thesan merged commit 022aadd into Joystream:dev Nov 15, 2023
6 checks passed
@ivanturlakov
Copy link

@chrlschwb same result as prev test

Comment on lines +225 to +229
fundingRequestsApproved: proposals(
where: {
inBlock_gt: $fromBlock
inBlock_lt: $toBlock
proposal: { details_json: { isTypeOf_eq: "FundingRequestProposalDetails" } }
statusSetAtBlock_gt: $fromBlock
statusSetAtBlock_lt: $toBlock
details_json: { isTypeOf_eq: "FundingRequestProposalDetails" }
Copy link
Member

Choose a reason for hiding this comment

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

The query should only return actually executed funding requests, and maybe just those approved between $fromBlock and $toBlock regardless from when they executed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-dev issue suitable for community-dev pipeline
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants