fix policy for specs-actors update
This commit is contained in:
parent
2315db161b
commit
1c03862854
@ -169,7 +169,7 @@ func TestPaymentChannels(t *testing.T, b APIBuilder, blocktime time.Duration) {
|
|||||||
return true, nil
|
return true, nil
|
||||||
}, func(ctx context.Context, ts *types.TipSet) error {
|
}, func(ctx context.Context, ts *types.TipSet) error {
|
||||||
return nil
|
return nil
|
||||||
}, int(build.MessageConfidence)+1, build.SealRandomnessLookbackLimit, func(oldTs, newTs *types.TipSet) (bool, events.StateChange, error) {
|
}, int(build.MessageConfidence)+1, build.Finality, func(oldTs, newTs *types.TipSet) (bool, events.StateChange, error) {
|
||||||
return preds.OnPaymentChannelActorChanged(channel, preds.OnToSendAmountChanges())(ctx, oldTs.Key(), newTs.Key())
|
return preds.OnPaymentChannelActorChanged(channel, preds.OnToSendAmountChanges())(ctx, oldTs.Key(), newTs.Key())
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -7,12 +7,12 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/policy"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-state-types/network"
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// /////
|
// /////
|
||||||
@ -35,7 +35,7 @@ const ForkLengthThreshold = Finality
|
|||||||
var BlocksPerEpoch = uint64(builtin.ExpectedLeadersPerEpoch)
|
var BlocksPerEpoch = uint64(builtin.ExpectedLeadersPerEpoch)
|
||||||
|
|
||||||
// Epochs
|
// Epochs
|
||||||
const Finality = miner0.ChainFinality
|
const Finality = policy.ChainFinality
|
||||||
const MessageConfidence = uint64(5)
|
const MessageConfidence = uint64(5)
|
||||||
|
|
||||||
// constants for Weight calculation
|
// constants for Weight calculation
|
||||||
@ -47,13 +47,8 @@ const WRatioDen = uint64(2)
|
|||||||
// Proofs
|
// Proofs
|
||||||
|
|
||||||
// Epochs
|
// Epochs
|
||||||
const SealRandomnessLookback = Finality
|
// TODO: unused
|
||||||
|
const SealRandomnessLookback = policy.SealRandomnessLookback
|
||||||
// Epochs
|
|
||||||
const SealRandomnessLookbackLimit = SealRandomnessLookback + 2000 // TODO: Get from spec specs-actors
|
|
||||||
|
|
||||||
// Maximum lookback that randomness can be sourced from for a seal proof submission
|
|
||||||
const MaxSealLookback = SealRandomnessLookbackLimit + 2000 // TODO: Get from specs-actors
|
|
||||||
|
|
||||||
// /////
|
// /////
|
||||||
// Mining
|
// Mining
|
||||||
|
@ -13,7 +13,8 @@ import (
|
|||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/go-state-types/network"
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/policy"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -32,7 +33,7 @@ var (
|
|||||||
|
|
||||||
AllowableClockDriftSecs = uint64(1)
|
AllowableClockDriftSecs = uint64(1)
|
||||||
|
|
||||||
Finality = miner0.ChainFinality
|
Finality = policy.ChainFinality
|
||||||
ForkLengthThreshold = Finality
|
ForkLengthThreshold = Finality
|
||||||
|
|
||||||
SlashablePowerDelay = 20
|
SlashablePowerDelay = 20
|
||||||
@ -47,9 +48,7 @@ var (
|
|||||||
BlsSignatureCacheSize = 40000
|
BlsSignatureCacheSize = 40000
|
||||||
VerifSigCacheSize = 32000
|
VerifSigCacheSize = 32000
|
||||||
|
|
||||||
SealRandomnessLookback = Finality
|
SealRandomnessLookback = policy.SealRandomnessLookback
|
||||||
SealRandomnessLookbackLimit = SealRandomnessLookback + 2000
|
|
||||||
MaxSealLookback = SealRandomnessLookbackLimit + 2000
|
|
||||||
|
|
||||||
TicketRandomnessLookback = abi.ChainEpoch(1)
|
TicketRandomnessLookback = abi.ChainEpoch(1)
|
||||||
WinningPoStSectorSetLookback = abi.ChainEpoch(10)
|
WinningPoStSectorSetLookback = abi.ChainEpoch(10)
|
||||||
|
@ -2,10 +2,19 @@ package policy
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
|
|
||||||
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
|
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||||
verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
||||||
|
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||||
|
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
|
||||||
|
verifreg2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/verifreg"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ChainFinality = miner0.ChainFinality
|
||||||
|
SealRandomnessLookback = ChainFinality
|
||||||
)
|
)
|
||||||
|
|
||||||
// SetSupportedProofTypes sets supported proof types, across all actor versions.
|
// SetSupportedProofTypes sets supported proof types, across all actor versions.
|
||||||
@ -17,6 +26,7 @@ func SetSupportedProofTypes(types ...abi.RegisteredSealProof) {
|
|||||||
}
|
}
|
||||||
// Set for all miner versions.
|
// Set for all miner versions.
|
||||||
miner0.SupportedProofTypes = newTypes
|
miner0.SupportedProofTypes = newTypes
|
||||||
|
miner2.SupportedProofTypes = newTypes
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddSupportedProofTypes sets supported proof types, across all actor versions.
|
// AddSupportedProofTypes sets supported proof types, across all actor versions.
|
||||||
@ -25,6 +35,7 @@ func AddSupportedProofTypes(types ...abi.RegisteredSealProof) {
|
|||||||
for _, t := range types {
|
for _, t := range types {
|
||||||
// Set for all miner versions.
|
// Set for all miner versions.
|
||||||
miner0.SupportedProofTypes[t] = struct{}{}
|
miner0.SupportedProofTypes[t] = struct{}{}
|
||||||
|
miner2.SupportedProofTypes[t] = struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,6 +44,7 @@ func AddSupportedProofTypes(types ...abi.RegisteredSealProof) {
|
|||||||
func SetPreCommitChallengeDelay(delay abi.ChainEpoch) {
|
func SetPreCommitChallengeDelay(delay abi.ChainEpoch) {
|
||||||
// Set for all miner versions.
|
// Set for all miner versions.
|
||||||
miner0.PreCommitChallengeDelay = delay
|
miner0.PreCommitChallengeDelay = delay
|
||||||
|
miner2.PreCommitChallengeDelay = delay
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this function shouldn't really exist. Instead, the API should expose the precommit delay.
|
// TODO: this function shouldn't really exist. Instead, the API should expose the precommit delay.
|
||||||
@ -45,10 +57,25 @@ func GetPreCommitChallengeDelay() abi.ChainEpoch {
|
|||||||
// for testing.
|
// for testing.
|
||||||
func SetConsensusMinerMinPower(p abi.StoragePower) {
|
func SetConsensusMinerMinPower(p abi.StoragePower) {
|
||||||
power0.ConsensusMinerMinPower = p
|
power0.ConsensusMinerMinPower = p
|
||||||
|
for _, policy := range builtin2.SealProofPolicies {
|
||||||
|
policy.ConsensusMinerMinPower = p
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetMinVerifiedDealSize sets the minimum size of a verified deal. This should
|
// SetMinVerifiedDealSize sets the minimum size of a verified deal. This should
|
||||||
// only be used for testing.
|
// only be used for testing.
|
||||||
func SetMinVerifiedDealSize(size abi.StoragePower) {
|
func SetMinVerifiedDealSize(size abi.StoragePower) {
|
||||||
verifreg0.MinVerifiedDealSize = size
|
verifreg0.MinVerifiedDealSize = size
|
||||||
|
verifreg2.MinVerifiedDealSize = size
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetMaxProveCommitDuration(ver actors.Version, t abi.RegisteredSealProof) abi.ChainEpoch {
|
||||||
|
switch ver {
|
||||||
|
case actors.Version0:
|
||||||
|
return miner0.MaxSealDuration[t]
|
||||||
|
case actors.Version2:
|
||||||
|
return miner2.MaxProveCommitDuration[t]
|
||||||
|
default:
|
||||||
|
panic("unsupported actors version")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,9 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
|
verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
||||||
|
miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner"
|
||||||
|
verifreg2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/verifreg"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSupportedProofTypes(t *testing.T) {
|
func TestSupportedProofTypes(t *testing.T) {
|
||||||
@ -34,3 +37,11 @@ func TestSupportedProofTypes(t *testing.T) {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tests assumptions about policies being the same between actor versions.
|
||||||
|
func TestAssumptions(t *testing.T) {
|
||||||
|
require.EqualValues(t, miner0.SupportedProofTypes, miner2.SupportedProofTypes)
|
||||||
|
require.Equal(t, miner0.PreCommitChallengeDelay, miner2.PreCommitChallengeDelay)
|
||||||
|
require.Equal(t, miner0.ChainFinality, miner2.ChainFinality)
|
||||||
|
require.Equal(t, verifreg0.MinVerifiedDealSize, verifreg2.MinVerifiedDealSize)
|
||||||
|
}
|
||||||
|
16
extern/storage-sealing/checks.go
vendored
16
extern/storage-sealing/checks.go
vendored
@ -4,11 +4,9 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/policy"
|
"github.com/filecoin-project/lotus/chain/actors/policy"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
|
||||||
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
|
||||||
|
|
||||||
proof0 "github.com/filecoin-project/specs-actors/actors/runtime/proof"
|
proof0 "github.com/filecoin-project/specs-actors/actors/runtime/proof"
|
||||||
|
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
@ -102,16 +100,10 @@ func checkPrecommit(ctx context.Context, maddr address.Address, si SectorInfo, t
|
|||||||
return &ErrApi{xerrors.Errorf("calling StateNetworkVersion: %w", err)}
|
return &ErrApi{xerrors.Errorf("calling StateNetworkVersion: %w", err)}
|
||||||
}
|
}
|
||||||
|
|
||||||
var msd abi.ChainEpoch
|
msd := policy.GetMaxProveCommitDuration(actors.VersionForNetwork(nv), si.SectorType)
|
||||||
if nv < build.ActorUpgradeNetworkVersion {
|
|
||||||
msd = miner0.MaxSealDuration[si.SectorType]
|
|
||||||
} else {
|
|
||||||
// TODO: ActorUpgrade(use MaxProveCommitDuration)
|
|
||||||
msd = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
if height-(si.TicketEpoch+SealRandomnessLookback) > msd {
|
if height-(si.TicketEpoch+policy.SealRandomnessLookback) > msd {
|
||||||
return &ErrExpiredTicket{xerrors.Errorf("ticket expired: seal height: %d, head: %d", si.TicketEpoch+SealRandomnessLookback, height)}
|
return &ErrExpiredTicket{xerrors.Errorf("ticket expired: seal height: %d, head: %d", si.TicketEpoch+policy.SealRandomnessLookback, height)}
|
||||||
}
|
}
|
||||||
|
|
||||||
pci, err := api.StateSectorPreCommitInfo(ctx, maddr, si.SectorNumber, tok)
|
pci, err := api.StateSectorPreCommitInfo(ctx, maddr, si.SectorNumber, tok)
|
||||||
|
7
extern/storage-sealing/constants.go
vendored
7
extern/storage-sealing/constants.go
vendored
@ -1,11 +1,4 @@
|
|||||||
package sealing
|
package sealing
|
||||||
|
|
||||||
import (
|
|
||||||
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Epochs
|
|
||||||
const SealRandomnessLookback = miner0.ChainFinality
|
|
||||||
|
|
||||||
// Epochs
|
// Epochs
|
||||||
const InteractivePoRepConfidence = 6
|
const InteractivePoRepConfidence = 6
|
||||||
|
13
extern/storage-sealing/states_sealing.go
vendored
13
extern/storage-sealing/states_sealing.go
vendored
@ -4,10 +4,9 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/policy"
|
"github.com/filecoin-project/lotus/chain/actors/policy"
|
||||||
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
|
||||||
|
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
@ -60,7 +59,7 @@ func (m *Sealing) getTicket(ctx statemachine.Context, sector SectorInfo) (abi.Se
|
|||||||
return nil, 0, nil
|
return nil, 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
ticketEpoch := epoch - SealRandomnessLookback
|
ticketEpoch := epoch - policy.SealRandomnessLookback
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
if err := m.maddr.MarshalCBOR(buf); err != nil {
|
if err := m.maddr.MarshalCBOR(buf); err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
@ -189,13 +188,7 @@ func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInf
|
|||||||
return ctx.Send(SectorSealPreCommit1Failed{xerrors.Errorf("failed to get network version: %w", err)})
|
return ctx.Send(SectorSealPreCommit1Failed{xerrors.Errorf("failed to get network version: %w", err)})
|
||||||
}
|
}
|
||||||
|
|
||||||
var msd abi.ChainEpoch
|
msd := policy.GetMaxProveCommitDuration(actors.VersionForNetwork(nv), sector.SectorType)
|
||||||
if nv < build.ActorUpgradeNetworkVersion {
|
|
||||||
msd = miner0.MaxSealDuration[sector.SectorType]
|
|
||||||
} else {
|
|
||||||
// TODO: ActorUpgrade(use MaxProveCommitDuration)
|
|
||||||
msd = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
if minExpiration := height + msd + miner.MinSectorExpiration + 10; expiration < minExpiration {
|
if minExpiration := height + msd + miner.MinSectorExpiration + 10; expiration < minExpiration {
|
||||||
expiration = minExpiration
|
expiration = minExpiration
|
||||||
|
Loading…
Reference in New Issue
Block a user