Change build params
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
parent
b611637652
commit
b90f45fa60
@ -1,12 +0,0 @@
|
|||||||
package build
|
|
||||||
|
|
||||||
import (
|
|
||||||
"math/big"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestEncodeMiningRewardInitial(t *testing.T) {
|
|
||||||
i := &big.Int{}
|
|
||||||
i.SetString("153856870367821447423", 10)
|
|
||||||
t.Logf("%#v", i.Bytes())
|
|
||||||
}
|
|
@ -1,5 +1,7 @@
|
|||||||
package build
|
package build
|
||||||
|
|
||||||
|
import "math/big"
|
||||||
|
|
||||||
// Core network constants
|
// Core network constants
|
||||||
|
|
||||||
const UnixfsChunkSize uint64 = 1 << 20
|
const UnixfsChunkSize uint64 = 1 << 20
|
||||||
@ -30,7 +32,9 @@ const CollateralPrecision = 100
|
|||||||
const TotalFilecoin = 2000000000
|
const TotalFilecoin = 2000000000
|
||||||
const MiningRewardTotal = 1400000000
|
const MiningRewardTotal = 1400000000
|
||||||
|
|
||||||
var MiningRewardInitialAttoFilBytes = []byte{0x8, 0x57, 0x31, 0x68, 0x6e, 0x4f, 0x52, 0x40, 0xff}
|
const MiningRewardInitialAttoFilString = "153856870367821447423"
|
||||||
|
|
||||||
|
var MiningRewardInitialAttoFil *big.Int
|
||||||
|
|
||||||
const FilecoinPrecision = 1000000000000000000
|
const FilecoinPrecision = 1000000000000000000
|
||||||
|
|
||||||
@ -42,3 +46,14 @@ const HalvingPeriodBlocks = 6 * 365 * 24 * 60 * 2
|
|||||||
const AdjustmentPeriod = 7 * 24 * 60 * 2
|
const AdjustmentPeriod = 7 * 24 * 60 * 2
|
||||||
|
|
||||||
// TODO: Move other important consts here
|
// TODO: Move other important consts here
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
MiningRewardInitialAttoFil = new(big.Int)
|
||||||
|
|
||||||
|
var ok bool
|
||||||
|
MiningRewardInitialAttoFil, ok = MiningRewardInitialAttoFil.
|
||||||
|
SetString(MiningRewardInitialAttoFilString, 10)
|
||||||
|
if !ok {
|
||||||
|
panic("could not parse MiningRewardInitialAttoFilString")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -633,14 +633,13 @@ func DepositFunds(act *types.Actor, amt types.BigInt) {
|
|||||||
act.Balance = types.BigAdd(act.Balance, amt)
|
act.Balance = types.BigAdd(act.Balance, amt)
|
||||||
}
|
}
|
||||||
|
|
||||||
var initialReward = types.BigInt{big.NewInt(0).SetBytes(build.MiningRewardInitialAttoFilBytes)}
|
|
||||||
var miningRewardTotal = types.FromFil(build.MiningRewardTotal)
|
var miningRewardTotal = types.FromFil(build.MiningRewardTotal)
|
||||||
|
|
||||||
// MiningReward returns correct mining reward
|
// MiningReward returns correct mining reward
|
||||||
// coffer is amount of FIL in NetworkAddress
|
// coffer is amount of FIL in NetworkAddress
|
||||||
func MiningReward(remainingReward types.BigInt) types.BigInt {
|
func MiningReward(remainingReward types.BigInt) types.BigInt {
|
||||||
ci := big.NewInt(0).Set(coffer.Int)
|
ci := big.NewInt(0).Set(remainingReward.Int)
|
||||||
res := ci.Mul(ci, IV.Int)
|
res := ci.Mul(ci, build.MiningRewardInitialAttoFil)
|
||||||
res = res.Div(res, miningRewardTotal.Int)
|
res = res.Div(res, miningRewardTotal.Int)
|
||||||
return types.BigInt{res}
|
return types.BigInt{res}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package vm
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math/big"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-lotus/build"
|
"github.com/filecoin-project/go-lotus/build"
|
||||||
@ -9,19 +10,19 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestBlockReward(t *testing.T) {
|
func TestBlockReward(t *testing.T) {
|
||||||
coffer := types.FromFil(build.MiningRewardTotal)
|
coffer := types.FromFil(build.MiningRewardTotal).Int
|
||||||
sum := types.NewInt(0)
|
sum := new(big.Int)
|
||||||
N := build.HalvingPeriodBlocks
|
N := build.HalvingPeriodBlocks
|
||||||
for i := 0; i < N; i++ {
|
for i := 0; i < N; i++ {
|
||||||
a := MiningReward(coffer)
|
a := MiningReward(types.BigInt{coffer})
|
||||||
sum = types.BigAdd(sum, a)
|
sum = sum.Add(sum, a.Int)
|
||||||
coffer = types.BigSub(coffer, a)
|
coffer = coffer.Sub(coffer, a.Int)
|
||||||
}
|
}
|
||||||
|
|
||||||
//sum = types.BigMul(sum, types.NewInt(60))
|
//sum = types.BigMul(sum, types.NewInt(60))
|
||||||
|
|
||||||
fmt.Println("After a halving period")
|
fmt.Println("After a halving period")
|
||||||
fmt.Printf("Total reward: %d\n", build.MiningRewardTotal)
|
fmt.Printf("Total reward: %d\n", build.MiningRewardTotal)
|
||||||
fmt.Printf("Remaining: %s\n", types.BigDiv(coffer, types.NewInt(build.FilecoinPrecision)))
|
fmt.Printf("Remaining: %s\n", types.BigDiv(types.BigInt{coffer}, types.NewInt(build.FilecoinPrecision)))
|
||||||
fmt.Printf("Given out: %s\n", types.BigDiv(sum, types.NewInt(build.FilecoinPrecision)))
|
fmt.Printf("Given out: %s\n", types.BigDiv(types.BigInt{sum}, types.NewInt(build.FilecoinPrecision)))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user