Skip to content

Commit 4e62e06

Browse files
authored
extend foundation bonus from fairbank to 1 yr later (iotexproject#2143)
* extend foundation bonus from fairbank to 1 yr later * add FoundationBonusP2StartEpoch, FoundationBonusP2EndEpoch in genesis.go
1 parent a6123bf commit 4e62e06

File tree

14 files changed

+44
-26
lines changed

14 files changed

+44
-26
lines changed

action/protocol/account/transfer_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestProtocol_HandleTransfer(t *testing.T) {
7878
}).AnyTimes()
7979

8080
p := NewProtocol(rewarding.DepositGas)
81-
reward := rewarding.NewProtocol(nil)
81+
reward := rewarding.NewProtocol(nil, 0, 0)
8282
registry := protocol.NewRegistry()
8383
require.NoError(reward.Register(registry))
8484
rp := rolldpos.NewProtocol(1, 1, 1)

action/protocol/execution/protocol_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ func (sct *SmartContractTest) prepareBlockchain(
313313
protocol.NewGenericValidator(sf, accountutil.AccountState),
314314
)),
315315
)
316-
reward := rewarding.NewProtocol(nil)
316+
reward := rewarding.NewProtocol(nil, 0, 0)
317317
r.NoError(reward.Register(registry))
318318

319319
r.NotNil(bc)

action/protocol/rewarding/protocol.go

+12-7
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,30 @@ type Productivity func(uint64, uint64) (map[string]uint64, error)
4646
// reward amount, users to donate tokens to the fund, block producers to grant them block and epoch reward and,
4747
// beneficiaries to claim the balance into their personal account.
4848
type Protocol struct {
49-
productivity Productivity
50-
keyPrefix []byte
51-
addr address.Address
49+
productivity Productivity
50+
keyPrefix []byte
51+
addr address.Address
52+
foundationBonusP2StartEpoch uint64
53+
foundationBonusP2EndEpoch uint64
5254
}
5355

5456
// NewProtocol instantiates a rewarding protocol instance.
5557
func NewProtocol(
5658
productivity Productivity,
59+
foundationBonusP2Start uint64,
60+
foundationBonusP2End uint64,
5761
) *Protocol {
5862
h := hash.Hash160b([]byte(protocolID))
5963
addr, err := address.FromBytes(h[:])
6064
if err != nil {
6165
log.L().Panic("Error when constructing the address of rewarding protocol", zap.Error(err))
6266
}
6367
return &Protocol{
64-
productivity: productivity,
65-
keyPrefix: h[:],
66-
addr: addr,
68+
productivity: productivity,
69+
keyPrefix: h[:],
70+
addr: addr,
71+
foundationBonusP2StartEpoch: foundationBonusP2Start,
72+
foundationBonusP2EndEpoch: foundationBonusP2End,
6773
}
6874
}
6975

@@ -98,7 +104,6 @@ func (p *Protocol) CreatePreStates(ctx context.Context, sm protocol.StateManager
98104
return err
99105
}
100106
}
101-
102107
return nil
103108
}
104109

action/protocol/rewarding/protocol_test.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ func testProtocol(t *testing.T, test func(*testing.T, context.Context, protocol.
8484
identityset.Address(31).String(): 2,
8585
},
8686
nil
87-
})
87+
},
88+
genesis.Default.FoundationBonusP2StartEpoch,
89+
genesis.Default.FoundationBonusP2EndEpoch,
90+
)
8891
candidates := []*state.Candidate{
8992
{
9093
Address: identityset.Address(27).String(),
@@ -288,7 +291,7 @@ func TestProtocol_Handle(t *testing.T) {
288291
p := NewProtocol(
289292
func(uint64, uint64) (map[string]uint64, error) {
290293
return nil, nil
291-
})
294+
}, 0, 0)
292295
require.NoError(t, p.Register(registry))
293296
// Test for ForceRegister
294297
require.NoError(t, p.ForceRegister(registry))

action/protocol/rewarding/reward.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ func (p *Protocol) GrantEpochReward(
215215
}
216216

217217
// Reward additional bootstrap bonus
218-
if epochNum <= a.foundationBonusLastEpoch {
218+
if epochNum <= a.foundationBonusLastEpoch || (epochNum >= p.foundationBonusP2StartEpoch && epochNum <= p.foundationBonusP2EndEpoch) {
219219
for i, count := 0, uint64(0); i < len(candidates) && count < a.numDelegatesForFoundationBonus; i++ {
220220
if _, ok := exemptAddrs[candidates[i].Address]; ok {
221221
continue

action/protocol/rewarding/reward_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ func TestProtocol_NoRewardAddr(t *testing.T) {
314314
identityset.Address(1).String(): 10,
315315
},
316316
nil
317-
})
317+
}, 0, 0)
318318
rp := rolldpos.NewProtocol(
319319
genesis.Default.NumCandidateDelegates,
320320
genesis.Default.NumDelegates,

api/api_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1997,7 +1997,7 @@ func setupChain(cfg config.Config) (blockchain.Blockchain, blockdao.BlockDAO, bl
19971997
r := rewarding.NewProtocol(
19981998
func(uint64, uint64) (map[string]uint64, error) {
19991999
return nil, nil
2000-
})
2000+
}, 0, 0)
20012001

20022002
if err := rolldposProtocol.Register(registry); err != nil {
20032003
return nil, nil, nil, nil, nil, nil, err

blockchain/blockchain_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ func TestCreateBlockchain(t *testing.T) {
424424
)
425425
ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGas)
426426
require.NoError(ep.Register(registry))
427-
rewardingProtocol := rewarding.NewProtocol(nil)
427+
rewardingProtocol := rewarding.NewProtocol(nil, 0, 0)
428428
require.NoError(rewardingProtocol.Register(registry))
429429
require.NoError(bc.Start(ctx))
430430
require.NotNil(bc)
@@ -465,7 +465,7 @@ func TestBlockchain_MintNewBlock(t *testing.T) {
465465
)
466466
ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGas)
467467
require.NoError(t, ep.Register(registry))
468-
rewardingProtocol := rewarding.NewProtocol(nil)
468+
rewardingProtocol := rewarding.NewProtocol(nil, 0, 0)
469469
require.NoError(t, rewardingProtocol.Register(registry))
470470
require.NoError(t, bc.Start(ctx))
471471
defer func() {
@@ -540,7 +540,7 @@ func TestBlockchain_MintNewBlock_PopAccount(t *testing.T) {
540540
require.NoError(t, rp.Register(registry))
541541
ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGas)
542542
require.NoError(t, ep.Register(registry))
543-
rewardingProtocol := rewarding.NewProtocol(nil)
543+
rewardingProtocol := rewarding.NewProtocol(nil, 0, 0)
544544
require.NoError(t, rewardingProtocol.Register(registry))
545545
require.NoError(t, bc.Start(ctx))
546546
defer func() {
@@ -641,7 +641,7 @@ func TestConstantinople(t *testing.T) {
641641
)
642642
ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGas)
643643
require.NoError(ep.Register(registry))
644-
rewardingProtocol := rewarding.NewProtocol(nil)
644+
rewardingProtocol := rewarding.NewProtocol(nil, 0, 0)
645645
require.NoError(rewardingProtocol.Register(registry))
646646
require.NoError(bc.Start(ctx))
647647
defer func() {
@@ -1054,7 +1054,7 @@ func TestBlockchainInitialCandidate(t *testing.T) {
10541054
genesis.Default.NumSubEpochs,
10551055
)
10561056
require.NoError(rolldposProtocol.Register(registry))
1057-
rewardingProtocol := rewarding.NewProtocol(nil)
1057+
rewardingProtocol := rewarding.NewProtocol(nil, 0, 0)
10581058
require.NoError(rewardingProtocol.Register(registry))
10591059
pollProtocol := poll.NewLifeLongDelegatesProtocol(cfg.Genesis.Delegates)
10601060
require.NoError(pollProtocol.Register(registry))

blockchain/genesis/genesis.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ func defaultConfig() Genesis {
7979
FoundationBonusStr: unit.ConvertIotxToRau(80).String(),
8080
NumDelegatesForFoundationBonus: 36,
8181
FoundationBonusLastEpoch: 8760,
82+
FoundationBonusP2StartEpoch: 0, // TODO: replace with fair bank epoch
83+
FoundationBonusP2EndEpoch: 0, // TODO: replace with fair bank epoch + 8760
8284
},
8385
Staking: Staking{
8486
VoteWeightCalConsts: VoteWeightCalConsts{
@@ -235,8 +237,11 @@ type (
235237
NumDelegatesForFoundationBonus uint64 `yaml:"numDelegatesForFoundationBonus"`
236238
// FoundationBonusLastEpoch is the last epoch number that bootstrap bonus will be granted
237239
FoundationBonusLastEpoch uint64 `yaml:"foundationBonusLastEpoch"`
238-
// ProductivityThreshold is the percentage number that a delegate's productivity needs to reach to get the
239-
// epoch reward
240+
// FoundationBonusP2StartEpoch is the start epoch number for part 2 foundation bonus
241+
FoundationBonusP2StartEpoch uint64 `yaml:"foundationBonusP2StartEpoch"`
242+
// FoundationBonusP2EndEpoch is the end epoch number for part 2 foundation bonus
243+
FoundationBonusP2EndEpoch uint64 `yaml:"foundationBonusP2EndEpoch"`
244+
// ProductivityThreshold is the percentage number that a delegate's productivity needs to reach not to get probation
240245
ProductivityThreshold uint64 `yaml:"productivityThreshold"`
241246
}
242247
// Staking contains the configs for staking protocol

chainservice/chainservice.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,10 @@ func New(
308308
rewardingProtocol := rewarding.NewProtocol(
309309
func(start uint64, end uint64) (map[string]uint64, error) {
310310
return blockchain.Productivity(chain, start, end)
311-
})
311+
},
312+
cfg.Genesis.FoundationBonusP2StartEpoch,
313+
cfg.Genesis.FoundationBonusP2EndEpoch,
314+
)
312315
// TODO: explorer dependency deleted at #1085, need to revive by migrating to api
313316
consensus, err := consensus.NewConsensus(cfg, chain, sf, actPool, copts...)
314317
if err != nil {

consensus/scheme/rolldpos/roundcalculator_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ func makeChain(t *testing.T) (blockchain.Blockchain, factory.Factory, *rolldpos.
196196
func(start uint64, end uint64) (map[string]uint64, error) {
197197
return blockchain.Productivity(chain, start, end)
198198
},
199+
0,
200+
0,
199201
)
200202
require.NoError(rewardingProtocol.Register(registry))
201203
acc := account.NewProtocol(rewarding.DepositGas)

e2etest/bigint_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func prepareBlockchain(ctx context.Context, executor string, r *require.Assertio
9292
)),
9393
)
9494
r.NotNil(bc)
95-
reward := rewarding.NewProtocol(nil)
95+
reward := rewarding.NewProtocol(nil, 0, 0)
9696
r.NoError(reward.Register(registry))
9797

9898
ep := execution.NewProtocol(dao.GetBlockHash, rewarding.DepositGas)

e2etest/local_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func TestLocalCommit(t *testing.T) {
191191
cfg.Genesis.NumSubEpochs,
192192
)
193193
require.NoError(rolldposProtocol.Register(registry))
194-
rewardingProtocol := rewarding.NewProtocol(nil)
194+
rewardingProtocol := rewarding.NewProtocol(nil, 0, 0)
195195
require.NoError(rewardingProtocol.Register(registry))
196196
acc := account.NewProtocol(rewarding.DepositGas)
197197
require.NoError(acc.Register(registry))

gasstation/gasstattion_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func TestSuggestGasPriceForUserAction(t *testing.T) {
6363
)
6464
ep := execution.NewProtocol(blkMemDao.GetBlockHash, rewarding.DepositGas)
6565
require.NoError(t, ep.Register(registry))
66-
rewardingProtocol := rewarding.NewProtocol(nil)
66+
rewardingProtocol := rewarding.NewProtocol(nil, 0, 0)
6767
require.NoError(t, rewardingProtocol.Register(registry))
6868
require.NoError(t, bc.Start(ctx))
6969
defer func() {
@@ -141,7 +141,7 @@ func TestSuggestGasPriceForSystemAction(t *testing.T) {
141141
)
142142
ep := execution.NewProtocol(blkMemDao.GetBlockHash, rewarding.DepositGas)
143143
require.NoError(t, ep.Register(registry))
144-
rewardingProtocol := rewarding.NewProtocol(nil)
144+
rewardingProtocol := rewarding.NewProtocol(nil, 0, 0)
145145
require.NoError(t, rewardingProtocol.Register(registry))
146146
require.NoError(t, bc.Start(ctx))
147147
defer func() {

0 commit comments

Comments
 (0)