diff --git a/api/impl/venus_market.go b/api/impl/venus_market.go index 5af33e33..06112621 100644 --- a/api/impl/venus_market.go +++ b/api/impl/venus_market.go @@ -38,7 +38,6 @@ import ( "github.com/filecoin-project/venus-market/v2/storageprovider" "github.com/filecoin-project/venus-market/v2/version" - "github.com/filecoin-project/go-state-types/builtin/v8/paych" "github.com/filecoin-project/venus/pkg/constants" v1api "github.com/filecoin-project/venus/venus-shared/api/chain/v1" marketapi "github.com/filecoin-project/venus/venus-shared/api/market" @@ -749,7 +748,7 @@ func (m *MarketNodeImpl) GetDeals(ctx context.Context, miner address.Address, pa return m.DealAssigner.GetDeals(ctx, miner, pageIndex, pageSize) } -func (m *MarketNodeImpl) PaychVoucherList(ctx context.Context, pch address.Address) ([]*paych.SignedVoucher, error) { +func (m *MarketNodeImpl) PaychVoucherList(ctx context.Context, pch address.Address) ([]*vTypes.SignedVoucher, error) { return m.PaychAPI.PaychVoucherList(ctx, pch) } diff --git a/cli/actor.go b/cli/actor.go index 354216e2..9eb9bd5d 100644 --- a/cli/actor.go +++ b/cli/actor.go @@ -12,7 +12,6 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/builtin" - miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/venus/venus-shared/actors" "github.com/filecoin-project/venus/venus-shared/types" ) @@ -133,7 +132,7 @@ var actorSetAddrsCmd = &cli.Command{ return err } - params, err := actors.SerializeParams(&miner9.ChangeMultiaddrsParams{NewMultiaddrs: addrs}) + params, err := actors.SerializeParams(&types.ChangeMultiaddrsParams{NewMultiaddrs: addrs}) if err != nil { return err } @@ -205,7 +204,7 @@ var actorSetPeeridCmd = &cli.Command{ return err } - params, err := actors.SerializeParams(&miner9.ChangePeerIDParams{NewID: abi.PeerID(pid)}) + params, err := actors.SerializeParams(&types.ChangePeerIDParams{NewID: abi.PeerID(pid)}) if err != nil { return err } diff --git a/client/client.go b/client/client.go index bb9ff843..e1de1271 100644 --- a/client/client.go +++ b/client/client.go @@ -55,7 +55,6 @@ import ( "github.com/filecoin-project/go-fil-markets/storagemarket/network" "github.com/filecoin-project/go-fil-markets/stores" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/builtin/v9/market" textselector "github.com/ipld/go-ipld-selector-text-lite" "github.com/filecoin-project/venus-market/v2/config" @@ -220,12 +219,12 @@ func (a *API) dealStarter(ctx context.Context, params *types.StartDealParams, is // stateless flow from here to the end // - label, err := market.NewLabelFromString(params.Data.Root.Encode(multibase.MustNewEncoder('u'))) + label, err := vTypes.NewLabelFromString(params.Data.Root.Encode(multibase.MustNewEncoder('u'))) if err != nil { return nil, fmt.Errorf("failed to encode label: %w", err) } - dealProposal := &market.DealProposal{ + dealProposal := &vTypes.DealProposal{ PieceCID: *params.Data.PieceCid, PieceSize: params.Data.PieceSize.Padded(), Client: walletKey, @@ -260,7 +259,7 @@ func (a *API) dealStarter(ctx context.Context, params *types.StartDealParams, is return nil, fmt.Errorf("failed to sign proposal : %w", err) } - dealProposalSigned := &market.ClientDealProposal{ + dealProposalSigned := &vTypes.ClientDealProposal{ Proposal: *dealProposal, ClientSignature: *dealProposalSig, } diff --git a/dagstore/market_api_test.go b/dagstore/market_api_test.go index fac99125..b5bd97cd 100644 --- a/dagstore/market_api_test.go +++ b/dagstore/market_api_test.go @@ -8,11 +8,11 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/builtin/v9/market" acrypto "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/venus-market/v2/config" "github.com/filecoin-project/venus-market/v2/models" "github.com/filecoin-project/venus-market/v2/piecestorage" + "github.com/filecoin-project/venus/venus-shared/types" markettypes "github.com/filecoin-project/venus/venus-shared/types/market" "github.com/ipfs/go-cid" "github.com/stretchr/testify/assert" @@ -33,8 +33,8 @@ func TestMarket(t *testing.T) { r := models.NewInMemoryRepo(t) err = r.StorageDealRepo().SaveDeal(ctx, &markettypes.MinerDeal{ - ClientDealProposal: market.ClientDealProposal{ - Proposal: market.DealProposal{ + ClientDealProposal: types.ClientDealProposal{ + Proposal: types.DealProposal{ Provider: address.TestAddress, Client: address.TestAddress, PieceCID: testResourceId, diff --git a/fundmgr/fundmanager.go b/fundmgr/fundmanager.go index 6181a5ce..fe110f72 100644 --- a/fundmgr/fundmanager.go +++ b/fundmgr/fundmanager.go @@ -17,7 +17,6 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/builtin" - "github.com/filecoin-project/go-state-types/builtin/v9/market" types2 "github.com/filecoin-project/venus/venus-shared/types" "github.com/ipfs/go-cid" logging "github.com/ipfs/go-log/v2" @@ -710,7 +709,7 @@ func (env *fundManagerEnvironment) WithdrawFunds( addr address.Address, amt abi.TokenAmount, ) (cid.Cid, error) { - params, err := actors.SerializeParams(&market.WithdrawBalanceParams{ + params, err := actors.SerializeParams(&types2.MarketWithdrawBalanceParams{ ProviderOrClientAddress: addr, Amount: amt, }) diff --git a/fundmgr/fundmanager_test.go b/fundmgr/fundmanager_test.go index 82802379..61dd3b53 100644 --- a/fundmgr/fundmanager_test.go +++ b/fundmgr/fundmanager_test.go @@ -10,7 +10,6 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/builtin" - "github.com/filecoin-project/go-state-types/builtin/v9/market" tutils "github.com/filecoin-project/specs-actors/v2/support/testing" "github.com/filecoin-project/venus-market/v2/models/badger" "github.com/filecoin-project/venus-market/v2/models/repo" @@ -661,7 +660,7 @@ func checkWithdrawMessageFields(t *testing.T, msg *types.Message, from address.A require.Equal(t, builtin.StorageMarketActorAddr, msg.To) require.Equal(t, abi.NewTokenAmount(0), msg.Value) - var params market.WithdrawBalanceParams + var params types.MarketWithdrawBalanceParams err := params.UnmarshalCBOR(bytes.NewReader(msg.Params)) require.NoError(t, err) require.Equal(t, addr, params.ProviderOrClientAddress) @@ -741,7 +740,7 @@ func (mapi *mockFundManagerAPI) completeMsg(msgCid cid.Cid) { mapi.escrow[escrowAcct] = escrow log.Debugf("%s: escrow %d -> %d", escrowAcct, before, escrow) } else { - var params market.WithdrawBalanceParams + var params types.MarketWithdrawBalanceParams err := params.UnmarshalCBOR(bytes.NewReader(pmsg.msg.Message.Params)) if err != nil { panic(err) diff --git a/models/badger/migrate/v2.2.0/types.go b/models/badger/migrate/v2.2.0/types.go index 8a79ed5a..580791fc 100644 --- a/models/badger/migrate/v2.2.0/types.go +++ b/models/badger/migrate/v2.2.0/types.go @@ -2,7 +2,7 @@ package v220 /* - 所有的类型都来源于老版本(venus-shared/v1.6.0)的拷贝. 用于badger持久化的类型的自动化迁移. + 所有的类型都来源于老版本(github.com/filecoin-project/venus/venus-shared@v1.6.0)的拷贝,用于badger持久化的类型的自动化迁移。 */ import ( @@ -20,8 +20,8 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/builtin/v8/paych" - "github.com/filecoin-project/go-state-types/builtin/v9/market" "github.com/filecoin-project/venus-market/v2/models/badger/statestore" + "github.com/filecoin-project/venus/venus-shared/types" "github.com/ipfs/go-cid" "github.com/ipfs/go-datastore" "github.com/libp2p/go-libp2p/core/peer" @@ -74,7 +74,7 @@ func (t *FundedAddressState) KeyWithNamespace() datastore.Key { type PieceStatus string type MinerDeal struct { - market.ClientDealProposal + types.ClientDealProposal ProposalCid cid.Cid AddFundsCid *cid.Cid PublishCid *cid.Cid diff --git a/models/badger/storage_deal_test.go b/models/badger/storage_deal_test.go index 5ba6416a..4451d5b8 100644 --- a/models/badger/storage_deal_test.go +++ b/models/badger/storage_deal_test.go @@ -7,34 +7,34 @@ import ( "github.com/filecoin-project/go-fil-markets/piecestore" "github.com/filecoin-project/go-fil-markets/storagemarket" - market8 "github.com/filecoin-project/go-state-types/builtin/v9/market" "github.com/ipfs/go-cid" "github.com/filecoin-project/go-address" "github.com/filecoin-project/venus-market/v2/models/repo" "github.com/stretchr/testify/assert" - m_types "github.com/filecoin-project/venus/venus-shared/types/market" + "github.com/filecoin-project/venus/venus-shared/types" + markettypes "github.com/filecoin-project/venus/venus-shared/types/market" "github.com/filecoin-project/venus/venus-shared/testutil" ) func init() { - testutil.MustRegisterDefaultValueProvier(func(t *testing.T) market8.DealLabel { - l, err := market8.NewLabelFromBytes([]byte{}) + testutil.MustRegisterDefaultValueProvier(func(t *testing.T) types.DealLabel { + l, err := types.NewLabelFromBytes([]byte{}) assert.NoError(t, err) return l }) } -func prepareStorageDealTest(t *testing.T) (context.Context, repo.StorageDealRepo, []m_types.MinerDeal) { +func prepareStorageDealTest(t *testing.T) (context.Context, repo.StorageDealRepo, []markettypes.MinerDeal) { ctx := context.Background() repo := setup(t) r := repo.StorageDealRepo() - dealCases := make([]m_types.MinerDeal, 10) + dealCases := make([]markettypes.MinerDeal, 10) testutil.Provide(t, &dealCases) - dealCases[0].PieceStatus = m_types.Assigned + dealCases[0].PieceStatus = markettypes.Assigned return ctx, r, dealCases } @@ -211,14 +211,14 @@ func TestGetStorageDealsByDataCidAndDealStatus(t *testing.T) { } t.Run("With Provider", func(t *testing.T) { - res, err := r.GetDealsByDataCidAndDealStatus(ctx, dealCases[0].Proposal.Provider, dealCases[0].Ref.Root, []m_types.PieceStatus{dealCases[0].PieceStatus}) + res, err := r.GetDealsByDataCidAndDealStatus(ctx, dealCases[0].Proposal.Provider, dealCases[0].Ref.Root, []markettypes.PieceStatus{dealCases[0].PieceStatus}) assert.NoError(t, err) assert.Equal(t, 1, len(res)) assert.Equal(t, dealCases[0], *res[0]) }) t.Run("Without Provider", func(t *testing.T) { - res, err := r.GetDealsByDataCidAndDealStatus(ctx, address.Undef, dealCases[0].Ref.Root, []m_types.PieceStatus{dealCases[0].PieceStatus}) + res, err := r.GetDealsByDataCidAndDealStatus(ctx, address.Undef, dealCases[0].Ref.Root, []markettypes.PieceStatus{dealCases[0].PieceStatus}) assert.NoError(t, err) assert.Equal(t, 1, len(res)) assert.Equal(t, dealCases[0], *res[0]) @@ -375,12 +375,12 @@ func TestUpdateStorageDealStatus(t *testing.T) { dealCases[i].CreationTime = res.CreationTime } - err := r.UpdateDealStatus(ctx, dealCases[0].ProposalCid, storagemarket.StorageDealActive, m_types.Proving) + err := r.UpdateDealStatus(ctx, dealCases[0].ProposalCid, storagemarket.StorageDealActive, markettypes.Proving) assert.NoError(t, err) res, err := r.GetDeal(ctx, dealCases[0].ProposalCid) assert.NoError(t, err) assert.Equal(t, storagemarket.StorageDealActive, res.State) - assert.Equal(t, m_types.Proving, res.PieceStatus) + assert.Equal(t, markettypes.Proving, res.PieceStatus) } func TestGroupStorageDealNumberByStatus(t *testing.T) { @@ -403,7 +403,7 @@ func TestGroupStorageDealNumberByStatus(t *testing.T) { repo := setup(t) r := repo.StorageDealRepo() - deals := make([]m_types.MinerDeal, 100) + deals := make([]markettypes.MinerDeal, 100) testutil.Provide(t, &deals) var addrs []address.Address @@ -438,7 +438,7 @@ func TestGroupStorageDealNumberByStatus(t *testing.T) { repo := setup(t) r := repo.StorageDealRepo() - deals := make([]m_types.MinerDeal, 10) + deals := make([]markettypes.MinerDeal, 10) testutil.Provide(t, &deals) result := map[storagemarket.StorageDealStatus]int64{} diff --git a/models/mysql/storage_deal.go b/models/mysql/storage_deal.go index 9b6558d4..2df19f7d 100644 --- a/models/mysql/storage_deal.go +++ b/models/mysql/storage_deal.go @@ -14,10 +14,10 @@ import ( "github.com/filecoin-project/go-fil-markets/piecestore" "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/builtin/v9/market" acrypto "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/venus-market/v2/models/repo" "github.com/filecoin-project/venus-messager/models/mtypes" + vTypes "github.com/filecoin-project/venus/venus-shared/types" types "github.com/filecoin-project/venus/venus-shared/types/market" "github.com/ipfs/go-cid" typegen "github.com/whyrusleeping/cbor-gen" @@ -207,19 +207,19 @@ func fromStorageDeal(src *types.MinerDeal) *storageDeal { } func toStorageDeal(src *storageDeal) (*types.MinerDeal, error) { - var label market.DealLabel + var label vTypes.DealLabel var err error if utf8.ValidString(src.Label) { - label, err = market.NewLabelFromString(src.Label) + label, err = vTypes.NewLabelFromString(src.Label) } else { - label, err = market.NewLabelFromBytes([]byte(src.Label)) + label, err = vTypes.NewLabelFromBytes([]byte(src.Label)) } if err != nil { return nil, err } md := &types.MinerDeal{ - ClientDealProposal: market.ClientDealProposal{ - Proposal: market.DealProposal{ + ClientDealProposal: vTypes.ClientDealProposal{ + Proposal: vTypes.DealProposal{ PieceCID: src.PieceCID.cid(), PieceSize: abi.PaddedPieceSize(src.PieceSize), VerifiedDeal: src.VerifiedDeal, diff --git a/models/mysql/storage_deal_test.go b/models/mysql/storage_deal_test.go index 71bd652f..b0ec1f97 100644 --- a/models/mysql/storage_deal_test.go +++ b/models/mysql/storage_deal_test.go @@ -10,8 +10,8 @@ import ( "github.com/filecoin-project/go-fil-markets/piecestore" "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/builtin/v9/market" "github.com/filecoin-project/venus-market/v2/models/repo" + vTypes "github.com/filecoin-project/venus/venus-shared/types" types "github.com/filecoin-project/venus/venus-shared/types/market" "github.com/ipfs/go-cid" "gorm.io/gorm/clause" @@ -430,8 +430,8 @@ func prepareStorageDealRepoTest(t *testing.T) (repo.Repo, sqlmock.Sqlmock, []*st ProposalCid: cid1, Miner: peer1, Client: peer1, - ClientDealProposal: market.ClientDealProposal{ - Proposal: market.DealProposal{ + ClientDealProposal: vTypes.ClientDealProposal{ + Proposal: vTypes.DealProposal{ Provider: getTestAddress(), PieceCID: cid1, }, @@ -449,8 +449,8 @@ func prepareStorageDealRepoTest(t *testing.T) (repo.Repo, sqlmock.Sqlmock, []*st ProposalCid: cid2, Miner: peer2, Client: peer2, - ClientDealProposal: market.ClientDealProposal{ - Proposal: market.DealProposal{ + ClientDealProposal: vTypes.ClientDealProposal{ + Proposal: vTypes.DealProposal{ Provider: getTestAddress(), PieceCID: cid2, }, diff --git a/models/paych_test.go b/models/paych_test.go index bd110cf1..0ccd5826 100644 --- a/models/paych_test.go +++ b/models/paych_test.go @@ -9,7 +9,7 @@ import ( "github.com/filecoin-project/venus-market/v2/models/repo" "github.com/filecoin-project/go-state-types/big" - paychTypes "github.com/filecoin-project/go-state-types/builtin/v8/paych" + vTypes "github.com/filecoin-project/venus/venus-shared/types" types "github.com/filecoin-project/venus/venus-shared/types/market" "github.com/google/uuid" "github.com/stretchr/testify/assert" @@ -43,11 +43,11 @@ func testChannelInfo(t *testing.T, channelRepo repo.PaychChannelInfoRepo, msgRep msgCid := randCid(t) vouchers := []*types.VoucherInfo{ { - Voucher: &paychTypes.SignedVoucher{ + Voucher: &vTypes.SignedVoucher{ ChannelAddr: addr, Nonce: 10, Amount: big.NewInt(100), - Extra: &paychTypes.ModVerifyParams{ + Extra: &vTypes.ModVerifyParams{ Actor: addr, Method: 1, Data: nil, diff --git a/models/storage_deal_test.go b/models/storage_deal_test.go index b96e6171..68dc0012 100644 --- a/models/storage_deal_test.go +++ b/models/storage_deal_test.go @@ -8,6 +8,7 @@ import ( "github.com/filecoin-project/go-address" + vTypes "github.com/filecoin-project/venus/venus-shared/types" types "github.com/filecoin-project/venus/venus-shared/types/market" "github.com/stretchr/testify/require" @@ -16,7 +17,6 @@ import ( datatransfer "github.com/filecoin-project/go-data-transfer" "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/builtin/v9/market" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/venus-market/v2/models/badger" "github.com/filecoin-project/venus-market/v2/models/repo" @@ -47,12 +47,12 @@ func getTestMinerDeal(t *testing.T) *types.MinerDeal { pid, err := peer.Decode("12D3KooWG8tR9PHjjXcMknbNPVWT75BuXXA2RaYx3fMwwg2oPZXd") assert.Nil(t, err) - label, err := market.NewLabelFromString("label") + label, err := vTypes.NewLabelFromString("label") assert.Nil(t, err) return &types.MinerDeal{ - ClientDealProposal: market.ClientDealProposal{ - Proposal: market.DealProposal{ + ClientDealProposal: vTypes.ClientDealProposal{ + Proposal: vTypes.DealProposal{ PieceCID: c, PieceSize: 1024, VerifiedDeal: false, diff --git a/paychmgr/api.go b/paychmgr/api.go index b3cc9b58..4d0bdfdc 100644 --- a/paychmgr/api.go +++ b/paychmgr/api.go @@ -8,7 +8,6 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/big" - "github.com/filecoin-project/go-state-types/builtin/v8/paych" "github.com/filecoin-project/venus/venus-shared/types" ) @@ -66,10 +65,10 @@ func (a *PaychAPI) PaychNewPayment(ctx context.Context, from, to address.Address return nil, err } - svs := make([]*paych.SignedVoucher, len(vouchers)) + svs := make([]*types.SignedVoucher, len(vouchers)) for i, v := range vouchers { - sv, err := a.paychMgr.CreateVoucher(ctx, ch.Channel, paych.SignedVoucher{ + sv, err := a.paychMgr.CreateVoucher(ctx, ch.Channel, types.SignedVoucher{ Amount: v.Amount, Lane: lane, @@ -118,15 +117,15 @@ func (a *PaychAPI) PaychCollect(ctx context.Context, addr address.Address) (cid. return a.paychMgr.Collect(ctx, addr) } -func (a *PaychAPI) PaychVoucherCheckValid(ctx context.Context, ch address.Address, sv *paych.SignedVoucher) error { +func (a *PaychAPI) PaychVoucherCheckValid(ctx context.Context, ch address.Address, sv *types.SignedVoucher) error { return a.paychMgr.CheckVoucherValid(ctx, ch, sv) } -func (a *PaychAPI) PaychVoucherCheckSpendable(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (bool, error) { +func (a *PaychAPI) PaychVoucherCheckSpendable(ctx context.Context, ch address.Address, sv *types.SignedVoucher, secret []byte, proof []byte) (bool, error) { return a.paychMgr.CheckVoucherSpendable(ctx, ch, sv, secret, proof) } -func (a *PaychAPI) PaychVoucherAdd(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, proof []byte, minDelta big.Int) (big.Int, error) { +func (a *PaychAPI) PaychVoucherAdd(ctx context.Context, ch address.Address, sv *types.SignedVoucher, proof []byte, minDelta big.Int) (big.Int, error) { return a.paychMgr.AddVoucherInbound(ctx, ch, sv, proof, minDelta) } @@ -138,16 +137,16 @@ func (a *PaychAPI) PaychVoucherAdd(ctx context.Context, ch address.Address, sv * // If there are insufficient funds in the channel to create the voucher, // returns a nil voucher and the shortfall. func (a *PaychAPI) PaychVoucherCreate(ctx context.Context, pch address.Address, amt big.Int, lane uint64) (*VoucherCreateResult, error) { - return a.paychMgr.CreateVoucher(ctx, pch, paych.SignedVoucher{Amount: amt, Lane: lane}) + return a.paychMgr.CreateVoucher(ctx, pch, types.SignedVoucher{Amount: amt, Lane: lane}) } -func (a *PaychAPI) PaychVoucherList(ctx context.Context, pch address.Address) ([]*paych.SignedVoucher, error) { +func (a *PaychAPI) PaychVoucherList(ctx context.Context, pch address.Address) ([]*types.SignedVoucher, error) { vi, err := a.paychMgr.ListVouchers(ctx, pch) if err != nil { return nil, err } - out := make([]*paych.SignedVoucher, len(vi)) + out := make([]*types.SignedVoucher, len(vi)) for k, v := range vi { out[k] = v.Voucher } @@ -155,6 +154,6 @@ func (a *PaychAPI) PaychVoucherList(ctx context.Context, pch address.Address) ([ return out, nil } -func (a *PaychAPI) PaychVoucherSubmit(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error) { +func (a *PaychAPI) PaychVoucherSubmit(ctx context.Context, ch address.Address, sv *types.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error) { return a.paychMgr.SubmitVoucher(ctx, ch, sv, secret, proof) } diff --git a/paychmgr/manager.go b/paychmgr/manager.go index b4eb582d..62984e95 100644 --- a/paychmgr/manager.go +++ b/paychmgr/manager.go @@ -8,7 +8,6 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/big" - "github.com/filecoin-project/go-state-types/builtin/v8/paych" "github.com/filecoin-project/venus-market/v2/api/clients" "github.com/filecoin-project/venus-market/v2/models/repo" v1api "github.com/filecoin-project/venus/venus-shared/api/chain/v1" @@ -49,7 +48,7 @@ type ChannelAvailableFunds struct { type VoucherCreateResult struct { // Voucher that was created, or nil if there was an error or if there // were insufficient funds in the channel - Voucher *paych.SignedVoucher + Voucher *types2.SignedVoucher // Shortfall is the additional amount that would be needed in the channel // in order to be able to create the voucher Shortfall big.Int @@ -226,7 +225,7 @@ func (pm *Manager) GetChannelInfo(ctx context.Context, addr address.Address) (*t return ca.getChannelInfo(ctx, addr) } -func (pm *Manager) CreateVoucher(ctx context.Context, ch address.Address, voucher paych.SignedVoucher) (*VoucherCreateResult, error) { +func (pm *Manager) CreateVoucher(ctx context.Context, ch address.Address, voucher types2.SignedVoucher) (*VoucherCreateResult, error) { ca, err := pm.accessorByAddress(ctx, ch) if err != nil { return nil, err @@ -237,7 +236,7 @@ func (pm *Manager) CreateVoucher(ctx context.Context, ch address.Address, vouche // CheckVoucherValid checks if the given voucher is valid (is or could become spendable at some point). // If the channel is not in the store, fetches the channel from state (and checks that // the channel To address is owned by the wallet). -func (pm *Manager) CheckVoucherValid(ctx context.Context, ch address.Address, sv *paych.SignedVoucher) error { +func (pm *Manager) CheckVoucherValid(ctx context.Context, ch address.Address, sv *types2.SignedVoucher) error { // Get an accessor for the channel, creating it from state if necessary ca, err := pm.inboundChannelAccessor(ctx, ch) if err != nil { @@ -249,7 +248,7 @@ func (pm *Manager) CheckVoucherValid(ctx context.Context, ch address.Address, sv } // CheckVoucherSpendable checks if the given voucher is currently spendable -func (pm *Manager) CheckVoucherSpendable(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (bool, error) { +func (pm *Manager) CheckVoucherSpendable(ctx context.Context, ch address.Address, sv *types2.SignedVoucher, secret []byte, proof []byte) (bool, error) { if len(proof) > 0 { return false, errProofNotSupported } @@ -263,7 +262,7 @@ func (pm *Manager) CheckVoucherSpendable(ctx context.Context, ch address.Address // AddVoucherOutbound adds a voucher for an outbound channel. // Returns an error if the channel is not already in the store. -func (pm *Manager) AddVoucherOutbound(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, proof []byte, minDelta big.Int) (big.Int, error) { +func (pm *Manager) AddVoucherOutbound(ctx context.Context, ch address.Address, sv *types2.SignedVoucher, proof []byte, minDelta big.Int) (big.Int, error) { if len(proof) > 0 { return big.NewInt(0), errProofNotSupported } @@ -277,7 +276,7 @@ func (pm *Manager) AddVoucherOutbound(ctx context.Context, ch address.Address, s // AddVoucherInbound adds a voucher for an inbound channel. // If the channel is not in the store, fetches the channel from state (and checks that // the channel To address is owned by the wallet). -func (pm *Manager) AddVoucherInbound(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, proof []byte, minDelta big.Int) (big.Int, error) { +func (pm *Manager) AddVoucherInbound(ctx context.Context, ch address.Address, sv *types2.SignedVoucher, proof []byte, minDelta big.Int) (big.Int, error) { if len(proof) > 0 { return big.NewInt(0), errProofNotSupported } @@ -368,7 +367,7 @@ func (pm *Manager) trackChannel(ctx context.Context, ci *types.ChannelInfo) (*ty } // TODO: secret vs proof doesn't make sense, there is only one, not two -func (pm *Manager) SubmitVoucher(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error) { +func (pm *Manager) SubmitVoucher(ctx context.Context, ch address.Address, sv *types2.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error) { if len(proof) > 0 { return cid.Undef, errProofNotSupported } diff --git a/paychmgr/paych.go b/paychmgr/paych.go index 43803a40..819c4b3c 100644 --- a/paychmgr/paych.go +++ b/paychmgr/paych.go @@ -12,7 +12,6 @@ import ( "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/actors" - "github.com/filecoin-project/go-state-types/builtin/v8/paych" "github.com/filecoin-project/venus/pkg/crypto" lpaych "github.com/filecoin-project/venus/venus-shared/actors/builtin/paych" types2 "github.com/filecoin-project/venus/venus-shared/types" @@ -118,7 +117,7 @@ func (ca *channelAccessor) outboundActiveByFromTo(ctx context.Context, from, to // nonce, signing the voucher and storing it in the local datastore. // If there are not enough funds in the channel to create the voucher, returns // the shortfall in funds. -func (ca *channelAccessor) createVoucher(ctx context.Context, ch address.Address, voucher paych.SignedVoucher) (*VoucherCreateResult, error) { +func (ca *channelAccessor) createVoucher(ctx context.Context, ch address.Address, voucher types2.SignedVoucher) (*VoucherCreateResult, error) { ca.lk.Lock() defer ca.lk.Unlock() @@ -177,14 +176,14 @@ func (ca *channelAccessor) nextNonceForLane(ci *types.ChannelInfo, lane uint64) return maxnonce + 1 } -func (ca *channelAccessor) checkVoucherValid(ctx context.Context, ch address.Address, sv *paych.SignedVoucher) (map[uint64]lpaych.LaneState, error) { +func (ca *channelAccessor) checkVoucherValid(ctx context.Context, ch address.Address, sv *types2.SignedVoucher) (map[uint64]lpaych.LaneState, error) { ca.lk.Lock() defer ca.lk.Unlock() return ca.checkVoucherValidUnlocked(ctx, ch, sv) } -func (ca *channelAccessor) checkVoucherValidUnlocked(ctx context.Context, ch address.Address, sv *paych.SignedVoucher) (map[uint64]lpaych.LaneState, error) { +func (ca *channelAccessor) checkVoucherValidUnlocked(ctx context.Context, ch address.Address, sv *types2.SignedVoucher) (map[uint64]lpaych.LaneState, error) { if sv.ChannelAddr != ch { return nil, fmt.Errorf("voucher ChannelAddr doesn't match channel address, got %s, expected %s", sv.ChannelAddr, ch) } @@ -293,7 +292,7 @@ func (ca *channelAccessor) checkVoucherValidUnlocked(ctx context.Context, ch add return laneStates, nil } -func (ca *channelAccessor) checkVoucherSpendable(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte) (bool, error) { +func (ca *channelAccessor) checkVoucherSpendable(ctx context.Context, ch address.Address, sv *types2.SignedVoucher, secret []byte) (bool, error) { ca.lk.Lock() defer ca.lk.Unlock() @@ -347,14 +346,14 @@ func (ca *channelAccessor) getPaychRecipient(ctx context.Context, ch address.Add return state.To() } -func (ca *channelAccessor) addVoucher(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, minDelta big.Int) (big.Int, error) { +func (ca *channelAccessor) addVoucher(ctx context.Context, ch address.Address, sv *types2.SignedVoucher, minDelta big.Int) (big.Int, error) { ca.lk.Lock() defer ca.lk.Unlock() return ca.addVoucherUnlocked(ctx, ch, sv, minDelta) } -func (ca *channelAccessor) addVoucherUnlocked(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, minDelta big.Int) (big.Int, error) { +func (ca *channelAccessor) addVoucherUnlocked(ctx context.Context, ch address.Address, sv *types2.SignedVoucher, minDelta big.Int) (big.Int, error) { ci, err := ca.channelInfoRepo.GetChannelByAddress(ctx, ch) if err != nil { return big.Int{}, err @@ -407,7 +406,7 @@ func (ca *channelAccessor) addVoucherUnlocked(ctx context.Context, ch address.Ad return delta, ca.channelInfoRepo.SaveChannel(ctx, ci) } -func (ca *channelAccessor) submitVoucher(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte) (cid.Cid, error) { +func (ca *channelAccessor) submitVoucher(ctx context.Context, ch address.Address, sv *types2.SignedVoucher, secret []byte) (cid.Cid, error) { ca.lk.Lock() defer ca.lk.Unlock() @@ -561,7 +560,7 @@ func (ca *channelAccessor) laneState(ctx context.Context, state lpaych.State, ch } // Get the total redeemed amount across all lanes, after applying the voucher -func (ca *channelAccessor) totalRedeemedWithVoucher(laneStates map[uint64]lpaych.LaneState, sv *paych.SignedVoucher) (big.Int, error) { +func (ca *channelAccessor) totalRedeemedWithVoucher(laneStates map[uint64]lpaych.LaneState, sv *types2.SignedVoucher) (big.Int, error) { // TODO: merges if len(sv.Merges) != 0 { return big.Int{}, fmt.Errorf("dont currently support paych lane merges") diff --git a/paychmgr/paych_test.go b/paychmgr/paych_test.go index 74081317..4142bb70 100644 --- a/paychmgr/paych_test.go +++ b/paychmgr/paych_test.go @@ -17,10 +17,8 @@ import ( "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/specs-actors/v7/actors/builtin" - paych7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/paych" tutils "github.com/filecoin-project/specs-actors/v7/support/testing" - "github.com/filecoin-project/go-state-types/builtin/v8/paych" _ "github.com/filecoin-project/venus/pkg/crypto/bls" _ "github.com/filecoin-project/venus/pkg/crypto/secp" lpaych "github.com/filecoin-project/venus/venus-shared/actors/builtin/paych" @@ -240,7 +238,7 @@ func TestCreateVoucher(t *testing.T) { // Create a voucher in lane 1 voucherLane1Amt := big.NewInt(5) - voucher := paych.SignedVoucher{ + voucher := types2.SignedVoucher{ Lane: 1, Amount: voucherLane1Amt, } @@ -255,7 +253,7 @@ func TestCreateVoucher(t *testing.T) { // Create a voucher in lane 1 again, with a higher amount voucherLane1Amt = big.NewInt(8) - voucher = paych.SignedVoucher{ + voucher = types2.SignedVoucher{ Lane: 1, Amount: voucherLane1Amt, } @@ -270,7 +268,7 @@ func TestCreateVoucher(t *testing.T) { // Create a voucher in lane 2 that covers all the remaining funds // in the channel voucherLane2Amt := big.Sub(s.amt, voucherLane1Amt) - voucher = paych.SignedVoucher{ + voucher = types2.SignedVoucher{ Lane: 2, Amount: voucherLane2Amt, } @@ -284,7 +282,7 @@ func TestCreateVoucher(t *testing.T) { // Create a voucher in lane 2 that exceeds the remaining funds in the // channel voucherLane2Amt = big.Add(voucherLane2Amt, big.NewInt(1)) - voucher = paych.SignedVoucher{ + voucher = types2.SignedVoucher{ Lane: 2, Amount: voucherLane2Amt, } @@ -621,7 +619,7 @@ func TestCheckSpendable(t *testing.T) { // Check that the secret was passed through correctly lastCall := s.mock.getLastCall() - var p paych7.UpdateChannelStateParams + var p types2.UpdateChannelStateParams err = p.UnmarshalCBOR(bytes.NewReader(lastCall.Params)) require.NoError(t, err) require.Equal(t, secret, p.Secret) @@ -675,7 +673,7 @@ func TestSubmitVoucher(t *testing.T) { // Check that the secret was passed through correctly msg := s.mock.pushedMessages(submitCid) - var p paych7.UpdateChannelStateParams + var p types2.UpdateChannelStateParams err = p.UnmarshalCBOR(bytes.NewReader(msg.Message.Params)) require.NoError(t, err) @@ -687,7 +685,7 @@ func TestSubmitVoucher(t *testing.T) { require.NoError(t, err) msg = s.mock.pushedMessages(submitCid) - var p3 paych7.UpdateChannelStateParams + var p3 types2.UpdateChannelStateParams err = p3.UnmarshalCBOR(bytes.NewReader(msg.Message.Params)) require.NoError(t, err) @@ -773,8 +771,8 @@ func testGenerateKeyPair(t *testing.T) ([]byte, []byte) { return priv, pub } -func createTestVoucher(t *testing.T, ch address.Address, voucherLane uint64, nonce uint64, voucherAmount big.Int, key []byte) *paych.SignedVoucher { - sv := &paych.SignedVoucher{ +func createTestVoucher(t *testing.T, ch address.Address, voucherLane uint64, nonce uint64, voucherAmount big.Int, key []byte) *types2.SignedVoucher { + sv := &types2.SignedVoucher{ ChannelAddr: ch, Lane: voucherLane, Nonce: nonce, @@ -793,13 +791,13 @@ type mockBestSpendableAPI struct { mgr *Manager } -func (m *mockBestSpendableAPI) PaychVoucherList(ctx context.Context, ch address.Address) ([]*paych.SignedVoucher, error) { +func (m *mockBestSpendableAPI) PaychVoucherList(ctx context.Context, ch address.Address) ([]*types2.SignedVoucher, error) { vi, err := m.mgr.ListVouchers(ctx, ch) if err != nil { return nil, err } - out := make([]*paych.SignedVoucher, len(vi)) + out := make([]*types2.SignedVoucher, len(vi)) for k, v := range vi { out[k] = v.Voucher } @@ -807,7 +805,7 @@ func (m *mockBestSpendableAPI) PaychVoucherList(ctx context.Context, ch address. return out, nil } -func (m *mockBestSpendableAPI) PaychVoucherCheckSpendable(ctx context.Context, ch address.Address, voucher *paych.SignedVoucher, secret []byte, proof []byte) (bool, error) { +func (m *mockBestSpendableAPI) PaychVoucherCheckSpendable(ctx context.Context, ch address.Address, voucher *types2.SignedVoucher, secret []byte, proof []byte) (bool, error) { return m.mgr.CheckVoucherSpendable(ctx, ch, voucher, secret, proof) } diff --git a/paychmgr/paychvoucherfunds_test.go b/paychmgr/paychvoucherfunds_test.go index 39bd2723..458cff8d 100644 --- a/paychmgr/paychvoucherfunds_test.go +++ b/paychmgr/paychvoucherfunds_test.go @@ -14,7 +14,6 @@ import ( builtin7 "github.com/filecoin-project/specs-actors/v7/actors/builtin" tutils2 "github.com/filecoin-project/specs-actors/v7/support/testing" - "github.com/filecoin-project/go-state-types/builtin/v8/paych" lpaych "github.com/filecoin-project/venus/venus-shared/actors/builtin/paych" paychmock "github.com/filecoin-project/venus/venus-shared/actors/builtin/paych/mock" ) @@ -66,7 +65,7 @@ func TestPaychAddVoucherAfterAddFunds(t *testing.T) { require.NoError(t, err) // Create a voucher with a value equal to the channel balance - voucher := paych.SignedVoucher{Amount: createAmt, Lane: 1} + voucher := types.SignedVoucher{Amount: createAmt, Lane: 1} res, err := mgr.CreateVoucher(ctx, ch, voucher) require.NoError(t, err) require.NotNil(t, res.Voucher) @@ -74,7 +73,7 @@ func TestPaychAddVoucherAfterAddFunds(t *testing.T) { // Create a voucher in a different lane with an amount that exceeds the // channel balance excessAmt := big.NewInt(5) - voucher = paych.SignedVoucher{Amount: excessAmt, Lane: 2} + voucher = types.SignedVoucher{Amount: excessAmt, Lane: 2} res, err = mgr.CreateVoucher(ctx, ch, voucher) require.NoError(t, err) require.Nil(t, res.Voucher) diff --git a/paychmgr/settler/settler.go b/paychmgr/settler/settler.go index 1c41ac57..bf0397f7 100644 --- a/paychmgr/settler/settler.go +++ b/paychmgr/settler/settler.go @@ -11,7 +11,6 @@ import ( "github.com/filecoin-project/venus-market/v2/paychmgr" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/builtin/v8/paych" "github.com/filecoin-project/venus/venus-shared/types" "github.com/ipfs/go-cid" logging "github.com/ipfs/go-log/v2" @@ -62,7 +61,7 @@ func (pcs *paymentChannelSettler) messageHandler(msg *types.Message, rec *types. if err != nil { return true, err } - go func(voucher *paych.SignedVoucher, submitMessageCID cid.Cid) { + go func(voucher *types.SignedVoucher, submitMessageCID cid.Cid) { defer wg.Done() msgLookup, err := pcs.api.WaitMsg(pcs.ctx, submitMessageCID, 1, constants.LookbackNoLimit, true) if err != nil { diff --git a/paychmgr/settler/stl.go b/paychmgr/settler/stl.go index 3380ae2e..408ea476 100644 --- a/paychmgr/settler/stl.go +++ b/paychmgr/settler/stl.go @@ -5,7 +5,6 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/builtin/v8/paych" "github.com/filecoin-project/venus-market/v2/paychmgr" "github.com/filecoin-project/venus/venus-shared/types" "github.com/ipfs/go-cid" @@ -14,9 +13,9 @@ import ( type Settler interface { PaychList(context.Context) ([]address.Address, error) PaychStatus(ctx context.Context, pch address.Address) (*types.Status, error) - PaychVoucherCheckSpendable(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (bool, error) - PaychVoucherList(context.Context, address.Address) ([]*paych.SignedVoucher, error) - PaychVoucherSubmit(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error) + PaychVoucherCheckSpendable(ctx context.Context, ch address.Address, sv *types.SignedVoucher, secret []byte, proof []byte) (bool, error) + PaychVoucherList(context.Context, address.Address) ([]*types.SignedVoucher, error) + PaychVoucherSubmit(ctx context.Context, ch address.Address, sv *types.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error) WaitMsg(ctx context.Context, cid cid.Cid, confidence uint64, limit abi.ChainEpoch, allowReplaced bool) (*types.MsgLookup, error) } @@ -44,25 +43,22 @@ func (o *settler) PaychStatus(ctx context.Context, pch address.Address) (*types. Direction: types.PCHDir(ci.Direction), }, nil } - -func (o *settler) PaychVoucherCheckSpendable(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (bool, error) { +func (o *settler) PaychVoucherCheckSpendable(ctx context.Context, ch address.Address, sv *types.SignedVoucher, secret []byte, proof []byte) (bool, error) { return o.mgr.CheckVoucherSpendable(ctx, ch, sv, secret, proof) } - -func (o *settler) PaychVoucherList(ctx context.Context, pch address.Address) ([]*paych.SignedVoucher, error) { +func (o *settler) PaychVoucherList(ctx context.Context, pch address.Address) ([]*types.SignedVoucher, error) { vi, err := o.mgr.ListVouchers(ctx, pch) if err != nil { return nil, err } - out := make([]*paych.SignedVoucher, len(vi)) + out := make([]*types.SignedVoucher, len(vi)) for k, v := range vi { out[k] = v.Voucher } return out, nil } - -func (o *settler) PaychVoucherSubmit(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error) { +func (o *settler) PaychVoucherSubmit(ctx context.Context, ch address.Address, sv *types.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error) { return o.mgr.SubmitVoucher(ctx, ch, sv, secret, proof) } diff --git a/paychmgr/util.go b/paychmgr/util.go index 1f03d2c8..a96574c9 100644 --- a/paychmgr/util.go +++ b/paychmgr/util.go @@ -4,23 +4,22 @@ import ( "context" "github.com/filecoin-project/go-address" - - "github.com/filecoin-project/go-state-types/builtin/v8/paych" + "github.com/filecoin-project/venus/venus-shared/types" ) type BestSpendableAPI interface { - PaychVoucherList(context.Context, address.Address) ([]*paych.SignedVoucher, error) - PaychVoucherCheckSpendable(context.Context, address.Address, *paych.SignedVoucher, []byte, []byte) (bool, error) + PaychVoucherList(context.Context, address.Address) ([]*types.SignedVoucher, error) + PaychVoucherCheckSpendable(context.Context, address.Address, *types.SignedVoucher, []byte, []byte) (bool, error) } // BestSpendableByLane return spendable voucher in channel address -func BestSpendableByLane(ctx context.Context, api BestSpendableAPI, ch address.Address) (map[uint64]*paych.SignedVoucher, error) { +func BestSpendableByLane(ctx context.Context, api BestSpendableAPI, ch address.Address) (map[uint64]*types.SignedVoucher, error) { vouchers, err := api.PaychVoucherList(ctx, ch) if err != nil { return nil, err } - bestByLane := make(map[uint64]*paych.SignedVoucher) + bestByLane := make(map[uint64]*types.SignedVoucher) for _, voucher := range vouchers { spendable, err := api.PaychVoucherCheckSpendable(ctx, ch, voucher, nil, nil) if err != nil { diff --git a/retrievalprovider/client.go b/retrievalprovider/client.go index 1414ce33..30aba053 100644 --- a/retrievalprovider/client.go +++ b/retrievalprovider/client.go @@ -11,7 +11,6 @@ import ( "github.com/filecoin-project/go-fil-markets/shared" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/builtin/v8/paych" v1api "github.com/filecoin-project/venus/venus-shared/api/chain/v1" "github.com/filecoin-project/venus/venus-shared/types" @@ -53,7 +52,7 @@ func (rcn *retrievalClientNode) AllocateLane(ctx context.Context, paymentChannel // CreatePaymentVoucher creates a new payment voucher in the given lane for a // given payment channel so that all the payment vouchers in the lane add up // to the given amount (so the payment voucher will be for the difference) -func (rcn *retrievalClientNode) CreatePaymentVoucher(ctx context.Context, paymentChannel address.Address, amount abi.TokenAmount, lane uint64, tok shared.TipSetToken) (*paych.SignedVoucher, error) { +func (rcn *retrievalClientNode) CreatePaymentVoucher(ctx context.Context, paymentChannel address.Address, amount abi.TokenAmount, lane uint64, tok shared.TipSetToken) (*types.SignedVoucher, error) { // TODO: respect the provided TipSetToken (a serialized TipSetKey) when // querying the chain voucher, err := rcn.payAPI.PaychVoucherCreate(ctx, paymentChannel, amount, lane) diff --git a/retrievalprovider/piecestore_test.go b/retrievalprovider/piecestore_test.go index 6cc753d8..2e81c1bf 100644 --- a/retrievalprovider/piecestore_test.go +++ b/retrievalprovider/piecestore_test.go @@ -18,13 +18,13 @@ import ( typegen "github.com/whyrusleeping/cbor-gen" builtinMarket "github.com/filecoin-project/venus/venus-shared/actors/builtin/market" + "github.com/filecoin-project/venus/venus-shared/types" "github.com/filecoin-project/venus/venus-shared/types/market" "github.com/ipfs/go-cid" "github.com/filecoin-project/venus-market/v2/dagstore" - market2 "github.com/filecoin-project/go-state-types/builtin/v9/market" "github.com/filecoin-project/venus-market/v2/models" ) @@ -108,14 +108,14 @@ func getTestMinerDeal(t *testing.T, datacid, pieceCid cid.Cid) *market.MinerDeal assert.Nil(t, err) return &market.MinerDeal{ - ClientDealProposal: market2.ClientDealProposal{ + ClientDealProposal: types.ClientDealProposal{ Proposal: builtinMarket.DealProposal{ PieceCID: pieceCid, PieceSize: 1024, VerifiedDeal: false, Client: randAddress(t), Provider: randAddress(t), - Label: market2.DealLabel{}, + Label: types.DealLabel{}, StartEpoch: 10, EndEpoch: 10, StoragePricePerEpoch: abi.NewTokenAmount(10), diff --git a/storageprovider/client.go b/storageprovider/client.go index 1a64ca6d..55ef3b9c 100644 --- a/storageprovider/client.go +++ b/storageprovider/client.go @@ -28,7 +28,6 @@ import ( "github.com/ipfs-force-community/metrics" "github.com/filecoin-project/go-state-types/builtin" - "github.com/filecoin-project/go-state-types/builtin/v9/market" "github.com/filecoin-project/venus/pkg/constants" vcrypto "github.com/filecoin-project/venus/pkg/crypto" "github.com/filecoin-project/venus/pkg/events" @@ -193,7 +192,7 @@ func (c *ClientNodeAdapter) ValidatePublishedDeal(ctx context.Context, deal stor return 0, fmt.Errorf("deal publish message called incorrect method (method=%s)", pubmsg.Method) } - var params market.PublishStorageDealsParams + var params types.PublishStorageDealsParams if err := params.UnmarshalCBOR(bytes.NewReader(pubmsg.Params)); err != nil { return 0, err } @@ -278,12 +277,12 @@ func (c *ClientNodeAdapter) DealProviderCollateralBounds(ctx context.Context, si } // TODO: Remove dealID parameter, change publishCid to be cid.Cid (instead of pointer) -func (c *ClientNodeAdapter) OnDealSectorPreCommitted(ctx context.Context, provider address.Address, dealID abi.DealID, proposal market.DealProposal, publishCid *cid.Cid, cb storagemarket.DealSectorPreCommittedCallback) error { +func (c *ClientNodeAdapter) OnDealSectorPreCommitted(ctx context.Context, provider address.Address, dealID abi.DealID, proposal types.DealProposal, publishCid *cid.Cid, cb storagemarket.DealSectorPreCommittedCallback) error { return c.scMgr.OnDealSectorPreCommitted(ctx, provider, proposal, *publishCid, cb) } // TODO: Remove dealID parameter, change publishCid to be cid.Cid (instead of pointer) -func (c *ClientNodeAdapter) OnDealSectorCommitted(ctx context.Context, provider address.Address, dealID abi.DealID, sectorNumber abi.SectorNumber, proposal market.DealProposal, publishCid *cid.Cid, cb storagemarket.DealSectorCommittedCallback) error { +func (c *ClientNodeAdapter) OnDealSectorCommitted(ctx context.Context, provider address.Address, dealID abi.DealID, sectorNumber abi.SectorNumber, proposal types.DealProposal, publishCid *cid.Cid, cb storagemarket.DealSectorCommittedCallback) error { return c.scMgr.OnDealSectorCommitted(ctx, provider, sectorNumber, proposal, *publishCid, cb) } @@ -377,7 +376,7 @@ func (c *ClientNodeAdapter) OnDealExpiredOrSlashed(ctx context.Context, dealID a return nil } -func (c *ClientNodeAdapter) SignProposal(ctx context.Context, signer address.Address, proposal market.DealProposal) (*market.ClientDealProposal, error) { +func (c *ClientNodeAdapter) SignProposal(ctx context.Context, signer address.Address, proposal types.DealProposal) (*types.ClientDealProposal, error) { // TODO: output spec signed proposal buf, err := cborutil.Dump(&proposal) if err != nil { @@ -396,7 +395,7 @@ func (c *ClientNodeAdapter) SignProposal(ctx context.Context, signer address.Add return nil, err } - return &market.ClientDealProposal{ + return &types.ClientDealProposal{ Proposal: proposal, ClientSignature: *sig, }, nil diff --git a/storageprovider/currentdealinfo.go b/storageprovider/currentdealinfo.go index df3b78b6..cecda952 100644 --- a/storageprovider/currentdealinfo.go +++ b/storageprovider/currentdealinfo.go @@ -10,7 +10,6 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/builtin/v9/market" "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/venus/pkg/constants" marketactor "github.com/filecoin-project/venus/venus-shared/actors/builtin/market" @@ -40,7 +39,7 @@ type CurrentDealInfoManager struct { // GetCurrentDealInfo gets the current deal state and deal ID. // Note that the deal ID is assigned when the deal is published, so it may // have changed if there was a reorg after the deal was published. -func (mgr *CurrentDealInfoManager) GetCurrentDealInfo(ctx context.Context, tok types.TipSetKey, proposal *market.DealProposal, publishCid cid.Cid) (CurrentDealInfo, error) { +func (mgr *CurrentDealInfoManager) GetCurrentDealInfo(ctx context.Context, tok types.TipSetKey, proposal *types.DealProposal, publishCid cid.Cid) (CurrentDealInfo, error) { // Lookup the deal ID by comparing the deal proposal to the proposals in // the publish deals message, and indexing into the message return value dealID, pubMsgTok, err := mgr.dealIDFromPublishDealsMsg(ctx, tok, proposal, publishCid) @@ -67,7 +66,7 @@ func (mgr *CurrentDealInfoManager) GetCurrentDealInfo(ctx context.Context, tok t // dealIDFromPublishDealsMsg looks up the publish deals message by cid, and finds the deal ID // by looking at the message return value -func (mgr *CurrentDealInfoManager) dealIDFromPublishDealsMsg(ctx context.Context, tok types.TipSetKey, proposal *market.DealProposal, publishCid cid.Cid) (abi.DealID, types.TipSetKey, error) { +func (mgr *CurrentDealInfoManager) dealIDFromPublishDealsMsg(ctx context.Context, tok types.TipSetKey, proposal *types.DealProposal, publishCid cid.Cid) (abi.DealID, types.TipSetKey, error) { dealID := abi.DealID(0) // Get the return value of the publish deals message @@ -124,7 +123,7 @@ func (mgr *CurrentDealInfoManager) dealIDFromPublishDealsMsg(ctx context.Context return dealID, types.TipSetKey{}, fmt.Errorf("getting publish deal message %s: %w", publishCid, err) } - var pubDealsParams market.PublishStorageDealsParams + var pubDealsParams types.PublishStorageDealsParams if err := pubDealsParams.UnmarshalCBOR(bytes.NewReader(pubmsg.Params)); err != nil { return dealID, types.TipSetKey{}, fmt.Errorf("unmarshalling publish deal message params for message %s: %w", publishCid, err) } @@ -171,7 +170,7 @@ func (mgr *CurrentDealInfoManager) dealIDFromPublishDealsMsg(ctx context.Context return dealIDs[outIdx], types.TipSetKey{}, nil } -func (mgr *CurrentDealInfoManager) CheckDealEquality(ctx context.Context, tok types.TipSetKey, p1, p2 market.DealProposal) (bool, error) { +func (mgr *CurrentDealInfoManager) CheckDealEquality(ctx context.Context, tok types.TipSetKey, p1, p2 types.DealProposal) (bool, error) { p1ClientID, err := mgr.CDAPI.StateLookupID(ctx, p1.Client, tok) if err != nil { return false, err diff --git a/storageprovider/deal_assign_util.go b/storageprovider/deal_assign_util.go index 725df933..771dcb9b 100644 --- a/storageprovider/deal_assign_util.go +++ b/storageprovider/deal_assign_util.go @@ -4,11 +4,10 @@ import ( "fmt" "math/bits" - "github.com/filecoin-project/go-state-types/builtin/v9/market" - "github.com/filecoin-project/go-commp-utils/zerocomm" "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/venus/venus-shared/types" mtypes "github.com/filecoin-project/venus/venus-shared/types/market" ) @@ -132,7 +131,7 @@ func pickAndAlign(deals []*mtypes.DealInfoIncludePath, ssize abi.SectorSize, spe // next piece cantainer is not enough, we should put a zeroed-piece if deal.PieceSize > nextPiece { res = append(res, &mtypes.DealInfoIncludePath{ - DealProposal: market.DealProposal{ + DealProposal: types.DealProposal{ PieceSize: nextPiece, PieceCID: zerocomm.ZeroPieceCommitment(nextPiece.Unpadded()), }, @@ -178,7 +177,7 @@ func pickAndAlign(deals []*mtypes.DealInfoIncludePath, ssize abi.SectorSize, spe for _, fillSize := range fillers { res = append(res, &mtypes.DealInfoIncludePath{ - DealProposal: market.DealProposal{ + DealProposal: types.DealProposal{ PieceSize: fillSize, PieceCID: zerocomm.ZeroPieceCommitment(fillSize.Unpadded()), }, diff --git a/storageprovider/deal_assign_util_test.go b/storageprovider/deal_assign_util_test.go index 4d8ac5e6..fa3bd2c7 100644 --- a/storageprovider/deal_assign_util_test.go +++ b/storageprovider/deal_assign_util_test.go @@ -3,9 +3,8 @@ package storageprovider import ( "testing" - "github.com/filecoin-project/go-state-types/builtin/v9/market" - "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/venus/venus-shared/types" mtypes "github.com/filecoin-project/venus/venus-shared/types/market" "github.com/stretchr/testify/require" ) @@ -18,7 +17,7 @@ const ( func generateTestingDeals(sizes []abi.PaddedPieceSize, lifetimes [][2]abi.ChainEpoch) []*mtypes.DealInfoIncludePath { deals := make([]*mtypes.DealInfoIncludePath, len(sizes)) for si, size := range sizes { - proposal := market.DealProposal{ + proposal := types.DealProposal{ PieceSize: size, } diff --git a/storageprovider/deal_handler.go b/storageprovider/deal_handler.go index a10175d0..54337688 100644 --- a/storageprovider/deal_handler.go +++ b/storageprovider/deal_handler.go @@ -157,7 +157,7 @@ func (storageDealPorcess *StorageDealProcessImpl) AcceptDeal(ctx context.Context // Check that the delta between the start and end epochs (the deal // duration) is within acceptable bounds - minDuration, maxDuration := market.DealDurationBounds(proposal.PieceSize) + minDuration, maxDuration := vTypes.DealDurationBounds(proposal.PieceSize) if proposal.Duration() < minDuration || proposal.Duration() > maxDuration { return storageDealPorcess.HandleReject(ctx, minerDeal, storagemarket.StorageDealRejecting, fmt.Errorf("deal duration out of bounds (min, max, provided): %d, %d, %d", minDuration, maxDuration, proposal.Duration())) } diff --git a/storageprovider/dealpublisher.go b/storageprovider/dealpublisher.go index ca536bec..7d41afed 100644 --- a/storageprovider/dealpublisher.go +++ b/storageprovider/dealpublisher.go @@ -11,7 +11,6 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/builtin" - "github.com/filecoin-project/go-state-types/builtin/v9/market" "github.com/filecoin-project/venus-market/v2/api/clients" "github.com/filecoin-project/venus-market/v2/config" types2 "github.com/filecoin-project/venus-market/v2/types" @@ -103,7 +102,7 @@ func (p *DealPublisher) ForcePublishPendingDeals() { } } -func (p *DealPublisher) Publish(ctx context.Context, deal market.ClientDealProposal) (cid.Cid, error) { +func (p *DealPublisher) Publish(ctx context.Context, deal types.ClientDealProposal) (cid.Cid, error) { pdeal := newPendingDeal(ctx, deal) p.lk.Lock() @@ -152,7 +151,7 @@ type singleDealPublisher struct { // A deal that is queued to be published type pendingDeal struct { ctx context.Context - deal market.ClientDealProposal + deal types.ClientDealProposal Result chan publishResult } @@ -162,7 +161,7 @@ type publishResult struct { err error } -func newPendingDeal(ctx context.Context, deal market.ClientDealProposal) *pendingDeal { +func newPendingDeal(ctx context.Context, deal types.ClientDealProposal) *pendingDeal { return &pendingDeal{ ctx: ctx, deal: deal, @@ -210,7 +209,7 @@ func (p *singleDealPublisher) pendingDeals() marketTypes.PendingDealInfo { } } - pending := make([]market.ClientDealProposal, len(deals)) + pending := make([]types.ClientDealProposal, len(deals)) for i, deal := range deals { pending[i] = deal.deal } @@ -357,7 +356,7 @@ func (p *singleDealPublisher) publishReady(ready []*pendingDeal) { // Validate each deal to make sure it can be published validated := make([]*pendingDeal, 0, len(ready)) - deals := make([]market.ClientDealProposal, 0, len(ready)) + deals := make([]types.ClientDealProposal, 0, len(ready)) for _, pd := range ready { // Validate the deal if err := p.validateDeal(pd.deal); err != nil { @@ -381,7 +380,7 @@ func (p *singleDealPublisher) publishReady(ready []*pendingDeal) { // validateDeal checks that the deal proposal start epoch hasn't already // elapsed -func (p *singleDealPublisher) validateDeal(deal market.ClientDealProposal) error { +func (p *singleDealPublisher) validateDeal(deal types.ClientDealProposal) error { head, err := p.api.ChainHead(p.ctx) if err != nil { return err @@ -395,7 +394,7 @@ func (p *singleDealPublisher) validateDeal(deal market.ClientDealProposal) error } // Sends the publish message -func (p *singleDealPublisher) publishDealProposals(deals []market.ClientDealProposal) (cid.Cid, error) { +func (p *singleDealPublisher) publishDealProposals(deals []types.ClientDealProposal) (cid.Cid, error) { if len(deals) == 0 { return cid.Undef, nil } @@ -418,7 +417,7 @@ func (p *singleDealPublisher) publishDealProposals(deals []market.ClientDealProp return cid.Undef, err } - params, err := actors.SerializeParams(&market.PublishStorageDealsParams{ + params, err := actors.SerializeParams(&types.PublishStorageDealsParams{ Deals: deals, }) if err != nil { @@ -443,7 +442,7 @@ func (p *singleDealPublisher) publishDealProposals(deals []market.ClientDealProp return msgId, nil } -func pieceCids(deals []market.ClientDealProposal) string { +func pieceCids(deals []types.ClientDealProposal) string { cids := make([]string, 0, len(deals)) for _, dl := range deals { cids = append(cids, dl.Proposal.PieceCID.String()) diff --git a/storageprovider/ondealsectorcommitted.go b/storageprovider/ondealsectorcommitted.go index dad76011..eac55284 100644 --- a/storageprovider/ondealsectorcommitted.go +++ b/storageprovider/ondealsectorcommitted.go @@ -13,7 +13,6 @@ import ( "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/builtin" - "github.com/filecoin-project/go-state-types/builtin/v9/miner" "github.com/filecoin-project/venus/pkg/constants" "github.com/filecoin-project/venus/pkg/events" "github.com/filecoin-project/venus/venus-shared/actors/builtin/market" @@ -275,12 +274,12 @@ func (mgr *SectorCommittedManager) OnDealSectorCommitted(ctx context.Context, pr } func dealSectorInReplicaUpdateSuccess(msg *types.Message, rec *types.MessageReceipt, res CurrentDealInfo) (*abi.SectorNumber, error) { - var params miner.ProveReplicaUpdatesParams + var params types.ProveReplicaUpdatesParams if err := params.UnmarshalCBOR(bytes.NewReader(msg.Params)); err != nil { return nil, fmt.Errorf("unmarshal prove replica update: %w", err) } - var seekUpdate miner.ReplicaUpdate + var seekUpdate types.ReplicaUpdate var found bool for _, update := range params.Updates { for _, did := range update.Deals { @@ -314,7 +313,7 @@ func dealSectorInReplicaUpdateSuccess(msg *types.Message, rec *types.MessageRece func dealSectorInPreCommitMsg(msg *types.Message, res CurrentDealInfo) (*abi.SectorNumber, error) { switch msg.Method { case builtin.MethodsMiner.PreCommitSector: - var params miner.SectorPreCommitInfo + var params types.SectorPreCommitInfo if err := params.UnmarshalCBOR(bytes.NewReader(msg.Params)); err != nil { return nil, fmt.Errorf("unmarshal pre commit: %w", err) } @@ -327,7 +326,7 @@ func dealSectorInPreCommitMsg(msg *types.Message, res CurrentDealInfo) (*abi.Sec } } case builtin.MethodsMiner.PreCommitSectorBatch: - var params miner.PreCommitSectorBatchParams + var params types.PreCommitSectorBatchParams if err := params.UnmarshalCBOR(bytes.NewReader(msg.Params)); err != nil { return nil, fmt.Errorf("unmarshal pre commit: %w", err) } @@ -352,7 +351,7 @@ func dealSectorInPreCommitMsg(msg *types.Message, res CurrentDealInfo) (*abi.Sec func sectorInCommitMsg(msg *types.Message, sectorNumber abi.SectorNumber) (bool, error) { switch msg.Method { case builtin.MethodsMiner.ProveCommitSector: - var params miner.ProveCommitSectorParams + var params types.ProveCommitSectorParams if err := params.UnmarshalCBOR(bytes.NewReader(msg.Params)); err != nil { return false, fmt.Errorf("failed to unmarshal prove commit sector params: %w", err) } @@ -360,7 +359,7 @@ func sectorInCommitMsg(msg *types.Message, sectorNumber abi.SectorNumber) (bool, return params.SectorNumber == sectorNumber, nil case builtin.MethodsMiner.ProveCommitAggregate: - var params miner.ProveCommitAggregateParams + var params types.ProveCommitAggregateParams if err := params.UnmarshalCBOR(bytes.NewReader(msg.Params)); err != nil { return false, fmt.Errorf("failed to unmarshal prove commit sector params: %w", err) } diff --git a/storageprovider/provider.go b/storageprovider/provider.go index cd090e1c..01cf3fd8 100644 --- a/storageprovider/provider.go +++ b/storageprovider/provider.go @@ -7,7 +7,6 @@ import ( "fmt" "github.com/filecoin-project/go-state-types/builtin" - "github.com/filecoin-project/go-state-types/builtin/v9/market" "github.com/filecoin-project/venus-market/v2/api/clients" "github.com/ipfs/go-cid" @@ -263,7 +262,7 @@ func (n *ProviderNodeAdapter) WaitForMessage(ctx context.Context, mcid cid.Cid, return cb(receipt.Receipt.ExitCode, receipt.Receipt.Return, receipt.Message, nil) } -func (n *ProviderNodeAdapter) WaitForPublishDeals(ctx context.Context, publishCid cid.Cid, proposal market.DealProposal) (*storagemarket.PublishDealsWaitResult, error) { +func (n *ProviderNodeAdapter) WaitForPublishDeals(ctx context.Context, publishCid cid.Cid, proposal types.DealProposal) (*storagemarket.PublishDealsWaitResult, error) { // Wait for deal to be published (plus additional time for confidence) receipt, err := n.msgClient.WaitMsg(ctx, publishCid, 2*constants.MessageConfidence, constants.LookbackNoLimit, true) if err != nil { @@ -343,7 +342,7 @@ type StorageProviderNode interface { PublishDeals(ctx context.Context, deal types2.MinerDeal) (cid.Cid, error) // WaitForPublishDeals waits for a deal publish message to land on chain. - WaitForPublishDeals(ctx context.Context, mcid cid.Cid, proposal market.DealProposal) (*storagemarket.PublishDealsWaitResult, error) + WaitForPublishDeals(ctx context.Context, mcid cid.Cid, proposal types.DealProposal) (*storagemarket.PublishDealsWaitResult, error) // GetMinerWorkerAddress returns the worker address associated with a miner GetMinerWorkerAddress(ctx context.Context, addr address.Address, tok shared.TipSetToken) (address.Address, error) diff --git a/storageprovider/storageprovider.go b/storageprovider/storageprovider.go index c9d65880..458fa6d5 100644 --- a/storageprovider/storageprovider.go +++ b/storageprovider/storageprovider.go @@ -39,8 +39,6 @@ import ( "github.com/filecoin-project/venus-market/v2/piecestorage" "github.com/filecoin-project/venus-market/v2/utils" - "github.com/filecoin-project/go-state-types/builtin/v9/market" - types2 "github.com/filecoin-project/venus/venus-shared/types" types "github.com/filecoin-project/venus/venus-shared/types/market" ) @@ -382,7 +380,7 @@ func (p *StorageProviderImpl) ImportPublishedDeal(ctx context.Context, deal type return fmt.Errorf("get account for %s err: %w", onlineDeal.Proposal.Client, err) } // change DealProposal the same as type in spec-actors - onlineProposal := market.DealProposal{ + onlineProposal := types2.DealProposal{ PieceCID: onlineDeal.Proposal.PieceCID, PieceSize: onlineDeal.Proposal.PieceSize, VerifiedDeal: onlineDeal.Proposal.VerifiedDeal, diff --git a/storageprovider/storageprovider_test.go b/storageprovider/storageprovider_test.go index b6e34e39..deabb73c 100644 --- a/storageprovider/storageprovider_test.go +++ b/storageprovider/storageprovider_test.go @@ -13,7 +13,6 @@ import ( "github.com/filecoin-project/go-fil-markets/storagemarket" "github.com/filecoin-project/go-fil-markets/storagemarket/network" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/builtin/v9/market" "github.com/filecoin-project/go-state-types/crypto" "github.com/filecoin-project/go-state-types/exitcode" "github.com/filecoin-project/venus-market/v2/config" @@ -268,8 +267,8 @@ func (m *mockProviderNode) PublishDeals(ctx context.Context, deal marketypes.Min panic("implement me") } -func (m *mockProviderNode) WaitForPublishDeals(ctx context.Context, mcid cid.Cid, proposal market.DealProposal) (*storagemarket.PublishDealsWaitResult, error) { - // TODO implement me +func (m *mockProviderNode) WaitForPublishDeals(ctx context.Context, mcid cid.Cid, proposal types.DealProposal) (*storagemarket.PublishDealsWaitResult, error) { + //TODO implement me panic("implement me") }