Skip to content
This repository has been archived by the owner on Apr 4, 2022. It is now read-only.

Commit

Permalink
Introduce reward decrease at block 5000001
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszmatczak committed Jun 25, 2020
1 parent cf4edd6 commit 2e5b6b1
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 39 deletions.
84 changes: 46 additions & 38 deletions core/assets/assets.go
Expand Up @@ -355,47 +355,55 @@ func init() {
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x22, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3a, 0x20, 0x33,
0x36, 0x30, 0x30, 0x30, 0x30, 0x31, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x5d, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x22, 0x62, 0x61, 0x64, 0x48, 0x61, 0x73, 0x68,
0x65, 0x73, 0x22, 0x3a, 0x20, 0x5b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x5d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x2c, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x22, 0x62, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72,
0x61, 0x70, 0x22, 0x3a, 0x20, 0x5b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x22, 0x65, 0x6e, 0x6f, 0x64, 0x65, 0x3a, 0x2f, 0x2f,
0x63, 0x36, 0x65, 0x63, 0x39, 0x61, 0x66, 0x35, 0x30, 0x62, 0x65, 0x38,
0x30, 0x34, 0x65, 0x33, 0x32, 0x62, 0x37, 0x33, 0x66, 0x30, 0x61, 0x32,
0x34, 0x66, 0x31, 0x34, 0x35, 0x62, 0x35, 0x35, 0x30, 0x33, 0x35, 0x64,
0x34, 0x38, 0x64, 0x61, 0x34, 0x34, 0x39, 0x37, 0x66, 0x39, 0x66, 0x31,
0x63, 0x64, 0x66, 0x64, 0x38, 0x64, 0x66, 0x65, 0x36, 0x36, 0x39, 0x32,
0x38, 0x38, 0x64, 0x64, 0x30, 0x61, 0x64, 0x33, 0x39, 0x39, 0x31, 0x38,
0x62, 0x66, 0x64, 0x35, 0x39, 0x61, 0x33, 0x32, 0x65, 0x34, 0x61, 0x30,
0x36, 0x38, 0x64, 0x61, 0x61, 0x65, 0x63, 0x31, 0x34, 0x36, 0x65, 0x32,
0x33, 0x33, 0x38, 0x31, 0x63, 0x31, 0x30, 0x63, 0x37, 0x66, 0x35, 0x35,
0x62, 0x34, 0x35, 0x66, 0x35, 0x38, 0x36, 0x65, 0x36, 0x61, 0x64, 0x31,
0x34, 0x62, 0x32, 0x30, 0x37, 0x31, 0x62, 0x63, 0x40, 0x32, 0x31, 0x32,
0x2e, 0x33, 0x32, 0x2e, 0x32, 0x35, 0x35, 0x2e, 0x38, 0x30, 0x3a, 0x33,
0x31, 0x34, 0x34, 0x30, 0x22, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x22, 0x65, 0x6e, 0x6f, 0x64, 0x65, 0x3a, 0x2f, 0x2f,
0x33, 0x33, 0x66, 0x31, 0x63, 0x36, 0x61, 0x39, 0x66, 0x63, 0x37, 0x65,
0x33, 0x32, 0x30, 0x37, 0x30, 0x62, 0x38, 0x64, 0x66, 0x61, 0x36, 0x35,
0x34, 0x64, 0x64, 0x64, 0x31, 0x38, 0x66, 0x64, 0x33, 0x63, 0x63, 0x38,
0x63, 0x31, 0x31, 0x66, 0x39, 0x66, 0x32, 0x31, 0x64, 0x33, 0x37, 0x31,
0x34, 0x31, 0x34, 0x36, 0x33, 0x34, 0x65, 0x38, 0x63, 0x61, 0x63, 0x61,
0x37, 0x35, 0x38, 0x61, 0x34, 0x31, 0x36, 0x36, 0x63, 0x35, 0x63, 0x61,
0x63, 0x61, 0x37, 0x66, 0x35, 0x35, 0x35, 0x63, 0x30, 0x64, 0x38, 0x34,
0x38, 0x31, 0x65, 0x38, 0x30, 0x34, 0x35, 0x32, 0x34, 0x39, 0x32, 0x64,
0x31, 0x62, 0x34, 0x66, 0x62, 0x36, 0x62, 0x35, 0x63, 0x63, 0x37, 0x31,
0x30, 0x32, 0x34, 0x38, 0x35, 0x38, 0x34, 0x39, 0x32, 0x66, 0x33, 0x35,
0x63, 0x36, 0x33, 0x37, 0x33, 0x37, 0x64, 0x34, 0x40, 0x32, 0x31, 0x32,
0x2e, 0x33, 0x32, 0x2e, 0x32, 0x35, 0x35, 0x2e, 0x31, 0x39, 0x35, 0x3a,
0x33, 0x31, 0x34, 0x34, 0x30, 0x22, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x5d,
0x0a, 0x7d, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x2c, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x22, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3a, 0x20,
0x22, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x32, 0x22, 0x2c, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x22, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3a, 0x20,
0x35, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5d, 0x2c, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x62, 0x61, 0x64, 0x48, 0x61, 0x73,
0x68, 0x65, 0x73, 0x22, 0x3a, 0x20, 0x5b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x5d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x2c,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x22, 0x62, 0x6f, 0x6f, 0x74, 0x73, 0x74,
0x72, 0x61, 0x70, 0x22, 0x3a, 0x20, 0x5b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x22, 0x65, 0x6e, 0x6f, 0x64, 0x65, 0x3a, 0x2f,
0x2f, 0x63, 0x36, 0x65, 0x63, 0x39, 0x61, 0x66, 0x35, 0x30, 0x62, 0x65,
0x38, 0x30, 0x34, 0x65, 0x33, 0x32, 0x62, 0x37, 0x33, 0x66, 0x30, 0x61,
0x32, 0x34, 0x66, 0x31, 0x34, 0x35, 0x62, 0x35, 0x35, 0x30, 0x33, 0x35,
0x64, 0x34, 0x38, 0x64, 0x61, 0x34, 0x34, 0x39, 0x37, 0x66, 0x39, 0x66,
0x31, 0x63, 0x64, 0x66, 0x64, 0x38, 0x64, 0x66, 0x65, 0x36, 0x36, 0x39,
0x32, 0x38, 0x38, 0x64, 0x64, 0x30, 0x61, 0x64, 0x33, 0x39, 0x39, 0x31,
0x38, 0x62, 0x66, 0x64, 0x35, 0x39, 0x61, 0x33, 0x32, 0x65, 0x34, 0x61,
0x30, 0x36, 0x38, 0x64, 0x61, 0x61, 0x65, 0x63, 0x31, 0x34, 0x36, 0x65,
0x32, 0x33, 0x33, 0x38, 0x31, 0x63, 0x31, 0x30, 0x63, 0x37, 0x66, 0x35,
0x35, 0x62, 0x34, 0x35, 0x66, 0x35, 0x38, 0x36, 0x65, 0x36, 0x61, 0x64,
0x31, 0x34, 0x62, 0x32, 0x30, 0x37, 0x31, 0x62, 0x63, 0x40, 0x32, 0x31,
0x32, 0x2e, 0x33, 0x32, 0x2e, 0x32, 0x35, 0x35, 0x2e, 0x38, 0x30, 0x3a,
0x33, 0x31, 0x34, 0x34, 0x30, 0x22, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x22, 0x65, 0x6e, 0x6f, 0x64, 0x65, 0x3a, 0x2f,
0x2f, 0x33, 0x33, 0x66, 0x31, 0x63, 0x36, 0x61, 0x39, 0x66, 0x63, 0x37,
0x65, 0x33, 0x32, 0x30, 0x37, 0x30, 0x62, 0x38, 0x64, 0x66, 0x61, 0x36,
0x35, 0x34, 0x64, 0x64, 0x64, 0x31, 0x38, 0x66, 0x64, 0x33, 0x63, 0x63,
0x38, 0x63, 0x31, 0x31, 0x66, 0x39, 0x66, 0x32, 0x31, 0x64, 0x33, 0x37,
0x31, 0x34, 0x31, 0x34, 0x36, 0x33, 0x34, 0x65, 0x38, 0x63, 0x61, 0x63,
0x61, 0x37, 0x35, 0x38, 0x61, 0x34, 0x31, 0x36, 0x36, 0x63, 0x35, 0x63,
0x61, 0x63, 0x61, 0x37, 0x66, 0x35, 0x35, 0x35, 0x63, 0x30, 0x64, 0x38,
0x34, 0x38, 0x31, 0x65, 0x38, 0x30, 0x34, 0x35, 0x32, 0x34, 0x39, 0x32,
0x64, 0x31, 0x62, 0x34, 0x66, 0x62, 0x36, 0x62, 0x35, 0x63, 0x63, 0x37,
0x31, 0x30, 0x32, 0x34, 0x38, 0x35, 0x38, 0x34, 0x39, 0x32, 0x66, 0x33,
0x35, 0x63, 0x36, 0x33, 0x37, 0x33, 0x37, 0x64, 0x34, 0x40, 0x32, 0x31,
0x32, 0x2e, 0x33, 0x32, 0x2e, 0x32, 0x35, 0x35, 0x2e, 0x31, 0x39, 0x35,
0x3a, 0x33, 0x31, 0x34, 0x34, 0x30, 0x22, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x5d, 0x0a, 0x7d, 0x0a,
},
fi: FileInfo{
name: "mainnet.json",
size: 3015,
modTime: time.Unix(0, 1575374661441734236),
size: 3112,
modTime: time.Unix(0, 1593069997257357428),
isDir: false,
},
}, "/core/config/morden.json": File{
Expand Down
4 changes: 4 additions & 0 deletions core/config/mainnet.json
Expand Up @@ -82,6 +82,10 @@
{
"name": "Reward",
"block": 3600001
},
{
"name": "Reward2",
"block": 5000001
}
],
"badHashes": [
Expand Down
7 changes: 6 additions & 1 deletion core/state_processor.go
Expand Up @@ -209,8 +209,10 @@ func GetBlockWinnerRewardByEra(eraOrig *big.Int) *big.Int {
return new(big.Int).Set(MaximumBlockReward)
}

if era.Cmp(big.NewInt(45)) >= 0 {
if era.Cmp(big.NewInt(45)) >= 0 && era.Cmp(big.NewInt(50)) < 0 {
era.Add(era, big.NewInt(475)) // skip 475 eras due to reward decrease
} else if era.Cmp(big.NewInt(56)) >= 0 {
era.Add(era, big.NewInt(865)) // skip 865 eras due to reward decrease
}

// MaxBlockReward _r_ * (249/250)**era == MaxBlockReward * (249**era) / (250**era)
Expand All @@ -227,6 +229,9 @@ func GetBlockWinnerRewardByEra(eraOrig *big.Int) *big.Int {
if era.Cmp(big.NewInt(36)) >= 0 && era.Cmp(big.NewInt(45)) < 0 {
rewards := []int64{2000, 1300, 1200, 1100, 1000, 900, 800, 700, 625}
r.Mul(big.NewInt(rewards[era.Int64()-36]), big.NewInt(10000000000000000))
} else if era.Cmp(big.NewInt(50)) >= 0 && era.Cmp(big.NewInt(56)) < 0 {
rewards := []int64{500, 400, 300, 225, 160, 125}
r.Mul(big.NewInt(rewards[era.Int64()-50]), big.NewInt(10000000000000000))
} else if era.Cmp(big.NewInt(33)) >= 0 && era.Cmp(big.NewInt(36)) < 0 {
// r - (r/2/(45-33) * (era-33+1))
r = GetBlockWinnerRewardByEra(big.NewInt(33-1))
Expand Down

0 comments on commit 2e5b6b1

Please sign in to comment.