Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Commit

Permalink
update chain components
Browse files Browse the repository at this point in the history
  • Loading branch information
zl03jsj committed Feb 11, 2022
1 parent 601fc2d commit 01f164b
Show file tree
Hide file tree
Showing 15 changed files with 203 additions and 164 deletions.
16 changes: 2 additions & 14 deletions api/fullnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,22 @@ package api

import (
"context"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-bitfield"
"github.com/filecoin-project/go-jsonrpc/auth"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/dline"
stnetwork "github.com/filecoin-project/go-state-types/network"

"github.com/filecoin-project/venus/venus-shared/actors/builtin/miner"
"github.com/filecoin-project/venus/venus-shared/types"
"github.com/google/uuid"
"github.com/ipfs/go-cid"
metrics "github.com/libp2p/go-libp2p-core/metrics"
"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
protocol "github.com/libp2p/go-libp2p-core/protocol"

"github.com/filecoin-project/venus/app/submodule/apitypes"
"github.com/filecoin-project/venus/venus-shared/actors/builtin/miner"
"github.com/filecoin-project/venus/venus-shared/types"

types2 "github.com/filecoin-project/venus-sealer/types"
)

Expand Down Expand Up @@ -354,9 +350,6 @@ type FullNode interface {
StateGetReceipt(context.Context, cid.Cid, types.TipSetKey) (*types.MessageReceipt, error)
// StateMinerSectorCount returns the number of sectors in a miner's sector set and proving set
StateMinerSectorCount(context.Context, address.Address, types.TipSetKey) (types.MinerSectors, error)
// StateCompute is a flexible command that applies the given messages on the given tipset.
// The messages are run as though the VM were at the provided height.
StateCompute(context.Context, abi.ChainEpoch, []*types.Message, types.TipSetKey) (*apitypes.ComputeStateOutput, error)
// StateVerifierStatus returns the data cap for the given address.
// Returns nil if there is no entry in the data cap table for the
// address.
Expand Down Expand Up @@ -619,7 +612,6 @@ type FullNodeStruct struct {
StateMinerSectorCount func(context.Context, address.Address, types.TipSetKey) (types.MinerSectors, error) `perm:"read"`
StateListMessages func(ctx context.Context, match *MessageMatch, tsk types.TipSetKey, toht abi.ChainEpoch) ([]cid.Cid, error) `perm:"read"`
StateDecodeParams func(context.Context, address.Address, abi.MethodNum, []byte, types.TipSetKey) (interface{}, error) `perm:"read"`
StateCompute func(context.Context, abi.ChainEpoch, []*types.Message, types.TipSetKey) (*apitypes.ComputeStateOutput, error) `perm:"read"`
StateVerifierStatus func(context.Context, address.Address, types.TipSetKey) (*abi.StoragePower, error) `perm:"read"`
StateVerifiedClientStatus func(context.Context, address.Address, types.TipSetKey) (*abi.StoragePower, error) `perm:"read"`
StateVerifiedRegistryRootKey func(ctx context.Context, tsk types.TipSetKey) (address.Address, error) `perm:"read"`
Expand Down Expand Up @@ -1167,10 +1159,6 @@ func (c *FullNodeStruct) StateDecodeParams(ctx context.Context, toAddr address.A
return c.Internal.StateDecodeParams(ctx, toAddr, method, params, tsk)
}

func (c *FullNodeStruct) StateCompute(ctx context.Context, height abi.ChainEpoch, msgs []*types.Message, tsk types.TipSetKey) (*apitypes.ComputeStateOutput, error) {
return c.Internal.StateCompute(ctx, height, msgs, tsk)
}

func (c *FullNodeStruct) StateVerifierStatus(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*abi.StoragePower, error) {
return c.Internal.StateVerifierStatus(ctx, addr, tsk)
}
Expand Down
14 changes: 6 additions & 8 deletions api/impl/strageminer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package impl
import (
"context"
"encoding/json"
"github.com/filecoin-project/venus/venus-shared/types/messager"
"net/http"
"strconv"
"time"
Expand All @@ -27,11 +28,6 @@ import (
api4 "github.com/filecoin-project/venus-market/api"
types4 "github.com/filecoin-project/venus-market/types"

"github.com/filecoin-project/venus/venus-shared/actors/builtin"
"github.com/filecoin-project/venus/venus-shared/types"

types3 "github.com/filecoin-project/venus-messager/types"

"github.com/filecoin-project/venus-sealer/api"
"github.com/filecoin-project/venus-sealer/config"
sectorstorage "github.com/filecoin-project/venus-sealer/sector-storage"
Expand All @@ -43,6 +39,8 @@ import (
"github.com/filecoin-project/venus-sealer/storage-sealing/sealiface"
"github.com/filecoin-project/venus-sealer/storage/sectorblocks"
types2 "github.com/filecoin-project/venus-sealer/types"
"github.com/filecoin-project/venus/venus-shared/actors/builtin"
"github.com/filecoin-project/venus/venus-shared/types"
)

var log = logging.Logger("sealer")
Expand Down Expand Up @@ -819,11 +817,11 @@ func (sm *StorageMinerAPI) MessagerWaitMessage(ctx context.Context, uuid string,
}, nil
}

func (sm *StorageMinerAPI) MessagerPushMessage(ctx context.Context, msg *types.Message, meta *types3.MsgMeta) (string, error) {
return sm.Messager.PushMessage(ctx, msg, meta)
func (sm *StorageMinerAPI) MessagerPushMessage(ctx context.Context, msg *types.Message, spec *messager.SendSpec) (string, error) {
return sm.Messager.PushMessage(ctx, msg, spec)
}

func (sm *StorageMinerAPI) MessagerGetMessage(ctx context.Context, uuid string) (*types3.Message, error) {
func (sm *StorageMinerAPI) MessagerGetMessage(ctx context.Context, uuid string) (*messager.Message, error) {
msg, err := sm.Messager.GetMessageByUid(ctx, uuid)
if err != nil {
return nil, err
Expand Down
48 changes: 21 additions & 27 deletions api/messager-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,23 @@ package api

import (
"context"
"time"

"golang.org/x/xerrors"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-jsonrpc"

"github.com/filecoin-project/venus-sealer/config"

"github.com/ipfs-force-community/venus-common-utils/apiinfo"

"github.com/filecoin-project/venus-messager/api/client"
types2 "github.com/filecoin-project/venus-messager/types"

"github.com/filecoin-project/venus-sealer/config"
"github.com/filecoin-project/venus/venus-shared/types"
"github.com/filecoin-project/venus/venus-shared/types/messager"
"github.com/ipfs-force-community/venus-common-utils/apiinfo"
"golang.org/x/xerrors"
"time"
)

type IMessager interface {
WalletHas(ctx context.Context, addr address.Address) (bool, error)
WaitMessage(ctx context.Context, id string, confidence uint64) (*types2.Message, error)
PushMessage(ctx context.Context, msg *types.Message, meta *types2.MsgMeta) (string, error)
PushMessageWithId(ctx context.Context, id string, msg *types.Message, meta *types2.MsgMeta) (string, error)
GetMessageByUid(ctx context.Context, id string) (*types2.Message, error)
WaitMessage(ctx context.Context, id string, confidence uint64) (*messager.Message, error)
PushMessage(ctx context.Context, msg *types.Message, spec *messager.SendSpec) (string, error)
PushMessageWithId(ctx context.Context, id string, msg *types.Message, spec *messager.SendSpec) (string, error)
GetMessageByUid(ctx context.Context, id string) (*messager.Message, error)
}

var _ IMessager = (*Messager)(nil)
Expand All @@ -37,7 +31,7 @@ func NewMessager(in client.IMessager) *Messager {
return &Messager{in: in}
}

func (message *Messager) WaitMessage(ctx context.Context, id string, confidence uint64) (*types2.Message, error) {
func (message *Messager) WaitMessage(ctx context.Context, id string, confidence uint64) (*messager.Message, error) {
tm := time.NewTicker(time.Second * 30)
defer tm.Stop()

Expand All @@ -56,22 +50,22 @@ func (message *Messager) WaitMessage(ctx context.Context, id string, confidence

switch msg.State {
//OffChain
case types2.FillMsg:
case messager.FillMsg:
fallthrough
case types2.UnFillMsg:
case messager.UnFillMsg:
fallthrough
case types2.UnKnown:
case messager.UnKnown:
continue
//OnChain
case types2.ReplacedMsg:
case messager.ReplacedMsg:
fallthrough
case types2.OnChainMsg:
case messager.OnChainMsg:
if msg.Confidence > int64(confidence) {
return msg, nil
}
continue
//Error
case types2.FailedMsg:
case messager.FailedMsg:
var reason string
if msg.Receipt != nil {
reason = string(msg.Receipt.Return)
Expand All @@ -91,15 +85,15 @@ func (m *Messager) WalletHas(ctx context.Context, addr address.Address) (bool, e
return m.in.WalletHas(ctx, addr)
}

func (m *Messager) PushMessage(ctx context.Context, msg *types.Message, meta *types2.MsgMeta) (string, error) {
return m.in.PushMessage(ctx, msg, meta)
func (m *Messager) PushMessage(ctx context.Context, msg *types.Message, spec *messager.SendSpec) (string, error) {
return m.in.PushMessage(ctx, msg, spec)
}

func (m *Messager) PushMessageWithId(ctx context.Context, id string, msg *types.Message, meta *types2.MsgMeta) (string, error) {
return m.in.PushMessageWithId(ctx, id, msg, meta)
func (m *Messager) PushMessageWithId(ctx context.Context, id string, msg *types.Message, spec *messager.SendSpec) (string, error) {
return m.in.PushMessageWithId(ctx, id, msg, spec)
}

func (m *Messager) GetMessageByUid(ctx context.Context, id string) (*types2.Message, error) {
func (m *Messager) GetMessageByUid(ctx context.Context, id string) (*messager.Message, error) {
return m.in.GetMessageByUid(ctx, id)
}

Expand Down
20 changes: 8 additions & 12 deletions api/storage_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package api

import (
"context"
"github.com/filecoin-project/venus/venus-shared/types/messager"
"golang.org/x/xerrors"
"time"

Expand All @@ -12,13 +13,8 @@ import (
"github.com/filecoin-project/go-fil-markets/piecestore"
"github.com/filecoin-project/go-state-types/abi"
abinetwork "github.com/filecoin-project/go-state-types/network"

"github.com/filecoin-project/specs-storage/storage"

types4 "github.com/filecoin-project/venus-market/types"

types3 "github.com/filecoin-project/venus-messager/types"

"github.com/filecoin-project/venus/venus-shared/actors/builtin"
types2 "github.com/filecoin-project/venus/venus-shared/types"

Expand Down Expand Up @@ -174,8 +170,8 @@ type StorageMiner interface {

//messager
MessagerWaitMessage(ctx context.Context, uuid string, confidence uint64) (*types2.MsgLookup, error)
MessagerPushMessage(ctx context.Context, msg *types2.Message, meta *types3.MsgMeta) (string, error)
MessagerGetMessage(ctx context.Context, uuid string) (*types3.Message, error)
MessagerPushMessage(ctx context.Context, msg *types2.Message, spec *messager.SendSpec) (string, error)
MessagerGetMessage(ctx context.Context, uuid string) (*messager.Message, error)

//for market
GetDeals(ctx context.Context, pageIndex, pageSize int) ([]*types4.DealInfo, error)
Expand Down Expand Up @@ -297,8 +293,8 @@ type StorageMinerStruct struct {
CheckProvable func(ctx context.Context, pp abi.RegisteredPoStProof, sectors []storage.SectorRef, expensive bool) (map[abi.SectorNumber]string, error) `perm:"admin"`

MessagerWaitMessage func(ctx context.Context, uuid string, confidence uint64) (*types2.MsgLookup, error) `perm:"read"`
MessagerPushMessage func(ctx context.Context, msg *types2.Message, meta *types3.MsgMeta) (string, error) `perm:"sign"`
MessagerGetMessage func(ctx context.Context, uuid string) (*types3.Message, error) `perm:"write"`
MessagerPushMessage func(ctx context.Context, msg *types2.Message, spec *messager.SendSpec) (string, error) `perm:"sign"`
MessagerGetMessage func(ctx context.Context, uuid string) (*messager.Message, error) `perm:"write"`

IsUnsealed func(ctx context.Context, sector storage.SectorRef, offset storiface.UnpaddedByteIndex, size abi.UnpaddedPieceSize) (bool, error) `perm:"read"`
SectorsStatus func(ctx context.Context, sid abi.SectorNumber, showOnChainInfo bool) (SectorInfo, error) `perm:"read"`
Expand Down Expand Up @@ -685,11 +681,11 @@ func (c *StorageMinerStruct) MessagerWaitMessage(ctx context.Context, uuid strin
return c.Internal.MessagerWaitMessage(ctx, uuid, confidence)
}

func (c *StorageMinerStruct) MessagerPushMessage(ctx context.Context, msg *types2.Message, meta *types3.MsgMeta) (string, error) {
return c.Internal.MessagerPushMessage(ctx, msg, meta)
func (c *StorageMinerStruct) MessagerPushMessage(ctx context.Context, msg *types2.Message, spec *messager.SendSpec) (string, error) {
return c.Internal.MessagerPushMessage(ctx, msg, spec)
}

func (c *StorageMinerStruct) MessagerGetMessage(ctx context.Context, uuid string) (*types3.Message, error) {
func (c *StorageMinerStruct) MessagerGetMessage(ctx context.Context, uuid string) (*messager.Message, error) {
return c.Internal.MessagerGetMessage(ctx, uuid)
}

Expand Down
4 changes: 2 additions & 2 deletions app/venus-sealer/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
"github.com/filecoin-project/venus/venus-shared/actors/policy"
"github.com/filecoin-project/venus/venus-shared/types"

types3 "github.com/filecoin-project/venus-messager/types"
types3 "github.com/filecoin-project/venus/venus-shared/types/messager"

"github.com/filecoin-project/venus-sealer/api"
"github.com/filecoin-project/venus-sealer/config"
Expand Down Expand Up @@ -622,7 +622,7 @@ func createStorageMiner(ctx context.Context, nodeAPI api.FullNode, messagerClien
GasPremium: gasPrice,
}

msgUid, err := messagerClient.PushMessage(ctx, createStorageMinerMsg, &types3.MsgMeta{MaxFee: types.FromFil(1)})
msgUid, err := messagerClient.PushMessage(ctx, createStorageMinerMsg, &types3.SendSpec{MaxFee: types.FromFil(1)})
if err != nil {
return address.Undef, xerrors.Errorf("pushing createMiner message: %w", err)
}
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ require (
github.com/filecoin-project/specs-actors/v6 v6.0.1
github.com/filecoin-project/specs-actors/v7 v7.0.0-rc1
github.com/filecoin-project/specs-storage v0.1.1-0.20211228030229-6d460d25a0c9
github.com/filecoin-project/venus v1.2.0-rc2
github.com/filecoin-project/venus-market v1.0.2-0.20220209102104-2edeb8e8c5b0
github.com/filecoin-project/venus-messager v1.4.0-rc1
github.com/filecoin-project/venus v1.2.0-rc5.0.20220210073318-71c52bbba9c5
github.com/filecoin-project/venus-market v1.0.2-0.20220210103815-5ea3e7f6c5ac
github.com/filecoin-project/venus-messager v1.4.0-rc2
github.com/gbrlsnchs/jwt/v3 v3.0.1
github.com/go-kit/kit v0.12.0 // indirect
github.com/golang/mock v1.6.0
Expand All @@ -48,7 +48,7 @@ require (
github.com/hashicorp/go-multierror v1.1.1
github.com/icza/backscanner v0.0.0-20210726202459-ac2ffc679f94
github.com/ipfs-force-community/venus-common-utils v0.0.0-20211122032945-eb6cab79c62a
github.com/ipfs-force-community/venus-gateway v1.2.0-rc1
github.com/ipfs-force-community/venus-gateway v1.2.0-rc2
github.com/ipfs/go-block-format v0.0.3
github.com/ipfs/go-cid v0.1.0
github.com/ipfs/go-datastore v0.5.1
Expand Down
Loading

0 comments on commit 01f164b

Please sign in to comment.