implement a minimum miner size
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
0b4db5530c
commit
d64f8a38d1
@ -29,6 +29,9 @@ const InteractivePoRepDelay = 2
|
|||||||
// Epochs
|
// Epochs
|
||||||
const InteractivePoRepConfidence = 6
|
const InteractivePoRepConfidence = 6
|
||||||
|
|
||||||
|
// Bytes
|
||||||
|
const MinimumMinerPower = 2 << 10 // 2KiB
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
os.Setenv("TRUST_PARAMS", "1")
|
os.Setenv("TRUST_PARAMS", "1")
|
||||||
}
|
}
|
||||||
|
@ -31,3 +31,6 @@ const InteractivePoRepDelay = 8
|
|||||||
|
|
||||||
// Epochs
|
// Epochs
|
||||||
const InteractivePoRepConfidence = 6
|
const InteractivePoRepConfidence = 6
|
||||||
|
|
||||||
|
// Bytes
|
||||||
|
const MinimumMinerPower = 20 << 30 // 20GB
|
||||||
|
@ -77,6 +77,7 @@ const CollateralPrecision = 1000
|
|||||||
const TotalFilecoin = 2_000_000_000
|
const TotalFilecoin = 2_000_000_000
|
||||||
const MiningRewardTotal = 1_400_000_000
|
const MiningRewardTotal = 1_400_000_000
|
||||||
|
|
||||||
|
|
||||||
const InitialRewardStr = "153856861913558700202"
|
const InitialRewardStr = "153856861913558700202"
|
||||||
|
|
||||||
var InitialReward *big.Int
|
var InitialReward *big.Int
|
||||||
|
@ -912,8 +912,14 @@ func onSuccessfulPoSt(self *StorageMinerActorState, vmctx types.VMContext) aerro
|
|||||||
faults := []uint64{} // TODO
|
faults := []uint64{} // TODO
|
||||||
|
|
||||||
oldPower := self.Power
|
oldPower := self.Power
|
||||||
self.Power = types.BigMul(types.NewInt(pss.Count-uint64(len(faults))),
|
newPower := types.BigMul(types.NewInt(pss.Count-uint64(len(faults))), types.NewInt(mi.SectorSize))
|
||||||
types.NewInt(mi.SectorSize))
|
|
||||||
|
// If below the minimum size requirement, miners have zero power
|
||||||
|
if newPower.LessThan(types.NewInt(build.MinimumMinerPower)) {
|
||||||
|
newPower = types.NewInt(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
self.Power = newPower
|
||||||
|
|
||||||
delta := types.BigSub(self.Power, oldPower)
|
delta := types.BigSub(self.Power, oldPower)
|
||||||
if self.SlashedAt != 0 {
|
if self.SlashedAt != 0 {
|
||||||
@ -922,11 +928,12 @@ func onSuccessfulPoSt(self *StorageMinerActorState, vmctx types.VMContext) aerro
|
|||||||
}
|
}
|
||||||
|
|
||||||
prevSlashingDeadline := self.ElectionPeriodStart + build.SlashablePowerDelay
|
prevSlashingDeadline := self.ElectionPeriodStart + build.SlashablePowerDelay
|
||||||
if !self.Active {
|
if !self.Active && newPower.GreaterThan(types.NewInt(0)) {
|
||||||
self.Active = true
|
self.Active = true
|
||||||
prevSlashingDeadline = 0
|
prevSlashingDeadline = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !(oldPower.IsZero() && newPower.IsZero()) {
|
||||||
enc, err := SerializeParams(&UpdateStorageParams{
|
enc, err := SerializeParams(&UpdateStorageParams{
|
||||||
Delta: delta,
|
Delta: delta,
|
||||||
NextProvingPeriodEnd: vmctx.BlockHeight() + build.SlashablePowerDelay,
|
NextProvingPeriodEnd: vmctx.BlockHeight() + build.SlashablePowerDelay,
|
||||||
@ -940,6 +947,7 @@ func onSuccessfulPoSt(self *StorageMinerActorState, vmctx types.VMContext) aerro
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self.ProvingSet = self.Sectors
|
self.ProvingSet = self.Sectors
|
||||||
self.ElectionPeriodStart = vmctx.BlockHeight()
|
self.ElectionPeriodStart = vmctx.BlockHeight()
|
||||||
|
@ -237,3 +237,7 @@ func (bi *BigInt) UnmarshalCBOR(br io.Reader) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (bi *BigInt) IsZero() bool {
|
||||||
|
return bi.Int.Sign() == 0
|
||||||
|
}
|
||||||
|
@ -17,6 +17,10 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/cmd/lotus-seed/seed"
|
"github.com/filecoin-project/lotus/cmd/lotus-seed/seed"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
build.SectorSizes = []uint64{1024}
|
||||||
|
}
|
||||||
|
|
||||||
func (api *api) Spawn() (nodeInfo, error) {
|
func (api *api) Spawn() (nodeInfo, error) {
|
||||||
dir, err := ioutil.TempDir(os.TempDir(), "lotus-")
|
dir, err := ioutil.TempDir(os.TempDir(), "lotus-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -36,7 +40,7 @@ func (api *api) Spawn() (nodeInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sbroot := filepath.Join(dir, "preseal")
|
sbroot := filepath.Join(dir, "preseal")
|
||||||
genm, err := seed.PreSeal(genMiner, build.SectorSizes[0], 0, 1, sbroot, []byte("8"))
|
genm, err := seed.PreSeal(genMiner, build.SectorSizes[0], 0, 2, sbroot, []byte("8"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nodeInfo{}, xerrors.Errorf("preseal failed: %w", err)
|
return nodeInfo{}, xerrors.Errorf("preseal failed: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -170,8 +170,6 @@ eventLoop:
|
|||||||
}
|
}
|
||||||
lastBase = *base
|
lastBase = *base
|
||||||
|
|
||||||
log.Infof("Time delta between now and our mining base: %ds", uint64(time.Now().Unix())-base.ts.MinTimestamp())
|
|
||||||
|
|
||||||
blks := make([]*types.BlockMsg, 0)
|
blks := make([]*types.BlockMsg, 0)
|
||||||
|
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
@ -272,6 +270,8 @@ func (m *Miner) mineOne(ctx context.Context, addr address.Address, base *MiningB
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Infof("Time delta between now and our mining base: %ds", uint64(time.Now().Unix())-base.ts.MinTimestamp())
|
||||||
|
|
||||||
ticket, err := m.computeTicket(ctx, addr, base)
|
ticket, err := m.computeTicket(ctx, addr, base)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("scratching ticket failed: %w", err)
|
return nil, xerrors.Errorf("scratching ticket failed: %w", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user