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

[reward] extend foundation bonus #2785

Merged
merged 2 commits into from
Sep 30, 2021
Merged

Conversation

dustinxie
Copy link
Member

No description provided.

@dustinxie dustinxie requested a review from a team as a code owner September 9, 2021 22:55
@codecov
Copy link

codecov bot commented Sep 10, 2021

Codecov Report

Merging #2785 (1faa53c) into master (baa0a92) will increase coverage by 0.09%.
The diff coverage is 88.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2785      +/-   ##
==========================================
+ Coverage   57.87%   57.97%   +0.09%     
==========================================
  Files         245      245              
  Lines       22445    22513      +68     
==========================================
+ Hits        12991    13051      +60     
- Misses       7805     7809       +4     
- Partials     1649     1653       +4     
Impacted Files Coverage Δ
action/protocol/rewarding/reward.go 71.23% <50.00%> (-0.55%) ⬇️
action/protocol/rewarding/protocol.go 69.83% <84.44%> (+3.49%) ⬆️
action/protocol/rewarding/admin.go 73.83% <100.00%> (+3.44%) ⬆️
blockchain/genesis/genesis.go 71.42% <100.00%> (+0.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update baa0a92...1faa53c. Read the comment docs.


for _, h := range []uint64{
g.GreenlandBlockHeight,
g.KamchatkaBlockHeight,
Copy link
Member Author

Choose a reason for hiding this comment

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

this test is refactored to cover migration at both Greenland and Kamchatka height

foundationBonusP2EndEpoch uint64
keyPrefix []byte
addr address.Address
cfg genesis.Rewarding
Copy link
Member Author

Choose a reason for hiding this comment

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

the P2 bonus extension is not done properly, we just add 2 numbers P2Start/End into the Protocol{}, business logic to determine bonus partly depends on the admin{} stored in the statedb, and partly depends on these 2
see comment in reward.go

if a.hasFoundationBonusExtension() {
grantFB = a.grantFoundationBonus(epochNum)
} else {
grantFB = epochNum <= a.foundationBonusLastEpoch || (epochNum >= p.cfg.FoundationBonusP2StartEpoch && epochNum <= p.cfg.FoundationBonusP2EndEpoch)
Copy link
Member Author

@dustinxie dustinxie Sep 10, 2021

Choose a reason for hiding this comment

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

grant bonus depends on both admin{} stored in statedb, and P2Start/End in local struct, which is kind of weird

at Kamchatka height, we add the bonus Start/End epoch into admin{}, so it solely depends on admin{} stored in statedb

@@ -96,6 +112,8 @@ func (p *Protocol) CreatePreStates(ctx context.Context, sm protocol.StateManager
return p.SetReward(ctx, sm, g.DardanellesBlockReward(), true)
case g.GreenlandBlockHeight:
return p.migrateValueGreenland(ctx, sm)
case g.KamchatkaBlockHeight:
return p.setFoundationBonusExtension(ctx, sm)
Copy link
Member Author

@dustinxie dustinxie Sep 10, 2021

Choose a reason for hiding this comment

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

at Kamchatka height, we add the bonus Start/End epoch into admin{}, so the business logic now solely depends on admin{} stored in statedb

// verify that foundation bonus extension epochs are in increasing order
func validateFoundationBonusExtension(cfg genesis.Rewarding) error {
end := cfg.FoundationBonusLastEpoch
if cfg.FoundationBonusP2StartEpoch < end || cfg.FoundationBonusP2EndEpoch < cfg.FoundationBonusP2StartEpoch {
Copy link
Collaborator

Choose a reason for hiding this comment

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

if FoundationBonusP2StartEpoch == 0 && FoundationBonusP2EndEpoch == 0, we may skip this validation

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch, updated PR

return errInvalidEpoch
}

end = cfg.FoundationBonusP2EndEpoch
Copy link
Collaborator

Choose a reason for hiding this comment

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

if cfg.FoundationBonusP2EndEpoch > end {
  end = cfg.FoundationBonusP2EndEpoch
}

return errInvalidEpoch
}

last := len(p.cfg.FoundationBonusExtension) - 1
Copy link
Member Author

Choose a reason for hiding this comment

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

for future extension, only need to add the last/new entry

a.foundationBonusExtension = append(a.foundationBonusExtension,
genesis.Period{v.Start, v.End})
hasP2Extension := (p.cfg.FoundationBonusP2StartEpoch > 0 || p.cfg.FoundationBonusP2EndEpoch > 0)
if !a.hasFoundationBonusExtension() {
Copy link
Member Author

Choose a reason for hiding this comment

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

first time add extension

@dustinxie dustinxie merged commit ebe895c into iotexproject:master Sep 30, 2021
millken added a commit that referenced this pull request Oct 8, 2021
* [reward] extend foundation bonus (#2785)

* Add unit tests to cover the functions in action/signedaction.go (#2824)

* limit the pagination size for all API calls to 5000 -- 2781 (#2800)

Co-authored-by: dayuanc <wentaicui@WENTAIs-MacBook-Pro.local>
Co-authored-by: CoderZhi <thecoderzhi@gmail.com>
Co-authored-by: Raullen Chai <raullenchai@gmail.com>

* remove unnecessary WithFeatureCtx() (#2823)

* fix ioctl accountDelete test (#2825)

* [ioctl] display chainID and encoding (#2820)

* bump Go to 1.17 (#2784)

* [api] add cache for ReadContract/State() (#2827)

Co-authored-by: dustinxie <dahuaxie@gmail.com>
Co-authored-by: dayuanc <34013965+dayuanc@users.noreply.github.com>
Co-authored-by: dayuanc <wentaicui@WENTAIs-MacBook-Pro.local>
Co-authored-by: CoderZhi <thecoderzhi@gmail.com>
Co-authored-by: Raullen Chai <raullenchai@gmail.com>
Co-authored-by: Haaai <55118568+Liuhaai@users.noreply.github.com>

Co-authored-by: dustinxie <dahuaxie@gmail.com>
Co-authored-by: dayuanc <34013965+dayuanc@users.noreply.github.com>
Co-authored-by: dayuanc <wentaicui@WENTAIs-MacBook-Pro.local>
Co-authored-by: CoderZhi <thecoderzhi@gmail.com>
Co-authored-by: Raullen Chai <raullenchai@gmail.com>
Co-authored-by: Haaai <55118568+Liuhaai@users.noreply.github.com>
millken added a commit that referenced this pull request Oct 8, 2021
* saving, switch to linux

* tracing grpc api

* saving, switch to linux

* tracing grpc api

* update tracer.go for test

* small change

* fix comments

* Squashed commit of the following:

commit 77a5a15
Author: dustinxie <dahuaxie@gmail.com>
Date:   Tue Oct 5 23:34:52 2021 -0700

    [api] add cache for ReadContract/State() (#2827)

commit 7d9bf96
Author: Haaai <55118568+Liuhaai@users.noreply.github.com>
Date:   Tue Oct 5 17:31:37 2021 -0700

    bump Go to 1.17 (#2784)

commit 09ef379
Author: dustinxie <dahuaxie@gmail.com>
Date:   Tue Oct 5 16:46:49 2021 -0700

    [ioctl] display chainID and encoding (#2820)

commit c2eab8d
Author: Haaai <55118568+Liuhaai@users.noreply.github.com>
Date:   Tue Oct 5 15:45:45 2021 -0700

    fix ioctl accountDelete test (#2825)

commit 9489b57
Author: dustinxie <dahuaxie@gmail.com>
Date:   Tue Oct 5 15:14:31 2021 -0700

    remove unnecessary WithFeatureCtx() (#2823)

commit 3933ae9
Author: dayuanc <34013965+dayuanc@users.noreply.github.com>
Date:   Tue Oct 5 07:40:32 2021 -0700

    limit the pagination size for all API calls to 5000 -- 2781 (#2800)

    Co-authored-by: dayuanc <wentaicui@WENTAIs-MacBook-Pro.local>
    Co-authored-by: CoderZhi <thecoderzhi@gmail.com>
    Co-authored-by: Raullen Chai <raullenchai@gmail.com>

commit 88d273d
Author: dayuanc <34013965+dayuanc@users.noreply.github.com>
Date:   Mon Oct 4 10:51:54 2021 -0700

    Add unit tests to cover the functions in action/signedaction.go (#2824)

commit ebe895c
Author: dustinxie <dahuaxie@gmail.com>
Date:   Thu Sep 30 15:32:52 2021 -0700

    [reward] extend foundation bonus (#2785)

commit baa0a92
Author: CoderZhi <thecoderzhi@gmail.com>
Date:   Tue Sep 28 14:09:44 2021 -0700

    Fix codecov (#2813)

commit 84f06d3
Author: dayuanc <34013965+dayuanc@users.noreply.github.com>
Date:   Tue Sep 28 12:17:47 2021 -0700

    reduce unnecessary logs for mainnet (#2808)

    * downgrade some unnecessary error and info logs

    * fix comments

    Co-authored-by: Raullen Chai <raullenchai@gmail.com>

commit a245185
Author: dustinxie <dahuaxie@gmail.com>
Date:   Mon Sep 27 15:27:59 2021 -0700

    [evm] panic in AccessList API (#2816)

commit 8eec1b7
Author: dustinxie <dahuaxie@gmail.com>
Date:   Mon Sep 27 11:01:34 2021 -0700

    set Jutland to activate at 10-11-2021 3pm PDT (#2812)

    Co-authored-by: Raullen Chai <raullenchai@gmail.com>

commit e89be88
Author: CoderZhi <thecoderzhi@gmail.com>
Date:   Sat Sep 25 22:51:54 2021 -0700

    set target height (#2807)

    Co-authored-by: dustinxie <dahuaxie@gmail.com>

commit dba4993
Author: CoderZhi <thecoderzhi@gmail.com>
Date:   Thu Sep 23 11:44:26 2021 -0700

    change commit block failure log level to error (#2810)

commit 0459a1f
Author: mas walker <handsome.void@gmail.com>
Date:   Wed Sep 22 20:18:23 2021 +0800

    unbound feature and version/height (#2768)

    * unbound feature and version/height

    Co-authored-by: Raullen Chai <raullenchai@gmail.com>

commit c1cea44
Author: millken <millken@gmail.com>
Date:   Tue Sep 21 06:31:57 2021 +0800

    update circleci config, using golang 1.16.6 #2789 (#2791)

    Co-authored-by: dustinxie <dahuaxie@gmail.com>

commit f245109
Author: Dustin Xie <dahuaxie@gmail.com>
Date:   Mon Sep 20 09:54:38 2021 -0700

    [evm] enable opCall fix at Jutland height

commit 3eea5b7
Author: Dustin Xie <dahuaxie@gmail.com>
Date:   Mon Sep 20 12:11:36 2021 -0700

    [evm] fix datacopy.json for TestIstanbul

commit 0641db0
Author: CoderZhi <thecoderzhi@gmail.com>
Date:   Fri Sep 17 14:37:28 2021 -0700

    [evm] fix snapshot bug (#2802)

    * fix snapshot bug

    * add unit test

    Co-authored-by: Raullen Chai <raullenchai@gmail.com>

commit e0683e8
Author: Haaai <55118568+Liuhaai@users.noreply.github.com>
Date:   Sat Sep 18 01:34:12 2021 +0800

    add datacopy contract test (#2788)

    * add datacopy test

    * modify contract

    * remove debug log

    * update testdata

    * add attack bytecode

    * update datacopy.json

    * correct code format

    * remove printStore() in datacopy.sol

    * update contract test data

    Co-authored-by: dustinxie <dahuaxie@gmail.com>

commit 44e0a68
Author: Haaai <55118568+Liuhaai@users.noreply.github.com>
Date:   Fri Sep 17 15:31:29 2021 +0800

    Allow ioctl to show the list of actions for an account (#2750)

    * [ioctl] allow ioctl to show the list of actions for an account

commit d10dabe
Author: Haaai <55118568+Liuhaai@users.noreply.github.com>
Date:   Fri Sep 17 12:08:33 2021 +0800

    [api] fix gas estimation calc bug (#2786)

    * fixed gas estimation bug in api.go

* Tracing (#2)

* [reward] extend foundation bonus (#2785)

* Add unit tests to cover the functions in action/signedaction.go (#2824)

* limit the pagination size for all API calls to 5000 -- 2781 (#2800)

Co-authored-by: dayuanc <wentaicui@WENTAIs-MacBook-Pro.local>
Co-authored-by: CoderZhi <thecoderzhi@gmail.com>
Co-authored-by: Raullen Chai <raullenchai@gmail.com>

* remove unnecessary WithFeatureCtx() (#2823)

* fix ioctl accountDelete test (#2825)

* [ioctl] display chainID and encoding (#2820)

* bump Go to 1.17 (#2784)

* [api] add cache for ReadContract/State() (#2827)

Co-authored-by: dustinxie <dahuaxie@gmail.com>
Co-authored-by: dayuanc <34013965+dayuanc@users.noreply.github.com>
Co-authored-by: dayuanc <wentaicui@WENTAIs-MacBook-Pro.local>
Co-authored-by: CoderZhi <thecoderzhi@gmail.com>
Co-authored-by: Raullen Chai <raullenchai@gmail.com>
Co-authored-by: Haaai <55118568+Liuhaai@users.noreply.github.com>

Co-authored-by: Raullen Chai <raullenchai@gmail.com>
Co-authored-by: dustinxie <dahuaxie@gmail.com>
Co-authored-by: dayuanc <34013965+dayuanc@users.noreply.github.com>
Co-authored-by: dayuanc <wentaicui@WENTAIs-MacBook-Pro.local>
Co-authored-by: CoderZhi <thecoderzhi@gmail.com>
Co-authored-by: Haaai <55118568+Liuhaai@users.noreply.github.com>
dustinxie added a commit to dustinxie/iotex-core that referenced this pull request Oct 16, 2021
dustinxie added a commit to dustinxie/iotex-core that referenced this pull request Oct 16, 2021
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.

3 participants