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 3600001
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszmatczak committed Dec 3, 2019
1 parent 1d30852 commit 6cf2a66
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
12 changes: 10 additions & 2 deletions core/assets/assets.go
Expand Up @@ -347,6 +347,14 @@ 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,
0x33, 0x30, 0x30, 0x30, 0x30, 0x31, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
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, 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, 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,
Expand Down Expand Up @@ -386,8 +394,8 @@ func init() {
},
fi: FileInfo{
name: "mainnet.json",
size: 2919,
modTime: time.Unix(0, 1571037183279753001),
size: 3015,
modTime: time.Unix(0, 1575374661441734236),
isDir: false,
},
}, "/core/config/morden.json": File{
Expand Down
4 changes: 4 additions & 0 deletions core/config/mainnet.json
Expand Up @@ -78,6 +78,10 @@
{
"name": "Halving",
"block": 3300001
},
{
"name": "Reward",
"block": 3600001
}
],
"badHashes": [
Expand Down
7 changes: 5 additions & 2 deletions core/state_processor.go
Expand Up @@ -210,7 +210,7 @@ func GetBlockWinnerRewardByEra(eraOrig *big.Int) *big.Int {
}

if era.Cmp(big.NewInt(45)) >= 0 {
era.Add(era, big.NewInt(162)) // skip 162 eras due to halving
era.Add(era, big.NewInt(475)) // skip 475 eras due to reward decrease
}

// MaxBlockReward _r_ * (249/250)**era == MaxBlockReward * (249**era) / (250**era)
Expand All @@ -224,7 +224,10 @@ func GetBlockWinnerRewardByEra(eraOrig *big.Int) *big.Int {
r.Mul(MaximumBlockReward, q)
r.Div(r, d)

if era.Cmp(big.NewInt(33)) >= 0 && era.Cmp(big.NewInt(45)) < 0 {
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(33)) >= 0 && era.Cmp(big.NewInt(36)) < 0 {
// r - (r/2/(45-33) * (era-33+1))
r = GetBlockWinnerRewardByEra(big.NewInt(33-1))
r2 := new(big.Int)
Expand Down

0 comments on commit 6cf2a66

Please sign in to comment.