Fix client market impl, gofmt

This commit is contained in:
Łukasz Magiera 2020-02-13 01:15:33 +01:00
parent 91b2d2c2fe
commit e5ab64a3ab
9 changed files with 55 additions and 55 deletions

View File

@ -76,11 +76,11 @@ type FullNodeStruct struct {
MinerCreateBlock func(context.Context, address.Address, *types.TipSet, *types.Ticket, *types.EPostProof, []*types.SignedMessage, abi.ChainEpoch, uint64) (*types.BlockMsg, error) `perm:"write"` MinerCreateBlock func(context.Context, address.Address, *types.TipSet, *types.Ticket, *types.EPostProof, []*types.SignedMessage, abi.ChainEpoch, uint64) (*types.BlockMsg, error) `perm:"write"`
WalletNew func(context.Context, crypto.SigType) (address.Address, error) `perm:"write"` WalletNew func(context.Context, crypto.SigType) (address.Address, error) `perm:"write"`
WalletHas func(context.Context, address.Address) (bool, error) `perm:"write"` WalletHas func(context.Context, address.Address) (bool, error) `perm:"write"`
WalletList func(context.Context) ([]address.Address, error) `perm:"write"` WalletList func(context.Context) ([]address.Address, error) `perm:"write"`
WalletBalance func(context.Context, address.Address) (types.BigInt, error) `perm:"read"` WalletBalance func(context.Context, address.Address) (types.BigInt, error) `perm:"read"`
WalletSign func(context.Context, address.Address, []byte) (*crypto.Signature, error) `perm:"sign"` WalletSign func(context.Context, address.Address, []byte) (*crypto.Signature, error) `perm:"sign"`
WalletSignMessage func(context.Context, address.Address, *types.Message) (*types.SignedMessage, error) `perm:"sign"` WalletSignMessage func(context.Context, address.Address, *types.Message) (*types.SignedMessage, error) `perm:"sign"`
WalletDefaultAddress func(context.Context) (address.Address, error) `perm:"write"` WalletDefaultAddress func(context.Context) (address.Address, error) `perm:"write"`
WalletSetDefault func(context.Context, address.Address) error `perm:"admin"` WalletSetDefault func(context.Context, address.Address) error `perm:"admin"`
@ -97,32 +97,32 @@ type FullNodeStruct struct {
ClientRetrieve func(ctx context.Context, order api.RetrievalOrder, path string) error `perm:"admin"` ClientRetrieve func(ctx context.Context, order api.RetrievalOrder, path string) error `perm:"admin"`
ClientQueryAsk func(ctx context.Context, p peer.ID, miner address.Address) (*types.SignedStorageAsk, error) `perm:"read"` ClientQueryAsk func(ctx context.Context, p peer.ID, miner address.Address) (*types.SignedStorageAsk, error) `perm:"read"`
StateMinerSectors func(context.Context, address.Address, *types.TipSet) ([]*api.ChainSectorInfo, error) `perm:"read"` StateMinerSectors func(context.Context, address.Address, *types.TipSet) ([]*api.ChainSectorInfo, error) `perm:"read"`
StateMinerProvingSet func(context.Context, address.Address, *types.TipSet) ([]*api.ChainSectorInfo, error) `perm:"read"` StateMinerProvingSet func(context.Context, address.Address, *types.TipSet) ([]*api.ChainSectorInfo, error) `perm:"read"`
StateMinerPower func(context.Context, address.Address, *types.TipSet) (api.MinerPower, error) `perm:"read"` StateMinerPower func(context.Context, address.Address, *types.TipSet) (api.MinerPower, error) `perm:"read"`
StateMinerWorker func(context.Context, address.Address, *types.TipSet) (address.Address, error) `perm:"read"` StateMinerWorker func(context.Context, address.Address, *types.TipSet) (address.Address, error) `perm:"read"`
StateMinerPeerID func(ctx context.Context, m address.Address, ts *types.TipSet) (peer.ID, error) `perm:"read"` StateMinerPeerID func(ctx context.Context, m address.Address, ts *types.TipSet) (peer.ID, error) `perm:"read"`
StateMinerPostState func(ctx context.Context, actor address.Address, ts *types.TipSet) (*miner.PoStState, error) `perm:"read"` StateMinerPostState func(ctx context.Context, actor address.Address, ts *types.TipSet) (*miner.PoStState, error) `perm:"read"`
StateMinerSectorSize func(context.Context, address.Address, *types.TipSet) (abi.SectorSize, error) `perm:"read"` StateMinerSectorSize func(context.Context, address.Address, *types.TipSet) (abi.SectorSize, error) `perm:"read"`
StateMinerFaults func(context.Context, address.Address, *types.TipSet) ([]abi.SectorNumber, error) `perm:"read"` StateMinerFaults func(context.Context, address.Address, *types.TipSet) ([]abi.SectorNumber, error) `perm:"read"`
StateCall func(context.Context, *types.Message, *types.TipSet) (*api.MethodCall, error) `perm:"read"` StateCall func(context.Context, *types.Message, *types.TipSet) (*api.MethodCall, error) `perm:"read"`
StateReplay func(context.Context, *types.TipSet, cid.Cid) (*api.ReplayResults, error) `perm:"read"` StateReplay func(context.Context, *types.TipSet, cid.Cid) (*api.ReplayResults, error) `perm:"read"`
StateGetActor func(context.Context, address.Address, *types.TipSet) (*types.Actor, error) `perm:"read"` StateGetActor func(context.Context, address.Address, *types.TipSet) (*types.Actor, error) `perm:"read"`
StateReadState func(context.Context, *types.Actor, *types.TipSet) (*api.ActorState, error) `perm:"read"` StateReadState func(context.Context, *types.Actor, *types.TipSet) (*api.ActorState, error) `perm:"read"`
StatePledgeCollateral func(context.Context, *types.TipSet) (types.BigInt, error) `perm:"read"` StatePledgeCollateral func(context.Context, *types.TipSet) (types.BigInt, error) `perm:"read"`
StateWaitMsg func(context.Context, cid.Cid) (*api.MsgWait, error) `perm:"read"` StateWaitMsg func(context.Context, cid.Cid) (*api.MsgWait, error) `perm:"read"`
StateListMiners func(context.Context, *types.TipSet) ([]address.Address, error) `perm:"read"` StateListMiners func(context.Context, *types.TipSet) ([]address.Address, error) `perm:"read"`
StateListActors func(context.Context, *types.TipSet) ([]address.Address, error) `perm:"read"` StateListActors func(context.Context, *types.TipSet) ([]address.Address, error) `perm:"read"`
StateMarketBalance func(context.Context, address.Address, *types.TipSet) (api.MarketBalance, error) `perm:"read"` StateMarketBalance func(context.Context, address.Address, *types.TipSet) (api.MarketBalance, error) `perm:"read"`
StateMarketParticipants func(context.Context, *types.TipSet) (map[string]api.MarketBalance, error) `perm:"read"` StateMarketParticipants func(context.Context, *types.TipSet) (map[string]api.MarketBalance, error) `perm:"read"`
StateMarketDeals func(context.Context, *types.TipSet) (map[string]api.MarketDeal, error) `perm:"read"` StateMarketDeals func(context.Context, *types.TipSet) (map[string]api.MarketDeal, error) `perm:"read"`
StateMarketStorageDeal func(context.Context, abi.DealID, *types.TipSet) (*api.MarketDeal, error) `perm:"read"` StateMarketStorageDeal func(context.Context, abi.DealID, *types.TipSet) (*api.MarketDeal, error) `perm:"read"`
StateLookupID func(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error) `perm:"read"` StateLookupID func(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error) `perm:"read"`
StateChangedActors func(context.Context, cid.Cid, cid.Cid) (map[string]types.Actor, error) `perm:"read"` StateChangedActors func(context.Context, cid.Cid, cid.Cid) (map[string]types.Actor, error) `perm:"read"`
StateGetReceipt func(context.Context, cid.Cid, *types.TipSet) (*types.MessageReceipt, error) `perm:"read"` StateGetReceipt func(context.Context, cid.Cid, *types.TipSet) (*types.MessageReceipt, error) `perm:"read"`
StateMinerSectorCount func(context.Context, address.Address, *types.TipSet) (api.MinerSectors, error) `perm:"read"` StateMinerSectorCount func(context.Context, address.Address, *types.TipSet) (api.MinerSectors, error) `perm:"read"`
StateListMessages func(ctx context.Context, match *types.Message, ts *types.TipSet, toht abi.ChainEpoch) ([]cid.Cid, error) `perm:"read"` StateListMessages func(ctx context.Context, match *types.Message, ts *types.TipSet, toht abi.ChainEpoch) ([]cid.Cid, error) `perm:"read"`
StateCompute func(context.Context, abi.ChainEpoch, []*types.Message, *types.TipSet) (cid.Cid, error) `perm:"read"` StateCompute func(context.Context, abi.ChainEpoch, []*types.Message, *types.TipSet) (cid.Cid, error) `perm:"read"`
MsigGetAvailableBalance func(context.Context, address.Address, *types.TipSet) (types.BigInt, error) `perm:"read"` MsigGetAvailableBalance func(context.Context, address.Address, *types.TipSet) (types.BigInt, error) `perm:"read"`

View File

@ -164,7 +164,7 @@ func NewGenerator() (*ChainGen, error) {
sys := vm.Syscalls(sectorbuilder.ProofVerifier) sys := vm.Syscalls(sectorbuilder.ProofVerifier)
tpl := genesis.Template{ tpl := genesis.Template{
Accounts: []genesis.Actor{ Accounts: []genesis.Actor{
{ {
Type: genesis.TAccount, Type: genesis.TAccount,
Balance: types.FromFil(40000), Balance: types.FromFil(40000),
@ -181,7 +181,7 @@ func NewGenerator() (*ChainGen, error) {
Meta: (&genesis.AccountMeta{Owner: banker}).ActorMeta(), Meta: (&genesis.AccountMeta{Owner: banker}).ActorMeta(),
}, },
}, },
Miners: []genesis.Miner{ Miners: []genesis.Miner{
*genm1, *genm1,
*genm2, *genm2,
}, },

View File

@ -110,7 +110,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
for pi, preseal := range m.Sectors { for pi, preseal := range m.Sectors {
// Precommit // Precommit
{ {
params := &miner.PreCommitSectorParams{Info:miner.SectorPreCommitInfo{ params := &miner.PreCommitSectorParams{Info: miner.SectorPreCommitInfo{
SectorNumber: preseal.SectorID, SectorNumber: preseal.SectorID,
SealedCID: commcid.ReplicaCommitmentV1ToCID(preseal.CommR[:]), SealedCID: commcid.ReplicaCommitmentV1ToCID(preseal.CommR[:]),
SealEpoch: 0, SealEpoch: 0,

View File

@ -183,8 +183,7 @@ func (st *StateTree) RegisterNewAddress(addr address.Address, act *types.Actor)
return out, nil return out, nil
} }
type adtStore struct{ cbor.IpldStore }
type adtStore struct {cbor.IpldStore}
func (a *adtStore) Context() context.Context { func (a *adtStore) Context() context.Context {
return context.TODO() return context.TODO()

View File

@ -2,6 +2,7 @@ package types
import ( import (
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-fil-markets/storagemarket"
cbor "github.com/ipfs/go-ipld-cbor" cbor "github.com/ipfs/go-ipld-cbor"
) )
@ -10,10 +11,7 @@ func init() {
cbor.RegisterCborType(StorageAsk{}) cbor.RegisterCborType(StorageAsk{})
} }
type SignedStorageAsk struct { type SignedStorageAsk = storagemarket.SignedStorageAsk
Ask *StorageAsk
Signature *Signature
}
type StorageAsk struct { type StorageAsk struct {
// Price per GiB / Epoch // Price per GiB / Epoch

View File

@ -10,6 +10,7 @@ import (
) )
type ActorType string type ActorType string
const ( const (
TAccount ActorType = "account" TAccount ActorType = "account"
TMultisig ActorType = "multisig" TMultisig ActorType = "multisig"

View File

@ -4,9 +4,9 @@ import (
"context" "context"
"errors" "errors"
"io" "io"
"math"
"os" "os"
"github.com/filecoin-project/specs-actors/actors/abi/big"
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/ipfs/go-blockservice" "github.com/ipfs/go-blockservice"
@ -26,6 +26,8 @@ import (
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-fil-markets/retrievalmarket" "github.com/filecoin-project/go-fil-markets/retrievalmarket"
"github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/go-fil-markets/storagemarket"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/store"
@ -34,10 +36,9 @@ import (
"github.com/filecoin-project/lotus/node/impl/full" "github.com/filecoin-project/lotus/node/impl/full"
"github.com/filecoin-project/lotus/node/impl/paych" "github.com/filecoin-project/lotus/node/impl/paych"
"github.com/filecoin-project/lotus/node/modules/dtypes" "github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/specs-actors/actors/abi"
) )
const dealStartBuffer abi.ChainEpoch 100 const dealStartBuffer abi.ChainEpoch = 10000 // TODO: allow setting
type API struct { type API struct {
fx.In fx.In
@ -80,16 +81,18 @@ func (a *API) ClientStartDeal(ctx context.Context, data cid.Cid, addr address.Ad
if err != nil { if err != nil {
return nil, xerrors.Errorf("failed getting chain height: %w", err) return nil, xerrors.Errorf("failed getting chain height: %w", err)
} }
currentEpoch := ts.Height()
result, err := a.SMDealClient.ProposeStorageDeal( result, err := a.SMDealClient.ProposeStorageDeal(
ctx, ctx,
addr, addr,
&providerInfo, &providerInfo,
data, &storagemarket.DataRef{
TransferType: storagemarket.TTGraphsync,
Root: data,
},
ts.Height()+dealStartBuffer, ts.Height()+dealStartBuffer,
ts.Height()+dealStartBuffer+abi.ChainEpoch(blocksDuration), ts.Height()+dealStartBuffer+abi.ChainEpoch(blocksDuration),
epochPrice, epochPrice,
tokenamount.Empty) big.Zero())
if err != nil { if err != nil {
return nil, xerrors.Errorf("failed to start deal: %w", err) return nil, xerrors.Errorf("failed to start deal: %w", err)
@ -111,11 +114,11 @@ func (a *API) ClientListDeals(ctx context.Context) ([]api.DealInfo, error) {
State: v.State, State: v.State,
Provider: v.Proposal.Provider, Provider: v.Proposal.Provider,
PieceRef: v.Proposal.PieceRef, PieceRef: v.Proposal.PieceCID.Bytes(),
Size: v.Proposal.PieceSize, Size: uint64(v.Proposal.PieceSize.Unpadded()),
PricePerEpoch: v.Proposal.StoragePricePerEpoch, PricePerEpoch: v.Proposal.StoragePricePerEpoch,
Duration: v.Proposal.Duration, Duration: uint64(v.Proposal.Duration()),
} }
} }
@ -132,10 +135,10 @@ func (a *API) ClientGetDealInfo(ctx context.Context, d cid.Cid) (*api.DealInfo,
ProposalCid: v.ProposalCid, ProposalCid: v.ProposalCid,
State: v.State, State: v.State,
Provider: v.Proposal.Provider, Provider: v.Proposal.Provider,
PieceRef: v.Proposal.PieceRef, PieceRef: v.Proposal.PieceCID.Bytes(),
Size: v.Proposal.PieceSize, Size: uint64(v.Proposal.PieceSize.Unpadded()),
PricePerEpoch: v.Proposal.StoragePricePerEpoch, PricePerEpoch: v.Proposal.StoragePricePerEpoch,
Duration: v.Proposal.Duration, Duration: uint64(v.Proposal.Duration()),
}, nil }, nil
} }
@ -300,7 +303,7 @@ func (a *API) ClientRetrieve(ctx context.Context, order api.RetrievalOrder, path
a.Retrieval.Retrieve( a.Retrieval.Retrieve(
ctx, ctx,
order.Root, order.Root,
retrievalmarket.NewParamsV0(types.BigDiv(order.Total, types.NewInt(order.Size)).Int, order.PaymentInterval, order.PaymentIntervalIncrease), retrievalmarket.NewParamsV0(types.BigDiv(order.Total, types.NewInt(order.Size)), order.PaymentInterval, order.PaymentIntervalIncrease),
order.Total, order.Total,
order.MinerPeerID, order.MinerPeerID,
order.Client, order.Client,
@ -327,11 +330,11 @@ func (a *API) ClientRetrieve(ctx context.Context, order api.RetrievalOrder, path
return files.WriteTo(file, path) return files.WriteTo(file, path)
} }
func (a *API) ClientQueryAsk(ctx context.Context, p peer.ID, miner address.Address) (*types.SignedStorageAsk, error) { func (a *API) ClientQueryAsk(ctx context.Context, p peer.ID, miner address.Address) (*storagemarket.SignedStorageAsk, error) {
info := utils.NewStorageProviderInfo(miner, address.Undef, 0, p) info := utils.NewStorageProviderInfo(miner, address.Undef, 0, p)
signedAsk, err := a.SMDealClient.GetAsk(ctx, info) signedAsk, err := a.SMDealClient.GetAsk(ctx, info)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return signedAsk return signedAsk, nil
} }

View File

@ -23,7 +23,7 @@ func (pm *Manager) createPaych(ctx context.Context, from, to address.Address, am
} }
enc, aerr := actors.SerializeParams(&init_.ExecParams{ enc, aerr := actors.SerializeParams(&init_.ExecParams{
CodeCID: actors.PaymentChannelCodeCid, CodeCID: actors.PaymentChannelCodeCid,
ConstructorParams: params, ConstructorParams: params,
}) })
if aerr != nil { if aerr != nil {

View File

@ -107,7 +107,6 @@ func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInf
SealEpoch: sector.Ticket.BlockHeight, SealEpoch: sector.Ticket.BlockHeight,
DealIDs: nil, // sector.deals(), // TODO: REFACTOR DealIDs: nil, // sector.deals(), // TODO: REFACTOR
}, },
} }
enc, aerr := actors.SerializeParams(params) enc, aerr := actors.SerializeParams(params)
if aerr != nil { if aerr != nil {
@ -190,7 +189,7 @@ func (m *Sealing) handleCommitting(ctx statemachine.Context, sector SectorInfo)
params := &miner.ProveCommitSectorParams{ params := &miner.ProveCommitSectorParams{
SectorNumber: sector.SectorID, SectorNumber: sector.SectorID,
Proof: abi.SealProof{ProofBytes:proof}, Proof: abi.SealProof{ProofBytes: proof},
} }
enc, aerr := actors.SerializeParams(params) enc, aerr := actors.SerializeParams(params)