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

update block reward target from KPI event, use that value to pay block rewards #366

Merged
merged 5 commits into from
May 12, 2020

Conversation

whyrusleeping
Copy link
Member

No description provided.

actors/builtin/reward/reward_actor.go Outdated Show resolved Hide resolved
actors/builtin/reward/reward_actor.go Outdated Show resolved Hide resolved
@codecov-io
Copy link

codecov-io commented May 12, 2020

Codecov Report

Merging #366 into master will increase coverage by 0.04%.
The diff coverage is 35.00%.

@@            Coverage Diff             @@
##           master     #366      +/-   ##
==========================================
+ Coverage   42.60%   42.64%   +0.04%     
==========================================
  Files          40       40              
  Lines        4204     4202       -2     
==========================================
+ Hits         1791     1792       +1     
+ Misses       2154     2152       -2     
+ Partials      259      258       -1     

Copy link
Member

@anorth anorth left a comment

Choose a reason for hiding this comment

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

I think this is the right direction. Based on my understanding of how the cumsums should work, I don't think it's quite right. I'll work though it with you

actors/builtin/reward/reward_policy.go Outdated Show resolved Hide resolved
actors/builtin/reward/reward_state.go Outdated Show resolved Hide resolved
newBaselinePower := a.newBaselinePower(&st)
st.BaselinePower = newBaselinePower
st.CumsumBaseline = big.Add(st.CumsumBaseline, st.BaselinePower)

st.RealizedPower = *currRealizedPower
st.CumsumRealized = big.Add(st.CumsumRealized, *currRealizedPower)
Copy link
Member

Choose a reason for hiding this comment

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

I think this needs to be added as many times as there are iterations in the loop below.

Copy link
Collaborator

Choose a reason for hiding this comment

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

what @anorth is saying is correct but not exactly right because of the edge cases of null rounds. If there is a null round and UpdateNetworkKPI is called in the round after that, we need to first add the RealizedPower at the null round (before the update) to CumsumRealized to account for the null round, and then update RealizedPower to currRealizedPower and then add that to CumsumRealized to account for the change in power in this round.


st.EffectiveNetworkTime = a.getEffectiveNetworkTime(&st, st.CumsumBaseline, st.CumsumRealized)

a.computePerEpochReward(&st, i, st.EffectiveNetworkTime, 1)
Copy link
Member

Choose a reason for hiding this comment

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

I would think we can do this just once at the end, though I could be missing a side-effect that's important.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, doing it once at the end sgtm unless im missing something too.

Copy link
Member

Choose a reason for hiding this comment

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

I was wrong, it has important side effects on the supply state

Copy link
Member

Choose a reason for hiding this comment

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

Actually I'm not so sure. Since no reward is actually minted on those null rounds, updating the supply as if there was also seems wrong.

@anorth anorth changed the title update block reward every epoch, use that value to pay block rewards update block reward target from KPI event, use that value to pay block rewards May 12, 2020
@anorth
Copy link
Member

anorth commented May 12, 2020

@whyrusleeping based on our discussion, I have pushed commits here that simplify the minting function to only count non-empty tipsets, since those are the only ones it pays out. The actor no longer references rt.CurrentEpoch() at all.

There are still a bunch of problems, most notably supply over-estimation, but this should pay non-zero rewards reliably (except on the first epoch 😭)

@anorth anorth force-pushed the feat/fix-block-reward-computation branch from c992364 to 3ae5472 Compare May 12, 2020 04:26
@magik6k magik6k merged commit 17cddcf into master May 12, 2020
@magik6k magik6k deleted the feat/fix-block-reward-computation branch May 12, 2020 12:02
aarshkshah1992 pushed a commit that referenced this pull request Jun 29, 2020
…k rewards (#366)

* update block reward every epoch, use that value to pay block rewards

* address review feedback

* fix CumsumRealized additions

* Change reward schedule to only pay on non-empty tipsets

Co-authored-by: anorth <[email protected]>
Co-authored-by: Łukasz Magiera <[email protected]>
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.

5 participants