Merge pull request #2149 from filecoin-project/feat/specs-actors-v0.7.0
Specs actors v0.7.0
This commit is contained in:
commit
472cf20b81
@ -220,7 +220,7 @@ type FullNode interface {
|
|||||||
// Returns all non-expired Faults that occur within lookback epochs of the given tipset
|
// Returns all non-expired Faults that occur within lookback epochs of the given tipset
|
||||||
StateAllMinerFaults(ctx context.Context, lookback abi.ChainEpoch, ts types.TipSetKey) ([]*Fault, error)
|
StateAllMinerFaults(ctx context.Context, lookback abi.ChainEpoch, ts types.TipSetKey) ([]*Fault, error)
|
||||||
StateMinerRecoveries(context.Context, address.Address, types.TipSetKey) (*abi.BitField, error)
|
StateMinerRecoveries(context.Context, address.Address, types.TipSetKey) (*abi.BitField, error)
|
||||||
StateMinerInitialPledgeCollateral(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (types.BigInt, error)
|
StateMinerInitialPledgeCollateral(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error)
|
||||||
StateMinerAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)
|
StateMinerAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)
|
||||||
StateSectorPreCommitInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error)
|
StateSectorPreCommitInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error)
|
||||||
StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error)
|
StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error)
|
||||||
@ -245,7 +245,7 @@ type FullNode interface {
|
|||||||
// filecoin network
|
// filecoin network
|
||||||
|
|
||||||
MsigGetAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)
|
MsigGetAvailableBalance(context.Context, address.Address, types.TipSetKey) (types.BigInt, error)
|
||||||
MsigCreate(context.Context, int64, []address.Address, types.BigInt, address.Address, types.BigInt) (cid.Cid, error)
|
MsigCreate(context.Context, uint64, []address.Address, types.BigInt, address.Address, types.BigInt) (cid.Cid, error)
|
||||||
MsigPropose(context.Context, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error)
|
MsigPropose(context.Context, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error)
|
||||||
MsigApprove(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error)
|
MsigApprove(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error)
|
||||||
MsigCancel(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error)
|
MsigCancel(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error)
|
||||||
|
@ -35,6 +35,9 @@ type StorageMiner interface {
|
|||||||
|
|
||||||
SectorsRefs(context.Context) (map[string][]SealedRef, error)
|
SectorsRefs(context.Context) (map[string][]SealedRef, error)
|
||||||
|
|
||||||
|
// SectorStartSealing can be called on sectors in Empty on WaitDeals states
|
||||||
|
// to trigger sealing early
|
||||||
|
SectorStartSealing(context.Context, abi.SectorNumber) error
|
||||||
SectorsUpdate(context.Context, abi.SectorNumber, SectorState) error
|
SectorsUpdate(context.Context, abi.SectorNumber, SectorState) error
|
||||||
SectorRemove(context.Context, abi.SectorNumber) error
|
SectorRemove(context.Context, abi.SectorNumber) error
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ type FullNodeStruct struct {
|
|||||||
StateMinerFaults func(context.Context, address.Address, types.TipSetKey) (*abi.BitField, error) `perm:"read"`
|
StateMinerFaults func(context.Context, address.Address, types.TipSetKey) (*abi.BitField, error) `perm:"read"`
|
||||||
StateAllMinerFaults func(context.Context, abi.ChainEpoch, types.TipSetKey) ([]*api.Fault, error) `perm:"read"`
|
StateAllMinerFaults func(context.Context, abi.ChainEpoch, types.TipSetKey) ([]*api.Fault, error) `perm:"read"`
|
||||||
StateMinerRecoveries func(context.Context, address.Address, types.TipSetKey) (*abi.BitField, error) `perm:"read"`
|
StateMinerRecoveries func(context.Context, address.Address, types.TipSetKey) (*abi.BitField, error) `perm:"read"`
|
||||||
StateMinerInitialPledgeCollateral func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
StateMinerInitialPledgeCollateral func(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
||||||
StateMinerAvailableBalance func(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
StateMinerAvailableBalance func(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
||||||
StateSectorPreCommitInfo func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) `perm:"read"`
|
StateSectorPreCommitInfo func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) `perm:"read"`
|
||||||
StateSectorGetInfo func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error) `perm:"read"`
|
StateSectorGetInfo func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error) `perm:"read"`
|
||||||
@ -158,7 +158,7 @@ type FullNodeStruct struct {
|
|||||||
StateCompute func(context.Context, abi.ChainEpoch, []*types.Message, types.TipSetKey) (*api.ComputeStateOutput, error) `perm:"read"`
|
StateCompute func(context.Context, abi.ChainEpoch, []*types.Message, types.TipSetKey) (*api.ComputeStateOutput, error) `perm:"read"`
|
||||||
|
|
||||||
MsigGetAvailableBalance func(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
MsigGetAvailableBalance func(context.Context, address.Address, types.TipSetKey) (types.BigInt, error) `perm:"read"`
|
||||||
MsigCreate func(context.Context, int64, []address.Address, types.BigInt, address.Address, types.BigInt) (cid.Cid, error) `perm:"sign"`
|
MsigCreate func(context.Context, uint64, []address.Address, types.BigInt, address.Address, types.BigInt) (cid.Cid, error) `perm:"sign"`
|
||||||
MsigPropose func(context.Context, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"`
|
MsigPropose func(context.Context, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"`
|
||||||
MsigApprove func(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"`
|
MsigApprove func(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"`
|
||||||
MsigCancel func(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"`
|
MsigCancel func(context.Context, address.Address, uint64, address.Address, address.Address, types.BigInt, address.Address, uint64, []byte) (cid.Cid, error) `perm:"sign"`
|
||||||
@ -202,11 +202,12 @@ type StorageMinerStruct struct {
|
|||||||
|
|
||||||
PledgeSector func(context.Context) error `perm:"write"`
|
PledgeSector func(context.Context) error `perm:"write"`
|
||||||
|
|
||||||
SectorsStatus func(context.Context, abi.SectorNumber) (api.SectorInfo, error) `perm:"read"`
|
SectorsStatus func(context.Context, abi.SectorNumber) (api.SectorInfo, error) `perm:"read"`
|
||||||
SectorsList func(context.Context) ([]abi.SectorNumber, error) `perm:"read"`
|
SectorsList func(context.Context) ([]abi.SectorNumber, error) `perm:"read"`
|
||||||
SectorsRefs func(context.Context) (map[string][]api.SealedRef, error) `perm:"read"`
|
SectorsRefs func(context.Context) (map[string][]api.SealedRef, error) `perm:"read"`
|
||||||
SectorsUpdate func(context.Context, abi.SectorNumber, api.SectorState) error `perm:"write"`
|
SectorStartSealing func(context.Context, abi.SectorNumber) error `perm:"write"`
|
||||||
SectorRemove func(context.Context, abi.SectorNumber) error `perm:"admin"`
|
SectorsUpdate func(context.Context, abi.SectorNumber, api.SectorState) error `perm:"admin"`
|
||||||
|
SectorRemove func(context.Context, abi.SectorNumber) error `perm:"admin"`
|
||||||
|
|
||||||
WorkerConnect func(context.Context, string) error `perm:"admin"` // TODO: worker perm
|
WorkerConnect func(context.Context, string) error `perm:"admin"` // TODO: worker perm
|
||||||
WorkerStats func(context.Context) (map[uint64]storiface.WorkerStats, error) `perm:"admin"`
|
WorkerStats func(context.Context) (map[uint64]storiface.WorkerStats, error) `perm:"admin"`
|
||||||
@ -590,8 +591,8 @@ func (c *FullNodeStruct) StateMinerRecoveries(ctx context.Context, actor address
|
|||||||
return c.Internal.StateMinerRecoveries(ctx, actor, tsk)
|
return c.Internal.StateMinerRecoveries(ctx, actor, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) StateMinerInitialPledgeCollateral(ctx context.Context, maddr address.Address, snum abi.SectorNumber, tsk types.TipSetKey) (types.BigInt, error) {
|
func (c *FullNodeStruct) StateMinerInitialPledgeCollateral(ctx context.Context, maddr address.Address, pci miner.SectorPreCommitInfo, tsk types.TipSetKey) (types.BigInt, error) {
|
||||||
return c.Internal.StateMinerInitialPledgeCollateral(ctx, maddr, snum, tsk)
|
return c.Internal.StateMinerInitialPledgeCollateral(ctx, maddr, pci, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) StateMinerAvailableBalance(ctx context.Context, maddr address.Address, tsk types.TipSetKey) (types.BigInt, error) {
|
func (c *FullNodeStruct) StateMinerAvailableBalance(ctx context.Context, maddr address.Address, tsk types.TipSetKey) (types.BigInt, error) {
|
||||||
@ -686,7 +687,7 @@ func (c *FullNodeStruct) MsigGetAvailableBalance(ctx context.Context, a address.
|
|||||||
return c.Internal.MsigGetAvailableBalance(ctx, a, tsk)
|
return c.Internal.MsigGetAvailableBalance(ctx, a, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) MsigCreate(ctx context.Context, req int64, addrs []address.Address, val types.BigInt, src address.Address, gp types.BigInt) (cid.Cid, error) {
|
func (c *FullNodeStruct) MsigCreate(ctx context.Context, req uint64, addrs []address.Address, val types.BigInt, src address.Address, gp types.BigInt) (cid.Cid, error) {
|
||||||
return c.Internal.MsigCreate(ctx, req, addrs, val, src, gp)
|
return c.Internal.MsigCreate(ctx, req, addrs, val, src, gp)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -786,6 +787,10 @@ func (c *StorageMinerStruct) SectorsRefs(ctx context.Context) (map[string][]api.
|
|||||||
return c.Internal.SectorsRefs(ctx)
|
return c.Internal.SectorsRefs(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *StorageMinerStruct) SectorStartSealing(ctx context.Context, number abi.SectorNumber) error {
|
||||||
|
return c.Internal.SectorStartSealing(ctx, number)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *StorageMinerStruct) SectorsUpdate(ctx context.Context, id abi.SectorNumber, state api.SectorState) error {
|
func (c *StorageMinerStruct) SectorsUpdate(ctx context.Context, id abi.SectorNumber, state api.SectorState) error {
|
||||||
return c.Internal.SectorsUpdate(ctx, id, state)
|
return c.Internal.SectorsUpdate(ctx, id, state)
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,9 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/ipfs/go-cid"
|
||||||
files "github.com/ipfs/go-ipfs-files"
|
files "github.com/ipfs/go-ipfs-files"
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
"github.com/ipld/go-car"
|
"github.com/ipld/go-car"
|
||||||
@ -21,6 +22,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
"github.com/filecoin-project/go-fil-markets/storagemarket"
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
|
sealing "github.com/filecoin-project/storage-fsm"
|
||||||
dag "github.com/ipfs/go-merkledag"
|
dag "github.com/ipfs/go-merkledag"
|
||||||
dstest "github.com/ipfs/go-merkledag/test"
|
dstest "github.com/ipfs/go-merkledag/test"
|
||||||
unixfile "github.com/ipfs/go-unixfs/file"
|
unixfile "github.com/ipfs/go-unixfs/file"
|
||||||
@ -127,7 +129,7 @@ func makeDeal(t *testing.T, ctx context.Context, rseed int, client *impl.FullNod
|
|||||||
|
|
||||||
// TODO: this sleep is only necessary because deals don't immediately get logged in the dealstore, we should fix this
|
// TODO: this sleep is only necessary because deals don't immediately get logged in the dealstore, we should fix this
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
waitDealSealed(t, ctx, client, deal)
|
waitDealSealed(t, ctx, miner, client, deal)
|
||||||
|
|
||||||
// Retrieval
|
// Retrieval
|
||||||
|
|
||||||
@ -157,7 +159,7 @@ func startDeal(t *testing.T, ctx context.Context, miner TestStorageNode, client
|
|||||||
return deal
|
return deal
|
||||||
}
|
}
|
||||||
|
|
||||||
func waitDealSealed(t *testing.T, ctx context.Context, client *impl.FullNodeAPI, deal *cid.Cid) {
|
func waitDealSealed(t *testing.T, ctx context.Context, miner TestStorageNode, client *impl.FullNodeAPI, deal *cid.Cid) {
|
||||||
loop:
|
loop:
|
||||||
for {
|
for {
|
||||||
di, err := client.ClientGetDealInfo(ctx, *deal)
|
di, err := client.ClientGetDealInfo(ctx, *deal)
|
||||||
@ -165,6 +167,8 @@ loop:
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
switch di.State {
|
switch di.State {
|
||||||
|
case storagemarket.StorageDealSealing:
|
||||||
|
startSealingWaiting(t, ctx, miner)
|
||||||
case storagemarket.StorageDealProposalRejected:
|
case storagemarket.StorageDealProposalRejected:
|
||||||
t.Fatal("deal rejected")
|
t.Fatal("deal rejected")
|
||||||
case storagemarket.StorageDealFailing:
|
case storagemarket.StorageDealFailing:
|
||||||
@ -180,6 +184,20 @@ loop:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func startSealingWaiting(t *testing.T, ctx context.Context, miner TestStorageNode) {
|
||||||
|
snums, err := miner.SectorsList(ctx)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
for _, snum := range snums {
|
||||||
|
si, err := miner.SectorsStatus(ctx, snum)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
if si.State == api.SectorState(sealing.WaitDeals) {
|
||||||
|
require.NoError(t, miner.SectorStartSealing(ctx, snum))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func testRetrieval(t *testing.T, ctx context.Context, err error, client *impl.FullNodeAPI, fcid cid.Cid, carExport bool, data []byte) {
|
func testRetrieval(t *testing.T, ctx context.Context, err error, client *impl.FullNodeAPI, fcid cid.Cid, carExport bool, data []byte) {
|
||||||
offers, err := client.ClientFindData(ctx, fcid)
|
offers, err := client.ClientFindData(ctx, fcid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -194,7 +194,7 @@ func TestDealMining(t *testing.T, b APIBuilder, blocktime time.Duration, carExpo
|
|||||||
// TODO: this sleep is only necessary because deals don't immediately get logged in the dealstore, we should fix this
|
// TODO: this sleep is only necessary because deals don't immediately get logged in the dealstore, we should fix this
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
|
|
||||||
waitDealSealed(t, ctx, client, deal)
|
waitDealSealed(t, ctx, provider, client, deal)
|
||||||
|
|
||||||
<-minedTwo
|
<-minedTwo
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ const ForkLengthThreshold = Finality
|
|||||||
var BlocksPerEpoch = uint64(builtin.ExpectedLeadersPerEpoch)
|
var BlocksPerEpoch = uint64(builtin.ExpectedLeadersPerEpoch)
|
||||||
|
|
||||||
// Epochs
|
// Epochs
|
||||||
const Finality = miner.ChainFinalityish
|
const Finality = miner.ChainFinality
|
||||||
const MessageConfidence = 5
|
const MessageConfidence = 5
|
||||||
|
|
||||||
// constants for Weight calculation
|
// constants for Weight calculation
|
||||||
|
@ -177,12 +177,12 @@ func NewGeneratorWithSectors(numSectors int) (*ChainGen, error) {
|
|||||||
Accounts: []genesis.Actor{
|
Accounts: []genesis.Actor{
|
||||||
{
|
{
|
||||||
Type: genesis.TAccount,
|
Type: genesis.TAccount,
|
||||||
Balance: types.FromFil(40000),
|
Balance: types.FromFil(40_000_000),
|
||||||
Meta: (&genesis.AccountMeta{Owner: mk1}).ActorMeta(),
|
Meta: (&genesis.AccountMeta{Owner: mk1}).ActorMeta(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Type: genesis.TAccount,
|
Type: genesis.TAccount,
|
||||||
Balance: types.FromFil(40000),
|
Balance: types.FromFil(40_000_000),
|
||||||
Meta: (&genesis.AccountMeta{Owner: mk2}).ActorMeta(),
|
Meta: (&genesis.AccountMeta{Owner: mk2}).ActorMeta(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -59,8 +59,14 @@ The process:
|
|||||||
- power.CreateMiner, set msg value to PowerBalance
|
- power.CreateMiner, set msg value to PowerBalance
|
||||||
- market.AddFunds with correct value
|
- market.AddFunds with correct value
|
||||||
- market.PublishDeals for related sectors
|
- market.PublishDeals for related sectors
|
||||||
- Set precommits
|
- Set network power in the power actor to what we'll have after genesis creation
|
||||||
- Commit presealed sectors
|
- For each precommitted sector
|
||||||
|
- Get deal weight
|
||||||
|
- Calculate QA Power
|
||||||
|
- Remove fake power from the power actor
|
||||||
|
- Calculate pledge
|
||||||
|
- Precommit
|
||||||
|
- Confirm valid
|
||||||
|
|
||||||
Data Types:
|
Data Types:
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
"github.com/filecoin-project/specs-actors/actors/crypto"
|
||||||
"github.com/filecoin-project/specs-actors/actors/runtime"
|
"github.com/filecoin-project/specs-actors/actors/runtime"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/chain/state"
|
|
||||||
"github.com/filecoin-project/lotus/chain/store"
|
"github.com/filecoin-project/lotus/chain/store"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/chain/vm"
|
"github.com/filecoin-project/lotus/chain/vm"
|
||||||
@ -56,6 +55,14 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
return cid.Undef, xerrors.New("no genesis miners")
|
return cid.Undef, xerrors.New("no genesis miners")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
minerInfos := make([]struct {
|
||||||
|
maddr address.Address
|
||||||
|
|
||||||
|
presealExp abi.ChainEpoch
|
||||||
|
|
||||||
|
dealIDs []abi.DealID
|
||||||
|
}, len(miners))
|
||||||
|
|
||||||
for i, m := range miners {
|
for i, m := range miners {
|
||||||
// Create miner through power actor
|
// Create miner through power actor
|
||||||
i := i
|
i := i
|
||||||
@ -66,7 +73,6 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
return cid.Undef, err
|
return cid.Undef, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var maddr address.Address
|
|
||||||
{
|
{
|
||||||
constructorParams := &power.CreateMinerParams{
|
constructorParams := &power.CreateMinerParams{
|
||||||
Owner: m.Worker,
|
Owner: m.Worker,
|
||||||
@ -90,13 +96,20 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
if ma.IDAddress != expma {
|
if ma.IDAddress != expma {
|
||||||
return cid.Undef, xerrors.Errorf("miner assigned wrong address: %s != %s", ma.IDAddress, expma)
|
return cid.Undef, xerrors.Errorf("miner assigned wrong address: %s != %s", ma.IDAddress, expma)
|
||||||
}
|
}
|
||||||
maddr = ma.IDAddress
|
minerInfos[i].maddr = ma.IDAddress
|
||||||
|
|
||||||
|
err = vm.MutateState(ctx, minerInfos[i].maddr, func(cst cbor.IpldStore, st *miner.State) error {
|
||||||
|
maxPeriods := miner.MaxSectorExpirationExtension / miner.WPoStProvingPeriod
|
||||||
|
minerInfos[i].presealExp = (maxPeriods-1)*miner.WPoStProvingPeriod + st.ProvingPeriodStart - 1
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add market funds
|
// Add market funds
|
||||||
|
|
||||||
{
|
{
|
||||||
params := mustEnc(&maddr)
|
params := mustEnc(&minerInfos[i].maddr)
|
||||||
_, err := doExecValue(ctx, vm, builtin.StorageMarketActorAddr, m.Worker, m.MarketBalance, builtin.MethodsMarket.AddBalance, params)
|
_, err := doExecValue(ctx, vm, builtin.StorageMarketActorAddr, m.Worker, m.MarketBalance, builtin.MethodsMarket.AddBalance, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err)
|
return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err)
|
||||||
@ -112,7 +125,6 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
|
|
||||||
// Publish preseal deals
|
// Publish preseal deals
|
||||||
|
|
||||||
var dealIDs []abi.DealID
|
|
||||||
{
|
{
|
||||||
publish := func(params *market.PublishStorageDealsParams) error {
|
publish := func(params *market.PublishStorageDealsParams) error {
|
||||||
fmt.Printf("publishing %d storage deals on miner %s with worker %s\n", len(params.Deals), params.Deals[0].Proposal.Provider, m.Worker)
|
fmt.Printf("publishing %d storage deals on miner %s with worker %s\n", len(params.Deals), params.Deals[0].Proposal.Provider, m.Worker)
|
||||||
@ -126,7 +138,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
return xerrors.Errorf("unmarsahling publishStorageDeals result: %w", err)
|
return xerrors.Errorf("unmarsahling publishStorageDeals result: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
dealIDs = append(dealIDs, ids.IDs...)
|
minerInfos[i].dealIDs = append(minerInfos[i].dealIDs, ids.IDs...)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,93 +165,106 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Commit sectors
|
// adjust total network power for equal pledge per sector
|
||||||
for pi, preseal := range m.Sectors {
|
rawPow, qaPow := big.NewInt(0), big.NewInt(0)
|
||||||
preseal := preseal
|
{
|
||||||
// TODO: Maybe check seal (Can just be snark inputs, doesn't go into the genesis file)
|
for i, m := range miners {
|
||||||
|
for pi := range m.Sectors {
|
||||||
|
rawPow = types.BigAdd(rawPow, types.NewInt(uint64(m.SectorSize)))
|
||||||
|
|
||||||
// check deals, get dealWeight
|
dweight, err := dealWeight(ctx, vm, minerInfos[i].maddr, []abi.DealID{minerInfos[i].dealIDs[pi]}, 0, minerInfos[i].presealExp)
|
||||||
var dealWeight market.VerifyDealsOnSectorProveCommitReturn
|
|
||||||
{
|
|
||||||
params := &market.VerifyDealsOnSectorProveCommitParams{
|
|
||||||
DealIDs: []abi.DealID{dealIDs[pi]},
|
|
||||||
SectorExpiry: preseal.Deal.EndEpoch,
|
|
||||||
}
|
|
||||||
|
|
||||||
ret, err := doExecValue(ctx, vm, builtin.StorageMarketActorAddr, maddr, big.Zero(), builtin.MethodsMarket.VerifyDealsOnSectorProveCommit, mustEnc(params))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cid.Undef, xerrors.Errorf("failed to verify preseal deals miner: %w", err)
|
return cid.Undef, xerrors.Errorf("getting deal weight: %w", err)
|
||||||
}
|
|
||||||
if err := dealWeight.UnmarshalCBOR(bytes.NewReader(ret)); err != nil {
|
|
||||||
return cid.Undef, xerrors.Errorf("unmarshaling market onProveCommit result: %w", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// update power claims
|
|
||||||
{
|
|
||||||
err = vm.MutateState(ctx, builtin.StoragePowerActorAddr, func(cst cbor.IpldStore, st *power.State) error {
|
|
||||||
weight := &power.SectorStorageWeightDesc{
|
|
||||||
SectorSize: m.SectorSize,
|
|
||||||
Duration: preseal.Deal.Duration(),
|
|
||||||
DealWeight: dealWeight.DealWeight,
|
|
||||||
VerifiedDealWeight: dealWeight.VerifiedDealWeight,
|
|
||||||
}
|
|
||||||
|
|
||||||
qapower := power.QAPowerForWeight(weight)
|
|
||||||
|
|
||||||
err := st.AddToClaim(&state.AdtStore{cst}, maddr, types.NewInt(uint64(weight.SectorSize)), qapower)
|
|
||||||
if err != nil {
|
|
||||||
return xerrors.Errorf("add to claim: %w", err)
|
|
||||||
}
|
|
||||||
fmt.Println("Added weight to claim: ", st.TotalRawBytePower, st.TotalQualityAdjPower)
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return cid.Undef, xerrors.Errorf("register power claim in power actor: %w", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Put sectors to miner sector sets
|
|
||||||
{
|
|
||||||
newSectorInfo := &miner.SectorOnChainInfo{
|
|
||||||
Info: miner.SectorPreCommitInfo{
|
|
||||||
SealProof: preseal.ProofType,
|
|
||||||
SectorNumber: preseal.SectorID,
|
|
||||||
SealedCID: preseal.CommR,
|
|
||||||
SealRandEpoch: 0,
|
|
||||||
DealIDs: []abi.DealID{dealIDs[pi]},
|
|
||||||
Expiration: preseal.Deal.EndEpoch,
|
|
||||||
},
|
|
||||||
ActivationEpoch: 0,
|
|
||||||
DealWeight: dealWeight.DealWeight,
|
|
||||||
VerifiedDealWeight: dealWeight.VerifiedDealWeight,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = vm.MutateState(ctx, maddr, func(cst cbor.IpldStore, st *miner.State) error {
|
sectorWeight := miner.QAPowerForWeight(m.SectorSize, minerInfos[i].presealExp, dweight.DealWeight, dweight.VerifiedDealWeight)
|
||||||
store := &state.AdtStore{cst}
|
|
||||||
|
|
||||||
if err = st.PutSector(store, newSectorInfo); err != nil {
|
qaPow = types.BigAdd(qaPow, sectorWeight)
|
||||||
return xerrors.Errorf("failed to put sector: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := st.AddNewSectors(newSectorInfo.Info.SectorNumber); err != nil {
|
|
||||||
return xerrors.Errorf("failed to add NewSector: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return cid.Cid{}, xerrors.Errorf("put to sset: %w", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = vm.MutateState(ctx, builtin.StoragePowerActorAddr, func(cst cbor.IpldStore, st *power.State) error {
|
||||||
|
st.TotalQualityAdjPower = qaPow
|
||||||
|
st.TotalRawBytePower = rawPow
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return cid.Undef, xerrors.Errorf("mutating state: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: to avoid division by zero, we set the initial power actor power to 1, this adjusts that back down so the accounting is accurate.
|
for i, m := range miners {
|
||||||
|
// Commit sectors
|
||||||
|
{
|
||||||
|
for pi, preseal := range m.Sectors {
|
||||||
|
params := &miner.SectorPreCommitInfo{
|
||||||
|
SealProof: preseal.ProofType,
|
||||||
|
SectorNumber: preseal.SectorID,
|
||||||
|
SealedCID: preseal.CommR,
|
||||||
|
SealRandEpoch: -1,
|
||||||
|
DealIDs: []abi.DealID{minerInfos[i].dealIDs[pi]},
|
||||||
|
Expiration: minerInfos[i].presealExp, // TODO: Allow setting externally!
|
||||||
|
}
|
||||||
|
|
||||||
|
dweight, err := dealWeight(ctx, vm, minerInfos[i].maddr, params.DealIDs, 0, minerInfos[i].presealExp)
|
||||||
|
if err != nil {
|
||||||
|
return cid.Undef, xerrors.Errorf("getting deal weight: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
sectorWeight := miner.QAPowerForWeight(m.SectorSize, minerInfos[i].presealExp, dweight.DealWeight, dweight.VerifiedDealWeight)
|
||||||
|
|
||||||
|
// we've added fake power for this sector above, remove it now
|
||||||
|
err = vm.MutateState(ctx, builtin.StoragePowerActorAddr, func(cst cbor.IpldStore, st *power.State) error {
|
||||||
|
st.TotalQualityAdjPower = types.BigSub(st.TotalQualityAdjPower, sectorWeight)
|
||||||
|
st.TotalRawBytePower = types.BigSub(st.TotalRawBytePower, types.NewInt(uint64(m.SectorSize)))
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return cid.Undef, xerrors.Errorf("removing fake power: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
epochReward, err := currentEpochBlockReward(ctx, vm, minerInfos[i].maddr)
|
||||||
|
if err != nil {
|
||||||
|
return cid.Undef, xerrors.Errorf("getting current epoch reward: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
tpow, err := currentTotalPower(ctx, vm, minerInfos[i].maddr)
|
||||||
|
if err != nil {
|
||||||
|
return cid.Undef, xerrors.Errorf("getting current total power: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
pledge := miner.InitialPledgeForPower(sectorWeight, tpow.QualityAdjPower, tpow.PledgeCollateral, epochReward, circSupply(ctx, vm, minerInfos[i].maddr))
|
||||||
|
|
||||||
|
_, err = doExecValue(ctx, vm, minerInfos[i].maddr, m.Worker, pledge, builtin.MethodsMiner.PreCommitSector, mustEnc(params))
|
||||||
|
if err != nil {
|
||||||
|
return cid.Undef, xerrors.Errorf("failed to confirm presealed sectors: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Commit one-by-one, otherwise pledge math tends to explode
|
||||||
|
confirmParams := &builtin.ConfirmSectorProofsParams{
|
||||||
|
Sectors: []abi.SectorNumber{preseal.SectorID},
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = doExecValue(ctx, vm, minerInfos[i].maddr, builtin.StoragePowerActorAddr, big.Zero(), builtin.MethodsMiner.ConfirmSectorProofsValid, mustEnc(confirmParams))
|
||||||
|
if err != nil {
|
||||||
|
return cid.Undef, xerrors.Errorf("failed to confirm presealed sectors: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sanity-check total network power
|
||||||
err = vm.MutateState(ctx, builtin.StoragePowerActorAddr, func(cst cbor.IpldStore, st *power.State) error {
|
err = vm.MutateState(ctx, builtin.StoragePowerActorAddr, func(cst cbor.IpldStore, st *power.State) error {
|
||||||
st.TotalQualityAdjPower = big.Sub(st.TotalQualityAdjPower, big.NewInt(1))
|
if !st.TotalRawBytePower.Equals(rawPow) {
|
||||||
|
return xerrors.Errorf("st.TotalRawBytePower doesn't match previously calculated rawPow")
|
||||||
|
}
|
||||||
|
|
||||||
|
if !st.TotalQualityAdjPower.Equals(qaPow) {
|
||||||
|
return xerrors.Errorf("st.TotalQualityAdjPower doesn't match previously calculated qaPow")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -261,3 +286,65 @@ func (fr *fakeRand) GetRandomness(ctx context.Context, personalization crypto.Do
|
|||||||
_, _ = rand.New(rand.NewSource(int64(randEpoch))).Read(out)
|
_, _ = rand.New(rand.NewSource(int64(randEpoch))).Read(out)
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func currentTotalPower(ctx context.Context, vm *vm.VM, maddr address.Address) (*power.CurrentTotalPowerReturn, error) {
|
||||||
|
pwret, err := doExecValue(ctx, vm, builtin.StoragePowerActorAddr, maddr, big.Zero(), builtin.MethodsPower.CurrentTotalPower, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var pwr power.CurrentTotalPowerReturn
|
||||||
|
if err := pwr.UnmarshalCBOR(bytes.NewReader(pwret)); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &pwr, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func dealWeight(ctx context.Context, vm *vm.VM, maddr address.Address, dealIDs []abi.DealID, sectorStart, sectorExpiry abi.ChainEpoch) (market.VerifyDealsForActivationReturn, error) {
|
||||||
|
params := &market.VerifyDealsForActivationParams{
|
||||||
|
DealIDs: dealIDs,
|
||||||
|
SectorStart: sectorStart,
|
||||||
|
SectorExpiry: sectorExpiry,
|
||||||
|
}
|
||||||
|
|
||||||
|
var dealWeights market.VerifyDealsForActivationReturn
|
||||||
|
ret, err := doExecValue(ctx, vm,
|
||||||
|
builtin.StorageMarketActorAddr,
|
||||||
|
maddr,
|
||||||
|
abi.NewTokenAmount(0),
|
||||||
|
builtin.MethodsMarket.VerifyDealsForActivation,
|
||||||
|
mustEnc(params),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return market.VerifyDealsForActivationReturn{}, err
|
||||||
|
}
|
||||||
|
if err := dealWeights.UnmarshalCBOR(bytes.NewReader(ret)); err != nil {
|
||||||
|
return market.VerifyDealsForActivationReturn{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return dealWeights, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func currentEpochBlockReward(ctx context.Context, vm *vm.VM, maddr address.Address) (abi.TokenAmount, error) {
|
||||||
|
rwret, err := doExecValue(ctx, vm, builtin.RewardActorAddr, maddr, big.Zero(), builtin.MethodsReward.LastPerEpochReward, nil)
|
||||||
|
if err != nil {
|
||||||
|
return abi.TokenAmount{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
epochReward := abi.NewTokenAmount(0)
|
||||||
|
if err := epochReward.UnmarshalCBOR(bytes.NewReader(rwret)); err != nil {
|
||||||
|
return abi.TokenAmount{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return epochReward, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func circSupply(ctx context.Context, vmi *vm.VM, maddr address.Address) abi.TokenAmount {
|
||||||
|
unsafeVM := &vm.UnsafeVM{VM: vmi}
|
||||||
|
rt := unsafeVM.MakeRuntime(ctx, &types.Message{
|
||||||
|
GasLimit: 1_000_000_000,
|
||||||
|
From: maddr,
|
||||||
|
}, maddr, 0, 0, 0)
|
||||||
|
|
||||||
|
return rt.TotalFilCircSupply()
|
||||||
|
}
|
||||||
|
@ -24,7 +24,7 @@ func SetupStoragePowerActor(bs bstore.Blockstore) (*types.Actor, error) {
|
|||||||
|
|
||||||
sms := &power.State{
|
sms := &power.State{
|
||||||
TotalRawBytePower: big.NewInt(0),
|
TotalRawBytePower: big.NewInt(0),
|
||||||
TotalQualityAdjPower: big.NewInt(1), // TODO: has to be 1 initially to avoid div by zero. Kinda annoying, should find a way to fix
|
TotalQualityAdjPower: big.NewInt(0),
|
||||||
TotalPledgeCollateral: big.NewInt(0),
|
TotalPledgeCollateral: big.NewInt(0),
|
||||||
MinerCount: 0,
|
MinerCount: 0,
|
||||||
CronEventQueue: emptyhamt,
|
CronEventQueue: emptyhamt,
|
||||||
|
@ -187,6 +187,7 @@ func (sm *StateManager) ApplyBlocks(ctx context.Context, pstate cid.Cid, bms []B
|
|||||||
Miner: b.Miner,
|
Miner: b.Miner,
|
||||||
Penalty: penalty,
|
Penalty: penalty,
|
||||||
GasReward: gasReward,
|
GasReward: gasReward,
|
||||||
|
WinCount: b.WinCount,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cid.Undef, cid.Undef, xerrors.Errorf("failed to serialize award params: %w", err)
|
return cid.Undef, cid.Undef, xerrors.Errorf("failed to serialize award params: %w", err)
|
||||||
|
@ -15,6 +15,7 @@ import (
|
|||||||
amt "github.com/filecoin-project/go-amt-ipld/v2"
|
amt "github.com/filecoin-project/go-amt-ipld/v2"
|
||||||
"github.com/filecoin-project/sector-storage/ffiwrapper"
|
"github.com/filecoin-project/sector-storage/ffiwrapper"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
|
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||||
@ -208,7 +209,7 @@ func GetSectorsForWinningPoSt(ctx context.Context, pv ffiwrapper.Verifier, sm *S
|
|||||||
out[i] = abi.SectorInfo{
|
out[i] = abi.SectorInfo{
|
||||||
SealProof: spt,
|
SealProof: spt,
|
||||||
SectorNumber: sectorSet[n].ID,
|
SectorNumber: sectorSet[n].ID,
|
||||||
SealedCID: sectorSet[n].Info.Info.SealedCID,
|
SealedCID: sectorSet[n].Info.SealedCID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,3 +540,28 @@ func MinerGetBaseInfo(ctx context.Context, sm *StateManager, bcn beacon.RandomBe
|
|||||||
BeaconEntries: entries,
|
BeaconEntries: entries,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (sm *StateManager) CirculatingSupply(ctx context.Context, ts *types.TipSet) (abi.TokenAmount, error) {
|
||||||
|
if ts == nil {
|
||||||
|
ts = sm.cs.GetHeaviestTipSet()
|
||||||
|
}
|
||||||
|
|
||||||
|
st, _, err := sm.TipSetState(ctx, ts)
|
||||||
|
if err != nil {
|
||||||
|
return big.Zero(), err
|
||||||
|
}
|
||||||
|
|
||||||
|
r := store.NewChainRand(sm.cs, ts.Cids(), ts.Height())
|
||||||
|
vmi, err := vm.NewVM(st, ts.Height(), r, sm.cs.Blockstore(), sm.cs.VMSys())
|
||||||
|
if err != nil {
|
||||||
|
return big.Zero(), err
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafeVM := &vm.UnsafeVM{VM: vmi}
|
||||||
|
rt := unsafeVM.MakeRuntime(ctx, &types.Message{
|
||||||
|
GasLimit: 1_000_000_000,
|
||||||
|
From: builtin.SystemActorAddr,
|
||||||
|
}, builtin.SystemActorAddr, 0, 0, 0)
|
||||||
|
|
||||||
|
return rt.TotalFilCircSupply(), nil
|
||||||
|
}
|
||||||
|
@ -365,7 +365,7 @@ func (rt *Runtime) Send(to address.Address, method abi.MethodNum, m vmr.CBORMars
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
log.Warnf("vmctx send failed: to: %s, method: %d: ret: %d, err: %s", to, method, ret, err)
|
log.Warnf("vmctx send failed: to: %s, method: %d: ret: %d, err: %s", to, method, ret, err)
|
||||||
return nil, err.RetCode()
|
return &dumbWrapperType{nil}, err.RetCode()
|
||||||
}
|
}
|
||||||
return &dumbWrapperType{ret}, 0
|
return &dumbWrapperType{ret}, 0
|
||||||
}
|
}
|
||||||
|
@ -126,6 +126,14 @@ func (vm *VM) makeRuntime(ctx context.Context, msg *types.Message, origin addres
|
|||||||
return rt
|
return rt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UnsafeVM struct {
|
||||||
|
VM *VM
|
||||||
|
}
|
||||||
|
|
||||||
|
func (vm *UnsafeVM) MakeRuntime(ctx context.Context, msg *types.Message, origin address.Address, originNonce uint64, usedGas int64, nac uint64) *Runtime {
|
||||||
|
return vm.VM.makeRuntime(ctx, msg, origin, originNonce, usedGas, nac)
|
||||||
|
}
|
||||||
|
|
||||||
type VM struct {
|
type VM struct {
|
||||||
cstate *state.StateTree
|
cstate *state.StateTree
|
||||||
base cid.Cid
|
base cid.Cid
|
||||||
|
@ -105,9 +105,9 @@ var msigCreateCmd = &cli.Command{
|
|||||||
|
|
||||||
intVal := types.BigInt(filval)
|
intVal := types.BigInt(filval)
|
||||||
|
|
||||||
required := cctx.Int64("required")
|
required := cctx.Uint64("required")
|
||||||
if required == 0 {
|
if required == 0 {
|
||||||
required = int64(len(addrs))
|
required = uint64(len(addrs))
|
||||||
}
|
}
|
||||||
|
|
||||||
gp := types.NewInt(1)
|
gp := types.NewInt(1)
|
||||||
|
@ -286,7 +286,7 @@ var stateSectorsCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range sectors {
|
for _, s := range sectors {
|
||||||
fmt.Printf("%d: %x\n", s.Info.Info.SectorNumber, s.Info.Info.SealedCID)
|
fmt.Printf("%d: %x\n", s.Info.SectorNumber, s.Info.SealedCID)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -326,7 +326,7 @@ var stateProvingSetCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, s := range sectors {
|
for _, s := range sectors {
|
||||||
fmt.Printf("%d: %x\n", s.Info.Info.SectorNumber, s.Info.Info.SealedCID)
|
fmt.Printf("%d: %x\n", s.Info.SectorNumber, s.Info.SealedCID)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
9
go.mod
9
go.mod
@ -14,7 +14,7 @@ require (
|
|||||||
github.com/drand/drand v0.9.2-0.20200616080806-a94e9c1636a4
|
github.com/drand/drand v0.9.2-0.20200616080806-a94e9c1636a4
|
||||||
github.com/drand/kyber v1.1.0
|
github.com/drand/kyber v1.1.0
|
||||||
github.com/fatih/color v1.8.0
|
github.com/fatih/color v1.8.0
|
||||||
github.com/filecoin-project/chain-validation v0.0.6-0.20200615191232-6be1a8c6ed09
|
github.com/filecoin-project/chain-validation v0.0.6-0.20200629051211-dc8dcf0923aa
|
||||||
github.com/filecoin-project/filecoin-ffi v0.26.1-0.20200508175440-05b30afeb00d
|
github.com/filecoin-project/filecoin-ffi v0.26.1-0.20200508175440-05b30afeb00d
|
||||||
github.com/filecoin-project/go-address v0.0.2-0.20200504173055-8b6f2fb2b3ef
|
github.com/filecoin-project/go-address v0.0.2-0.20200504173055-8b6f2fb2b3ef
|
||||||
github.com/filecoin-project/go-amt-ipld/v2 v2.0.1-0.20200424220931-6263827e49f2
|
github.com/filecoin-project/go-amt-ipld/v2 v2.0.1-0.20200424220931-6263827e49f2
|
||||||
@ -25,14 +25,13 @@ require (
|
|||||||
github.com/filecoin-project/go-fil-commcid v0.0.0-20200208005934-2b8bd03caca5
|
github.com/filecoin-project/go-fil-commcid v0.0.0-20200208005934-2b8bd03caca5
|
||||||
github.com/filecoin-project/go-fil-markets v0.3.0
|
github.com/filecoin-project/go-fil-markets v0.3.0
|
||||||
github.com/filecoin-project/go-jsonrpc v0.1.1-0.20200602181149-522144ab4e24
|
github.com/filecoin-project/go-jsonrpc v0.1.1-0.20200602181149-522144ab4e24
|
||||||
github.com/filecoin-project/go-padreader v0.0.0-20200210211231-548257017ca6
|
|
||||||
github.com/filecoin-project/go-paramfetch v0.0.2-0.20200605171344-fcac609550ca
|
github.com/filecoin-project/go-paramfetch v0.0.2-0.20200605171344-fcac609550ca
|
||||||
github.com/filecoin-project/go-statestore v0.1.0
|
github.com/filecoin-project/go-statestore v0.1.0
|
||||||
github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b
|
github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b
|
||||||
github.com/filecoin-project/sector-storage v0.0.0-20200625154333-98ef8e4ef246
|
github.com/filecoin-project/sector-storage v0.0.0-20200626110003-76ce3b9d9496
|
||||||
github.com/filecoin-project/specs-actors v0.6.2-0.20200617175406-de392ca14121
|
github.com/filecoin-project/specs-actors v0.7.1-0.20200629045128-8b4965e097bb
|
||||||
github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea
|
github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea
|
||||||
github.com/filecoin-project/storage-fsm v0.0.0-20200625160832-379a4655b044
|
github.com/filecoin-project/storage-fsm v0.0.0-20200626155829-408c9a7b3336
|
||||||
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1
|
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1
|
||||||
github.com/go-kit/kit v0.10.0
|
github.com/go-kit/kit v0.10.0
|
||||||
github.com/go-ole/go-ole v1.2.4 // indirect
|
github.com/go-ole/go-ole v1.2.4 // indirect
|
||||||
|
16
go.sum
16
go.sum
@ -212,8 +212,8 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv
|
|||||||
github.com/fatih/color v1.8.0 h1:5bzFgL+oy7JITMTxUPJ00n7VxmYd/PdMp5mHFX40/RY=
|
github.com/fatih/color v1.8.0 h1:5bzFgL+oy7JITMTxUPJ00n7VxmYd/PdMp5mHFX40/RY=
|
||||||
github.com/fatih/color v1.8.0/go.mod h1:3l45GVGkyrnYNl9HoIjnp2NnNWvh6hLAqD8yTfGjnw8=
|
github.com/fatih/color v1.8.0/go.mod h1:3l45GVGkyrnYNl9HoIjnp2NnNWvh6hLAqD8yTfGjnw8=
|
||||||
github.com/fd/go-nat v1.0.0/go.mod h1:BTBu/CKvMmOMUPkKVef1pngt2WFH/lg7E6yQnulfp6E=
|
github.com/fd/go-nat v1.0.0/go.mod h1:BTBu/CKvMmOMUPkKVef1pngt2WFH/lg7E6yQnulfp6E=
|
||||||
github.com/filecoin-project/chain-validation v0.0.6-0.20200615191232-6be1a8c6ed09 h1:GuiNSEZ9nc05LUpKhABw/SO6t9wqCfsJX1D0ByWQjkc=
|
github.com/filecoin-project/chain-validation v0.0.6-0.20200629051211-dc8dcf0923aa h1:SqbkG8F5DuUHJFMz+UMxNN/uwg6Ot1szP0YXCCumVv0=
|
||||||
github.com/filecoin-project/chain-validation v0.0.6-0.20200615191232-6be1a8c6ed09/go.mod h1:HEJn6kOXMNhCNBYNTO/lrEI7wSgqCOR6hN5ecfYUnC8=
|
github.com/filecoin-project/chain-validation v0.0.6-0.20200629051211-dc8dcf0923aa/go.mod h1:TEHSeSMoZX7agpgOhwEfiF7iP/44sIuNkA2jFYYVFTQ=
|
||||||
github.com/filecoin-project/go-address v0.0.0-20200107215422-da8eea2842b5/go.mod h1:SAOwJoakQ8EPjwNIsiakIQKsoKdkcbx8U3IapgCg9R0=
|
github.com/filecoin-project/go-address v0.0.0-20200107215422-da8eea2842b5/go.mod h1:SAOwJoakQ8EPjwNIsiakIQKsoKdkcbx8U3IapgCg9R0=
|
||||||
github.com/filecoin-project/go-address v0.0.2-0.20200218010043-eb9bb40ed5be/go.mod h1:SAOwJoakQ8EPjwNIsiakIQKsoKdkcbx8U3IapgCg9R0=
|
github.com/filecoin-project/go-address v0.0.2-0.20200218010043-eb9bb40ed5be/go.mod h1:SAOwJoakQ8EPjwNIsiakIQKsoKdkcbx8U3IapgCg9R0=
|
||||||
github.com/filecoin-project/go-address v0.0.2-0.20200504173055-8b6f2fb2b3ef h1:Wi5E+P1QfHP8IF27eUiTx5vYfqQZwfPxzq3oFEq8w8U=
|
github.com/filecoin-project/go-address v0.0.2-0.20200504173055-8b6f2fb2b3ef h1:Wi5E+P1QfHP8IF27eUiTx5vYfqQZwfPxzq3oFEq8w8U=
|
||||||
@ -256,17 +256,21 @@ github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b/
|
|||||||
github.com/filecoin-project/sector-storage v0.0.0-20200615154852-728a47ab99d6/go.mod h1:M59QnAeA/oV+Z8oHFLoNpGMv0LZ8Rll+vHVXX7GirPM=
|
github.com/filecoin-project/sector-storage v0.0.0-20200615154852-728a47ab99d6/go.mod h1:M59QnAeA/oV+Z8oHFLoNpGMv0LZ8Rll+vHVXX7GirPM=
|
||||||
github.com/filecoin-project/sector-storage v0.0.0-20200625154333-98ef8e4ef246 h1:NfYQRmVRe0LzlNbK5Ket3vbBOwFD5TvtcNtfo/Sd8mg=
|
github.com/filecoin-project/sector-storage v0.0.0-20200625154333-98ef8e4ef246 h1:NfYQRmVRe0LzlNbK5Ket3vbBOwFD5TvtcNtfo/Sd8mg=
|
||||||
github.com/filecoin-project/sector-storage v0.0.0-20200625154333-98ef8e4ef246/go.mod h1:8f0hWDzzIi1hKs4IVKH9RnDsO4LEHVz8BNat0okDOuY=
|
github.com/filecoin-project/sector-storage v0.0.0-20200625154333-98ef8e4ef246/go.mod h1:8f0hWDzzIi1hKs4IVKH9RnDsO4LEHVz8BNat0okDOuY=
|
||||||
|
github.com/filecoin-project/sector-storage v0.0.0-20200626110003-76ce3b9d9496 h1:Z/7aDwuIJmarXsR7gcTOU5+ypu0ch1c8KVaSLlWMmDw=
|
||||||
|
github.com/filecoin-project/sector-storage v0.0.0-20200626110003-76ce3b9d9496/go.mod h1:8f0hWDzzIi1hKs4IVKH9RnDsO4LEHVz8BNat0okDOuY=
|
||||||
github.com/filecoin-project/specs-actors v0.0.0-20200210130641-2d1fbd8672cf/go.mod h1:xtDZUB6pe4Pksa/bAJbJ693OilaC5Wbot9jMhLm3cZA=
|
github.com/filecoin-project/specs-actors v0.0.0-20200210130641-2d1fbd8672cf/go.mod h1:xtDZUB6pe4Pksa/bAJbJ693OilaC5Wbot9jMhLm3cZA=
|
||||||
github.com/filecoin-project/specs-actors v0.3.0/go.mod h1:nQYnFbQ7Y0bHZyq6HDEuVlCPR+U3z5Q3wMOQ+2aiV+Y=
|
github.com/filecoin-project/specs-actors v0.3.0/go.mod h1:nQYnFbQ7Y0bHZyq6HDEuVlCPR+U3z5Q3wMOQ+2aiV+Y=
|
||||||
github.com/filecoin-project/specs-actors v0.6.0/go.mod h1:dRdy3cURykh2R8O/DKqy8olScl70rmIS7GrB4hB1IDY=
|
github.com/filecoin-project/specs-actors v0.6.0/go.mod h1:dRdy3cURykh2R8O/DKqy8olScl70rmIS7GrB4hB1IDY=
|
||||||
github.com/filecoin-project/specs-actors v0.6.2-0.20200617175406-de392ca14121 h1:oRA+b4iN4H86xXDXbU3TOyvmBZp7//c5VqTc0oJ6nLg=
|
github.com/filecoin-project/specs-actors v0.7.0 h1:tldjW8pFiJcMtyGPsXmPoFdbN/18mKW3BpEMlO4NJAc=
|
||||||
github.com/filecoin-project/specs-actors v0.6.2-0.20200617175406-de392ca14121/go.mod h1:dRdy3cURykh2R8O/DKqy8olScl70rmIS7GrB4hB1IDY=
|
github.com/filecoin-project/specs-actors v0.7.0/go.mod h1:+z0htZu/wLBDbOLcQTKKUEC2rkUTFzL2KJ/bRAVWkws=
|
||||||
|
github.com/filecoin-project/specs-actors v0.7.1-0.20200629045128-8b4965e097bb h1:09FJswK8kHQSJtVD49ZjwePjoS4wGrqR/Y+tl7TN10w=
|
||||||
|
github.com/filecoin-project/specs-actors v0.7.1-0.20200629045128-8b4965e097bb/go.mod h1:+z0htZu/wLBDbOLcQTKKUEC2rkUTFzL2KJ/bRAVWkws=
|
||||||
github.com/filecoin-project/specs-storage v0.1.0 h1:PkDgTOT5W5Ao7752onjDl4QSv+sgOVdJbvFjOnD5w94=
|
github.com/filecoin-project/specs-storage v0.1.0 h1:PkDgTOT5W5Ao7752onjDl4QSv+sgOVdJbvFjOnD5w94=
|
||||||
github.com/filecoin-project/specs-storage v0.1.0/go.mod h1:Pr5ntAaxsh+sLG/LYiL4tKzvA83Vk5vLODYhfNwOg7k=
|
github.com/filecoin-project/specs-storage v0.1.0/go.mod h1:Pr5ntAaxsh+sLG/LYiL4tKzvA83Vk5vLODYhfNwOg7k=
|
||||||
github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea h1:iixjULRQFPn7Q9KlIqfwLJnlAXO10bbkI+xy5GKGdLY=
|
github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea h1:iixjULRQFPn7Q9KlIqfwLJnlAXO10bbkI+xy5GKGdLY=
|
||||||
github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea/go.mod h1:Pr5ntAaxsh+sLG/LYiL4tKzvA83Vk5vLODYhfNwOg7k=
|
github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea/go.mod h1:Pr5ntAaxsh+sLG/LYiL4tKzvA83Vk5vLODYhfNwOg7k=
|
||||||
github.com/filecoin-project/storage-fsm v0.0.0-20200625160832-379a4655b044 h1:i4oMhv1kx/MAUxRN4EM5tag5fI1uagrwQwINgKrzUt4=
|
github.com/filecoin-project/storage-fsm v0.0.0-20200626155829-408c9a7b3336 h1:zg2YbDReOfovC9g2M7YmtL/RQe0hBZiIOYeuy/NAV4Y=
|
||||||
github.com/filecoin-project/storage-fsm v0.0.0-20200625160832-379a4655b044/go.mod h1:JD7fmV1BYADDcy4EYQnqFH/rUzXsh0Je0jXarCjZqSk=
|
github.com/filecoin-project/storage-fsm v0.0.0-20200626155829-408c9a7b3336/go.mod h1:e1FIsgLiVFP0ybBdHeGEbhCu3idjCDtEJj+hMgaSJpI=
|
||||||
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
||||||
github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk=
|
github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk=
|
||||||
github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY=
|
github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY=
|
||||||
|
@ -26,9 +26,9 @@ type MsigAPI struct {
|
|||||||
MpoolAPI MpoolAPI
|
MpoolAPI MpoolAPI
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *MsigAPI) MsigCreate(ctx context.Context, req int64, addrs []address.Address, val types.BigInt, src address.Address, gp types.BigInt) (cid.Cid, error) {
|
func (a *MsigAPI) MsigCreate(ctx context.Context, req uint64, addrs []address.Address, val types.BigInt, src address.Address, gp types.BigInt) (cid.Cid, error) {
|
||||||
|
|
||||||
lenAddrs := int64(len(addrs))
|
lenAddrs := uint64(len(addrs))
|
||||||
|
|
||||||
if lenAddrs < req {
|
if lenAddrs < req {
|
||||||
return cid.Undef, xerrors.Errorf("cannot require signing of more addresses than provided for multisig")
|
return cid.Undef, xerrors.Errorf("cannot require signing of more addresses than provided for multisig")
|
||||||
|
@ -15,6 +15,16 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/go-amt-ipld/v2"
|
"github.com/filecoin-project/go-amt-ipld/v2"
|
||||||
|
"github.com/filecoin-project/sector-storage/ffiwrapper"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||||
|
samsig "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/builtin/reward"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/actors"
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
"github.com/filecoin-project/lotus/chain/beacon"
|
"github.com/filecoin-project/lotus/chain/beacon"
|
||||||
@ -27,14 +37,6 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/wallet"
|
"github.com/filecoin-project/lotus/chain/wallet"
|
||||||
"github.com/filecoin-project/lotus/lib/bufbstore"
|
"github.com/filecoin-project/lotus/lib/bufbstore"
|
||||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
"github.com/filecoin-project/sector-storage/ffiwrapper"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
|
||||||
samsig "github.com/filecoin-project/specs-actors/actors/builtin/multisig"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type StateAPI struct {
|
type StateAPI struct {
|
||||||
@ -696,39 +698,53 @@ func (a *StateAPI) MsigGetAvailableBalance(ctx context.Context, addr address.Add
|
|||||||
var initialPledgeNum = types.NewInt(103)
|
var initialPledgeNum = types.NewInt(103)
|
||||||
var initialPledgeDen = types.NewInt(100)
|
var initialPledgeDen = types.NewInt(100)
|
||||||
|
|
||||||
func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr address.Address, snum abi.SectorNumber, tsk types.TipSetKey) (types.BigInt, error) {
|
func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr address.Address, pci miner.SectorPreCommitInfo, tsk types.TipSetKey) (types.BigInt, error) {
|
||||||
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.EmptyInt, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
return types.EmptyInt, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
act, err := a.StateManager.GetActor(maddr, ts)
|
|
||||||
if err != nil {
|
|
||||||
return types.EmptyInt, err
|
|
||||||
}
|
|
||||||
|
|
||||||
as := store.ActorStore(ctx, a.Chain.Blockstore())
|
as := store.ActorStore(ctx, a.Chain.Blockstore())
|
||||||
|
|
||||||
var st miner.State
|
var minerState miner.State
|
||||||
if err := as.Get(ctx, act.Head, &st); err != nil {
|
{
|
||||||
return types.EmptyInt, err
|
act, err := a.StateManager.GetActor(maddr, ts)
|
||||||
|
if err != nil {
|
||||||
|
return types.EmptyInt, err
|
||||||
|
}
|
||||||
|
if err := as.Get(ctx, act.Head, &minerState); err != nil {
|
||||||
|
return types.EmptyInt, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
precommit, found, err := st.GetPrecommittedSector(as, snum)
|
var powerState power.State
|
||||||
if err != nil {
|
{
|
||||||
return types.EmptyInt, err
|
act, err := a.StateManager.GetActor(builtin.StoragePowerActorAddr, ts)
|
||||||
|
if err != nil {
|
||||||
|
return types.EmptyInt, err
|
||||||
|
}
|
||||||
|
if err := as.Get(ctx, act.Head, &powerState); err != nil {
|
||||||
|
return types.EmptyInt, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !found {
|
var rewardState reward.State
|
||||||
return types.EmptyInt, xerrors.Errorf("no precommit found for sector %d", snum)
|
{
|
||||||
|
act, err := a.StateManager.GetActor(builtin.RewardActorAddr, ts)
|
||||||
|
if err != nil {
|
||||||
|
return types.EmptyInt, err
|
||||||
|
}
|
||||||
|
if err := as.Get(ctx, act.Head, &rewardState); err != nil {
|
||||||
|
return types.EmptyInt, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var dealWeights market.VerifyDealsOnSectorProveCommitReturn
|
var dealWeights market.VerifyDealsForActivationReturn
|
||||||
{
|
{
|
||||||
var err error
|
var err error
|
||||||
params, err := actors.SerializeParams(&market.VerifyDealsOnSectorProveCommitParams{
|
params, err := actors.SerializeParams(&market.VerifyDealsForActivationParams{
|
||||||
DealIDs: precommit.Info.DealIDs,
|
DealIDs: pci.DealIDs,
|
||||||
SectorExpiry: precommit.Info.Expiration,
|
SectorExpiry: pci.Expiration,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.EmptyInt, err
|
return types.EmptyInt, err
|
||||||
@ -737,7 +753,7 @@ func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr
|
|||||||
ret, err := a.StateManager.Call(ctx, &types.Message{
|
ret, err := a.StateManager.Call(ctx, &types.Message{
|
||||||
From: maddr,
|
From: maddr,
|
||||||
To: builtin.StorageMarketActorAddr,
|
To: builtin.StorageMarketActorAddr,
|
||||||
Method: builtin.MethodsMarket.VerifyDealsOnSectorProveCommit,
|
Method: builtin.MethodsMarket.VerifyDealsForActivation,
|
||||||
GasLimit: 100000000000,
|
GasLimit: 100000000000,
|
||||||
GasPrice: types.NewInt(0),
|
GasPrice: types.NewInt(0),
|
||||||
Params: params,
|
Params: params,
|
||||||
@ -751,42 +767,21 @@ func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initialPledge := big.Zero()
|
ssize, err := pci.SealProof.SectorSize()
|
||||||
{
|
if err != nil {
|
||||||
ssize, err := precommit.Info.SealProof.SectorSize()
|
return types.EmptyInt, err
|
||||||
if err != nil {
|
|
||||||
return types.EmptyInt, err
|
|
||||||
}
|
|
||||||
|
|
||||||
params, err := actors.SerializeParams(&power.OnSectorProveCommitParams{
|
|
||||||
Weight: power.SectorStorageWeightDesc{
|
|
||||||
SectorSize: ssize,
|
|
||||||
Duration: precommit.Info.Expiration - ts.Height(), // NB: not exactly accurate, but should always lead us to *over* estimate, not under
|
|
||||||
DealWeight: dealWeights.DealWeight,
|
|
||||||
VerifiedDealWeight: dealWeights.VerifiedDealWeight,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return types.EmptyInt, err
|
|
||||||
}
|
|
||||||
|
|
||||||
ret, err := a.StateManager.Call(ctx, &types.Message{
|
|
||||||
From: maddr,
|
|
||||||
To: builtin.StoragePowerActorAddr,
|
|
||||||
Method: builtin.MethodsPower.OnSectorProveCommit,
|
|
||||||
GasLimit: 10000000000,
|
|
||||||
GasPrice: types.NewInt(0),
|
|
||||||
Params: params,
|
|
||||||
}, ts)
|
|
||||||
if err != nil {
|
|
||||||
return types.EmptyInt, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := initialPledge.UnmarshalCBOR(bytes.NewReader(ret.MsgRct.Return)); err != nil {
|
|
||||||
return types.BigInt{}, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
duration := pci.Expiration - ts.Height() // NB: not exactly accurate, but should always lead us to *over* estimate, not under
|
||||||
|
|
||||||
|
circSupply, err := a.StateManager.CirculatingSupply(ctx, ts)
|
||||||
|
if err != nil {
|
||||||
|
return big.Zero(), xerrors.Errorf("getting circulating supply: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
sectorWeight := miner.QAPowerForWeight(ssize, duration, dealWeights.DealWeight, dealWeights.VerifiedDealWeight)
|
||||||
|
initialPledge := miner.InitialPledgeForPower(sectorWeight, powerState.TotalQualityAdjPower, powerState.TotalPledgeCollateral, rewardState.LastPerEpochReward, circSupply)
|
||||||
|
|
||||||
return types.BigDiv(types.BigMul(initialPledge, initialPledgeNum), initialPledgeDen), nil
|
return types.BigDiv(types.BigMul(initialPledge, initialPledgeNum), initialPledgeDen), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,6 +171,10 @@ func (sm *StorageMinerAPI) StorageStat(ctx context.Context, id stores.ID) (store
|
|||||||
return sm.StorageMgr.FsStat(ctx, id)
|
return sm.StorageMgr.FsStat(ctx, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (sm *StorageMinerAPI) SectorStartSealing(ctx context.Context, number abi.SectorNumber) error {
|
||||||
|
return sm.Miner.StartPackingSector(number)
|
||||||
|
}
|
||||||
|
|
||||||
func (sm *StorageMinerAPI) SectorsUpdate(ctx context.Context, id abi.SectorNumber, state api.SectorState) error {
|
func (sm *StorageMinerAPI) SectorsUpdate(ctx context.Context, id abi.SectorNumber, state api.SectorState) error {
|
||||||
return sm.Miner.ForceSectorState(ctx, id, sealing.SectorState(state))
|
return sm.Miner.ForceSectorState(ctx, id, sealing.SectorState(state))
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@ func builder(t *testing.T, nFull int, storage []test.StorageMiner) ([]test.TestN
|
|||||||
|
|
||||||
genaccs = append(genaccs, genesis.Actor{
|
genaccs = append(genaccs, genesis.Actor{
|
||||||
Type: genesis.TAccount,
|
Type: genesis.TAccount,
|
||||||
Balance: big.Mul(big.NewInt(50000), types.NewInt(build.FilecoinPrecision)),
|
Balance: big.Mul(big.NewInt(400_000_000), types.NewInt(build.FilecoinPrecision)),
|
||||||
Meta: (&genesis.AccountMeta{Owner: wk.Address}).ActorMeta(),
|
Meta: (&genesis.AccountMeta{Owner: wk.Address}).ActorMeta(),
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -336,7 +336,7 @@ func mockSbBuilder(t *testing.T, nFull int, storage []test.StorageMiner) ([]test
|
|||||||
|
|
||||||
genaccs = append(genaccs, genesis.Actor{
|
genaccs = append(genaccs, genesis.Actor{
|
||||||
Type: genesis.TAccount,
|
Type: genesis.TAccount,
|
||||||
Balance: big.Mul(big.NewInt(50000), types.NewInt(build.FilecoinPrecision)),
|
Balance: big.Mul(big.NewInt(400_000_000_000), types.NewInt(build.FilecoinPrecision)),
|
||||||
Meta: (&genesis.AccountMeta{Owner: wk.Address}).ActorMeta(),
|
Meta: (&genesis.AccountMeta{Owner: wk.Address}).ActorMeta(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -49,13 +49,13 @@ func (s SealingAPIAdapter) StateMinerSectorSize(ctx context.Context, maddr addre
|
|||||||
return mi.SectorSize, nil
|
return mi.SectorSize, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SealingAPIAdapter) StateMinerInitialPledgeCollateral(ctx context.Context, a address.Address, n abi.SectorNumber, tok sealing.TipSetToken) (big.Int, error) {
|
func (s SealingAPIAdapter) StateMinerInitialPledgeCollateral(ctx context.Context, a address.Address, pci miner.SectorPreCommitInfo, tok sealing.TipSetToken) (big.Int, error) {
|
||||||
tsk, err := types.TipSetKeyFromBytes(tok)
|
tsk, err := types.TipSetKeyFromBytes(tok)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return big.Zero(), xerrors.Errorf("failed to unmarshal TipSetToken to TipSetKey: %w", err)
|
return big.Zero(), xerrors.Errorf("failed to unmarshal TipSetToken to TipSetKey: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.delegate.StateMinerInitialPledgeCollateral(ctx, a, n, tsk)
|
return s.delegate.StateMinerInitialPledgeCollateral(ctx, a, pci, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SealingAPIAdapter) StateMinerWorkerAddress(ctx context.Context, maddr address.Address, tok sealing.TipSetToken) (address.Address, error) {
|
func (s SealingAPIAdapter) StateMinerWorkerAddress(ctx context.Context, maddr address.Address, tok sealing.TipSetToken) (address.Address, error) {
|
||||||
|
@ -53,7 +53,7 @@ type storageMinerApi interface {
|
|||||||
StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error)
|
StateSectorGetInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (*miner.SectorOnChainInfo, error)
|
||||||
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error)
|
StateMinerInfo(context.Context, address.Address, types.TipSetKey) (api.MinerInfo, error)
|
||||||
StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*miner.DeadlineInfo, error)
|
StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*miner.DeadlineInfo, error)
|
||||||
StateMinerInitialPledgeCollateral(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (types.BigInt, error)
|
StateMinerInitialPledgeCollateral(context.Context, address.Address, miner.SectorPreCommitInfo, types.TipSetKey) (types.BigInt, error)
|
||||||
StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64) (*api.MsgLookup, error) // TODO: removeme eventually
|
StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64) (*api.MsgLookup, error) // TODO: removeme eventually
|
||||||
StateGetActor(ctx context.Context, actor address.Address, ts types.TipSetKey) (*types.Actor, error)
|
StateGetActor(ctx context.Context, actor address.Address, ts types.TipSetKey) (*types.Actor, error)
|
||||||
StateGetReceipt(context.Context, cid.Cid, types.TipSetKey) (*types.MessageReceipt, error)
|
StateGetReceipt(context.Context, cid.Cid, types.TipSetKey) (*types.MessageReceipt, error)
|
||||||
@ -105,7 +105,7 @@ func (m *Miner) Run(ctx context.Context) error {
|
|||||||
|
|
||||||
evts := events.NewEvents(ctx, m.api)
|
evts := events.NewEvents(ctx, m.api)
|
||||||
adaptedAPI := NewSealingAPIAdapter(m.api)
|
adaptedAPI := NewSealingAPIAdapter(m.api)
|
||||||
pcp := sealing.NewBasicPreCommitPolicy(adaptedAPI, 10000000, md.PeriodStart%miner.WPoStProvingPeriod)
|
pcp := sealing.NewBasicPreCommitPolicy(adaptedAPI, miner.MaxSectorExpirationExtension-(miner.WPoStProvingPeriod*2), md.PeriodStart%miner.WPoStProvingPeriod)
|
||||||
m.sealing = sealing.New(adaptedAPI, NewEventsAdapter(evts), m.maddr, m.ds, m.sealer, m.sc, m.verif, &pcp)
|
m.sealing = sealing.New(adaptedAPI, NewEventsAdapter(evts), m.maddr, m.ds, m.sealer, m.sc, m.verif, &pcp)
|
||||||
|
|
||||||
go m.sealing.Run(ctx) //nolint:errcheck // logged intside the function
|
go m.sealing.Run(ctx) //nolint:errcheck // logged intside the function
|
||||||
|
@ -16,12 +16,12 @@ func (m *Miner) Address() address.Address {
|
|||||||
return m.sealing.Address()
|
return m.sealing.Address()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Miner) AllocatePiece(size abi.UnpaddedPieceSize) (sectorID abi.SectorNumber, offset uint64, err error) {
|
func (m *Miner) AddPieceToAnySector(ctx context.Context, size abi.UnpaddedPieceSize, r io.Reader, d sealing.DealInfo) (abi.SectorNumber, uint64, error) {
|
||||||
return m.sealing.AllocatePiece(size)
|
return m.sealing.AddPieceToAnySector(ctx, size, r, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Miner) SealPiece(ctx context.Context, size abi.UnpaddedPieceSize, r io.Reader, sectorID abi.SectorNumber, d sealing.DealInfo) error {
|
func (m *Miner) StartPackingSector(sectorNum abi.SectorNumber) error {
|
||||||
return m.sealing.SealPiece(ctx, size, r, sectorID, d)
|
return m.sealing.StartPacking(sectorNum)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Miner) ListSectors() ([]sealing.SectorInfo, error) {
|
func (m *Miner) ListSectors() ([]sealing.SectorInfo, error) {
|
||||||
|
@ -15,7 +15,6 @@ import (
|
|||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
cborutil "github.com/filecoin-project/go-cbor-util"
|
cborutil "github.com/filecoin-project/go-cbor-util"
|
||||||
"github.com/filecoin-project/go-padreader"
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
sealing "github.com/filecoin-project/storage-fsm"
|
sealing "github.com/filecoin-project/storage-fsm"
|
||||||
|
|
||||||
@ -97,18 +96,18 @@ func (st *SectorBlocks) writeRef(dealID abi.DealID, sectorID abi.SectorNumber, o
|
|||||||
return st.keys.Put(DealIDToDsKey(dealID), newRef) // TODO: batch somehow
|
return st.keys.Put(DealIDToDsKey(dealID), newRef) // TODO: batch somehow
|
||||||
}
|
}
|
||||||
|
|
||||||
func (st *SectorBlocks) AddPiece(ctx context.Context, size abi.UnpaddedPieceSize, r io.Reader, d sealing.DealInfo) (sectorID abi.SectorNumber, err error) {
|
func (st *SectorBlocks) AddPiece(ctx context.Context, size abi.UnpaddedPieceSize, r io.Reader, d sealing.DealInfo) (abi.SectorNumber, error) {
|
||||||
sectorID, pieceOffset, err := st.Miner.AllocatePiece(padreader.PaddedSize(uint64(size)))
|
sn, offset, err := st.Miner.AddPieceToAnySector(ctx, size, r, d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = st.writeRef(d.DealID, sectorID, pieceOffset, size)
|
err = st.writeRef(d.DealID, sn, offset, size)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, xerrors.Errorf("writeRef: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return sectorID, st.Miner.SealPiece(ctx, size, r, sectorID, d)
|
return sn, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (st *SectorBlocks) List() (map[uint64][]api.SealedRef, error) {
|
func (st *SectorBlocks) List() (map[uint64][]api.SealedRef, error) {
|
||||||
|
@ -463,8 +463,8 @@ func (s *WindowPoStScheduler) sortedSectorInfo(ctx context.Context, deadlineSect
|
|||||||
for k, sector := range sset {
|
for k, sector := range sset {
|
||||||
sbsi[k] = abi.SectorInfo{
|
sbsi[k] = abi.SectorInfo{
|
||||||
SectorNumber: sector.ID,
|
SectorNumber: sector.ID,
|
||||||
SealedCID: sector.Info.Info.SealedCID,
|
SealedCID: sector.Info.SealedCID,
|
||||||
SealProof: sector.Info.Info.SealProof,
|
SealProof: sector.Info.SealProof,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user