fix initial reward actor balance
This commit is contained in:
parent
84a887cc58
commit
34ad13fc22
@ -84,23 +84,15 @@ const CollateralPrecision = 1000
|
||||
const TotalFilecoin = 2_000_000_000
|
||||
const MiningRewardTotal = 1_400_000_000
|
||||
|
||||
const InitialRewardStr = "153856861913558700202"
|
||||
|
||||
var InitialReward *big.Int
|
||||
|
||||
const FilecoinPrecision = 1_000_000_000_000_000_000
|
||||
|
||||
var InitialRewardBalance *big.Int
|
||||
|
||||
// TODO: Move other important consts here
|
||||
|
||||
func init() {
|
||||
InitialReward = new(big.Int)
|
||||
|
||||
var ok bool
|
||||
InitialReward, ok = InitialReward.
|
||||
SetString(InitialRewardStr, 10)
|
||||
if !ok {
|
||||
panic("could not parse InitialRewardStr")
|
||||
}
|
||||
InitialRewardBalance = big.NewInt(MiningRewardTotal)
|
||||
InitialRewardBalance = InitialRewardBalance.Mul(InitialRewardBalance, big.NewInt(FilecoinPrecision))
|
||||
}
|
||||
|
||||
// Sync
|
||||
|
@ -30,7 +30,7 @@ func SetupRewardActor(bs bstore.Blockstore) (*types.Actor, error) {
|
||||
|
||||
return &types.Actor{
|
||||
Code: builtin.RewardActorCodeID,
|
||||
Balance: types.BigInt{Int: build.InitialReward},
|
||||
Balance: types.BigInt{Int: build.InitialRewardBalance},
|
||||
Head: hcid,
|
||||
}, nil
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ import (
|
||||
"github.com/filecoin-project/specs-actors/actors/runtime"
|
||||
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
|
||||
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/actors/aerrors"
|
||||
"github.com/filecoin-project/lotus/chain/state"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
@ -775,16 +774,3 @@ func deductFunds(act *types.Actor, amt types.BigInt) error {
|
||||
func depositFunds(act *types.Actor, amt types.BigInt) {
|
||||
act.Balance = types.BigAdd(act.Balance, amt)
|
||||
}
|
||||
|
||||
var miningRewardTotal = types.FromFil(build.MiningRewardTotal)
|
||||
var blocksPerEpoch = types.NewInt(build.BlocksPerEpoch)
|
||||
|
||||
// MiningReward returns correct mining reward
|
||||
// coffer is amount of FIL in NetworkAddress
|
||||
func MiningReward(remainingReward types.BigInt) types.BigInt {
|
||||
ci := big.NewInt(0).Set(remainingReward.Int)
|
||||
res := ci.Mul(ci, build.InitialReward)
|
||||
res = res.Div(res, miningRewardTotal.Int)
|
||||
res = res.Div(res, blocksPerEpoch.Int)
|
||||
return types.BigInt{Int: res}
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
package vm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"testing"
|
||||
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
|
||||
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
|
||||
)
|
||||
|
||||
const HalvingPeriodEpochs = 6 * 365 * 24 * 60 * 2
|
||||
|
||||
func TestBlockReward(t *testing.T) {
|
||||
t.Skip()
|
||||
coffer := types.FromFil(build.MiningRewardTotal).Int
|
||||
sum := new(big.Int)
|
||||
N := HalvingPeriodEpochs
|
||||
for i := 0; i < N; i++ {
|
||||
a := MiningReward(types.BigInt{coffer})
|
||||
sum = sum.Add(sum, a.Int)
|
||||
coffer = coffer.Sub(coffer, a.Int)
|
||||
}
|
||||
|
||||
//sum = types.BigMul(sum, types.NewInt(60))
|
||||
|
||||
fmt.Println("After a halving period")
|
||||
fmt.Printf("Total reward: %d\n", build.MiningRewardTotal)
|
||||
fmt.Printf("Remaining: %s\n", types.BigDiv(types.BigInt{coffer}, 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