storageminer: Updates to new types
This commit is contained in:
parent
220bd376b4
commit
255f511abd
@ -40,32 +40,32 @@ From a list of parameters, create a genesis block / initial state
|
||||
|
||||
The process:
|
||||
- Bootstrap state (MakeInitialStateTree)
|
||||
- Create empty state
|
||||
- Make init actor
|
||||
- Create empty state
|
||||
- Make init actor
|
||||
- Create accounts mappings
|
||||
- Set NextID to MinerStart
|
||||
- Setup Reward (1.4B fil)
|
||||
- Setup Cron
|
||||
- Create empty power actor
|
||||
- Create empty power actor
|
||||
- Create empty market
|
||||
- Setup burnt fund address
|
||||
- Initialize account / msig balances
|
||||
- Initialize account / msig balances
|
||||
- Instantiate early vm with genesis syscalls
|
||||
- Create miners
|
||||
- Each:
|
||||
- power.CreateMiner, set msg value to PowerBalance
|
||||
- Each:
|
||||
- power.CreateMiner, set msg value to PowerBalance
|
||||
- market.AddFunds with correct value
|
||||
- market.PublishDeals for related sectors
|
||||
- Set precommits
|
||||
- Commit presealed sectors
|
||||
- Set precommits
|
||||
- Commit presealed sectors
|
||||
|
||||
Data Types:
|
||||
|
||||
PreSeal :{
|
||||
CommR CID
|
||||
CommD CID
|
||||
SectorID SectorNumber
|
||||
Deal market.DealProposal # Start at 0, self-deal!
|
||||
CommR CID
|
||||
CommD CID
|
||||
SectorID SectorNumber
|
||||
Deal market.DealProposal # Start at 0, self-deal!
|
||||
}
|
||||
|
||||
Genesis: {
|
||||
|
@ -7,14 +7,14 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/gen"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
lru "github.com/hashicorp/golang-lru"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/gen"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
"go.opencensus.io/trace"
|
||||
"golang.org/x/xerrors"
|
||||
@ -342,7 +342,7 @@ func (m *Miner) mineOne(ctx context.Context, addr address.Address, base *MiningB
|
||||
}
|
||||
|
||||
func (m *Miner) computeVRF(ctx context.Context, addr address.Address, input []byte) ([]byte, error) {
|
||||
w, err := m.getMinerWorker(ctx, addr, nil)
|
||||
w, err := m.api.StateMinerWorker(ctx, addr, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -350,28 +350,6 @@ func (m *Miner) computeVRF(ctx context.Context, addr address.Address, input []by
|
||||
return gen.ComputeVRF(ctx, m.api.WalletSign, w, addr, gen.DSepTicket, input)
|
||||
}
|
||||
|
||||
func (m *Miner) getMinerWorker(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error) {
|
||||
ret, err := m.api.StateCall(ctx, &types.Message{
|
||||
From: addr,
|
||||
To: addr,
|
||||
Method: actors.MAMethods.GetWorkerAddr,
|
||||
}, ts)
|
||||
if err != nil {
|
||||
return address.Undef, xerrors.Errorf("failed to get miner worker addr: %w", err)
|
||||
}
|
||||
|
||||
if ret.ExitCode != 0 {
|
||||
return address.Undef, xerrors.Errorf("failed to get miner worker addr (exit code %d)", ret.ExitCode)
|
||||
}
|
||||
|
||||
w, err := address.NewFromBytes(ret.Return)
|
||||
if err != nil {
|
||||
return address.Undef, xerrors.Errorf("GetWorkerAddr returned malformed address: %w", err)
|
||||
}
|
||||
|
||||
return w, nil
|
||||
}
|
||||
|
||||
func (m *Miner) computeTicket(ctx context.Context, addr address.Address, base *MiningBase) (*types.Ticket, error) {
|
||||
|
||||
vrfBase := base.ts.MinTicket().VRFProof
|
||||
|
@ -7,6 +7,8 @@ import (
|
||||
ffi "github.com/filecoin-project/filecoin-ffi"
|
||||
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||
"go.opencensus.io/trace"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
@ -51,7 +53,7 @@ func (s *FPoStScheduler) doPost(ctx context.Context, eps abi.ChainEpoch, ts *typ
|
||||
}()
|
||||
}
|
||||
|
||||
func (s *FPoStScheduler) declareFaults(ctx context.Context, fc uint64, params *actors.DeclareFaultsParams) error {
|
||||
func (s *FPoStScheduler) declareFaults(ctx context.Context, fc uint64, params *miner.DeclareTemporaryFaultsParams) error {
|
||||
log.Warnf("DECLARING %d FAULTS", fc)
|
||||
|
||||
enc, aerr := actors.SerializeParams(params)
|
||||
@ -62,7 +64,7 @@ func (s *FPoStScheduler) declareFaults(ctx context.Context, fc uint64, params *a
|
||||
msg := &types.Message{
|
||||
To: s.actor,
|
||||
From: s.worker,
|
||||
Method: actors.MAMethods.DeclareFaults,
|
||||
Method: builtin.MethodsMiner.DeclareTemporaryFaults,
|
||||
Params: enc,
|
||||
Value: types.NewInt(0),
|
||||
GasLimit: types.NewInt(10000000), // i dont know help
|
||||
@ -103,35 +105,32 @@ func (s *FPoStScheduler) checkFaults(ctx context.Context, ssi sectorbuilder.Sort
|
||||
}
|
||||
}
|
||||
|
||||
var faultIDs []abi.SectorNumber
|
||||
if len(faults) > 0 {
|
||||
params := &actors.DeclareFaultsParams{Faults: types.NewBitField()}
|
||||
params := &miner.DeclareTemporaryFaultsParams{Duration: 900} // TODO: duration is annoying
|
||||
|
||||
for _, fault := range faults {
|
||||
if _, ok := declaredFaults[abi.SectorNumber(fault.SectorNum)]; ok {
|
||||
if _, ok := declaredFaults[(fault.SectorNum)]; ok {
|
||||
continue
|
||||
}
|
||||
|
||||
log.Warnf("new fault detected: sector %d: %s", fault.SectorNum, fault.Err)
|
||||
declaredFaults[fault.SectorNum] = struct{}{}
|
||||
params.Faults.Set(uint64(fault.SectorNum))
|
||||
}
|
||||
|
||||
pc, err := params.Faults.Count()
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("counting faults: %w", err)
|
||||
faultIDs = make([]abi.SectorNumber, 0, len(declaredFaults))
|
||||
for fault := range declaredFaults {
|
||||
faultIDs = append(faultIDs, abi.SectorNumber(fault))
|
||||
}
|
||||
if pc > 0 {
|
||||
if err := s.declareFaults(ctx, pc, params); err != nil {
|
||||
params.SectorNumbers = faultIDs
|
||||
|
||||
if len(faultIDs) > 0 {
|
||||
if err := s.declareFaults(ctx, uint64(len(faultIDs)), params); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
faultIDs := make([]abi.SectorNumber, 0, len(declaredFaults))
|
||||
for fault := range declaredFaults {
|
||||
faultIDs = append(faultIDs, abi.SectorNumber(fault))
|
||||
}
|
||||
|
||||
return faultIDs, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user