diff --git a/.circleci/config.yml b/.circleci/config.yml index c5bdeaa1b..0cff77eb2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -68,7 +68,7 @@ jobs: - run: sudo apt-get install npm - restore_cache: name: restore go mod cache - key: v1-go-deps-{{ arch }}-{{ checksum "/home/circleci/project/lotus/go.mod" }} + key: v1-go-deps-{{ arch }}-{{ checksum "/home/circleci/project/go.mod" }} - run: command: make buildall - store_artifacts: diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..6ba83a258 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# lotus changelog + +## 0.1.0 / 2019-12-11 + +We are very excited to release **lotus** 0.1.0. This is our testnet release. To install lotus and join the testnet, please visit [docs.lotu.sh](docs.lotu.sh). Please file bug reports as [issues](https://github.com/filecoin-project/lotus/issues). + +A huge thank you to all contributors for this testnet release! \ No newline at end of file diff --git a/Makefile b/Makefile index b7d0f98e2..e37dcf3e8 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +SHELL=/usr/bin/env bash + all: build .PHONY: all @@ -70,7 +72,16 @@ lotus-seal-worker: $(BUILD_DEPS) .PHONY: lotus-seal-worker BINS+=lotus-seal-worker +lotus-shed: $(BUILD_DEPS) + rm -f lotus-shed + go build $(GOFLAGS) -o lotus-shed ./cmd/lotus-shed +.PHONY: lotus-seal-worker +BINS+=lotus-seal-worker + build: lotus lotus-storage-miner lotus-seal-worker + @[[ $$(type -P "lotus") ]] && echo "Caution: you have \ +an existing lotus binary in your PATH. This may cause problems if you don't run 'sudo make install'" || true + .PHONY: build install: diff --git a/api/api_common.go b/api/api_common.go index c83a4c260..ee99f6d76 100644 --- a/api/api_common.go +++ b/api/api_common.go @@ -10,6 +10,8 @@ import ( "github.com/filecoin-project/lotus/build" ) +type Permission = string + type Common interface { // Auth AuthVerify(ctx context.Context, token string) ([]Permission, error) diff --git a/api/api_storage.go b/api/api_storage.go index 816ad74bf..1a1aff853 100644 --- a/api/api_storage.go +++ b/api/api_storage.go @@ -29,6 +29,10 @@ const ( CommitFailed FailedUnrecoverable + + Faulty // sector is corrupted or gone for some reason + FaultReported // sector has been declared as a fault on chain + FaultedFinal // fault declared on chain ) var SectorStates = []string{ @@ -39,6 +43,7 @@ var SectorStates = []string{ PreCommitting: "PreCommitting", PreCommitted: "PreCommitted", Committing: "Committing", + CommitWait: "CommitWait", Proving: "Proving", SealFailed: "SealFailed", @@ -47,6 +52,10 @@ var SectorStates = []string{ CommitFailed: "CommitFailed", FailedUnrecoverable: "FailedUnrecoverable", + + Faulty: "Faulty", + FaultReported: "FaultReported", + FaultedFinal: "FaultedFinal", } // StorageMiner is a low-level interface to the Filecoin network storage miner node @@ -87,9 +96,9 @@ type SectorInfo struct { Deals []uint64 Ticket sectorbuilder.SealTicket Seed sectorbuilder.SealSeed - Retries uint64 + Retries uint64 - LastErr string + LastErr string } type SealedRef struct { diff --git a/api/permissioned.go b/api/apistruct/permissioned.go similarity index 68% rename from api/permissioned.go rename to api/apistruct/permissioned.go index 58d027278..4c29f6688 100644 --- a/api/permissioned.go +++ b/api/apistruct/permissioned.go @@ -1,50 +1,50 @@ -package api +package apistruct import ( "context" "reflect" "golang.org/x/xerrors" + + "github.com/filecoin-project/lotus/api" ) type permKey int var permCtxKey permKey -type Permission = string - const ( // When changing these, update docs/API.md too - PermRead Permission = "read" // default - PermWrite Permission = "write" - PermSign Permission = "sign" // Use wallet keys for signing - PermAdmin Permission = "admin" // Manage permissions + PermRead api.Permission = "read" // default + PermWrite api.Permission = "write" + PermSign api.Permission = "sign" // Use wallet keys for signing + PermAdmin api.Permission = "admin" // Manage permissions ) -var AllPermissions = []Permission{PermRead, PermWrite, PermSign, PermAdmin} -var defaultPerms = []Permission{PermRead} +var AllPermissions = []api.Permission{PermRead, PermWrite, PermSign, PermAdmin} +var defaultPerms = []api.Permission{PermRead} -func WithPerm(ctx context.Context, perms []Permission) context.Context { +func WithPerm(ctx context.Context, perms []api.Permission) context.Context { return context.WithValue(ctx, permCtxKey, perms) } -func PermissionedStorMinerAPI(a StorageMiner) StorageMiner { +func PermissionedStorMinerAPI(a api.StorageMiner) api.StorageMiner { var out StorageMinerStruct permissionedAny(a, &out.Internal) permissionedAny(a, &out.CommonStruct.Internal) return &out } -func PermissionedFullAPI(a FullNode) FullNode { +func PermissionedFullAPI(a api.FullNode) api.FullNode { var out FullNodeStruct permissionedAny(a, &out.Internal) permissionedAny(a, &out.CommonStruct.Internal) return &out } -func HasPerm(ctx context.Context, perm Permission) bool { - callerPerms, ok := ctx.Value(permCtxKey).([]Permission) +func HasPerm(ctx context.Context, perm api.Permission) bool { + callerPerms, ok := ctx.Value(permCtxKey).([]api.Permission) if !ok { callerPerms = defaultPerms } @@ -63,7 +63,7 @@ func permissionedAny(in interface{}, out interface{}) { for f := 0; f < rint.NumField(); f++ { field := rint.Type().Field(f) - requiredPerm := Permission(field.Tag.Get("perm")) + requiredPerm := api.Permission(field.Tag.Get("perm")) if requiredPerm == "" { panic("missing 'perm' tag on " + field.Name) // ok } diff --git a/api/struct.go b/api/apistruct/struct.go similarity index 86% rename from api/struct.go rename to api/apistruct/struct.go index c0ab86713..8afb8e376 100644 --- a/api/struct.go +++ b/api/apistruct/struct.go @@ -1,4 +1,4 @@ -package api +package apistruct import ( "context" @@ -9,6 +9,7 @@ import ( "github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/peer" + "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/address" "github.com/filecoin-project/lotus/chain/store" @@ -20,8 +21,8 @@ var _ = AllPermissions type CommonStruct struct { Internal struct { - AuthVerify func(ctx context.Context, token string) ([]Permission, error) `perm:"read"` - AuthNew func(ctx context.Context, perms []Permission) ([]byte, error) `perm:"admin"` + AuthVerify func(ctx context.Context, token string) ([]api.Permission, error) `perm:"read"` + AuthNew func(ctx context.Context, perms []api.Permission) ([]byte, error) `perm:"admin"` NetConnectedness func(context.Context, peer.ID) (network.Connectedness, error) `perm:"read"` NetPeers func(context.Context) ([]peer.AddrInfo, error) `perm:"read"` @@ -29,8 +30,8 @@ type CommonStruct struct { NetAddrsListen func(context.Context) (peer.AddrInfo, error) `perm:"read"` NetDisconnect func(context.Context, peer.ID) error `perm:"write"` - ID func(context.Context) (peer.ID, error) `perm:"read"` - Version func(context.Context) (Version, error) `perm:"read"` + ID func(context.Context) (peer.ID, error) `perm:"read"` + Version func(context.Context) (api.Version, error) `perm:"read"` } } @@ -44,16 +45,16 @@ type FullNodeStruct struct { ChainGetRandomness func(context.Context, types.TipSetKey, int64) ([]byte, error) `perm:"read"` ChainGetBlock func(context.Context, cid.Cid) (*types.BlockHeader, error) `perm:"read"` ChainGetTipSet func(context.Context, types.TipSetKey) (*types.TipSet, error) `perm:"read"` - ChainGetBlockMessages func(context.Context, cid.Cid) (*BlockMessages, error) `perm:"read"` + ChainGetBlockMessages func(context.Context, cid.Cid) (*api.BlockMessages, error) `perm:"read"` ChainGetParentReceipts func(context.Context, cid.Cid) ([]*types.MessageReceipt, error) `perm:"read"` - ChainGetParentMessages func(context.Context, cid.Cid) ([]Message, error) `perm:"read"` + ChainGetParentMessages func(context.Context, cid.Cid) ([]api.Message, error) `perm:"read"` ChainGetTipSetByHeight func(context.Context, uint64, *types.TipSet) (*types.TipSet, error) `perm:"read"` ChainReadObj func(context.Context, cid.Cid) ([]byte, error) `perm:"read"` ChainSetHead func(context.Context, *types.TipSet) error `perm:"admin"` ChainGetGenesis func(context.Context) (*types.TipSet, error) `perm:"read"` ChainTipSetWeight func(context.Context, *types.TipSet) (types.BigInt, error) `perm:"read"` - SyncState func(context.Context) (*SyncState, error) `perm:"read"` + SyncState func(context.Context) (*api.SyncState, error) `perm:"read"` SyncSubmitBlock func(ctx context.Context, blk *types.BlockMsg) error `perm:"write"` SyncIncomingBlocks func(ctx context.Context) (<-chan *types.BlockHeader, error) `perm:"read"` @@ -61,7 +62,7 @@ type FullNodeStruct struct { MpoolPush func(context.Context, *types.SignedMessage) error `perm:"write"` MpoolPushMessage func(context.Context, *types.Message) (*types.SignedMessage, error) `perm:"sign"` MpoolGetNonce func(context.Context, address.Address) (uint64, error) `perm:"read"` - MpoolSub func(context.Context) (<-chan MpoolUpdate, error) `perm:"read"` + MpoolSub func(context.Context) (<-chan api.MpoolUpdate, error) `perm:"read"` MinerCreateBlock func(context.Context, address.Address, *types.TipSet, *types.Ticket, *types.EPostProof, []*types.SignedMessage, uint64, uint64) (*types.BlockMsg, error) `perm:"write"` @@ -77,28 +78,28 @@ type FullNodeStruct struct { WalletImport func(context.Context, *types.KeyInfo) (address.Address, error) `perm:"admin"` ClientImport func(ctx context.Context, path string) (cid.Cid, error) `perm:"admin"` - ClientListImports func(ctx context.Context) ([]Import, error) `perm:"write"` + ClientListImports func(ctx context.Context) ([]api.Import, error) `perm:"write"` ClientHasLocal func(ctx context.Context, root cid.Cid) (bool, error) `perm:"write"` - ClientFindData func(ctx context.Context, root cid.Cid) ([]QueryOffer, error) `perm:"read"` + ClientFindData func(ctx context.Context, root cid.Cid) ([]api.QueryOffer, error) `perm:"read"` ClientStartDeal func(ctx context.Context, data cid.Cid, miner address.Address, price types.BigInt, blocksDuration uint64) (*cid.Cid, error) `perm:"admin"` - ClientGetDealInfo func(context.Context, cid.Cid) (*DealInfo, error) `perm:"read"` - ClientListDeals func(ctx context.Context) ([]DealInfo, error) `perm:"write"` - ClientRetrieve func(ctx context.Context, order RetrievalOrder, path string) error `perm:"admin"` + ClientGetDealInfo func(context.Context, cid.Cid) (*api.DealInfo, error) `perm:"read"` + ClientListDeals func(ctx context.Context) ([]api.DealInfo, error) `perm:"write"` + 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"` - StateMinerSectors func(context.Context, address.Address, *types.TipSet) ([]*ChainSectorInfo, error) `perm:"read"` - StateMinerProvingSet func(context.Context, address.Address, *types.TipSet) ([]*ChainSectorInfo, error) `perm:"read"` - StateMinerPower func(context.Context, address.Address, *types.TipSet) (MinerPower, 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"` + 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"` StateMinerPeerID func(ctx context.Context, m address.Address, ts *types.TipSet) (peer.ID, error) `perm:"read"` StateMinerElectionPeriodStart func(ctx context.Context, actor address.Address, ts *types.TipSet) (uint64, error) `perm:"read"` StateMinerSectorSize func(context.Context, address.Address, *types.TipSet) (uint64, error) `perm:"read"` StateCall func(context.Context, *types.Message, *types.TipSet) (*types.MessageReceipt, error) `perm:"read"` - StateReplay func(context.Context, *types.TipSet, cid.Cid) (*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"` - StateReadState func(context.Context, *types.Actor, *types.TipSet) (*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"` - StateWaitMsg func(context.Context, cid.Cid) (*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"` StateListActors func(context.Context, *types.TipSet) ([]address.Address, error) `perm:"read"` StateMarketBalance func(context.Context, address.Address, *types.TipSet) (actors.StorageParticipantBalance, error) `perm:"read"` @@ -111,19 +112,19 @@ type FullNodeStruct struct { MarketEnsureAvailable func(context.Context, address.Address, types.BigInt) error `perm:"sign"` - PaychGet func(ctx context.Context, from, to address.Address, ensureFunds types.BigInt) (*ChannelInfo, error) `perm:"sign"` - PaychList func(context.Context) ([]address.Address, error) `perm:"read"` - PaychStatus func(context.Context, address.Address) (*PaychStatus, error) `perm:"read"` - PaychClose func(context.Context, address.Address) (cid.Cid, error) `perm:"sign"` - PaychAllocateLane func(context.Context, address.Address) (uint64, error) `perm:"sign"` - PaychNewPayment func(ctx context.Context, from, to address.Address, vouchers []VoucherSpec) (*PaymentInfo, error) `perm:"sign"` - PaychVoucherCheck func(context.Context, *types.SignedVoucher) error `perm:"read"` - PaychVoucherCheckValid func(context.Context, address.Address, *types.SignedVoucher) error `perm:"read"` - PaychVoucherCheckSpendable func(context.Context, address.Address, *types.SignedVoucher, []byte, []byte) (bool, error) `perm:"read"` - PaychVoucherAdd func(context.Context, address.Address, *types.SignedVoucher, []byte, types.BigInt) (types.BigInt, error) `perm:"write"` - PaychVoucherCreate func(context.Context, address.Address, types.BigInt, uint64) (*types.SignedVoucher, error) `perm:"sign"` - PaychVoucherList func(context.Context, address.Address) ([]*types.SignedVoucher, error) `perm:"write"` - PaychVoucherSubmit func(context.Context, address.Address, *types.SignedVoucher) (cid.Cid, error) `perm:"sign"` + PaychGet func(ctx context.Context, from, to address.Address, ensureFunds types.BigInt) (*api.ChannelInfo, error) `perm:"sign"` + PaychList func(context.Context) ([]address.Address, error) `perm:"read"` + PaychStatus func(context.Context, address.Address) (*api.PaychStatus, error) `perm:"read"` + PaychClose func(context.Context, address.Address) (cid.Cid, error) `perm:"sign"` + PaychAllocateLane func(context.Context, address.Address) (uint64, error) `perm:"sign"` + PaychNewPayment func(ctx context.Context, from, to address.Address, vouchers []api.VoucherSpec) (*api.PaymentInfo, error) `perm:"sign"` + PaychVoucherCheck func(context.Context, *types.SignedVoucher) error `perm:"read"` + PaychVoucherCheckValid func(context.Context, address.Address, *types.SignedVoucher) error `perm:"read"` + PaychVoucherCheckSpendable func(context.Context, address.Address, *types.SignedVoucher, []byte, []byte) (bool, error) `perm:"read"` + PaychVoucherAdd func(context.Context, address.Address, *types.SignedVoucher, []byte, types.BigInt) (types.BigInt, error) `perm:"write"` + PaychVoucherCreate func(context.Context, address.Address, types.BigInt, uint64) (*types.SignedVoucher, error) `perm:"sign"` + PaychVoucherList func(context.Context, address.Address) ([]*types.SignedVoucher, error) `perm:"write"` + PaychVoucherSubmit func(context.Context, address.Address, *types.SignedVoucher) (cid.Cid, error) `perm:"sign"` } } @@ -136,10 +137,10 @@ type StorageMinerStruct struct { PledgeSector func(context.Context) error `perm:"write"` - SectorsStatus func(context.Context, uint64) (SectorInfo, error) `perm:"read"` - SectorsList func(context.Context) ([]uint64, error) `perm:"read"` - SectorsRefs func(context.Context) (map[string][]SealedRef, error) `perm:"read"` - SectorsUpdate func(context.Context, uint64, SectorState) error `perm:"write"` + SectorsStatus func(context.Context, uint64) (api.SectorInfo, error) `perm:"read"` + SectorsList func(context.Context) ([]uint64, error) `perm:"read"` + SectorsRefs func(context.Context) (map[string][]api.SealedRef, error) `perm:"read"` + SectorsUpdate func(context.Context, uint64, api.SectorState) error `perm:"write"` WorkerStats func(context.Context) (sectorbuilder.WorkerStats, error) `perm:"read"` @@ -148,11 +149,11 @@ type StorageMinerStruct struct { } } -func (c *CommonStruct) AuthVerify(ctx context.Context, token string) ([]Permission, error) { +func (c *CommonStruct) AuthVerify(ctx context.Context, token string) ([]api.Permission, error) { return c.Internal.AuthVerify(ctx, token) } -func (c *CommonStruct) AuthNew(ctx context.Context, perms []Permission) ([]byte, error) { +func (c *CommonStruct) AuthNew(ctx context.Context, perms []api.Permission) ([]byte, error) { return c.Internal.AuthNew(ctx, perms) } @@ -182,11 +183,11 @@ func (c *CommonStruct) ID(ctx context.Context) (peer.ID, error) { } // Version implements API.Version -func (c *CommonStruct) Version(ctx context.Context) (Version, error) { +func (c *CommonStruct) Version(ctx context.Context) (api.Version, error) { return c.Internal.Version(ctx) } -func (c *FullNodeStruct) ClientListImports(ctx context.Context) ([]Import, error) { +func (c *FullNodeStruct) ClientListImports(ctx context.Context) ([]api.Import, error) { return c.Internal.ClientListImports(ctx) } @@ -198,22 +199,22 @@ func (c *FullNodeStruct) ClientHasLocal(ctx context.Context, root cid.Cid) (bool return c.Internal.ClientHasLocal(ctx, root) } -func (c *FullNodeStruct) ClientFindData(ctx context.Context, root cid.Cid) ([]QueryOffer, error) { +func (c *FullNodeStruct) ClientFindData(ctx context.Context, root cid.Cid) ([]api.QueryOffer, error) { return c.Internal.ClientFindData(ctx, root) } func (c *FullNodeStruct) ClientStartDeal(ctx context.Context, data cid.Cid, miner address.Address, price types.BigInt, blocksDuration uint64) (*cid.Cid, error) { return c.Internal.ClientStartDeal(ctx, data, miner, price, blocksDuration) } -func (c *FullNodeStruct) ClientGetDealInfo(ctx context.Context, deal cid.Cid) (*DealInfo, error) { +func (c *FullNodeStruct) ClientGetDealInfo(ctx context.Context, deal cid.Cid) (*api.DealInfo, error) { return c.Internal.ClientGetDealInfo(ctx, deal) } -func (c *FullNodeStruct) ClientListDeals(ctx context.Context) ([]DealInfo, error) { +func (c *FullNodeStruct) ClientListDeals(ctx context.Context) ([]api.DealInfo, error) { return c.Internal.ClientListDeals(ctx) } -func (c *FullNodeStruct) ClientRetrieve(ctx context.Context, order RetrievalOrder, path string) error { +func (c *FullNodeStruct) ClientRetrieve(ctx context.Context, order api.RetrievalOrder, path string) error { return c.Internal.ClientRetrieve(ctx, order, path) } @@ -233,7 +234,7 @@ func (c *FullNodeStruct) MpoolPushMessage(ctx context.Context, msg *types.Messag return c.Internal.MpoolPushMessage(ctx, msg) } -func (c *FullNodeStruct) MpoolSub(ctx context.Context) (<-chan MpoolUpdate, error) { +func (c *FullNodeStruct) MpoolSub(ctx context.Context) (<-chan api.MpoolUpdate, error) { return c.Internal.MpoolSub(ctx) } @@ -305,7 +306,7 @@ func (c *FullNodeStruct) ChainGetTipSet(ctx context.Context, key types.TipSetKey return c.Internal.ChainGetTipSet(ctx, key) } -func (c *FullNodeStruct) ChainGetBlockMessages(ctx context.Context, b cid.Cid) (*BlockMessages, error) { +func (c *FullNodeStruct) ChainGetBlockMessages(ctx context.Context, b cid.Cid) (*api.BlockMessages, error) { return c.Internal.ChainGetBlockMessages(ctx, b) } @@ -313,7 +314,7 @@ func (c *FullNodeStruct) ChainGetParentReceipts(ctx context.Context, b cid.Cid) return c.Internal.ChainGetParentReceipts(ctx, b) } -func (c *FullNodeStruct) ChainGetParentMessages(ctx context.Context, b cid.Cid) ([]Message, error) { +func (c *FullNodeStruct) ChainGetParentMessages(ctx context.Context, b cid.Cid) ([]api.Message, error) { return c.Internal.ChainGetParentMessages(ctx, b) } @@ -337,7 +338,7 @@ func (c *FullNodeStruct) ChainTipSetWeight(ctx context.Context, ts *types.TipSet return c.Internal.ChainTipSetWeight(ctx, ts) } -func (c *FullNodeStruct) SyncState(ctx context.Context) (*SyncState, error) { +func (c *FullNodeStruct) SyncState(ctx context.Context) (*api.SyncState, error) { return c.Internal.SyncState(ctx) } @@ -349,15 +350,15 @@ func (c *FullNodeStruct) SyncIncomingBlocks(ctx context.Context) (<-chan *types. return c.Internal.SyncIncomingBlocks(ctx) } -func (c *FullNodeStruct) StateMinerSectors(ctx context.Context, addr address.Address, ts *types.TipSet) ([]*ChainSectorInfo, error) { +func (c *FullNodeStruct) StateMinerSectors(ctx context.Context, addr address.Address, ts *types.TipSet) ([]*api.ChainSectorInfo, error) { return c.Internal.StateMinerSectors(ctx, addr, ts) } -func (c *FullNodeStruct) StateMinerProvingSet(ctx context.Context, addr address.Address, ts *types.TipSet) ([]*ChainSectorInfo, error) { +func (c *FullNodeStruct) StateMinerProvingSet(ctx context.Context, addr address.Address, ts *types.TipSet) ([]*api.ChainSectorInfo, error) { return c.Internal.StateMinerProvingSet(ctx, addr, ts) } -func (c *FullNodeStruct) StateMinerPower(ctx context.Context, a address.Address, ts *types.TipSet) (MinerPower, error) { +func (c *FullNodeStruct) StateMinerPower(ctx context.Context, a address.Address, ts *types.TipSet) (api.MinerPower, error) { return c.Internal.StateMinerPower(ctx, a, ts) } @@ -381,7 +382,7 @@ func (c *FullNodeStruct) StateCall(ctx context.Context, msg *types.Message, ts * return c.Internal.StateCall(ctx, msg, ts) } -func (c *FullNodeStruct) StateReplay(ctx context.Context, ts *types.TipSet, mc cid.Cid) (*ReplayResults, error) { +func (c *FullNodeStruct) StateReplay(ctx context.Context, ts *types.TipSet, mc cid.Cid) (*api.ReplayResults, error) { return c.Internal.StateReplay(ctx, ts, mc) } @@ -389,7 +390,7 @@ func (c *FullNodeStruct) StateGetActor(ctx context.Context, actor address.Addres return c.Internal.StateGetActor(ctx, actor, ts) } -func (c *FullNodeStruct) StateReadState(ctx context.Context, act *types.Actor, ts *types.TipSet) (*ActorState, error) { +func (c *FullNodeStruct) StateReadState(ctx context.Context, act *types.Actor, ts *types.TipSet) (*api.ActorState, error) { return c.Internal.StateReadState(ctx, act, ts) } @@ -397,7 +398,7 @@ func (c *FullNodeStruct) StatePledgeCollateral(ctx context.Context, ts *types.Ti return c.Internal.StatePledgeCollateral(ctx, ts) } -func (c *FullNodeStruct) StateWaitMsg(ctx context.Context, msgc cid.Cid) (*MsgWait, error) { +func (c *FullNodeStruct) StateWaitMsg(ctx context.Context, msgc cid.Cid) (*api.MsgWait, error) { return c.Internal.StateWaitMsg(ctx, msgc) } func (c *FullNodeStruct) StateListMiners(ctx context.Context, ts *types.TipSet) ([]address.Address, error) { @@ -440,7 +441,7 @@ func (c *FullNodeStruct) MarketEnsureAvailable(ctx context.Context, addr address return c.Internal.MarketEnsureAvailable(ctx, addr, amt) } -func (c *FullNodeStruct) PaychGet(ctx context.Context, from, to address.Address, ensureFunds types.BigInt) (*ChannelInfo, error) { +func (c *FullNodeStruct) PaychGet(ctx context.Context, from, to address.Address, ensureFunds types.BigInt) (*api.ChannelInfo, error) { return c.Internal.PaychGet(ctx, from, to, ensureFunds) } @@ -448,7 +449,7 @@ func (c *FullNodeStruct) PaychList(ctx context.Context) ([]address.Address, erro return c.Internal.PaychList(ctx) } -func (c *FullNodeStruct) PaychStatus(ctx context.Context, pch address.Address) (*PaychStatus, error) { +func (c *FullNodeStruct) PaychStatus(ctx context.Context, pch address.Address) (*api.PaychStatus, error) { return c.Internal.PaychStatus(ctx, pch) } @@ -480,7 +481,7 @@ func (c *FullNodeStruct) PaychAllocateLane(ctx context.Context, ch address.Addre return c.Internal.PaychAllocateLane(ctx, ch) } -func (c *FullNodeStruct) PaychNewPayment(ctx context.Context, from, to address.Address, vouchers []VoucherSpec) (*PaymentInfo, error) { +func (c *FullNodeStruct) PaychNewPayment(ctx context.Context, from, to address.Address, vouchers []api.VoucherSpec) (*api.PaymentInfo, error) { return c.Internal.PaychNewPayment(ctx, from, to, vouchers) } @@ -501,7 +502,7 @@ func (c *StorageMinerStruct) PledgeSector(ctx context.Context) error { } // Get the status of a given sector by ID -func (c *StorageMinerStruct) SectorsStatus(ctx context.Context, sid uint64) (SectorInfo, error) { +func (c *StorageMinerStruct) SectorsStatus(ctx context.Context, sid uint64) (api.SectorInfo, error) { return c.Internal.SectorsStatus(ctx, sid) } @@ -510,11 +511,11 @@ func (c *StorageMinerStruct) SectorsList(ctx context.Context) ([]uint64, error) return c.Internal.SectorsList(ctx) } -func (c *StorageMinerStruct) SectorsRefs(ctx context.Context) (map[string][]SealedRef, error) { +func (c *StorageMinerStruct) SectorsRefs(ctx context.Context) (map[string][]api.SealedRef, error) { return c.Internal.SectorsRefs(ctx) } -func (c *StorageMinerStruct) SectorsUpdate(ctx context.Context, id uint64, state SectorState) error { +func (c *StorageMinerStruct) SectorsUpdate(ctx context.Context, id uint64, state api.SectorState) error { return c.Internal.SectorsUpdate(ctx, id, state) } @@ -530,6 +531,6 @@ func (c *StorageMinerStruct) WorkerDone(ctx context.Context, task uint64, res se return c.Internal.WorkerDone(ctx, task, res) } -var _ Common = &CommonStruct{} -var _ FullNode = &FullNodeStruct{} -var _ StorageMiner = &StorageMinerStruct{} +var _ api.Common = &CommonStruct{} +var _ api.FullNode = &FullNodeStruct{} +var _ api.StorageMiner = &StorageMinerStruct{} diff --git a/api/cbor_gen.go b/api/cbor_gen.go index 15464c648..7e1192037 100644 --- a/api/cbor_gen.go +++ b/api/cbor_gen.go @@ -18,16 +18,29 @@ func (t *PaymentInfo) MarshalCBOR(w io.Writer) error { _, err := w.Write(cbg.CborNull) return err } - if _, err := w.Write([]byte{131}); err != nil { + if _, err := w.Write([]byte{163}); err != nil { + return err + } + + // t.Channel (address.Address) (struct) + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Channel")))); err != nil { + return err + } + if _, err := w.Write([]byte("Channel")); err != nil { return err } - // t.t.Channel (address.Address) (struct) if err := t.Channel.MarshalCBOR(w); err != nil { return err } - // t.t.ChannelMessage (cid.Cid) (struct) + // t.ChannelMessage (cid.Cid) (struct) + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("ChannelMessage")))); err != nil { + return err + } + if _, err := w.Write([]byte("ChannelMessage")); err != nil { + return err + } if t.ChannelMessage == nil { if _, err := w.Write(cbg.CborNull); err != nil { @@ -39,7 +52,14 @@ func (t *PaymentInfo) MarshalCBOR(w io.Writer) error { } } - // t.t.Vouchers ([]*types.SignedVoucher) (slice) + // t.Vouchers ([]*types.SignedVoucher) (slice) + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Vouchers")))); err != nil { + return err + } + if _, err := w.Write([]byte("Vouchers")); err != nil { + return err + } + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Vouchers)))); err != nil { return err } @@ -58,15 +78,30 @@ func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error { if err != nil { return err } - if maj != cbg.MajArray { - return fmt.Errorf("cbor input should be of type array") + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") } if extra != 3 { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Channel (address.Address) (struct) + var name string + + // t.Channel (address.Address) (struct) + + { + sval, err := cbg.ReadString(br) + if err != nil { + return err + } + + name = string(sval) + } + + if name != "Channel" { + return fmt.Errorf("expected struct map entry %s to be Channel", name) + } { @@ -75,7 +110,20 @@ func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error { } } - // t.t.ChannelMessage (cid.Cid) (struct) + // t.ChannelMessage (cid.Cid) (struct) + + { + sval, err := cbg.ReadString(br) + if err != nil { + return err + } + + name = string(sval) + } + + if name != "ChannelMessage" { + return fmt.Errorf("expected struct map entry %s to be ChannelMessage", name) + } { @@ -99,7 +147,20 @@ func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Vouchers ([]*types.SignedVoucher) (slice) + // t.Vouchers ([]*types.SignedVoucher) (slice) + + { + sval, err := cbg.ReadString(br) + if err != nil { + return err + } + + name = string(sval) + } + + if name != "Vouchers" { + return fmt.Errorf("expected struct map entry %s to be Vouchers", name) + } maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -134,21 +195,42 @@ func (t *SealedRef) MarshalCBOR(w io.Writer) error { _, err := w.Write(cbg.CborNull) return err } - if _, err := w.Write([]byte{131}); err != nil { + if _, err := w.Write([]byte{163}); err != nil { + return err + } + + // t.SectorID (uint64) (uint64) + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("SectorID")))); err != nil { + return err + } + if _, err := w.Write([]byte("SectorID")); err != nil { return err } - // t.t.SectorID (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SectorID))); err != nil { return err } - // t.t.Offset (uint64) (uint64) + // t.Offset (uint64) (uint64) + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Offset")))); err != nil { + return err + } + if _, err := w.Write([]byte("Offset")); err != nil { + return err + } + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Offset))); err != nil { return err } - // t.t.Size (uint64) (uint64) + // t.Size (uint64) (uint64) + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Size")))); err != nil { + return err + } + if _, err := w.Write([]byte("Size")); err != nil { + return err + } + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Size))); err != nil { return err } @@ -162,15 +244,30 @@ func (t *SealedRef) UnmarshalCBOR(r io.Reader) error { if err != nil { return err } - if maj != cbg.MajArray { - return fmt.Errorf("cbor input should be of type array") + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") } if extra != 3 { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.SectorID (uint64) (uint64) + var name string + + // t.SectorID (uint64) (uint64) + + { + sval, err := cbg.ReadString(br) + if err != nil { + return err + } + + name = string(sval) + } + + if name != "SectorID" { + return fmt.Errorf("expected struct map entry %s to be SectorID", name) + } maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -180,7 +277,20 @@ func (t *SealedRef) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.SectorID = uint64(extra) - // t.t.Offset (uint64) (uint64) + // t.Offset (uint64) (uint64) + + { + sval, err := cbg.ReadString(br) + if err != nil { + return err + } + + name = string(sval) + } + + if name != "Offset" { + return fmt.Errorf("expected struct map entry %s to be Offset", name) + } maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -190,7 +300,20 @@ func (t *SealedRef) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Offset = uint64(extra) - // t.t.Size (uint64) (uint64) + // t.Size (uint64) (uint64) + + { + sval, err := cbg.ReadString(br) + if err != nil { + return err + } + + name = string(sval) + } + + if name != "Size" { + return fmt.Errorf("expected struct map entry %s to be Size", name) + } maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -208,11 +331,18 @@ func (t *SealedRefs) MarshalCBOR(w io.Writer) error { _, err := w.Write(cbg.CborNull) return err } - if _, err := w.Write([]byte{129}); err != nil { + if _, err := w.Write([]byte{161}); err != nil { + return err + } + + // t.Refs ([]api.SealedRef) (slice) + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Refs")))); err != nil { + return err + } + if _, err := w.Write([]byte("Refs")); err != nil { return err } - // t.t.Refs ([]api.SealedRef) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Refs)))); err != nil { return err } @@ -231,15 +361,30 @@ func (t *SealedRefs) UnmarshalCBOR(r io.Reader) error { if err != nil { return err } - if maj != cbg.MajArray { - return fmt.Errorf("cbor input should be of type array") + if maj != cbg.MajMap { + return fmt.Errorf("cbor input should be of type map") } if extra != 1 { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Refs ([]api.SealedRef) (slice) + var name string + + // t.Refs ([]api.SealedRef) (slice) + + { + sval, err := cbg.ReadString(br) + if err != nil { + return err + } + + name = string(sval) + } + + if name != "Refs" { + return fmt.Errorf("expected struct map entry %s to be Refs", name) + } maj, extra, err = cbg.CborReadHeader(br) if err != nil { diff --git a/api/client/client.go b/api/client/client.go index ffca93363..0e19f65c2 100644 --- a/api/client/client.go +++ b/api/client/client.go @@ -1,6 +1,7 @@ package client import ( + "github.com/filecoin-project/lotus/api/apistruct" "net/http" "github.com/filecoin-project/lotus/api" @@ -9,7 +10,7 @@ import ( // NewCommonRPC creates a new http jsonrpc client. func NewCommonRPC(addr string, requestHeader http.Header) (api.Common, jsonrpc.ClientCloser, error) { - var res api.CommonStruct + var res apistruct.CommonStruct closer, err := jsonrpc.NewMergeClient(addr, "Filecoin", []interface{}{ &res.Internal, @@ -20,7 +21,7 @@ func NewCommonRPC(addr string, requestHeader http.Header) (api.Common, jsonrpc.C // NewFullNodeRPC creates a new http jsonrpc client. func NewFullNodeRPC(addr string, requestHeader http.Header) (api.FullNode, jsonrpc.ClientCloser, error) { - var res api.FullNodeStruct + var res apistruct.FullNodeStruct closer, err := jsonrpc.NewMergeClient(addr, "Filecoin", []interface{}{ &res.CommonStruct.Internal, @@ -32,7 +33,7 @@ func NewFullNodeRPC(addr string, requestHeader http.Header) (api.FullNode, jsonr // NewStorageMinerRPC creates a new http jsonrpc client for storage miner func NewStorageMinerRPC(addr string, requestHeader http.Header) (api.StorageMiner, jsonrpc.ClientCloser, error) { - var res api.StorageMinerStruct + var res apistruct.StorageMinerStruct closer, err := jsonrpc.NewMergeClient(addr, "Filecoin", []interface{}{ &res.CommonStruct.Internal, diff --git a/build/bootstrap/bootstrappers.pi b/build/bootstrap/bootstrappers.pi index 64a8787b7..9c619b1bb 100644 --- a/build/bootstrap/bootstrappers.pi +++ b/build/bootstrap/bootstrappers.pi @@ -1,2 +1,6 @@ -/ip4/147.75.80.29/tcp/1347/p2p/12D3KooWDzb12XyoKT4uJAqmRVsSYqY9EZczXeWJ7WqehugBTVAT -/ip4/147.75.80.17/tcp/1347/p2p/12D3KooWDsfpmaYPouFT2RxvSf8eCuUS63T4dAKvDPqzWKdv7Qc7 +/dns4/lotus-bootstrap-0.dfw.fil-test.net/tcp/1347/p2p/12D3KooWHwGBSiLR5ts7KW9MgH4BMzC2iXe18kwAQ8Ee3LUd1jeR +/dns4/lotus-bootstrap-1.dfw.fil-test.net/tcp/1347/p2p/12D3KooWCLFaawdhLGcSpiqg43DtZ9QzPQ6HcB8Vvyu2Cnta8UWc +/dns4/lotus-bootstrap-0.fra.fil-test.net/tcp/1347/p2p/12D3KooWMmaL7eaUCF6tVAghVmgozxz4uztbuFUQv6dyFpHRarHR +/dns4/lotus-bootstrap-1.fra.fil-test.net/tcp/1347/p2p/12D3KooWLLpNYoKdf9NgcWudBhXLdTcXncqAsTzozw1scMMu6nS5 +/dns4/lotus-bootstrap-0.sin.fil-test.net/tcp/1347/p2p/12D3KooWCNL9vXaXwNs3Bu8uRAJK4pxpCyPeM7jZLSDpJma1wrV8 +/dns4/lotus-bootstrap-1.sin.fil-test.net/tcp/1347/p2p/12D3KooWNGGxFda1eC5U2YKAgs4ypoFHn3Z3xHCsjmFdrCcytoxm diff --git a/build/genesis/devnet.car b/build/genesis/devnet.car index 2810d469f..d0aef2486 100644 Binary files a/build/genesis/devnet.car and b/build/genesis/devnet.car differ diff --git a/build/paramfetch.go b/build/paramfetch.go index b647f675b..14bb80f29 100644 --- a/build/paramfetch.go +++ b/build/paramfetch.go @@ -25,6 +25,7 @@ var log = logging.Logger("build") //const gateway = "http://198.211.99.118/ipfs/" const gateway = "https://ipfs.io/ipfs/" const paramdir = "/var/tmp/filecoin-proof-parameters" +const dirEnv = "FIL_PROOFS_PARAMETER_CACHE" type paramFile struct { Cid string `json:"cid"` @@ -39,8 +40,15 @@ type fetch struct { errs []error } +func getParamDir() string { + if os.Getenv(dirEnv) == "" { + return paramdir + } + return os.Getenv(dirEnv) +} + func GetParams(storageSize uint64) error { - if err := os.Mkdir(paramdir, 0755); err != nil && !os.IsExist(err) { + if err := os.Mkdir(getParamDir(), 0755); err != nil && !os.IsExist(err) { return err } @@ -70,7 +78,7 @@ func (ft *fetch) maybeFetchAsync(name string, info paramFile) { go func() { defer ft.wg.Done() - path := filepath.Join(paramdir, name) + path := filepath.Join(getParamDir(), name) err := ft.checkFile(path, info) if !os.IsNotExist(err) && err != nil { diff --git a/build/params_debug.go b/build/params_debug.go index 093566aa7..938b03925 100644 --- a/build/params_debug.go +++ b/build/params_debug.go @@ -29,6 +29,9 @@ const InteractivePoRepDelay = 2 // Epochs const InteractivePoRepConfidence = 6 +// Bytes +var MinimumMinerPower uint64 = 2 << 10 // 2KiB + func init() { os.Setenv("TRUST_PARAMS", "1") } diff --git a/build/params_shared.go b/build/params_shared.go index 3d3bc9aac..97fe788d3 100644 --- a/build/params_shared.go +++ b/build/params_shared.go @@ -25,7 +25,7 @@ func SupportedSectorSize(ssize uint64) bool { // Payments // Epochs -const PaymentChannelClosingDelay = 6 * 60 * 2 // six hours +const PaymentChannelClosingDelay = 6 * 60 * 60 / BlockDelay // six hours // ///// // Consensus / Network @@ -83,10 +83,6 @@ var InitialReward *big.Int const FilecoinPrecision = 1_000_000_000_000_000_000 -// six years -// Epochs -const HalvingPeriodEpochs = 6 * 365 * 24 * 60 * 2 - // TODO: Move other important consts here func init() { diff --git a/build/params_devnet.go b/build/params_testnet.go similarity index 82% rename from build/params_devnet.go rename to build/params_testnet.go index f187bf60a..aa75ebcd7 100644 --- a/build/params_devnet.go +++ b/build/params_testnet.go @@ -3,16 +3,14 @@ package build var SectorSizes = []uint64{ - 16 << 20, - 256 << 20, 1 << 30, 32 << 30, } // Seconds -const BlockDelay = 30 +const BlockDelay = 45 -const PropagationDelay = 5 +const PropagationDelay = 6 // FallbackPoStDelay is the number of epochs the miner needs to wait after // ElectionPeriodStart before starting fallback post computation @@ -31,3 +29,6 @@ const InteractivePoRepDelay = 8 // Epochs const InteractivePoRepConfidence = 6 + +// Bytes +var MinimumMinerPower uint64 = 512 << 30 // 512GB diff --git a/build/proof-params/parameters.json b/build/proof-params/parameters.json index 9093cf15e..7e1988a41 100644 --- a/build/proof-params/parameters.json +++ b/build/proof-params/parameters.json @@ -1,54 +1,54 @@ { - "v20-proof-of-spacetime-election-09ae025de08399327e14f0cb6b4c907b6fe1e8b77046e31de8921bde588de900.params": { - "cid": "QmbbP455Dmu4GvEYgJTJjDvN8pj98cAKBQWgo4wmzUQhHM", - "digest": "34ecd0781d730a78f905c93dc35f107b", - "sector_size": 268435456 - }, - "v20-proof-of-spacetime-election-09ae025de08399327e14f0cb6b4c907b6fe1e8b77046e31de8921bde588de900.vk": { - "cid": "QmUEsQPP46mjiZkFoVdgJMBt8yhDxrzGTdqExWHAMA2eAX", - "digest": "cb5096105e25070e4894f682a0e7ce7e", - "sector_size": 268435456 - }, - "v20-proof-of-spacetime-election-4a2342062706429612fac099694f77294e355c6c9265b80feaff12a0268b0a92.params": { - "cid": "QmNegxzrsuFT9Z44B1zyxYGsxjUn5zVTCAqyBU6fp4X1Lw", - "digest": "1d3e2add91e31a4c7ad7f985d758e844", - "sector_size": 1024 - }, - "v20-proof-of-spacetime-election-4a2342062706429612fac099694f77294e355c6c9265b80feaff12a0268b0a92.vk": { - "cid": "QmSDyi3BQrYXTQp4vSVAjZSF2RfU5iZJzzJ8jM5WSMTgjd", - "digest": "21f6b4c8fb316c41a7b2ffd0e2bf39ca", - "sector_size": 1024 - }, - "v20-proof-of-spacetime-election-512f5e6dc00a37fa13c8b0e468188f85957b7bf1ab36d17fb9fe9ed49ae8d657.params": { - "cid": "QmQQhB1g98j3bPQLTnvUcMLzqhAaFjpE6giwMZp4BkLSkj", - "digest": "54c4ef0dffee9b3f52319ae0a13e0ed0", - "sector_size": 1073741824 - }, - "v20-proof-of-spacetime-election-512f5e6dc00a37fa13c8b0e468188f85957b7bf1ab36d17fb9fe9ed49ae8d657.vk": { - "cid": "QmcDgvf8B7LNNG1UD9JQ9srbmGCqWQ3SpYnSt11Q7M6N6o", - "digest": "f3cd7afac7b4635c7d90ce7108539649", - "sector_size": 1073741824 - }, - "v20-proof-of-spacetime-election-6c7cbfe7eed40b6c0b23a213a70648770aed65d9ca03ae85451573c18532304b.params": { - "cid": "QmX2Tfu49qnSUbz42s9jPf7WTVjmAPNAXFzqroAAWXN4ms", - "digest": "5078bde58986f57f4393e96be9623536", - "sector_size": 16777216 - }, - "v20-proof-of-spacetime-election-6c7cbfe7eed40b6c0b23a213a70648770aed65d9ca03ae85451573c18532304b.vk": { - "cid": "QmaTM9V7AguRAHbjsadVKtHdVvXS8k18qt8rh1S1JPPyJT", - "digest": "2a1d0da743c8162a937ca21e15424d3f", - "sector_size": 16777216 - }, - "v20-proof-of-spacetime-election-7e98e29a3b6fd661ce53507e168a8194bc7c8a29aa069b5c057d95462a8fcf9f.params": { - "cid": "QmRkidQgNyNiG39ikHrQ4pWv6VzVuSNT8f6JG5i6W2BfJG", - "digest": "81906993f9e4525345074c88c6238f61", + "v20-proof-of-spacetime-election-5f585aca354eb68e411c8582ed0efd800792430e4e76d73468c4fc03f1a8d6d2.params": { + "cid": "QmX7tYeNPWae2fjZ3Am6GB9dmHvLqvoz8dKo3PR98VYxH9", + "digest": "39a9edec3355516674f0d12b926be493", "sector_size": 34359738368 }, - "v20-proof-of-spacetime-election-7e98e29a3b6fd661ce53507e168a8194bc7c8a29aa069b5c057d95462a8fcf9f.vk": { - "cid": "QmTcr7okdprbf2rak2t9S7DZEN4i6sKzJSiSigL36d7Qb5", - "digest": "95638189775b411a489980cb3839cf3d", + "v20-proof-of-spacetime-election-5f585aca354eb68e411c8582ed0efd800792430e4e76d73468c4fc03f1a8d6d2.vk": { + "cid": "QmbNGx7pNbGiEr8ykoHxVXHW2LNSmGdsxKtj1onZCyguCX", + "digest": "0227ae7df4f2affe529ebafbbc7540ee", "sector_size": 34359738368 }, + "v20-proof-of-spacetime-election-a4e18190d4b4657ba1b4d08a341871b2a6f398e327cb9951b28ab141fbdbf49d.params": { + "cid": "QmRGZsNp4mp1cZshcXqt3VMuWscAEsiMa2iepF4CsWWoiv", + "digest": "991041a354b12c280542741f58c7f2ca", + "sector_size": 1024 + }, + "v20-proof-of-spacetime-election-a4e18190d4b4657ba1b4d08a341871b2a6f398e327cb9951b28ab141fbdbf49d.vk": { + "cid": "QmWpmrhCGVcfqLyqp5oGAnhPmCE5hGTPaauHi25mpQwRSU", + "digest": "91fac550e1f9bccab213830bb0c85bd6", + "sector_size": 1024 + }, + "v20-proof-of-spacetime-election-a9eb6d90b896a282ec2d3a875c6143e3fcff778f0da1460709e051833651559b.params": { + "cid": "QmenSZXh1EsSyHiSRvA6wb8yaPhYBTjrKehJw96Px5HnN4", + "digest": "6322eacd2773163ddd51f9ca7d645fc4", + "sector_size": 1073741824 + }, + "v20-proof-of-spacetime-election-a9eb6d90b896a282ec2d3a875c6143e3fcff778f0da1460709e051833651559b.vk": { + "cid": "QmPvZoMKofw6eDhDg5ESJA2QAZP8HvM6qMQk7fw4pq9bQf", + "digest": "0df62745fceac922e3e70847cfc70b52", + "sector_size": 1073741824 + }, + "v20-proof-of-spacetime-election-bf872523641b1de33553db2a177df13e412d7b3b0103e6696ae0a1cf5d525259.params": { + "cid": "QmVibFqzkZoL8cwQmzj8njPokCQGCCx4pBcUH77bzgJgV9", + "digest": "de9d71e672f286706a1673bd57abdaac", + "sector_size": 16777216 + }, + "v20-proof-of-spacetime-election-bf872523641b1de33553db2a177df13e412d7b3b0103e6696ae0a1cf5d525259.vk": { + "cid": "QmZa5FX27XyiEXQQLQpHqtMJKLzrcY8wMuj3pxzmSimSyu", + "digest": "7f796d3a0f13499181e44b5eee0cc744", + "sector_size": 16777216 + }, + "v20-proof-of-spacetime-election-ffc3fb192364238b60977839d14e3154d4a98313e30d46694a12af54b6874975.params": { + "cid": "Qmbt2SWWAmMcYoY3DAiRDXA8fAuqdqRLWucJMSxYmzBCmN", + "digest": "151ae0ae183fc141e8c2bebc28e5cc10", + "sector_size": 268435456 + }, + "v20-proof-of-spacetime-election-ffc3fb192364238b60977839d14e3154d4a98313e30d46694a12af54b6874975.vk": { + "cid": "QmUxvPu4xdVmjMFihUKoYyEdXBqxsXkvmxRweU7KouWHji", + "digest": "95eb89588e9d1832aca044c3a13178af", + "sector_size": 268435456 + }, "v20-stacked-proof-of-replication-117839dacd1ef31e5968a6fd13bcd6fa86638d85c40c9241a1d07c2a954eb89b.params": { "cid": "QmQZe8eLo2xXbhSDxtyYZNqEjqjdcWGdADywECRvNEZQdX", "digest": "fcd50e2e08a8560a6bb3418e883567ed", @@ -99,4 +99,5 @@ "digest": "834408e5c3fce6ec5d1bf64e64cee94e", "sector_size": 16777216 } -} \ No newline at end of file +} + diff --git a/build/version.go b/build/version.go index 8ff70926d..10832a76a 100644 --- a/build/version.go +++ b/build/version.go @@ -1,7 +1,7 @@ package build // Version is the local build version, set by build system -const Version = "0.11.0" +const Version = "0.1.0" // APIVersion is a hex semver version of the rpc api exposed // @@ -12,15 +12,19 @@ const Version = "0.11.0" // R R H // |\vv/| // vv vv -const APIVersion = 0x000b01 +const APIVersion = 0x000100 const ( MajorMask = 0xff0000 MinorMask = 0xffff00 PatchMask = 0xffffff + + MajorOnlyMask = 0xff0000 + MinorOnlyMask = 0x00ff00 + PatchOnlyMask = 0x0000ff ) // VersionInts returns (major, minor, patch) versions func VersionInts(version uint32) (uint32, uint32, uint32) { - return (version & MajorMask) >> 16, (version & MinorMask) >> 8, version & PatchMask + return (version & MajorOnlyMask) >> 16, (version & MinorOnlyMask) >> 8, version & PatchOnlyMask } diff --git a/chain/actors/actor_miner.go b/chain/actors/actor_miner.go index 6c775eac0..3360f5e25 100644 --- a/chain/actors/actor_miner.go +++ b/chain/actors/actor_miner.go @@ -53,14 +53,10 @@ type StorageMinerActorState struct { // Contains mostly static info about this miner Info cid.Cid - // Faulty sectors reported since last SubmitPost, - // up to the current proving period's challenge time. - CurrentFaultSet types.BitField + // Faulty sectors reported since last SubmitPost + FaultSet types.BitField - // Faults submitted after the current proving period's challenge time, - // but before the PoSt for that period is submitted. - // These become the currentFaultSet when a PoSt is submitted. - NextFaultSet types.BitField + LastFaultSubmission uint64 // Amount of power this miner has. Power types.BigInt @@ -340,7 +336,7 @@ func (sma StorageMinerActor) ProveCommitSector(act *types.Actor, vmctx types.VMC return nil, aerrors.Wrapf(err, "failed to compute data commitment (sector %d, deals: %v)", params.SectorID, params.DealIDs) } - if ok, err := ValidatePoRep(ctx, maddr, mi.SectorSize, commD, us.Info.CommR, ticket, params.Proof, seed, params.SectorID); err != nil { + if ok, err := vmctx.Sys().ValidatePoRep(ctx, maddr, mi.SectorSize, commD, us.Info.CommR, ticket, params.Proof, seed, params.SectorID); err != nil { return nil, err } else if !ok { return nil, aerrors.Newf(2, "porep proof was invalid (t:%x; s:%x(%d); p:%s)", ticket, seed, us.ReceivedEpoch+build.InteractivePoRepDelay, truncateHexPrint(params.Proof)) @@ -463,8 +459,17 @@ func (sma StorageMinerActor) SubmitFallbackPoSt(act *types.Actor, vmctx types.VM return nil, aerrors.HandleExternalError(lerr, "could not load proving set node") } + faults, nerr := self.FaultSet.AllMap() + if nerr != nil { + return nil, aerrors.Absorb(err, 5, "RLE+ invalid") + } + var sectorInfos []ffi.PublicSectorInfo if err := pss.ForEach(func(id uint64, v *cbg.Deferred) error { + if faults[id] { + return nil + } + var comms [][]byte if err := cbor.DecodeInto(v.Raw, &comms); err != nil { return xerrors.New("could not decode comms") @@ -485,12 +490,6 @@ func (sma StorageMinerActor) SubmitFallbackPoSt(act *types.Actor, vmctx types.VM return nil, aerrors.Absorb(err, 3, "could not decode sectorset") } - faults, nerr := self.CurrentFaultSet.All() - if nerr != nil { - return nil, aerrors.Absorb(err, 5, "RLE+ invalid") - } - _ = faults - proverID := vmctx.Message().To // TODO: normalize to ID address var candidates []sectorbuilder.EPostCandidate @@ -598,6 +597,25 @@ func GetFromSectorSet(ctx context.Context, s types.Storage, ss cid.Cid, sectorID return true, comms[0], comms[1], nil } +func RemoveFromSectorSet(ctx context.Context, s types.Storage, ss cid.Cid, ids []uint64) (cid.Cid, aerrors.ActorError) { + + ssr, err := amt.LoadAMT(types.WrapStorage(s), ss) + if err != nil { + return cid.Undef, aerrors.HandleExternalError(err, "could not load sector set node") + } + + if err := ssr.BatchDelete(ids); err != nil { + return cid.Undef, aerrors.HandleExternalError(err, "failed to delete from sector set") + } + + ncid, err := ssr.Flush() + if err != nil { + return cid.Undef, aerrors.HandleExternalError(err, "failed to flush sector set") + } + + return ncid, nil +} + func ValidatePoRep(ctx context.Context, maddr address.Address, ssize uint64, commD, commR, ticket, proof, seed []byte, sectorID uint64) (bool, ActorError) { _, span := trace.StartSpan(ctx, "ValidatePoRep") defer span.End() @@ -787,34 +805,28 @@ type DeclareFaultsParams struct { } func (sma StorageMinerActor) DeclareFaults(act *types.Actor, vmctx types.VMContext, params *DeclareFaultsParams) ([]byte, ActorError) { - /* - oldstate, self, aerr := loadState(vmctx) - if aerr != nil { - return nil, aerr - } + oldstate, self, aerr := loadState(vmctx) + if aerr != nil { + return nil, aerr + } - challengeHeight := self.ProvingPeriodEnd - build.PoStChallangeTime + nfaults, err := types.MergeBitFields(params.Faults, self.FaultSet) + if err != nil { + return nil, aerrors.Absorb(err, 1, "failed to merge bitfields") + } - if vmctx.BlockHeight() < challengeHeight { - // TODO: optimized bitfield methods - for _, v := range params.Faults.All() { - self.CurrentFaultSet.Set(v) - } - } else { - for _, v := range params.Faults.All() { - self.NextFaultSet.Set(v) - } - } + self.FaultSet = nfaults - nstate, err := vmctx.Storage().Put(self) - if err != nil { - return nil, err - } - if err := vmctx.Storage().Commit(oldstate, nstate); err != nil { - return nil, err - } + self.LastFaultSubmission = vmctx.BlockHeight() + + nstate, aerr := vmctx.Storage().Put(self) + if err != nil { + return nil, aerr + } + if err := vmctx.Storage().Commit(oldstate, nstate); err != nil { + return nil, err + } - */ return nil, nil } @@ -906,14 +918,22 @@ func onSuccessfulPoSt(self *StorageMinerActorState, vmctx types.VMContext) aerro return aerrors.HandleExternalError(nerr, "failed to load proving set") } - self.CurrentFaultSet = self.NextFaultSet - self.NextFaultSet = types.NewBitField() + faults, nerr := self.FaultSet.All() + if nerr != nil { + return aerrors.Absorb(nerr, 1, "invalid bitfield (fatal?)") + } - faults := []uint64{} // TODO + self.FaultSet = types.NewBitField() oldPower := self.Power - self.Power = types.BigMul(types.NewInt(pss.Count-uint64(len(faults))), - types.NewInt(mi.SectorSize)) + newPower := types.BigMul(types.NewInt(pss.Count-uint64(len(faults))), types.NewInt(mi.SectorSize)) + + // If below the minimum size requirement, miners have zero power + if newPower.LessThan(types.NewInt(build.MinimumMinerPower)) { + newPower = types.NewInt(0) + } + + self.Power = newPower delta := types.BigSub(self.Power, oldPower) if self.SlashedAt != 0 { @@ -922,26 +942,34 @@ func onSuccessfulPoSt(self *StorageMinerActorState, vmctx types.VMContext) aerro } prevSlashingDeadline := self.ElectionPeriodStart + build.SlashablePowerDelay - if !self.Active { + if !self.Active && newPower.GreaterThan(types.NewInt(0)) { self.Active = true prevSlashingDeadline = 0 } - enc, err := SerializeParams(&UpdateStorageParams{ - Delta: delta, - NextProvingPeriodEnd: vmctx.BlockHeight() + build.SlashablePowerDelay, - PreviousProvingPeriodEnd: prevSlashingDeadline, - }) + if !(oldPower.IsZero() && newPower.IsZero()) { + enc, err := SerializeParams(&UpdateStorageParams{ + Delta: delta, + NextProvingPeriodEnd: vmctx.BlockHeight() + build.SlashablePowerDelay, + PreviousProvingPeriodEnd: prevSlashingDeadline, + }) + if err != nil { + return err + } + + _, err = vmctx.Send(StoragePowerAddress, SPAMethods.UpdateStorage, types.NewInt(0), enc) + if err != nil { + return err + } + } + + ncid, err := RemoveFromSectorSet(vmctx.Context(), vmctx.Storage(), self.Sectors, faults) if err != nil { return err } - _, err = vmctx.Send(StoragePowerAddress, SPAMethods.UpdateStorage, types.NewInt(0), enc) - if err != nil { - return err - } - - self.ProvingSet = self.Sectors + self.Sectors = ncid + self.ProvingSet = ncid self.ElectionPeriodStart = vmctx.BlockHeight() return nil } diff --git a/chain/actors/actor_miner_test.go b/chain/actors/actor_miner_test.go new file mode 100644 index 000000000..28a5ce046 --- /dev/null +++ b/chain/actors/actor_miner_test.go @@ -0,0 +1,157 @@ +package actors_test + +import ( + "bytes" + "context" + "math/rand" + "testing" + + "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/actors/aerrors" + "github.com/filecoin-project/lotus/chain/address" + "github.com/filecoin-project/lotus/chain/stmgr" + "github.com/filecoin-project/lotus/chain/types" + "github.com/filecoin-project/lotus/lib/sectorbuilder" + hamt "github.com/ipfs/go-hamt-ipld" + blockstore "github.com/ipfs/go-ipfs-blockstore" + cbg "github.com/whyrusleeping/cbor-gen" +) + +func TestMinerCommitSectors(t *testing.T) { + var worker, client address.Address + var minerAddr address.Address + opts := []HarnessOpt{ + HarnessAddr(&worker, 1000000), + HarnessAddr(&client, 1000000), + HarnessActor(&minerAddr, &worker, actors.StorageMinerCodeCid, + func() cbg.CBORMarshaler { + return &actors.StorageMinerConstructorParams{ + Owner: worker, + Worker: worker, + SectorSize: 1024, + PeerID: "fakepeerid", + } + }), + } + + h := NewHarness(t, opts...) + h.vm.Syscalls.ValidatePoRep = func(ctx context.Context, maddr address.Address, ssize uint64, commD, commR, ticket, proof, seed []byte, sectorID uint64) (bool, aerrors.ActorError) { + // all proofs are valid + return true, nil + } + + ret, _ := h.SendFunds(t, worker, minerAddr, types.NewInt(100000)) + ApplyOK(t, ret) + + ret, _ = h.InvokeWithValue(t, client, actors.StorageMarketAddress, actors.SMAMethods.AddBalance, types.NewInt(2000), nil) + ApplyOK(t, ret) + + addSectorToMiner(h, t, minerAddr, worker, client, 1) + + assertSectorIDs(h, t, minerAddr, []uint64{1}) +} + +func addSectorToMiner(h *Harness, t *testing.T, minerAddr, worker, client address.Address, sid uint64) { + t.Helper() + s := sectorbuilder.UserBytesForSectorSize(1024) + deal := h.makeFakeDeal(t, minerAddr, worker, client, s) + ret, _ := h.Invoke(t, worker, actors.StorageMarketAddress, actors.SMAMethods.PublishStorageDeals, + &actors.PublishStorageDealsParams{ + Deals: []actors.StorageDealProposal{*deal}, + }) + ApplyOK(t, ret) + var dealIds actors.PublishStorageDealResponse + if err := dealIds.UnmarshalCBOR(bytes.NewReader(ret.Return)); err != nil { + t.Fatal(err) + } + + dealid := dealIds.DealIDs[0] + + ret, _ = h.Invoke(t, worker, minerAddr, actors.MAMethods.PreCommitSector, + &actors.SectorPreCommitInfo{ + SectorNumber: sid, + CommR: []byte("cats"), + SealEpoch: 10, + DealIDs: []uint64{dealid}, + }) + ApplyOK(t, ret) + + h.BlockHeight += 100 + ret, _ = h.Invoke(t, worker, minerAddr, actors.MAMethods.ProveCommitSector, + &actors.SectorProveCommitInfo{ + Proof: []byte("prooofy"), + SectorID: sid, + DealIDs: []uint64{dealid}, // TODO: weird that i have to pass this again + }) + ApplyOK(t, ret) +} + +func assertSectorIDs(h *Harness, t *testing.T, maddr address.Address, ids []uint64) { + t.Helper() + sectors, err := getMinerSectorSet(context.TODO(), h.vm.StateTree(), h.bs, maddr) + if err != nil { + t.Fatal(err) + } + + if len(sectors) != len(ids) { + t.Fatal("miner has wrong number of sectors in their sector set") + } + + all := make(map[uint64]bool) + for _, s := range sectors { + all[s.SectorID] = true + } + + for _, id := range ids { + if !all[id] { + t.Fatal("expected to find sector ID: ", id) + } + } +} + +func getMinerSectorSet(ctx context.Context, st types.StateTree, bs blockstore.Blockstore, maddr address.Address) ([]*api.ChainSectorInfo, error) { + mact, err := st.GetActor(maddr) + if err != nil { + return nil, err + } + + cst := hamt.CSTFromBstore(bs) + + var mstate actors.StorageMinerActorState + if err := cst.Get(ctx, mact.Head, &mstate); err != nil { + return nil, err + } + + return stmgr.LoadSectorsFromSet(ctx, bs, mstate.Sectors) +} + +func (h *Harness) makeFakeDeal(t *testing.T, miner, worker, client address.Address, size uint64) *actors.StorageDealProposal { + data := make([]byte, size) + rand.Read(data) + commP, err := sectorbuilder.GeneratePieceCommitment(bytes.NewReader(data), size) + if err != nil { + t.Fatal(err) + } + + prop := actors.StorageDealProposal{ + PieceRef: commP[:], + PieceSize: size, + //PieceSerialization SerializationMode // Needs to be here as it tells how data in the sector maps to PieceRef cid + + Client: client, + Provider: miner, + + ProposalExpiration: 10000, + Duration: 150, + + StoragePricePerEpoch: types.NewInt(1), + StorageCollateral: types.NewInt(0), + } + + if err := api.SignWith(context.TODO(), h.w.Sign, client, &prop); err != nil { + t.Fatal(err) + } + + return &prop +} diff --git a/chain/actors/actor_paych_test.go b/chain/actors/actor_paych_test.go index e23acdf4a..55de306c0 100644 --- a/chain/actors/actor_paych_test.go +++ b/chain/actors/actor_paych_test.go @@ -83,7 +83,7 @@ func TestPaychUpdate(t *testing.T) { ApplyOK(t, ret) // now we have to 'wait' for the chain to advance. - h.vm.SetBlockHeight(1000) + h.BlockHeight = 1000 ret, _ = h.Invoke(t, targetAddr, pch, actors.PCAMethods.Collect, nil) ApplyOK(t, ret) diff --git a/chain/actors/actor_storagemarket.go b/chain/actors/actor_storagemarket.go index 651fd8f71..dd3e78bec 100644 --- a/chain/actors/actor_storagemarket.go +++ b/chain/actors/actor_storagemarket.go @@ -3,6 +3,8 @@ package actors import ( "bytes" "context" + "sort" + "golang.org/x/xerrors" "github.com/filecoin-project/go-amt-ipld" @@ -73,9 +75,8 @@ const ( ) type StorageDealProposal struct { - PieceRef []byte // cid bytes // TODO: spec says to use cid.Cid, probably not a good idea - PieceSize uint64 - PieceSerialization SerializationMode // Needs to be here as it tells how data in the sector maps to PieceRef cid + PieceRef []byte // cid bytes // TODO: spec says to use cid.Cid, probably not a good idea + PieceSize uint64 Client address.Address Provider address.Address @@ -131,36 +132,19 @@ func (sdp *StorageDealProposal) Verify() error { return sdp.ProposerSignature.Verify(sdp.Client, buf.Bytes()) } -func (d *StorageDeal) Sign(ctx context.Context, sign SignFunc) error { - var buf bytes.Buffer - if err := d.Proposal.MarshalCBOR(&buf); err != nil { - return err - } - sig, err := sign(ctx, buf.Bytes()) - if err != nil { - return err - } - d.CounterSignature = sig - return nil -} - -func (d *StorageDeal) Verify(proposerWorker address.Address) error { - var buf bytes.Buffer - if err := d.Proposal.MarshalCBOR(&buf); err != nil { - return err - } - - return d.CounterSignature.Verify(proposerWorker, buf.Bytes()) -} - -type StorageDeal struct { - Proposal StorageDealProposal - CounterSignature *types.Signature -} - type OnChainDeal struct { - Deal StorageDeal - ActivationEpoch uint64 // 0 = inactive + PieceRef []byte // cid bytes // TODO: spec says to use cid.Cid, probably not a good idea + PieceSize uint64 + + Client address.Address + Provider address.Address + + ProposalExpiration uint64 + Duration uint64 // TODO: spec + + StoragePricePerEpoch types.BigInt + StorageCollateral types.BigInt + ActivationEpoch uint64 // 0 = inactive } type WithdrawBalanceParams struct { @@ -245,8 +229,15 @@ func (sma StorageMarketActor) AddBalance(act *types.Actor, vmctx types.VMContext } func setMarketBalances(vmctx types.VMContext, nd *hamt.Node, set map[address.Address]StorageParticipantBalance) (cid.Cid, ActorError) { - for addr, b := range set { - balance := b // to stop linter complaining + keys := make([]address.Address, 0, len(set)) + for k := range set { + keys = append(keys, k) + } + sort.Slice(keys, func(i, j int) bool { + return bytes.Compare(keys[i].Bytes(), keys[j].Bytes()) < 0 + }) + for _, addr := range keys { + balance := set[addr] if err := nd.Set(vmctx.Context(), string(addr.Bytes()), &balance); err != nil { return cid.Undef, aerrors.HandleExternalError(err, "setting new balance") } @@ -297,7 +288,7 @@ func (sma StorageMarketActor) CheckLockedBalance(act *types.Actor, vmctx types.V */ type PublishStorageDealsParams struct { - Deals []StorageDeal + Deals []StorageDealProposal } type PublishStorageDealResponse struct { @@ -326,7 +317,7 @@ func (sma StorageMarketActor) PublishStorageDeals(act *types.Actor, vmctx types. DealIDs: make([]uint64, len(params.Deals)), } - workerBytes, aerr := vmctx.Send(params.Deals[0].Proposal.Provider, MAMethods.GetWorkerAddr, types.NewInt(0), nil) + workerBytes, aerr := vmctx.Send(params.Deals[0].Provider, MAMethods.GetWorkerAddr, types.NewInt(0), nil) if aerr != nil { return nil, aerr } @@ -342,7 +333,20 @@ func (sma StorageMarketActor) PublishStorageDeals(act *types.Actor, vmctx types. return nil, err } - err := deals.Set(self.NextDealID, &OnChainDeal{Deal: deal}) + err := deals.Set(self.NextDealID, &OnChainDeal{ + PieceRef: deal.PieceRef, + PieceSize: deal.PieceSize, + + Client: deal.Client, + Provider: deal.Provider, + + ProposalExpiration: deal.ProposalExpiration, + Duration: deal.Duration, + + StoragePricePerEpoch: deal.StoragePricePerEpoch, + StorageCollateral: deal.StorageCollateral, + ActivationEpoch: 0, + }) if err != nil { return nil, aerrors.HandleExternalError(err, "setting deal in deal AMT") } @@ -376,34 +380,28 @@ func (sma StorageMarketActor) PublishStorageDeals(act *types.Actor, vmctx types. return outBuf.Bytes(), nil } -func (st *StorageMarketState) validateDeal(vmctx types.VMContext, deal StorageDeal, providerWorker address.Address) aerrors.ActorError { - if vmctx.BlockHeight() > deal.Proposal.ProposalExpiration { +func (st *StorageMarketState) validateDeal(vmctx types.VMContext, deal StorageDealProposal, providerWorker address.Address) aerrors.ActorError { + if vmctx.BlockHeight() > deal.ProposalExpiration { return aerrors.New(1, "deal proposal already expired") } - if err := deal.Proposal.Verify(); err != nil { - return aerrors.Absorb(err, 2, "verifying proposer signature") + if vmctx.Message().From != providerWorker { + return aerrors.New(2, "Deals must be submitted by the miner worker") } - err := deal.Verify(providerWorker) - if err != nil { - return aerrors.Absorb(err, 2, "verifying provider signature") - } - - // TODO: maybe this is actually fine - if vmctx.Message().From != providerWorker && vmctx.Message().From != deal.Proposal.Client { - return aerrors.New(4, "message not sent by deal participant") + if err := deal.Verify(); err != nil { + return aerrors.Absorb(err, 3, "verifying proposer signature") } // TODO: do some caching (changes gas so needs to be in spec too) - b, bnd, aerr := GetMarketBalances(vmctx.Context(), vmctx.Ipld(), st.Balances, deal.Proposal.Client, providerWorker) + b, bnd, aerr := GetMarketBalances(vmctx.Context(), vmctx.Ipld(), st.Balances, deal.Client, providerWorker) if aerr != nil { return aerrors.Wrap(aerr, "getting client, and provider balances") } clientBalance := b[0] providerBalance := b[1] - totalPrice := deal.Proposal.TotalStoragePrice() + totalPrice := deal.TotalStoragePrice() if clientBalance.Available.LessThan(totalPrice) { return aerrors.Newf(5, "client doesn't have enough available funds to cover storage price; %d < %d", clientBalance.Available, totalPrice) @@ -412,17 +410,17 @@ func (st *StorageMarketState) validateDeal(vmctx types.VMContext, deal StorageDe clientBalance = lockFunds(clientBalance, totalPrice) // TODO: REVIEW: Not clear who pays for this - if providerBalance.Available.LessThan(deal.Proposal.StorageCollateral) { - return aerrors.Newf(6, "provider doesn't have enough available funds to cover StorageCollateral; %d < %d", providerBalance.Available, deal.Proposal.StorageCollateral) + if providerBalance.Available.LessThan(deal.StorageCollateral) { + return aerrors.Newf(6, "provider doesn't have enough available funds to cover StorageCollateral; %d < %d", providerBalance.Available, deal.StorageCollateral) } - providerBalance = lockFunds(providerBalance, deal.Proposal.StorageCollateral) + providerBalance = lockFunds(providerBalance, deal.StorageCollateral) // TODO: piece checks (e.g. size > sectorSize)? bcid, aerr := setMarketBalances(vmctx, bnd, map[address.Address]StorageParticipantBalance{ - deal.Proposal.Client: clientBalance, - providerWorker: providerBalance, + deal.Client: clientBalance, + providerWorker: providerBalance, }) if aerr != nil { return aerr @@ -458,11 +456,11 @@ func (sma StorageMarketActor) ActivateStorageDeals(act *types.Actor, vmctx types return nil, aerrors.HandleExternalError(err, "getting deal info failed") } - if vmctx.Message().From != dealInfo.Deal.Proposal.Provider { + if vmctx.Message().From != dealInfo.Provider { return nil, aerrors.New(1, "ActivateStorageDeals can only be called by the deal provider") } - if vmctx.BlockHeight() > dealInfo.Deal.Proposal.ProposalExpiration { + if vmctx.BlockHeight() > dealInfo.ProposalExpiration { return nil, aerrors.New(2, "deal cannot be activated: proposal expired") } @@ -533,7 +531,7 @@ func (sma StorageMarketActor) ProcessStorageDealsPayment(act *types.Actor, vmctx return nil, aerrors.HandleExternalError(err, "getting deal info failed") } - if dealInfo.Deal.Proposal.Provider != vmctx.Message().From { + if dealInfo.Provider != vmctx.Message().From { return nil, aerrors.New(3, "ProcessStorageDealsPayment can only be called by deal provider") } @@ -542,15 +540,15 @@ func (sma StorageMarketActor) ProcessStorageDealsPayment(act *types.Actor, vmctx return nil, aerrors.New(4, "ActivationEpoch lower than block height") } - if vmctx.BlockHeight() > dealInfo.ActivationEpoch+dealInfo.Deal.Proposal.Duration { + if vmctx.BlockHeight() > dealInfo.ActivationEpoch+dealInfo.Duration { // Deal expired, miner should drop it // TODO: process payment for the remainder of last proving period return nil, nil } - toPay := types.BigMul(dealInfo.Deal.Proposal.StoragePricePerEpoch, types.NewInt(build.SlashablePowerDelay)) + toPay := types.BigMul(dealInfo.StoragePricePerEpoch, types.NewInt(build.SlashablePowerDelay)) - b, bnd, aerr := GetMarketBalances(vmctx.Context(), vmctx.Ipld(), self.Balances, dealInfo.Deal.Proposal.Client, providerWorker) + b, bnd, aerr := GetMarketBalances(vmctx.Context(), vmctx.Ipld(), self.Balances, dealInfo.Client, providerWorker) if aerr != nil { return nil, aerr } @@ -561,8 +559,8 @@ func (sma StorageMarketActor) ProcessStorageDealsPayment(act *types.Actor, vmctx // TODO: call set once bcid, aerr := setMarketBalances(vmctx, bnd, map[address.Address]StorageParticipantBalance{ - dealInfo.Deal.Proposal.Client: clientBal, - providerWorker: providerBal, + dealInfo.Client: clientBal, + providerWorker: providerBal, }) if aerr != nil { return nil, aerr @@ -625,15 +623,15 @@ func (sma StorageMarketActor) ComputeDataCommitment(act *types.Actor, vmctx type return nil, aerrors.HandleExternalError(err, "getting deal info failed") } - if dealInfo.Deal.Proposal.Provider != vmctx.Message().From { + if dealInfo.Provider != vmctx.Message().From { return nil, aerrors.New(5, "referenced deal was not from caller") } var commP [32]byte - copy(commP[:], dealInfo.Deal.Proposal.PieceRef) + copy(commP[:], dealInfo.PieceRef) pieces = append(pieces, sectorbuilder.PublicPieceInfo{ - Size: dealInfo.Deal.Proposal.PieceSize, + Size: dealInfo.PieceSize, CommP: commP, }) } diff --git a/chain/actors/cbor_gen.go b/chain/actors/cbor_gen.go index 111ba7532..83582a44b 100644 --- a/chain/actors/cbor_gen.go +++ b/chain/actors/cbor_gen.go @@ -25,13 +25,13 @@ func (t *InitActorState) MarshalCBOR(w io.Writer) error { return err } - // t.t.AddressMap (cid.Cid) (struct) + // t.AddressMap (cid.Cid) (struct) if err := cbg.WriteCid(w, t.AddressMap); err != nil { return xerrors.Errorf("failed to write cid field t.AddressMap: %w", err) } - // t.t.NextID (uint64) (uint64) + // t.NextID (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.NextID))); err != nil { return err } @@ -53,7 +53,7 @@ func (t *InitActorState) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.AddressMap (cid.Cid) (struct) + // t.AddressMap (cid.Cid) (struct) { @@ -65,7 +65,7 @@ func (t *InitActorState) UnmarshalCBOR(r io.Reader) error { t.AddressMap = c } - // t.t.NextID (uint64) (uint64) + // t.NextID (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -87,13 +87,13 @@ func (t *ExecParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.Code (cid.Cid) (struct) + // t.Code (cid.Cid) (struct) if err := cbg.WriteCid(w, t.Code); err != nil { return xerrors.Errorf("failed to write cid field t.Code: %w", err) } - // t.t.Params ([]uint8) (slice) + // t.Params ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Params)))); err != nil { return err } @@ -118,7 +118,7 @@ func (t *ExecParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Code (cid.Cid) (struct) + // t.Code (cid.Cid) (struct) { @@ -130,7 +130,7 @@ func (t *ExecParams) UnmarshalCBOR(r io.Reader) error { t.Code = c } - // t.t.Params ([]uint8) (slice) + // t.Params ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -159,7 +159,7 @@ func (t *AccountActorState) MarshalCBOR(w io.Writer) error { return err } - // t.t.Address (address.Address) (struct) + // t.Address (address.Address) (struct) if err := t.Address.MarshalCBOR(w); err != nil { return err } @@ -181,7 +181,7 @@ func (t *AccountActorState) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Address (address.Address) (struct) + // t.Address (address.Address) (struct) { @@ -202,7 +202,7 @@ func (t *StorageMinerActorState) MarshalCBOR(w io.Writer) error { return err } - // t.t.PreCommittedSectors (map[string]*actors.PreCommittedSector) (map) + // t.PreCommittedSectors (map[string]*actors.PreCommittedSector) (map) { if err := cbg.CborWriteHeader(w, cbg.MajMap, uint64(len(t.PreCommittedSectors))); err != nil { return err @@ -230,50 +230,50 @@ func (t *StorageMinerActorState) MarshalCBOR(w io.Writer) error { } } - // t.t.Sectors (cid.Cid) (struct) + // t.Sectors (cid.Cid) (struct) if err := cbg.WriteCid(w, t.Sectors); err != nil { return xerrors.Errorf("failed to write cid field t.Sectors: %w", err) } - // t.t.ProvingSet (cid.Cid) (struct) + // t.ProvingSet (cid.Cid) (struct) if err := cbg.WriteCid(w, t.ProvingSet); err != nil { return xerrors.Errorf("failed to write cid field t.ProvingSet: %w", err) } - // t.t.Info (cid.Cid) (struct) + // t.Info (cid.Cid) (struct) if err := cbg.WriteCid(w, t.Info); err != nil { return xerrors.Errorf("failed to write cid field t.Info: %w", err) } - // t.t.CurrentFaultSet (types.BitField) (struct) - if err := t.CurrentFaultSet.MarshalCBOR(w); err != nil { + // t.FaultSet (types.BitField) (struct) + if err := t.FaultSet.MarshalCBOR(w); err != nil { return err } - // t.t.NextFaultSet (types.BitField) (struct) - if err := t.NextFaultSet.MarshalCBOR(w); err != nil { + // t.LastFaultSubmission (uint64) (uint64) + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.LastFaultSubmission))); err != nil { return err } - // t.t.Power (types.BigInt) (struct) + // t.Power (types.BigInt) (struct) if err := t.Power.MarshalCBOR(w); err != nil { return err } - // t.t.Active (bool) (bool) + // t.Active (bool) (bool) if err := cbg.WriteBool(w, t.Active); err != nil { return err } - // t.t.SlashedAt (uint64) (uint64) + // t.SlashedAt (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SlashedAt))); err != nil { return err } - // t.t.ElectionPeriodStart (uint64) (uint64) + // t.ElectionPeriodStart (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.ElectionPeriodStart))); err != nil { return err } @@ -295,7 +295,7 @@ func (t *StorageMinerActorState) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.PreCommittedSectors (map[string]*actors.PreCommittedSector) (map) + // t.PreCommittedSectors (map[string]*actors.PreCommittedSector) (map) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -348,7 +348,7 @@ func (t *StorageMinerActorState) UnmarshalCBOR(r io.Reader) error { t.PreCommittedSectors[k] = v } - // t.t.Sectors (cid.Cid) (struct) + // t.Sectors (cid.Cid) (struct) { @@ -360,7 +360,7 @@ func (t *StorageMinerActorState) UnmarshalCBOR(r io.Reader) error { t.Sectors = c } - // t.t.ProvingSet (cid.Cid) (struct) + // t.ProvingSet (cid.Cid) (struct) { @@ -372,7 +372,7 @@ func (t *StorageMinerActorState) UnmarshalCBOR(r io.Reader) error { t.ProvingSet = c } - // t.t.Info (cid.Cid) (struct) + // t.Info (cid.Cid) (struct) { @@ -384,25 +384,26 @@ func (t *StorageMinerActorState) UnmarshalCBOR(r io.Reader) error { t.Info = c } - // t.t.CurrentFaultSet (types.BitField) (struct) + // t.FaultSet (types.BitField) (struct) { - if err := t.CurrentFaultSet.UnmarshalCBOR(br); err != nil { + if err := t.FaultSet.UnmarshalCBOR(br); err != nil { return err } } - // t.t.NextFaultSet (types.BitField) (struct) - - { - - if err := t.NextFaultSet.UnmarshalCBOR(br); err != nil { - return err - } + // t.LastFaultSubmission (uint64) (uint64) + maj, extra, err = cbg.CborReadHeader(br) + if err != nil { + return err } - // t.t.Power (types.BigInt) (struct) + if maj != cbg.MajUnsignedInt { + return fmt.Errorf("wrong type for uint64 field") + } + t.LastFaultSubmission = uint64(extra) + // t.Power (types.BigInt) (struct) { @@ -411,7 +412,7 @@ func (t *StorageMinerActorState) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Active (bool) (bool) + // t.Active (bool) (bool) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -428,7 +429,7 @@ func (t *StorageMinerActorState) UnmarshalCBOR(r io.Reader) error { default: return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) } - // t.t.SlashedAt (uint64) (uint64) + // t.SlashedAt (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -438,7 +439,7 @@ func (t *StorageMinerActorState) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.SlashedAt = uint64(extra) - // t.t.ElectionPeriodStart (uint64) (uint64) + // t.ElectionPeriodStart (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -460,22 +461,22 @@ func (t *StorageMinerConstructorParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.Owner (address.Address) (struct) + // t.Owner (address.Address) (struct) if err := t.Owner.MarshalCBOR(w); err != nil { return err } - // t.t.Worker (address.Address) (struct) + // t.Worker (address.Address) (struct) if err := t.Worker.MarshalCBOR(w); err != nil { return err } - // t.t.SectorSize (uint64) (uint64) + // t.SectorSize (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SectorSize))); err != nil { return err } - // t.t.PeerID (peer.ID) (string) + // t.PeerID (peer.ID) (string) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.PeerID)))); err != nil { return err } @@ -500,7 +501,7 @@ func (t *StorageMinerConstructorParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Owner (address.Address) (struct) + // t.Owner (address.Address) (struct) { @@ -509,7 +510,7 @@ func (t *StorageMinerConstructorParams) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Worker (address.Address) (struct) + // t.Worker (address.Address) (struct) { @@ -518,7 +519,7 @@ func (t *StorageMinerConstructorParams) UnmarshalCBOR(r io.Reader) error { } } - // t.t.SectorSize (uint64) (uint64) + // t.SectorSize (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -528,7 +529,7 @@ func (t *StorageMinerConstructorParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.SectorSize = uint64(extra) - // t.t.PeerID (peer.ID) (string) + // t.PeerID (peer.ID) (string) { sval, err := cbg.ReadString(br) @@ -550,12 +551,12 @@ func (t *SectorPreCommitInfo) MarshalCBOR(w io.Writer) error { return err } - // t.t.SectorNumber (uint64) (uint64) + // t.SectorNumber (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SectorNumber))); err != nil { return err } - // t.t.CommR ([]uint8) (slice) + // t.CommR ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.CommR)))); err != nil { return err } @@ -563,12 +564,12 @@ func (t *SectorPreCommitInfo) MarshalCBOR(w io.Writer) error { return err } - // t.t.SealEpoch (uint64) (uint64) + // t.SealEpoch (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SealEpoch))); err != nil { return err } - // t.t.DealIDs ([]uint64) (slice) + // t.DealIDs ([]uint64) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.DealIDs)))); err != nil { return err } @@ -595,7 +596,7 @@ func (t *SectorPreCommitInfo) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.SectorNumber (uint64) (uint64) + // t.SectorNumber (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -605,7 +606,7 @@ func (t *SectorPreCommitInfo) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.SectorNumber = uint64(extra) - // t.t.CommR ([]uint8) (slice) + // t.CommR ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -622,7 +623,7 @@ func (t *SectorPreCommitInfo) UnmarshalCBOR(r io.Reader) error { if _, err := io.ReadFull(br, t.CommR); err != nil { return err } - // t.t.SealEpoch (uint64) (uint64) + // t.SealEpoch (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -632,7 +633,7 @@ func (t *SectorPreCommitInfo) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.SealEpoch = uint64(extra) - // t.t.DealIDs ([]uint64) (slice) + // t.DealIDs ([]uint64) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -675,12 +676,12 @@ func (t *PreCommittedSector) MarshalCBOR(w io.Writer) error { return err } - // t.t.Info (actors.SectorPreCommitInfo) (struct) + // t.Info (actors.SectorPreCommitInfo) (struct) if err := t.Info.MarshalCBOR(w); err != nil { return err } - // t.t.ReceivedEpoch (uint64) (uint64) + // t.ReceivedEpoch (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.ReceivedEpoch))); err != nil { return err } @@ -702,7 +703,7 @@ func (t *PreCommittedSector) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Info (actors.SectorPreCommitInfo) (struct) + // t.Info (actors.SectorPreCommitInfo) (struct) { @@ -711,7 +712,7 @@ func (t *PreCommittedSector) UnmarshalCBOR(r io.Reader) error { } } - // t.t.ReceivedEpoch (uint64) (uint64) + // t.ReceivedEpoch (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -733,17 +734,17 @@ func (t *MinerInfo) MarshalCBOR(w io.Writer) error { return err } - // t.t.Owner (address.Address) (struct) + // t.Owner (address.Address) (struct) if err := t.Owner.MarshalCBOR(w); err != nil { return err } - // t.t.Worker (address.Address) (struct) + // t.Worker (address.Address) (struct) if err := t.Worker.MarshalCBOR(w); err != nil { return err } - // t.t.PeerID (peer.ID) (string) + // t.PeerID (peer.ID) (string) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.PeerID)))); err != nil { return err } @@ -751,7 +752,7 @@ func (t *MinerInfo) MarshalCBOR(w io.Writer) error { return err } - // t.t.SectorSize (uint64) (uint64) + // t.SectorSize (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SectorSize))); err != nil { return err } @@ -773,7 +774,7 @@ func (t *MinerInfo) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Owner (address.Address) (struct) + // t.Owner (address.Address) (struct) { @@ -782,7 +783,7 @@ func (t *MinerInfo) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Worker (address.Address) (struct) + // t.Worker (address.Address) (struct) { @@ -791,7 +792,7 @@ func (t *MinerInfo) UnmarshalCBOR(r io.Reader) error { } } - // t.t.PeerID (peer.ID) (string) + // t.PeerID (peer.ID) (string) { sval, err := cbg.ReadString(br) @@ -801,7 +802,7 @@ func (t *MinerInfo) UnmarshalCBOR(r io.Reader) error { t.PeerID = peer.ID(sval) } - // t.t.SectorSize (uint64) (uint64) + // t.SectorSize (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -823,7 +824,7 @@ func (t *SubmitFallbackPoStParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.Proof ([]uint8) (slice) + // t.Proof ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Proof)))); err != nil { return err } @@ -831,7 +832,7 @@ func (t *SubmitFallbackPoStParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.Candidates ([]types.EPostTicket) (slice) + // t.Candidates ([]types.EPostTicket) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Candidates)))); err != nil { return err } @@ -858,7 +859,7 @@ func (t *SubmitFallbackPoStParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Proof ([]uint8) (slice) + // t.Proof ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -875,7 +876,7 @@ func (t *SubmitFallbackPoStParams) UnmarshalCBOR(r io.Reader) error { if _, err := io.ReadFull(br, t.Proof); err != nil { return err } - // t.t.Candidates ([]types.EPostTicket) (slice) + // t.Candidates ([]types.EPostTicket) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -914,7 +915,7 @@ func (t *PaymentVerifyParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.Extra ([]uint8) (slice) + // t.Extra ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Extra)))); err != nil { return err } @@ -922,7 +923,7 @@ func (t *PaymentVerifyParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.Proof ([]uint8) (slice) + // t.Proof ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Proof)))); err != nil { return err } @@ -947,7 +948,7 @@ func (t *PaymentVerifyParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Extra ([]uint8) (slice) + // t.Extra ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -964,7 +965,7 @@ func (t *PaymentVerifyParams) UnmarshalCBOR(r io.Reader) error { if _, err := io.ReadFull(br, t.Extra); err != nil { return err } - // t.t.Proof ([]uint8) (slice) + // t.Proof ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -993,7 +994,7 @@ func (t *UpdatePeerIDParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.PeerID (peer.ID) (string) + // t.PeerID (peer.ID) (string) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.PeerID)))); err != nil { return err } @@ -1018,7 +1019,7 @@ func (t *UpdatePeerIDParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.PeerID (peer.ID) (string) + // t.PeerID (peer.ID) (string) { sval, err := cbg.ReadString(br) @@ -1031,6 +1032,49 @@ func (t *UpdatePeerIDParams) UnmarshalCBOR(r io.Reader) error { return nil } +func (t *DeclareFaultsParams) MarshalCBOR(w io.Writer) error { + if t == nil { + _, err := w.Write(cbg.CborNull) + return err + } + if _, err := w.Write([]byte{129}); err != nil { + return err + } + + // t.Faults (types.BitField) (struct) + if err := t.Faults.MarshalCBOR(w); err != nil { + return err + } + return nil +} + +func (t *DeclareFaultsParams) UnmarshalCBOR(r io.Reader) error { + br := cbg.GetPeeker(r) + + maj, extra, err := cbg.CborReadHeader(br) + if err != nil { + return err + } + if maj != cbg.MajArray { + return fmt.Errorf("cbor input should be of type array") + } + + if extra != 1 { + return fmt.Errorf("cbor input had wrong number of fields") + } + + // t.Faults (types.BitField) (struct) + + { + + if err := t.Faults.UnmarshalCBOR(br); err != nil { + return err + } + + } + return nil +} + func (t *MultiSigActorState) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) @@ -1040,7 +1084,7 @@ func (t *MultiSigActorState) MarshalCBOR(w io.Writer) error { return err } - // t.t.Signers ([]address.Address) (slice) + // t.Signers ([]address.Address) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Signers)))); err != nil { return err } @@ -1050,32 +1094,32 @@ func (t *MultiSigActorState) MarshalCBOR(w io.Writer) error { } } - // t.t.Required (uint64) (uint64) + // t.Required (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Required))); err != nil { return err } - // t.t.NextTxID (uint64) (uint64) + // t.NextTxID (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.NextTxID))); err != nil { return err } - // t.t.InitialBalance (types.BigInt) (struct) + // t.InitialBalance (types.BigInt) (struct) if err := t.InitialBalance.MarshalCBOR(w); err != nil { return err } - // t.t.StartingBlock (uint64) (uint64) + // t.StartingBlock (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.StartingBlock))); err != nil { return err } - // t.t.UnlockDuration (uint64) (uint64) + // t.UnlockDuration (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.UnlockDuration))); err != nil { return err } - // t.t.Transactions ([]actors.MTransaction) (slice) + // t.Transactions ([]actors.MTransaction) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Transactions)))); err != nil { return err } @@ -1102,7 +1146,7 @@ func (t *MultiSigActorState) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Signers ([]address.Address) (slice) + // t.Signers ([]address.Address) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1129,7 +1173,7 @@ func (t *MultiSigActorState) UnmarshalCBOR(r io.Reader) error { t.Signers[i] = v } - // t.t.Required (uint64) (uint64) + // t.Required (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1139,7 +1183,7 @@ func (t *MultiSigActorState) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Required = uint64(extra) - // t.t.NextTxID (uint64) (uint64) + // t.NextTxID (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1149,7 +1193,7 @@ func (t *MultiSigActorState) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.NextTxID = uint64(extra) - // t.t.InitialBalance (types.BigInt) (struct) + // t.InitialBalance (types.BigInt) (struct) { @@ -1158,7 +1202,7 @@ func (t *MultiSigActorState) UnmarshalCBOR(r io.Reader) error { } } - // t.t.StartingBlock (uint64) (uint64) + // t.StartingBlock (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1168,7 +1212,7 @@ func (t *MultiSigActorState) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.StartingBlock = uint64(extra) - // t.t.UnlockDuration (uint64) (uint64) + // t.UnlockDuration (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1178,7 +1222,7 @@ func (t *MultiSigActorState) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.UnlockDuration = uint64(extra) - // t.t.Transactions ([]actors.MTransaction) (slice) + // t.Transactions ([]actors.MTransaction) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1217,7 +1261,7 @@ func (t *MultiSigConstructorParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.Signers ([]address.Address) (slice) + // t.Signers ([]address.Address) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Signers)))); err != nil { return err } @@ -1227,12 +1271,12 @@ func (t *MultiSigConstructorParams) MarshalCBOR(w io.Writer) error { } } - // t.t.Required (uint64) (uint64) + // t.Required (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Required))); err != nil { return err } - // t.t.UnlockDuration (uint64) (uint64) + // t.UnlockDuration (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.UnlockDuration))); err != nil { return err } @@ -1254,7 +1298,7 @@ func (t *MultiSigConstructorParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Signers ([]address.Address) (slice) + // t.Signers ([]address.Address) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1281,7 +1325,7 @@ func (t *MultiSigConstructorParams) UnmarshalCBOR(r io.Reader) error { t.Signers[i] = v } - // t.t.Required (uint64) (uint64) + // t.Required (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1291,7 +1335,7 @@ func (t *MultiSigConstructorParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Required = uint64(extra) - // t.t.UnlockDuration (uint64) (uint64) + // t.UnlockDuration (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1313,22 +1357,22 @@ func (t *MultiSigProposeParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.To (address.Address) (struct) + // t.To (address.Address) (struct) if err := t.To.MarshalCBOR(w); err != nil { return err } - // t.t.Value (types.BigInt) (struct) + // t.Value (types.BigInt) (struct) if err := t.Value.MarshalCBOR(w); err != nil { return err } - // t.t.Method (uint64) (uint64) + // t.Method (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Method))); err != nil { return err } - // t.t.Params ([]uint8) (slice) + // t.Params ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Params)))); err != nil { return err } @@ -1353,7 +1397,7 @@ func (t *MultiSigProposeParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.To (address.Address) (struct) + // t.To (address.Address) (struct) { @@ -1362,7 +1406,7 @@ func (t *MultiSigProposeParams) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Value (types.BigInt) (struct) + // t.Value (types.BigInt) (struct) { @@ -1371,7 +1415,7 @@ func (t *MultiSigProposeParams) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Method (uint64) (uint64) + // t.Method (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1381,7 +1425,7 @@ func (t *MultiSigProposeParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Method = uint64(extra) - // t.t.Params ([]uint8) (slice) + // t.Params ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1410,7 +1454,7 @@ func (t *MultiSigTxID) MarshalCBOR(w io.Writer) error { return err } - // t.t.TxID (uint64) (uint64) + // t.TxID (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.TxID))); err != nil { return err } @@ -1432,7 +1476,7 @@ func (t *MultiSigTxID) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.TxID (uint64) (uint64) + // t.TxID (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1454,12 +1498,12 @@ func (t *MultiSigSwapSignerParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.From (address.Address) (struct) + // t.From (address.Address) (struct) if err := t.From.MarshalCBOR(w); err != nil { return err } - // t.t.To (address.Address) (struct) + // t.To (address.Address) (struct) if err := t.To.MarshalCBOR(w); err != nil { return err } @@ -1481,7 +1525,7 @@ func (t *MultiSigSwapSignerParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.From (address.Address) (struct) + // t.From (address.Address) (struct) { @@ -1490,7 +1534,7 @@ func (t *MultiSigSwapSignerParams) UnmarshalCBOR(r io.Reader) error { } } - // t.t.To (address.Address) (struct) + // t.To (address.Address) (struct) { @@ -1511,7 +1555,7 @@ func (t *MultiSigChangeReqParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.Req (uint64) (uint64) + // t.Req (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Req))); err != nil { return err } @@ -1533,7 +1577,7 @@ func (t *MultiSigChangeReqParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Req (uint64) (uint64) + // t.Req (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1555,32 +1599,32 @@ func (t *MTransaction) MarshalCBOR(w io.Writer) error { return err } - // t.t.Created (uint64) (uint64) + // t.Created (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Created))); err != nil { return err } - // t.t.TxID (uint64) (uint64) + // t.TxID (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.TxID))); err != nil { return err } - // t.t.To (address.Address) (struct) + // t.To (address.Address) (struct) if err := t.To.MarshalCBOR(w); err != nil { return err } - // t.t.Value (types.BigInt) (struct) + // t.Value (types.BigInt) (struct) if err := t.Value.MarshalCBOR(w); err != nil { return err } - // t.t.Method (uint64) (uint64) + // t.Method (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Method))); err != nil { return err } - // t.t.Params ([]uint8) (slice) + // t.Params ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Params)))); err != nil { return err } @@ -1588,7 +1632,7 @@ func (t *MTransaction) MarshalCBOR(w io.Writer) error { return err } - // t.t.Approved ([]address.Address) (slice) + // t.Approved ([]address.Address) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Approved)))); err != nil { return err } @@ -1598,17 +1642,17 @@ func (t *MTransaction) MarshalCBOR(w io.Writer) error { } } - // t.t.Complete (bool) (bool) + // t.Complete (bool) (bool) if err := cbg.WriteBool(w, t.Complete); err != nil { return err } - // t.t.Canceled (bool) (bool) + // t.Canceled (bool) (bool) if err := cbg.WriteBool(w, t.Canceled); err != nil { return err } - // t.t.RetCode (uint64) (uint64) + // t.RetCode (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.RetCode))); err != nil { return err } @@ -1630,7 +1674,7 @@ func (t *MTransaction) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Created (uint64) (uint64) + // t.Created (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1640,7 +1684,7 @@ func (t *MTransaction) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Created = uint64(extra) - // t.t.TxID (uint64) (uint64) + // t.TxID (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1650,7 +1694,7 @@ func (t *MTransaction) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.TxID = uint64(extra) - // t.t.To (address.Address) (struct) + // t.To (address.Address) (struct) { @@ -1659,7 +1703,7 @@ func (t *MTransaction) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Value (types.BigInt) (struct) + // t.Value (types.BigInt) (struct) { @@ -1668,7 +1712,7 @@ func (t *MTransaction) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Method (uint64) (uint64) + // t.Method (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1678,7 +1722,7 @@ func (t *MTransaction) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Method = uint64(extra) - // t.t.Params ([]uint8) (slice) + // t.Params ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1695,7 +1739,7 @@ func (t *MTransaction) UnmarshalCBOR(r io.Reader) error { if _, err := io.ReadFull(br, t.Params); err != nil { return err } - // t.t.Approved ([]address.Address) (slice) + // t.Approved ([]address.Address) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1722,7 +1766,7 @@ func (t *MTransaction) UnmarshalCBOR(r io.Reader) error { t.Approved[i] = v } - // t.t.Complete (bool) (bool) + // t.Complete (bool) (bool) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1739,7 +1783,7 @@ func (t *MTransaction) UnmarshalCBOR(r io.Reader) error { default: return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) } - // t.t.Canceled (bool) (bool) + // t.Canceled (bool) (bool) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1756,7 +1800,7 @@ func (t *MTransaction) UnmarshalCBOR(r io.Reader) error { default: return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) } - // t.t.RetCode (uint64) (uint64) + // t.RetCode (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1778,12 +1822,12 @@ func (t *MultiSigRemoveSignerParam) MarshalCBOR(w io.Writer) error { return err } - // t.t.Signer (address.Address) (struct) + // t.Signer (address.Address) (struct) if err := t.Signer.MarshalCBOR(w); err != nil { return err } - // t.t.Decrease (bool) (bool) + // t.Decrease (bool) (bool) if err := cbg.WriteBool(w, t.Decrease); err != nil { return err } @@ -1805,7 +1849,7 @@ func (t *MultiSigRemoveSignerParam) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Signer (address.Address) (struct) + // t.Signer (address.Address) (struct) { @@ -1814,7 +1858,7 @@ func (t *MultiSigRemoveSignerParam) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Decrease (bool) (bool) + // t.Decrease (bool) (bool) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1843,12 +1887,12 @@ func (t *MultiSigAddSignerParam) MarshalCBOR(w io.Writer) error { return err } - // t.t.Signer (address.Address) (struct) + // t.Signer (address.Address) (struct) if err := t.Signer.MarshalCBOR(w); err != nil { return err } - // t.t.Increase (bool) (bool) + // t.Increase (bool) (bool) if err := cbg.WriteBool(w, t.Increase); err != nil { return err } @@ -1870,7 +1914,7 @@ func (t *MultiSigAddSignerParam) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Signer (address.Address) (struct) + // t.Signer (address.Address) (struct) { @@ -1879,7 +1923,7 @@ func (t *MultiSigAddSignerParam) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Increase (bool) (bool) + // t.Increase (bool) (bool) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1908,32 +1952,32 @@ func (t *PaymentChannelActorState) MarshalCBOR(w io.Writer) error { return err } - // t.t.From (address.Address) (struct) + // t.From (address.Address) (struct) if err := t.From.MarshalCBOR(w); err != nil { return err } - // t.t.To (address.Address) (struct) + // t.To (address.Address) (struct) if err := t.To.MarshalCBOR(w); err != nil { return err } - // t.t.ToSend (types.BigInt) (struct) + // t.ToSend (types.BigInt) (struct) if err := t.ToSend.MarshalCBOR(w); err != nil { return err } - // t.t.ClosingAt (uint64) (uint64) + // t.ClosingAt (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.ClosingAt))); err != nil { return err } - // t.t.MinCloseHeight (uint64) (uint64) + // t.MinCloseHeight (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.MinCloseHeight))); err != nil { return err } - // t.t.LaneStates (map[string]*actors.LaneState) (map) + // t.LaneStates (map[string]*actors.LaneState) (map) { if err := cbg.CborWriteHeader(w, cbg.MajMap, uint64(len(t.LaneStates))); err != nil { return err @@ -1978,7 +2022,7 @@ func (t *PaymentChannelActorState) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.From (address.Address) (struct) + // t.From (address.Address) (struct) { @@ -1987,7 +2031,7 @@ func (t *PaymentChannelActorState) UnmarshalCBOR(r io.Reader) error { } } - // t.t.To (address.Address) (struct) + // t.To (address.Address) (struct) { @@ -1996,7 +2040,7 @@ func (t *PaymentChannelActorState) UnmarshalCBOR(r io.Reader) error { } } - // t.t.ToSend (types.BigInt) (struct) + // t.ToSend (types.BigInt) (struct) { @@ -2005,7 +2049,7 @@ func (t *PaymentChannelActorState) UnmarshalCBOR(r io.Reader) error { } } - // t.t.ClosingAt (uint64) (uint64) + // t.ClosingAt (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -2015,7 +2059,7 @@ func (t *PaymentChannelActorState) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.ClosingAt = uint64(extra) - // t.t.MinCloseHeight (uint64) (uint64) + // t.MinCloseHeight (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -2025,7 +2069,7 @@ func (t *PaymentChannelActorState) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.MinCloseHeight = uint64(extra) - // t.t.LaneStates (map[string]*actors.LaneState) (map) + // t.LaneStates (map[string]*actors.LaneState) (map) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -2090,7 +2134,7 @@ func (t *PCAConstructorParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.To (address.Address) (struct) + // t.To (address.Address) (struct) if err := t.To.MarshalCBOR(w); err != nil { return err } @@ -2112,7 +2156,7 @@ func (t *PCAConstructorParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.To (address.Address) (struct) + // t.To (address.Address) (struct) { @@ -2133,17 +2177,17 @@ func (t *LaneState) MarshalCBOR(w io.Writer) error { return err } - // t.t.Closed (bool) (bool) + // t.Closed (bool) (bool) if err := cbg.WriteBool(w, t.Closed); err != nil { return err } - // t.t.Redeemed (types.BigInt) (struct) + // t.Redeemed (types.BigInt) (struct) if err := t.Redeemed.MarshalCBOR(w); err != nil { return err } - // t.t.Nonce (uint64) (uint64) + // t.Nonce (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Nonce))); err != nil { return err } @@ -2165,7 +2209,7 @@ func (t *LaneState) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Closed (bool) (bool) + // t.Closed (bool) (bool) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -2182,7 +2226,7 @@ func (t *LaneState) UnmarshalCBOR(r io.Reader) error { default: return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) } - // t.t.Redeemed (types.BigInt) (struct) + // t.Redeemed (types.BigInt) (struct) { @@ -2191,7 +2235,7 @@ func (t *LaneState) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Nonce (uint64) (uint64) + // t.Nonce (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -2213,12 +2257,12 @@ func (t *PCAUpdateChannelStateParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.Sv (types.SignedVoucher) (struct) + // t.Sv (types.SignedVoucher) (struct) if err := t.Sv.MarshalCBOR(w); err != nil { return err } - // t.t.Secret ([]uint8) (slice) + // t.Secret ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Secret)))); err != nil { return err } @@ -2226,7 +2270,7 @@ func (t *PCAUpdateChannelStateParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.Proof ([]uint8) (slice) + // t.Proof ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Proof)))); err != nil { return err } @@ -2251,7 +2295,7 @@ func (t *PCAUpdateChannelStateParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Sv (types.SignedVoucher) (struct) + // t.Sv (types.SignedVoucher) (struct) { @@ -2260,7 +2304,7 @@ func (t *PCAUpdateChannelStateParams) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Secret ([]uint8) (slice) + // t.Secret ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -2277,7 +2321,7 @@ func (t *PCAUpdateChannelStateParams) UnmarshalCBOR(r io.Reader) error { if _, err := io.ReadFull(br, t.Secret); err != nil { return err } - // t.t.Proof ([]uint8) (slice) + // t.Proof ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -2306,17 +2350,17 @@ func (t *PaymentInfo) MarshalCBOR(w io.Writer) error { return err } - // t.t.PayChActor (address.Address) (struct) + // t.PayChActor (address.Address) (struct) if err := t.PayChActor.MarshalCBOR(w); err != nil { return err } - // t.t.Payer (address.Address) (struct) + // t.Payer (address.Address) (struct) if err := t.Payer.MarshalCBOR(w); err != nil { return err } - // t.t.ChannelMessage (cid.Cid) (struct) + // t.ChannelMessage (cid.Cid) (struct) if t.ChannelMessage == nil { if _, err := w.Write(cbg.CborNull); err != nil { @@ -2328,7 +2372,7 @@ func (t *PaymentInfo) MarshalCBOR(w io.Writer) error { } } - // t.t.Vouchers ([]*types.SignedVoucher) (slice) + // t.Vouchers ([]*types.SignedVoucher) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Vouchers)))); err != nil { return err } @@ -2355,7 +2399,7 @@ func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.PayChActor (address.Address) (struct) + // t.PayChActor (address.Address) (struct) { @@ -2364,7 +2408,7 @@ func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Payer (address.Address) (struct) + // t.Payer (address.Address) (struct) { @@ -2373,7 +2417,7 @@ func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error { } } - // t.t.ChannelMessage (cid.Cid) (struct) + // t.ChannelMessage (cid.Cid) (struct) { @@ -2397,7 +2441,7 @@ func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Vouchers ([]*types.SignedVoucher) (slice) + // t.Vouchers ([]*types.SignedVoucher) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -2436,29 +2480,29 @@ func (t *StoragePowerState) MarshalCBOR(w io.Writer) error { return err } - // t.t.Miners (cid.Cid) (struct) + // t.Miners (cid.Cid) (struct) if err := cbg.WriteCid(w, t.Miners); err != nil { return xerrors.Errorf("failed to write cid field t.Miners: %w", err) } - // t.t.ProvingBuckets (cid.Cid) (struct) + // t.ProvingBuckets (cid.Cid) (struct) if err := cbg.WriteCid(w, t.ProvingBuckets); err != nil { return xerrors.Errorf("failed to write cid field t.ProvingBuckets: %w", err) } - // t.t.MinerCount (uint64) (uint64) + // t.MinerCount (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.MinerCount))); err != nil { return err } - // t.t.LastMinerCheck (uint64) (uint64) + // t.LastMinerCheck (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.LastMinerCheck))); err != nil { return err } - // t.t.TotalStorage (types.BigInt) (struct) + // t.TotalStorage (types.BigInt) (struct) if err := t.TotalStorage.MarshalCBOR(w); err != nil { return err } @@ -2480,7 +2524,7 @@ func (t *StoragePowerState) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Miners (cid.Cid) (struct) + // t.Miners (cid.Cid) (struct) { @@ -2492,7 +2536,7 @@ func (t *StoragePowerState) UnmarshalCBOR(r io.Reader) error { t.Miners = c } - // t.t.ProvingBuckets (cid.Cid) (struct) + // t.ProvingBuckets (cid.Cid) (struct) { @@ -2504,7 +2548,7 @@ func (t *StoragePowerState) UnmarshalCBOR(r io.Reader) error { t.ProvingBuckets = c } - // t.t.MinerCount (uint64) (uint64) + // t.MinerCount (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -2514,7 +2558,7 @@ func (t *StoragePowerState) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.MinerCount = uint64(extra) - // t.t.LastMinerCheck (uint64) (uint64) + // t.LastMinerCheck (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -2524,7 +2568,7 @@ func (t *StoragePowerState) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.LastMinerCheck = uint64(extra) - // t.t.TotalStorage (types.BigInt) (struct) + // t.TotalStorage (types.BigInt) (struct) { @@ -2545,22 +2589,22 @@ func (t *CreateStorageMinerParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.Owner (address.Address) (struct) + // t.Owner (address.Address) (struct) if err := t.Owner.MarshalCBOR(w); err != nil { return err } - // t.t.Worker (address.Address) (struct) + // t.Worker (address.Address) (struct) if err := t.Worker.MarshalCBOR(w); err != nil { return err } - // t.t.SectorSize (uint64) (uint64) + // t.SectorSize (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SectorSize))); err != nil { return err } - // t.t.PeerID (peer.ID) (string) + // t.PeerID (peer.ID) (string) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.PeerID)))); err != nil { return err } @@ -2585,7 +2629,7 @@ func (t *CreateStorageMinerParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Owner (address.Address) (struct) + // t.Owner (address.Address) (struct) { @@ -2594,7 +2638,7 @@ func (t *CreateStorageMinerParams) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Worker (address.Address) (struct) + // t.Worker (address.Address) (struct) { @@ -2603,7 +2647,7 @@ func (t *CreateStorageMinerParams) UnmarshalCBOR(r io.Reader) error { } } - // t.t.SectorSize (uint64) (uint64) + // t.SectorSize (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -2613,7 +2657,7 @@ func (t *CreateStorageMinerParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.SectorSize = uint64(extra) - // t.t.PeerID (peer.ID) (string) + // t.PeerID (peer.ID) (string) { sval, err := cbg.ReadString(br) @@ -2635,7 +2679,7 @@ func (t *IsValidMinerParam) MarshalCBOR(w io.Writer) error { return err } - // t.t.Addr (address.Address) (struct) + // t.Addr (address.Address) (struct) if err := t.Addr.MarshalCBOR(w); err != nil { return err } @@ -2657,7 +2701,7 @@ func (t *IsValidMinerParam) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Addr (address.Address) (struct) + // t.Addr (address.Address) (struct) { @@ -2678,7 +2722,7 @@ func (t *PowerLookupParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.Miner (address.Address) (struct) + // t.Miner (address.Address) (struct) if err := t.Miner.MarshalCBOR(w); err != nil { return err } @@ -2700,7 +2744,7 @@ func (t *PowerLookupParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Miner (address.Address) (struct) + // t.Miner (address.Address) (struct) { @@ -2721,17 +2765,17 @@ func (t *UpdateStorageParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.Delta (types.BigInt) (struct) + // t.Delta (types.BigInt) (struct) if err := t.Delta.MarshalCBOR(w); err != nil { return err } - // t.t.NextProvingPeriodEnd (uint64) (uint64) + // t.NextProvingPeriodEnd (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.NextProvingPeriodEnd))); err != nil { return err } - // t.t.PreviousProvingPeriodEnd (uint64) (uint64) + // t.PreviousProvingPeriodEnd (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.PreviousProvingPeriodEnd))); err != nil { return err } @@ -2753,7 +2797,7 @@ func (t *UpdateStorageParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Delta (types.BigInt) (struct) + // t.Delta (types.BigInt) (struct) { @@ -2762,7 +2806,7 @@ func (t *UpdateStorageParams) UnmarshalCBOR(r io.Reader) error { } } - // t.t.NextProvingPeriodEnd (uint64) (uint64) + // t.NextProvingPeriodEnd (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -2772,7 +2816,7 @@ func (t *UpdateStorageParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.NextProvingPeriodEnd = uint64(extra) - // t.t.PreviousProvingPeriodEnd (uint64) (uint64) + // t.PreviousProvingPeriodEnd (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -2794,12 +2838,12 @@ func (t *ArbitrateConsensusFaultParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.Block1 (types.BlockHeader) (struct) + // t.Block1 (types.BlockHeader) (struct) if err := t.Block1.MarshalCBOR(w); err != nil { return err } - // t.t.Block2 (types.BlockHeader) (struct) + // t.Block2 (types.BlockHeader) (struct) if err := t.Block2.MarshalCBOR(w); err != nil { return err } @@ -2821,7 +2865,7 @@ func (t *ArbitrateConsensusFaultParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Block1 (types.BlockHeader) (struct) + // t.Block1 (types.BlockHeader) (struct) { @@ -2842,7 +2886,7 @@ func (t *ArbitrateConsensusFaultParams) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Block2 (types.BlockHeader) (struct) + // t.Block2 (types.BlockHeader) (struct) { @@ -2875,7 +2919,7 @@ func (t *PledgeCollateralParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.Size (types.BigInt) (struct) + // t.Size (types.BigInt) (struct) if err := t.Size.MarshalCBOR(w); err != nil { return err } @@ -2897,7 +2941,7 @@ func (t *PledgeCollateralParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Size (types.BigInt) (struct) + // t.Size (types.BigInt) (struct) { @@ -2918,17 +2962,17 @@ func (t *MinerSlashConsensusFault) MarshalCBOR(w io.Writer) error { return err } - // t.t.Slasher (address.Address) (struct) + // t.Slasher (address.Address) (struct) if err := t.Slasher.MarshalCBOR(w); err != nil { return err } - // t.t.AtHeight (uint64) (uint64) + // t.AtHeight (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.AtHeight))); err != nil { return err } - // t.t.SlashedCollateral (types.BigInt) (struct) + // t.SlashedCollateral (types.BigInt) (struct) if err := t.SlashedCollateral.MarshalCBOR(w); err != nil { return err } @@ -2950,7 +2994,7 @@ func (t *MinerSlashConsensusFault) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Slasher (address.Address) (struct) + // t.Slasher (address.Address) (struct) { @@ -2959,7 +3003,7 @@ func (t *MinerSlashConsensusFault) UnmarshalCBOR(r io.Reader) error { } } - // t.t.AtHeight (uint64) (uint64) + // t.AtHeight (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -2969,7 +3013,7 @@ func (t *MinerSlashConsensusFault) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.AtHeight = uint64(extra) - // t.t.SlashedCollateral (types.BigInt) (struct) + // t.SlashedCollateral (types.BigInt) (struct) { @@ -2990,12 +3034,12 @@ func (t *StorageParticipantBalance) MarshalCBOR(w io.Writer) error { return err } - // t.t.Locked (types.BigInt) (struct) + // t.Locked (types.BigInt) (struct) if err := t.Locked.MarshalCBOR(w); err != nil { return err } - // t.t.Available (types.BigInt) (struct) + // t.Available (types.BigInt) (struct) if err := t.Available.MarshalCBOR(w); err != nil { return err } @@ -3017,7 +3061,7 @@ func (t *StorageParticipantBalance) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Locked (types.BigInt) (struct) + // t.Locked (types.BigInt) (struct) { @@ -3026,7 +3070,7 @@ func (t *StorageParticipantBalance) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Available (types.BigInt) (struct) + // t.Available (types.BigInt) (struct) { @@ -3047,19 +3091,19 @@ func (t *StorageMarketState) MarshalCBOR(w io.Writer) error { return err } - // t.t.Balances (cid.Cid) (struct) + // t.Balances (cid.Cid) (struct) if err := cbg.WriteCid(w, t.Balances); err != nil { return xerrors.Errorf("failed to write cid field t.Balances: %w", err) } - // t.t.Deals (cid.Cid) (struct) + // t.Deals (cid.Cid) (struct) if err := cbg.WriteCid(w, t.Deals); err != nil { return xerrors.Errorf("failed to write cid field t.Deals: %w", err) } - // t.t.NextDealID (uint64) (uint64) + // t.NextDealID (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.NextDealID))); err != nil { return err } @@ -3081,7 +3125,7 @@ func (t *StorageMarketState) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Balances (cid.Cid) (struct) + // t.Balances (cid.Cid) (struct) { @@ -3093,7 +3137,7 @@ func (t *StorageMarketState) UnmarshalCBOR(r io.Reader) error { t.Balances = c } - // t.t.Deals (cid.Cid) (struct) + // t.Deals (cid.Cid) (struct) { @@ -3105,7 +3149,7 @@ func (t *StorageMarketState) UnmarshalCBOR(r io.Reader) error { t.Deals = c } - // t.t.NextDealID (uint64) (uint64) + // t.NextDealID (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -3127,7 +3171,7 @@ func (t *WithdrawBalanceParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.Balance (types.BigInt) (struct) + // t.Balance (types.BigInt) (struct) if err := t.Balance.MarshalCBOR(w); err != nil { return err } @@ -3149,7 +3193,7 @@ func (t *WithdrawBalanceParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Balance (types.BigInt) (struct) + // t.Balance (types.BigInt) (struct) { @@ -3166,11 +3210,11 @@ func (t *StorageDealProposal) MarshalCBOR(w io.Writer) error { _, err := w.Write(cbg.CborNull) return err } - if _, err := w.Write([]byte{138}); err != nil { + if _, err := w.Write([]byte{137}); err != nil { return err } - // t.t.PieceRef ([]uint8) (slice) + // t.PieceRef ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.PieceRef)))); err != nil { return err } @@ -3178,47 +3222,42 @@ func (t *StorageDealProposal) MarshalCBOR(w io.Writer) error { return err } - // t.t.PieceSize (uint64) (uint64) + // t.PieceSize (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.PieceSize))); err != nil { return err } - // t.t.PieceSerialization (uint64) (uint64) - if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.PieceSerialization))); err != nil { - return err - } - - // t.t.Client (address.Address) (struct) + // t.Client (address.Address) (struct) if err := t.Client.MarshalCBOR(w); err != nil { return err } - // t.t.Provider (address.Address) (struct) + // t.Provider (address.Address) (struct) if err := t.Provider.MarshalCBOR(w); err != nil { return err } - // t.t.ProposalExpiration (uint64) (uint64) + // t.ProposalExpiration (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.ProposalExpiration))); err != nil { return err } - // t.t.Duration (uint64) (uint64) + // t.Duration (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Duration))); err != nil { return err } - // t.t.StoragePricePerEpoch (types.BigInt) (struct) + // t.StoragePricePerEpoch (types.BigInt) (struct) if err := t.StoragePricePerEpoch.MarshalCBOR(w); err != nil { return err } - // t.t.StorageCollateral (types.BigInt) (struct) + // t.StorageCollateral (types.BigInt) (struct) if err := t.StorageCollateral.MarshalCBOR(w); err != nil { return err } - // t.t.ProposerSignature (types.Signature) (struct) + // t.ProposerSignature (types.Signature) (struct) if err := t.ProposerSignature.MarshalCBOR(w); err != nil { return err } @@ -3236,11 +3275,11 @@ func (t *StorageDealProposal) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input should be of type array") } - if extra != 10 { + if extra != 9 { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.PieceRef ([]uint8) (slice) + // t.PieceRef ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -3257,7 +3296,7 @@ func (t *StorageDealProposal) UnmarshalCBOR(r io.Reader) error { if _, err := io.ReadFull(br, t.PieceRef); err != nil { return err } - // t.t.PieceSize (uint64) (uint64) + // t.PieceSize (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -3267,17 +3306,7 @@ func (t *StorageDealProposal) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.PieceSize = uint64(extra) - // t.t.PieceSerialization (uint64) (uint64) - - maj, extra, err = cbg.CborReadHeader(br) - if err != nil { - return err - } - if maj != cbg.MajUnsignedInt { - return fmt.Errorf("wrong type for uint64 field") - } - t.PieceSerialization = uint64(extra) - // t.t.Client (address.Address) (struct) + // t.Client (address.Address) (struct) { @@ -3286,7 +3315,7 @@ func (t *StorageDealProposal) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Provider (address.Address) (struct) + // t.Provider (address.Address) (struct) { @@ -3295,7 +3324,7 @@ func (t *StorageDealProposal) UnmarshalCBOR(r io.Reader) error { } } - // t.t.ProposalExpiration (uint64) (uint64) + // t.ProposalExpiration (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -3305,7 +3334,7 @@ func (t *StorageDealProposal) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.ProposalExpiration = uint64(extra) - // t.t.Duration (uint64) (uint64) + // t.Duration (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -3315,7 +3344,7 @@ func (t *StorageDealProposal) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Duration = uint64(extra) - // t.t.StoragePricePerEpoch (types.BigInt) (struct) + // t.StoragePricePerEpoch (types.BigInt) (struct) { @@ -3324,7 +3353,7 @@ func (t *StorageDealProposal) UnmarshalCBOR(r io.Reader) error { } } - // t.t.StorageCollateral (types.BigInt) (struct) + // t.StorageCollateral (types.BigInt) (struct) { @@ -3333,7 +3362,7 @@ func (t *StorageDealProposal) UnmarshalCBOR(r io.Reader) error { } } - // t.t.ProposerSignature (types.Signature) (struct) + // t.ProposerSignature (types.Signature) (struct) { @@ -3357,75 +3386,6 @@ func (t *StorageDealProposal) UnmarshalCBOR(r io.Reader) error { return nil } -func (t *StorageDeal) MarshalCBOR(w io.Writer) error { - if t == nil { - _, err := w.Write(cbg.CborNull) - return err - } - if _, err := w.Write([]byte{130}); err != nil { - return err - } - - // t.t.Proposal (actors.StorageDealProposal) (struct) - if err := t.Proposal.MarshalCBOR(w); err != nil { - return err - } - - // t.t.CounterSignature (types.Signature) (struct) - if err := t.CounterSignature.MarshalCBOR(w); err != nil { - return err - } - return nil -} - -func (t *StorageDeal) UnmarshalCBOR(r io.Reader) error { - br := cbg.GetPeeker(r) - - maj, extra, err := cbg.CborReadHeader(br) - if err != nil { - return err - } - if maj != cbg.MajArray { - return fmt.Errorf("cbor input should be of type array") - } - - if extra != 2 { - return fmt.Errorf("cbor input had wrong number of fields") - } - - // t.t.Proposal (actors.StorageDealProposal) (struct) - - { - - if err := t.Proposal.UnmarshalCBOR(br); err != nil { - return err - } - - } - // t.t.CounterSignature (types.Signature) (struct) - - { - - pb, err := br.PeekByte() - if err != nil { - return err - } - if pb == cbg.CborNull[0] { - var nbuf [1]byte - if _, err := br.Read(nbuf[:]); err != nil { - return err - } - } else { - t.CounterSignature = new(types.Signature) - if err := t.CounterSignature.UnmarshalCBOR(br); err != nil { - return err - } - } - - } - return nil -} - func (t *PublishStorageDealsParams) MarshalCBOR(w io.Writer) error { if t == nil { _, err := w.Write(cbg.CborNull) @@ -3435,7 +3395,7 @@ func (t *PublishStorageDealsParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.Deals ([]actors.StorageDeal) (slice) + // t.Deals ([]actors.StorageDealProposal) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Deals)))); err != nil { return err } @@ -3462,7 +3422,7 @@ func (t *PublishStorageDealsParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Deals ([]actors.StorageDeal) (slice) + // t.Deals ([]actors.StorageDealProposal) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -3477,11 +3437,11 @@ func (t *PublishStorageDealsParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("expected cbor array") } if extra > 0 { - t.Deals = make([]StorageDeal, extra) + t.Deals = make([]StorageDealProposal, extra) } for i := 0; i < int(extra); i++ { - var v StorageDeal + var v StorageDealProposal if err := v.UnmarshalCBOR(br); err != nil { return err } @@ -3501,7 +3461,7 @@ func (t *PublishStorageDealResponse) MarshalCBOR(w io.Writer) error { return err } - // t.t.DealIDs ([]uint64) (slice) + // t.DealIDs ([]uint64) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.DealIDs)))); err != nil { return err } @@ -3528,7 +3488,7 @@ func (t *PublishStorageDealResponse) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.DealIDs ([]uint64) (slice) + // t.DealIDs ([]uint64) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -3571,7 +3531,7 @@ func (t *ActivateStorageDealsParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.Deals ([]uint64) (slice) + // t.Deals ([]uint64) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Deals)))); err != nil { return err } @@ -3598,7 +3558,7 @@ func (t *ActivateStorageDealsParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Deals ([]uint64) (slice) + // t.Deals ([]uint64) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -3641,7 +3601,7 @@ func (t *ProcessStorageDealsPaymentParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.DealIDs ([]uint64) (slice) + // t.DealIDs ([]uint64) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.DealIDs)))); err != nil { return err } @@ -3668,7 +3628,7 @@ func (t *ProcessStorageDealsPaymentParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.DealIDs ([]uint64) (slice) + // t.DealIDs ([]uint64) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -3707,16 +3667,54 @@ func (t *OnChainDeal) MarshalCBOR(w io.Writer) error { _, err := w.Write(cbg.CborNull) return err } - if _, err := w.Write([]byte{130}); err != nil { + if _, err := w.Write([]byte{137}); err != nil { return err } - // t.t.Deal (actors.StorageDeal) (struct) - if err := t.Deal.MarshalCBOR(w); err != nil { + // t.PieceRef ([]uint8) (slice) + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.PieceRef)))); err != nil { + return err + } + if _, err := w.Write(t.PieceRef); err != nil { return err } - // t.t.ActivationEpoch (uint64) (uint64) + // t.PieceSize (uint64) (uint64) + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.PieceSize))); err != nil { + return err + } + + // t.Client (address.Address) (struct) + if err := t.Client.MarshalCBOR(w); err != nil { + return err + } + + // t.Provider (address.Address) (struct) + if err := t.Provider.MarshalCBOR(w); err != nil { + return err + } + + // t.ProposalExpiration (uint64) (uint64) + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.ProposalExpiration))); err != nil { + return err + } + + // t.Duration (uint64) (uint64) + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Duration))); err != nil { + return err + } + + // t.StoragePricePerEpoch (types.BigInt) (struct) + if err := t.StoragePricePerEpoch.MarshalCBOR(w); err != nil { + return err + } + + // t.StorageCollateral (types.BigInt) (struct) + if err := t.StorageCollateral.MarshalCBOR(w); err != nil { + return err + } + + // t.ActivationEpoch (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.ActivationEpoch))); err != nil { return err } @@ -3734,20 +3732,94 @@ func (t *OnChainDeal) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input should be of type array") } - if extra != 2 { + if extra != 9 { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Deal (actors.StorageDeal) (struct) + // t.PieceRef ([]uint8) (slice) + + maj, extra, err = cbg.CborReadHeader(br) + if err != nil { + return err + } + + if extra > cbg.ByteArrayMaxLen { + return fmt.Errorf("t.PieceRef: byte array too large (%d)", extra) + } + if maj != cbg.MajByteString { + return fmt.Errorf("expected byte array") + } + t.PieceRef = make([]byte, extra) + if _, err := io.ReadFull(br, t.PieceRef); err != nil { + return err + } + // t.PieceSize (uint64) (uint64) + + maj, extra, err = cbg.CborReadHeader(br) + if err != nil { + return err + } + if maj != cbg.MajUnsignedInt { + return fmt.Errorf("wrong type for uint64 field") + } + t.PieceSize = uint64(extra) + // t.Client (address.Address) (struct) { - if err := t.Deal.UnmarshalCBOR(br); err != nil { + if err := t.Client.UnmarshalCBOR(br); err != nil { return err } } - // t.t.ActivationEpoch (uint64) (uint64) + // t.Provider (address.Address) (struct) + + { + + if err := t.Provider.UnmarshalCBOR(br); err != nil { + return err + } + + } + // t.ProposalExpiration (uint64) (uint64) + + maj, extra, err = cbg.CborReadHeader(br) + if err != nil { + return err + } + if maj != cbg.MajUnsignedInt { + return fmt.Errorf("wrong type for uint64 field") + } + t.ProposalExpiration = uint64(extra) + // t.Duration (uint64) (uint64) + + maj, extra, err = cbg.CborReadHeader(br) + if err != nil { + return err + } + if maj != cbg.MajUnsignedInt { + return fmt.Errorf("wrong type for uint64 field") + } + t.Duration = uint64(extra) + // t.StoragePricePerEpoch (types.BigInt) (struct) + + { + + if err := t.StoragePricePerEpoch.UnmarshalCBOR(br); err != nil { + return err + } + + } + // t.StorageCollateral (types.BigInt) (struct) + + { + + if err := t.StorageCollateral.UnmarshalCBOR(br); err != nil { + return err + } + + } + // t.ActivationEpoch (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -3769,7 +3841,7 @@ func (t *ComputeDataCommitmentParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.DealIDs ([]uint64) (slice) + // t.DealIDs ([]uint64) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.DealIDs)))); err != nil { return err } @@ -3779,7 +3851,7 @@ func (t *ComputeDataCommitmentParams) MarshalCBOR(w io.Writer) error { } } - // t.t.SectorSize (uint64) (uint64) + // t.SectorSize (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SectorSize))); err != nil { return err } @@ -3801,7 +3873,7 @@ func (t *ComputeDataCommitmentParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.DealIDs ([]uint64) (slice) + // t.DealIDs ([]uint64) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -3832,7 +3904,7 @@ func (t *ComputeDataCommitmentParams) UnmarshalCBOR(r io.Reader) error { t.DealIDs[i] = val } - // t.t.SectorSize (uint64) (uint64) + // t.SectorSize (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -3854,7 +3926,7 @@ func (t *SectorProveCommitInfo) MarshalCBOR(w io.Writer) error { return err } - // t.t.Proof ([]uint8) (slice) + // t.Proof ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Proof)))); err != nil { return err } @@ -3862,12 +3934,12 @@ func (t *SectorProveCommitInfo) MarshalCBOR(w io.Writer) error { return err } - // t.t.SectorID (uint64) (uint64) + // t.SectorID (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SectorID))); err != nil { return err } - // t.t.DealIDs ([]uint64) (slice) + // t.DealIDs ([]uint64) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.DealIDs)))); err != nil { return err } @@ -3894,7 +3966,7 @@ func (t *SectorProveCommitInfo) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Proof ([]uint8) (slice) + // t.Proof ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -3911,7 +3983,7 @@ func (t *SectorProveCommitInfo) UnmarshalCBOR(r io.Reader) error { if _, err := io.ReadFull(br, t.Proof); err != nil { return err } - // t.t.SectorID (uint64) (uint64) + // t.SectorID (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -3921,7 +3993,7 @@ func (t *SectorProveCommitInfo) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.SectorID = uint64(extra) - // t.t.DealIDs ([]uint64) (slice) + // t.DealIDs ([]uint64) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -3964,7 +4036,7 @@ func (t *CheckMinerParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.NetworkPower (types.BigInt) (struct) + // t.NetworkPower (types.BigInt) (struct) if err := t.NetworkPower.MarshalCBOR(w); err != nil { return err } @@ -3986,7 +4058,7 @@ func (t *CheckMinerParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.NetworkPower (types.BigInt) (struct) + // t.NetworkPower (types.BigInt) (struct) { diff --git a/chain/actors/harness2_test.go b/chain/actors/harness2_test.go index 0ffc02b1b..6f1da8d58 100644 --- a/chain/actors/harness2_test.go +++ b/chain/actors/harness2_test.go @@ -3,6 +3,7 @@ package actors_test import ( "bytes" "context" + "math/rand" "testing" "github.com/ipfs/go-cid" @@ -41,10 +42,12 @@ const ( type HarnessOpt func(testing.TB, *Harness) error type Harness struct { - HI HarnessInit - Stage HarnessStage - Nonces map[address.Address]uint64 - GasCharges map[address.Address]types.BigInt + HI HarnessInit + Stage HarnessStage + Nonces map[address.Address]uint64 + GasCharges map[address.Address]types.BigInt + Rand vm.Rand + BlockHeight uint64 lastBalanceCheck map[address.Address]types.BigInt @@ -127,6 +130,7 @@ func NewHarness(t *testing.T, options ...HarnessOpt) *Harness { h := &Harness{ Stage: HarnessPreInit, Nonces: make(map[address.Address]uint64), + Rand: &fakeRand{}, HI: HarnessInit{ NAddrs: 1, Miner: blsaddr(0), @@ -140,6 +144,7 @@ func NewHarness(t *testing.T, options ...HarnessOpt) *Harness { w: w, ctx: context.Background(), bs: bstore.NewBlockstore(dstore.NewMapDatastore()), + BlockHeight: 0, } for _, opt := range options { err := opt(t, h) @@ -157,8 +162,14 @@ func NewHarness(t *testing.T, options ...HarnessOpt) *Harness { if err != nil { t.Fatal(err) } + + stateroot, err = gen.SetupStorageMarketActor(h.bs, stateroot, nil) + if err != nil { + t.Fatal(err) + } + h.cs = store.NewChainStore(h.bs, nil) - h.vm, err = vm.NewVM(stateroot, 1, nil, h.HI.Miner, h.cs.Blockstore()) + h.vm, err = vm.NewVM(stateroot, 1, h.Rand, h.HI.Miner, h.cs.Blockstore()) if err != nil { t.Fatal(err) } @@ -246,6 +257,7 @@ func (h *Harness) Invoke(t testing.TB, from address.Address, to address.Address, func (h *Harness) InvokeWithValue(t testing.TB, from address.Address, to address.Address, method uint64, value types.BigInt, params cbg.CBORMarshaler) (*vm.ApplyRet, *state.StateTree) { t.Helper() + h.vm.SetBlockHeight(h.BlockHeight) return h.Apply(t, types.Message{ To: to, From: from, @@ -315,3 +327,11 @@ func DumpObject(t testing.TB, obj cbg.CBORMarshaler) []byte { } return b.Bytes() } + +type fakeRand struct{} + +func (fr *fakeRand) GetRandomness(ctx context.Context, h int64) ([]byte, error) { + out := make([]byte, 32) + rand.New(rand.NewSource(h)).Read(out) + return out, nil +} diff --git a/chain/blocksync/blocksync_client.go b/chain/blocksync/blocksync_client.go index 8e487b812..d3ae6de43 100644 --- a/chain/blocksync/blocksync_client.go +++ b/chain/blocksync/blocksync_client.go @@ -22,6 +22,7 @@ import ( "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/lib/cborutil" "github.com/filecoin-project/lotus/node/modules/dtypes" + "github.com/filecoin-project/lotus/peermgr" ) type BlockSync struct { @@ -29,13 +30,15 @@ type BlockSync struct { host host.Host syncPeers *bsPeerTracker + peerMgr *peermgr.PeerMgr } -func NewBlockSyncClient(bserv dtypes.ChainBlockService, h host.Host) *BlockSync { +func NewBlockSyncClient(bserv dtypes.ChainBlockService, h host.Host, pmgr peermgr.MaybePeerMgr) *BlockSync { return &BlockSync{ bserv: bserv, host: h, - syncPeers: newPeerTracker(), + syncPeers: newPeerTracker(pmgr.Mgr), + peerMgr: pmgr.Mgr, } } @@ -392,11 +395,14 @@ type bsPeerTracker struct { peers map[peer.ID]*peerStats avgGlobalTime time.Duration + + pmgr *peermgr.PeerMgr } -func newPeerTracker() *bsPeerTracker { +func newPeerTracker(pmgr *peermgr.PeerMgr) *bsPeerTracker { return &bsPeerTracker{ peers: make(map[peer.ID]*peerStats), + pmgr: pmgr, } } @@ -435,20 +441,31 @@ func (bpt *bsPeerTracker) prefSortedPeers() []peer.ID { var costI, costJ float64 + getPeerInitLat := func(p peer.ID) float64 { + var res float64 + if bpt.pmgr != nil { + if lat, ok := bpt.pmgr.GetPeerLatency(out[i]); ok { + res = float64(lat) + } + } + if res == 0 { + res = float64(bpt.avgGlobalTime) + } + return res * newPeerMul + } + if pi.successes+pi.failures > 0 { failRateI := float64(pi.failures) / float64(pi.failures+pi.successes) costI = float64(pi.averageTime) + failRateI*float64(bpt.avgGlobalTime) } else { - // we know nothing about this peer - // make them bit better than average - costI = 0.9 * float64(bpt.avgGlobalTime) + costI = getPeerInitLat(out[i]) } if pj.successes+pj.failures > 0 { failRateJ := float64(pj.failures) / float64(pj.failures+pj.successes) costJ = float64(pj.averageTime) + failRateJ*float64(bpt.avgGlobalTime) } else { - costJ = 0.9 * float64(bpt.avgGlobalTime) + costI = getPeerInitLat(out[i]) } return costI < costJ diff --git a/chain/blocksync/cbor_gen.go b/chain/blocksync/cbor_gen.go index 2f6be4e18..8e2627cb7 100644 --- a/chain/blocksync/cbor_gen.go +++ b/chain/blocksync/cbor_gen.go @@ -23,7 +23,7 @@ func (t *BlockSyncRequest) MarshalCBOR(w io.Writer) error { return err } - // t.t.Start ([]cid.Cid) (slice) + // t.Start ([]cid.Cid) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Start)))); err != nil { return err } @@ -33,12 +33,12 @@ func (t *BlockSyncRequest) MarshalCBOR(w io.Writer) error { } } - // t.t.RequestLength (uint64) (uint64) + // t.RequestLength (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.RequestLength))); err != nil { return err } - // t.t.Options (uint64) (uint64) + // t.Options (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Options))); err != nil { return err } @@ -60,7 +60,7 @@ func (t *BlockSyncRequest) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Start ([]cid.Cid) (slice) + // t.Start ([]cid.Cid) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -86,7 +86,7 @@ func (t *BlockSyncRequest) UnmarshalCBOR(r io.Reader) error { t.Start[i] = c } - // t.t.RequestLength (uint64) (uint64) + // t.RequestLength (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -96,7 +96,7 @@ func (t *BlockSyncRequest) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.RequestLength = uint64(extra) - // t.t.Options (uint64) (uint64) + // t.Options (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -118,7 +118,7 @@ func (t *BlockSyncResponse) MarshalCBOR(w io.Writer) error { return err } - // t.t.Chain ([]*blocksync.BSTipSet) (slice) + // t.Chain ([]*blocksync.BSTipSet) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Chain)))); err != nil { return err } @@ -128,12 +128,12 @@ func (t *BlockSyncResponse) MarshalCBOR(w io.Writer) error { } } - // t.t.Status (uint64) (uint64) + // t.Status (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Status))); err != nil { return err } - // t.t.Message (string) (string) + // t.Message (string) (string) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.Message)))); err != nil { return err } @@ -158,7 +158,7 @@ func (t *BlockSyncResponse) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Chain ([]*blocksync.BSTipSet) (slice) + // t.Chain ([]*blocksync.BSTipSet) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -185,7 +185,7 @@ func (t *BlockSyncResponse) UnmarshalCBOR(r io.Reader) error { t.Chain[i] = &v } - // t.t.Status (uint64) (uint64) + // t.Status (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -195,7 +195,7 @@ func (t *BlockSyncResponse) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Status = uint64(extra) - // t.t.Message (string) (string) + // t.Message (string) (string) { sval, err := cbg.ReadString(br) @@ -217,7 +217,7 @@ func (t *BSTipSet) MarshalCBOR(w io.Writer) error { return err } - // t.t.Blocks ([]*types.BlockHeader) (slice) + // t.Blocks ([]*types.BlockHeader) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Blocks)))); err != nil { return err } @@ -227,7 +227,7 @@ func (t *BSTipSet) MarshalCBOR(w io.Writer) error { } } - // t.t.BlsMessages ([]*types.Message) (slice) + // t.BlsMessages ([]*types.Message) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.BlsMessages)))); err != nil { return err } @@ -237,7 +237,7 @@ func (t *BSTipSet) MarshalCBOR(w io.Writer) error { } } - // t.t.BlsMsgIncludes ([][]uint64) (slice) + // t.BlsMsgIncludes ([][]uint64) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.BlsMsgIncludes)))); err != nil { return err } @@ -252,7 +252,7 @@ func (t *BSTipSet) MarshalCBOR(w io.Writer) error { } } - // t.t.SecpkMessages ([]*types.SignedMessage) (slice) + // t.SecpkMessages ([]*types.SignedMessage) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.SecpkMessages)))); err != nil { return err } @@ -262,7 +262,7 @@ func (t *BSTipSet) MarshalCBOR(w io.Writer) error { } } - // t.t.SecpkMsgIncludes ([][]uint64) (slice) + // t.SecpkMsgIncludes ([][]uint64) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.SecpkMsgIncludes)))); err != nil { return err } @@ -294,7 +294,7 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Blocks ([]*types.BlockHeader) (slice) + // t.Blocks ([]*types.BlockHeader) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -321,7 +321,7 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error { t.Blocks[i] = &v } - // t.t.BlsMessages ([]*types.Message) (slice) + // t.BlsMessages ([]*types.Message) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -348,7 +348,7 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error { t.BlsMessages[i] = &v } - // t.t.BlsMsgIncludes ([][]uint64) (slice) + // t.BlsMsgIncludes ([][]uint64) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -403,7 +403,7 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error { } } - // t.t.SecpkMessages ([]*types.SignedMessage) (slice) + // t.SecpkMessages ([]*types.SignedMessage) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -430,7 +430,7 @@ func (t *BSTipSet) UnmarshalCBOR(r io.Reader) error { t.SecpkMessages[i] = &v } - // t.t.SecpkMsgIncludes ([][]uint64) (slice) + // t.SecpkMsgIncludes ([][]uint64) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { diff --git a/chain/deals/cbor_gen.go b/chain/deals/cbor_gen.go index a5e20bb54..5d175fc72 100644 --- a/chain/deals/cbor_gen.go +++ b/chain/deals/cbor_gen.go @@ -24,7 +24,7 @@ func (t *AskRequest) MarshalCBOR(w io.Writer) error { return err } - // t.t.Miner (address.Address) (struct) + // t.Miner (address.Address) (struct) if err := t.Miner.MarshalCBOR(w); err != nil { return err } @@ -46,7 +46,7 @@ func (t *AskRequest) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Miner (address.Address) (struct) + // t.Miner (address.Address) (struct) { @@ -67,7 +67,7 @@ func (t *AskResponse) MarshalCBOR(w io.Writer) error { return err } - // t.t.Ask (types.SignedStorageAsk) (struct) + // t.Ask (types.SignedStorageAsk) (struct) if err := t.Ask.MarshalCBOR(w); err != nil { return err } @@ -89,7 +89,7 @@ func (t *AskResponse) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Ask (types.SignedStorageAsk) (struct) + // t.Ask (types.SignedStorageAsk) (struct) { @@ -122,12 +122,12 @@ func (t *Proposal) MarshalCBOR(w io.Writer) error { return err } - // t.t.DealProposal (actors.StorageDealProposal) (struct) + // t.DealProposal (actors.StorageDealProposal) (struct) if err := t.DealProposal.MarshalCBOR(w); err != nil { return err } - // t.t.Piece (cid.Cid) (struct) + // t.Piece (cid.Cid) (struct) if err := cbg.WriteCid(w, t.Piece); err != nil { return xerrors.Errorf("failed to write cid field t.Piece: %w", err) @@ -151,7 +151,7 @@ func (t *Proposal) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.DealProposal (actors.StorageDealProposal) (struct) + // t.DealProposal (actors.StorageDealProposal) (struct) { @@ -172,7 +172,7 @@ func (t *Proposal) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Piece (cid.Cid) (struct) + // t.Piece (cid.Cid) (struct) { @@ -192,16 +192,16 @@ func (t *Response) MarshalCBOR(w io.Writer) error { _, err := w.Write(cbg.CborNull) return err } - if _, err := w.Write([]byte{133}); err != nil { + if _, err := w.Write([]byte{132}); err != nil { return err } - // t.t.State (uint64) (uint64) + // t.State (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.State))); err != nil { return err } - // t.t.Message (string) (string) + // t.Message (string) (string) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.Message)))); err != nil { return err } @@ -209,29 +209,16 @@ func (t *Response) MarshalCBOR(w io.Writer) error { return err } - // t.t.Proposal (cid.Cid) (struct) + // t.Proposal (cid.Cid) (struct) if err := cbg.WriteCid(w, t.Proposal); err != nil { return xerrors.Errorf("failed to write cid field t.Proposal: %w", err) } - // t.t.StorageDeal (actors.StorageDeal) (struct) - if err := t.StorageDeal.MarshalCBOR(w); err != nil { + // t.StorageDealSubmission (types.SignedMessage) (struct) + if err := t.StorageDealSubmission.MarshalCBOR(w); err != nil { return err } - - // t.t.PublishMessage (cid.Cid) (struct) - - if t.PublishMessage == nil { - if _, err := w.Write(cbg.CborNull); err != nil { - return err - } - } else { - if err := cbg.WriteCid(w, *t.PublishMessage); err != nil { - return xerrors.Errorf("failed to write cid field t.PublishMessage: %w", err) - } - } - return nil } @@ -246,11 +233,11 @@ func (t *Response) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input should be of type array") } - if extra != 5 { + if extra != 4 { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.State (uint64) (uint64) + // t.State (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -260,7 +247,7 @@ func (t *Response) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.State = uint64(extra) - // t.t.Message (string) (string) + // t.Message (string) (string) { sval, err := cbg.ReadString(br) @@ -270,7 +257,7 @@ func (t *Response) UnmarshalCBOR(r io.Reader) error { t.Message = string(sval) } - // t.t.Proposal (cid.Cid) (struct) + // t.Proposal (cid.Cid) (struct) { @@ -282,7 +269,7 @@ func (t *Response) UnmarshalCBOR(r io.Reader) error { t.Proposal = c } - // t.t.StorageDeal (actors.StorageDeal) (struct) + // t.StorageDealSubmission (types.SignedMessage) (struct) { @@ -296,36 +283,12 @@ func (t *Response) UnmarshalCBOR(r io.Reader) error { return err } } else { - t.StorageDeal = new(actors.StorageDeal) - if err := t.StorageDeal.UnmarshalCBOR(br); err != nil { + t.StorageDealSubmission = new(types.SignedMessage) + if err := t.StorageDealSubmission.UnmarshalCBOR(br); err != nil { return err } } - } - // t.t.PublishMessage (cid.Cid) (struct) - - { - - pb, err := br.PeekByte() - if err != nil { - return err - } - if pb == cbg.CborNull[0] { - var nbuf [1]byte - if _, err := br.Read(nbuf[:]); err != nil { - return err - } - } else { - - c, err := cbg.ReadCid(br) - if err != nil { - return xerrors.Errorf("failed to read cid field t.PublishMessage: %w", err) - } - - t.PublishMessage = &c - } - } return nil } @@ -339,12 +302,12 @@ func (t *SignedResponse) MarshalCBOR(w io.Writer) error { return err } - // t.t.Response (deals.Response) (struct) + // t.Response (deals.Response) (struct) if err := t.Response.MarshalCBOR(w); err != nil { return err } - // t.t.Signature (types.Signature) (struct) + // t.Signature (types.Signature) (struct) if err := t.Signature.MarshalCBOR(w); err != nil { return err } @@ -366,7 +329,7 @@ func (t *SignedResponse) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Response (deals.Response) (struct) + // t.Response (deals.Response) (struct) { @@ -375,7 +338,7 @@ func (t *SignedResponse) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Signature (types.Signature) (struct) + // t.Signature (types.Signature) (struct) { @@ -408,43 +371,43 @@ func (t *ClientDealProposal) MarshalCBOR(w io.Writer) error { return err } - // t.t.Data (cid.Cid) (struct) + // t.Data (cid.Cid) (struct) if err := cbg.WriteCid(w, t.Data); err != nil { return xerrors.Errorf("failed to write cid field t.Data: %w", err) } - // t.t.PricePerEpoch (types.BigInt) (struct) + // t.PricePerEpoch (types.BigInt) (struct) if err := t.PricePerEpoch.MarshalCBOR(w); err != nil { return err } - // t.t.ProposalExpiration (uint64) (uint64) + // t.ProposalExpiration (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.ProposalExpiration))); err != nil { return err } - // t.t.Duration (uint64) (uint64) + // t.Duration (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Duration))); err != nil { return err } - // t.t.ProviderAddress (address.Address) (struct) + // t.ProviderAddress (address.Address) (struct) if err := t.ProviderAddress.MarshalCBOR(w); err != nil { return err } - // t.t.Client (address.Address) (struct) + // t.Client (address.Address) (struct) if err := t.Client.MarshalCBOR(w); err != nil { return err } - // t.t.MinerWorker (address.Address) (struct) + // t.MinerWorker (address.Address) (struct) if err := t.MinerWorker.MarshalCBOR(w); err != nil { return err } - // t.t.MinerID (peer.ID) (string) + // t.MinerID (peer.ID) (string) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.MinerID)))); err != nil { return err } @@ -469,7 +432,7 @@ func (t *ClientDealProposal) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Data (cid.Cid) (struct) + // t.Data (cid.Cid) (struct) { @@ -481,7 +444,7 @@ func (t *ClientDealProposal) UnmarshalCBOR(r io.Reader) error { t.Data = c } - // t.t.PricePerEpoch (types.BigInt) (struct) + // t.PricePerEpoch (types.BigInt) (struct) { @@ -490,7 +453,7 @@ func (t *ClientDealProposal) UnmarshalCBOR(r io.Reader) error { } } - // t.t.ProposalExpiration (uint64) (uint64) + // t.ProposalExpiration (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -500,7 +463,7 @@ func (t *ClientDealProposal) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.ProposalExpiration = uint64(extra) - // t.t.Duration (uint64) (uint64) + // t.Duration (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -510,7 +473,7 @@ func (t *ClientDealProposal) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Duration = uint64(extra) - // t.t.ProviderAddress (address.Address) (struct) + // t.ProviderAddress (address.Address) (struct) { @@ -519,7 +482,7 @@ func (t *ClientDealProposal) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Client (address.Address) (struct) + // t.Client (address.Address) (struct) { @@ -528,7 +491,7 @@ func (t *ClientDealProposal) UnmarshalCBOR(r io.Reader) error { } } - // t.t.MinerWorker (address.Address) (struct) + // t.MinerWorker (address.Address) (struct) { @@ -537,7 +500,7 @@ func (t *ClientDealProposal) UnmarshalCBOR(r io.Reader) error { } } - // t.t.MinerID (peer.ID) (string) + // t.MinerID (peer.ID) (string) { sval, err := cbg.ReadString(br) @@ -559,23 +522,23 @@ func (t *ClientDeal) MarshalCBOR(w io.Writer) error { return err } - // t.t.ProposalCid (cid.Cid) (struct) + // t.ProposalCid (cid.Cid) (struct) if err := cbg.WriteCid(w, t.ProposalCid); err != nil { return xerrors.Errorf("failed to write cid field t.ProposalCid: %w", err) } - // t.t.Proposal (actors.StorageDealProposal) (struct) + // t.Proposal (actors.StorageDealProposal) (struct) if err := t.Proposal.MarshalCBOR(w); err != nil { return err } - // t.t.State (uint64) (uint64) + // t.State (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.State))); err != nil { return err } - // t.t.Miner (peer.ID) (string) + // t.Miner (peer.ID) (string) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.Miner)))); err != nil { return err } @@ -583,28 +546,20 @@ func (t *ClientDeal) MarshalCBOR(w io.Writer) error { return err } - // t.t.MinerWorker (address.Address) (struct) + // t.MinerWorker (address.Address) (struct) if err := t.MinerWorker.MarshalCBOR(w); err != nil { return err } - // t.t.DealID (uint64) (uint64) + // t.DealID (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.DealID))); err != nil { return err } - // t.t.PublishMessage (cid.Cid) (struct) - - if t.PublishMessage == nil { - if _, err := w.Write(cbg.CborNull); err != nil { - return err - } - } else { - if err := cbg.WriteCid(w, *t.PublishMessage); err != nil { - return xerrors.Errorf("failed to write cid field t.PublishMessage: %w", err) - } + // t.PublishMessage (types.SignedMessage) (struct) + if err := t.PublishMessage.MarshalCBOR(w); err != nil { + return err } - return nil } @@ -623,7 +578,7 @@ func (t *ClientDeal) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.ProposalCid (cid.Cid) (struct) + // t.ProposalCid (cid.Cid) (struct) { @@ -635,7 +590,7 @@ func (t *ClientDeal) UnmarshalCBOR(r io.Reader) error { t.ProposalCid = c } - // t.t.Proposal (actors.StorageDealProposal) (struct) + // t.Proposal (actors.StorageDealProposal) (struct) { @@ -644,7 +599,7 @@ func (t *ClientDeal) UnmarshalCBOR(r io.Reader) error { } } - // t.t.State (uint64) (uint64) + // t.State (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -654,7 +609,7 @@ func (t *ClientDeal) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.State = uint64(extra) - // t.t.Miner (peer.ID) (string) + // t.Miner (peer.ID) (string) { sval, err := cbg.ReadString(br) @@ -664,7 +619,7 @@ func (t *ClientDeal) UnmarshalCBOR(r io.Reader) error { t.Miner = peer.ID(sval) } - // t.t.MinerWorker (address.Address) (struct) + // t.MinerWorker (address.Address) (struct) { @@ -673,7 +628,7 @@ func (t *ClientDeal) UnmarshalCBOR(r io.Reader) error { } } - // t.t.DealID (uint64) (uint64) + // t.DealID (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -683,7 +638,7 @@ func (t *ClientDeal) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.DealID = uint64(extra) - // t.t.PublishMessage (cid.Cid) (struct) + // t.PublishMessage (types.SignedMessage) (struct) { @@ -697,13 +652,10 @@ func (t *ClientDeal) UnmarshalCBOR(r io.Reader) error { return err } } else { - - c, err := cbg.ReadCid(br) - if err != nil { - return xerrors.Errorf("failed to read cid field t.PublishMessage: %w", err) + t.PublishMessage = new(types.SignedMessage) + if err := t.PublishMessage.UnmarshalCBOR(br); err != nil { + return err } - - t.PublishMessage = &c } } @@ -719,7 +671,7 @@ func (t *MinerDeal) MarshalCBOR(w io.Writer) error { return err } - // t.t.Client (peer.ID) (string) + // t.Client (peer.ID) (string) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.Client)))); err != nil { return err } @@ -727,34 +679,34 @@ func (t *MinerDeal) MarshalCBOR(w io.Writer) error { return err } - // t.t.Proposal (actors.StorageDealProposal) (struct) + // t.Proposal (actors.StorageDealProposal) (struct) if err := t.Proposal.MarshalCBOR(w); err != nil { return err } - // t.t.ProposalCid (cid.Cid) (struct) + // t.ProposalCid (cid.Cid) (struct) if err := cbg.WriteCid(w, t.ProposalCid); err != nil { return xerrors.Errorf("failed to write cid field t.ProposalCid: %w", err) } - // t.t.State (uint64) (uint64) + // t.State (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.State))); err != nil { return err } - // t.t.Ref (cid.Cid) (struct) + // t.Ref (cid.Cid) (struct) if err := cbg.WriteCid(w, t.Ref); err != nil { return xerrors.Errorf("failed to write cid field t.Ref: %w", err) } - // t.t.DealID (uint64) (uint64) + // t.DealID (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.DealID))); err != nil { return err } - // t.t.SectorID (uint64) (uint64) + // t.SectorID (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SectorID))); err != nil { return err } @@ -776,7 +728,7 @@ func (t *MinerDeal) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Client (peer.ID) (string) + // t.Client (peer.ID) (string) { sval, err := cbg.ReadString(br) @@ -786,7 +738,7 @@ func (t *MinerDeal) UnmarshalCBOR(r io.Reader) error { t.Client = peer.ID(sval) } - // t.t.Proposal (actors.StorageDealProposal) (struct) + // t.Proposal (actors.StorageDealProposal) (struct) { @@ -795,7 +747,7 @@ func (t *MinerDeal) UnmarshalCBOR(r io.Reader) error { } } - // t.t.ProposalCid (cid.Cid) (struct) + // t.ProposalCid (cid.Cid) (struct) { @@ -807,7 +759,7 @@ func (t *MinerDeal) UnmarshalCBOR(r io.Reader) error { t.ProposalCid = c } - // t.t.State (uint64) (uint64) + // t.State (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -817,7 +769,7 @@ func (t *MinerDeal) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.State = uint64(extra) - // t.t.Ref (cid.Cid) (struct) + // t.Ref (cid.Cid) (struct) { @@ -829,7 +781,7 @@ func (t *MinerDeal) UnmarshalCBOR(r io.Reader) error { t.Ref = c } - // t.t.DealID (uint64) (uint64) + // t.DealID (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -839,7 +791,7 @@ func (t *MinerDeal) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.DealID = uint64(extra) - // t.t.SectorID (uint64) (uint64) + // t.SectorID (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -861,13 +813,13 @@ func (t *StorageDataTransferVoucher) MarshalCBOR(w io.Writer) error { return err } - // t.t.Proposal (cid.Cid) (struct) + // t.Proposal (cid.Cid) (struct) if err := cbg.WriteCid(w, t.Proposal); err != nil { return xerrors.Errorf("failed to write cid field t.Proposal: %w", err) } - // t.t.DealID (uint64) (uint64) + // t.DealID (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.DealID))); err != nil { return err } @@ -889,7 +841,7 @@ func (t *StorageDataTransferVoucher) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Proposal (cid.Cid) (struct) + // t.Proposal (cid.Cid) (struct) { @@ -901,7 +853,7 @@ func (t *StorageDataTransferVoucher) UnmarshalCBOR(r io.Reader) error { t.Proposal = c } - // t.t.DealID (uint64) (uint64) + // t.DealID (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { diff --git a/chain/deals/client.go b/chain/deals/client.go index 988bc52b6..8580a2bbd 100644 --- a/chain/deals/client.go +++ b/chain/deals/client.go @@ -36,7 +36,7 @@ type ClientDeal struct { MinerWorker address.Address DealID uint64 - PublishMessage *cid.Cid + PublishMessage *types.SignedMessage s inet.Stream } @@ -206,7 +206,6 @@ func (c *Client) Start(ctx context.Context, p ClientDealProposal) (cid.Cid, erro dealProposal := &actors.StorageDealProposal{ PieceRef: commP, PieceSize: uint64(pieceSize), - PieceSerialization: actors.SerializationUnixFSv0, Client: p.Client, Provider: p.ProviderAddress, ProposalExpiration: p.ProposalExpiration, diff --git a/chain/deals/client_states.go b/chain/deals/client_states.go index bac7aab47..23643b058 100644 --- a/chain/deals/client_states.go +++ b/chain/deals/client_states.go @@ -44,6 +44,9 @@ func (c *Client) new(ctx context.Context, deal ClientDeal) (func(*ClientDeal), e if err != nil { return nil, err } + + // TODO: verify StorageDealSubmission + if err := c.disconnect(deal); err != nil { return nil, err } @@ -54,18 +57,14 @@ func (c *Client) new(ctx context.Context, deal ClientDeal) (func(*ClientDeal), e } return func(info *ClientDeal) { - info.PublishMessage = resp.PublishMessage + info.PublishMessage = resp.StorageDealSubmission }, nil } func (c *Client) accepted(ctx context.Context, deal ClientDeal) (func(*ClientDeal), error) { log.Infow("DEAL ACCEPTED!") - pubmsg, err := c.chain.GetMessage(*deal.PublishMessage) - if err != nil { - return nil, xerrors.Errorf("getting deal pubsish message: %w", err) - } - + pubmsg := deal.PublishMessage.Message pw, err := stmgr.GetMinerWorker(ctx, c.sm, nil, deal.Proposal.Provider) if err != nil { return nil, xerrors.Errorf("getting miner worker failed: %w", err) @@ -91,7 +90,8 @@ func (c *Client) accepted(ctx context.Context, deal ClientDeal) (func(*ClientDea dealIdx := -1 for i, storageDeal := range params.Deals { // TODO: make it less hacky - eq, err := cborutil.Equals(&deal.Proposal, &storageDeal.Proposal) + sd := storageDeal + eq, err := cborutil.Equals(&deal.Proposal, &sd) if err != nil { return nil, err } @@ -102,11 +102,11 @@ func (c *Client) accepted(ctx context.Context, deal ClientDeal) (func(*ClientDea } if dealIdx == -1 { - return nil, xerrors.Errorf("deal publish didn't contain our deal (message cid: %s)", deal.PublishMessage) + return nil, xerrors.Errorf("deal publish didn't contain our deal (message cid: %s)", deal.PublishMessage.Cid()) } // TODO: timeout - _, ret, err := c.sm.WaitForMessage(ctx, *deal.PublishMessage) + _, ret, err := c.sm.WaitForMessage(ctx, deal.PublishMessage.Cid()) if err != nil { return nil, xerrors.Errorf("waiting for deal publish message: %w", err) } diff --git a/chain/deals/provider_states.go b/chain/deals/provider_states.go index 56843e7d0..4faa44973 100644 --- a/chain/deals/provider_states.go +++ b/chain/deals/provider_states.go @@ -42,13 +42,6 @@ func (p *Provider) handle(ctx context.Context, deal MinerDeal, cb providerHandle // ACCEPTED func (p *Provider) accept(ctx context.Context, deal MinerDeal) (func(*MinerDeal), error) { - switch deal.Proposal.PieceSerialization { - //case SerializationRaw: - //case SerializationIPLD: - case actors.SerializationUnixFSv0: - default: - return nil, xerrors.Errorf("deal proposal with unsupported serialization: %s", deal.Proposal.PieceSerialization) - } head, err := p.full.ChainHead(ctx) if err != nil { @@ -93,15 +86,8 @@ func (p *Provider) accept(ctx context.Context, deal MinerDeal) (func(*MinerDeal) log.Info("publishing deal") - storageDeal := actors.StorageDeal{ - Proposal: deal.Proposal, - } - if err := api.SignWith(ctx, p.full.WalletSign, waddr, &storageDeal); err != nil { - return nil, xerrors.Errorf("signing storage deal failed: ", err) - } - params, err := actors.SerializeParams(&actors.PublishStorageDealsParams{ - Deals: []actors.StorageDeal{storageDeal}, + Deals: []actors.StorageDealProposal{deal.Proposal}, }) if err != nil { return nil, xerrors.Errorf("serializing PublishStorageDeals params failed: ", err) @@ -136,13 +122,11 @@ func (p *Provider) accept(ctx context.Context, deal MinerDeal) (func(*MinerDeal) } log.Infof("fetching data for a deal %d", resp.DealIDs[0]) - mcid := smsg.Cid() err = p.sendSignedResponse(&Response{ State: api.DealAccepted, - Proposal: deal.ProposalCid, - PublishMessage: &mcid, - StorageDeal: &storageDeal, + Proposal: deal.ProposalCid, + StorageDealSubmission: smsg, }) if err != nil { return nil, err diff --git a/chain/deals/types.go b/chain/deals/types.go index 3ea80ebe7..eebca4f60 100644 --- a/chain/deals/types.go +++ b/chain/deals/types.go @@ -58,8 +58,7 @@ type Response struct { Proposal cid.Cid // DealAccepted - StorageDeal *actors.StorageDeal - PublishMessage *cid.Cid + StorageDealSubmission *types.SignedMessage } // TODO: Do we actually need this to be signed? diff --git a/chain/gen/gen.go b/chain/gen/gen.go index 866a75357..07565d4b8 100644 --- a/chain/gen/gen.go +++ b/chain/gen/gen.go @@ -528,7 +528,7 @@ func IsRoundWinner(ctx context.Context, ts *types.TipSet, round int64, miner add var winners []sectorbuilder.EPostCandidate for _, c := range candidates { - if types.IsTicketWinner(c.PartialTicket[:], ssize, pow.TotalPower) { + if types.IsTicketWinner(c.PartialTicket[:], ssize, uint64(len(sinfos)), pow.TotalPower) { winners = append(winners, c) } } diff --git a/chain/gen/gen_test.go b/chain/gen/gen_test.go index 3ab989e72..260259869 100644 --- a/chain/gen/gen_test.go +++ b/chain/gen/gen_test.go @@ -8,6 +8,7 @@ import ( func init() { build.SectorSizes = []uint64{1024} + build.MinimumMinerPower = 1024 } func testGeneration(t testing.TB, n int, msgs int) { diff --git a/chain/gen/utils.go b/chain/gen/utils.go index 34cdce95b..c707f2242 100644 --- a/chain/gen/utils.go +++ b/chain/gen/utils.go @@ -197,7 +197,7 @@ func SetupStoragePowerActor(bs bstore.Blockstore) (*types.Actor, error) { }, nil } -func SetupStorageMarketActor(bs bstore.Blockstore, sroot cid.Cid, deals []actors.StorageDeal) (cid.Cid, error) { +func SetupStorageMarketActor(bs bstore.Blockstore, sroot cid.Cid, deals []actors.StorageDealProposal) (cid.Cid, error) { cst := hamt.CSTFromBstore(bs) nd := hamt.NewNode(cst) emptyHAMT, err := cst.Put(context.TODO(), nd) @@ -210,8 +210,15 @@ func SetupStorageMarketActor(bs bstore.Blockstore, sroot cid.Cid, deals []actors cdeals := make([]cbg.CBORMarshaler, len(deals)) for i, deal := range deals { cdeals[i] = &actors.OnChainDeal{ - Deal: deal, - ActivationEpoch: 1, + PieceRef: deal.PieceRef, + PieceSize: deal.PieceSize, + Client: deal.Client, + Provider: deal.Provider, + ProposalExpiration: deal.ProposalExpiration, + Duration: deal.Duration, + StoragePricePerEpoch: deal.StoragePricePerEpoch, + StorageCollateral: deal.StorageCollateral, + ActivationEpoch: 1, } } @@ -267,7 +274,7 @@ func mustEnc(i cbg.CBORMarshaler) []byte { return enc } -func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid, gmcfg *GenMinerCfg) (cid.Cid, []actors.StorageDeal, error) { +func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid, gmcfg *GenMinerCfg) (cid.Cid, []actors.StorageDealProposal, error) { vm, err := vm.NewVM(sroot, 0, nil, actors.NetworkAddress, cs.Blockstore()) if err != nil { return cid.Undef, nil, xerrors.Errorf("failed to create NewVM: %w", err) @@ -281,7 +288,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid return cid.Undef, nil, xerrors.Errorf("miner address list, and preseal count doesn't match (%d != %d)", len(gmcfg.MinerAddrs), len(gmcfg.PreSeals)) } - var deals []actors.StorageDeal + var deals []actors.StorageDealProposal for i, maddr := range gmcfg.MinerAddrs { ps, psok := gmcfg.PreSeals[maddr.String()] @@ -344,7 +351,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid if err := cst.Get(ctx, mact.Head, &mstate); err != nil { return cid.Undef, nil, xerrors.Errorf("getting miner actor state failed: %w", err) } - mstate.Power = types.BigMul(types.NewInt(build.SectorSizes[0]), types.NewInt(uint64(len(ps.Sectors)))) + mstate.Power = types.BigMul(types.NewInt(ps.SectorSize), types.NewInt(uint64(len(ps.Sectors)))) blks := amt.WrapBlockstore(cs.Blockstore()) diff --git a/chain/messagepool/messagepool.go b/chain/messagepool/messagepool.go index 1a827c1bd..0ae295516 100644 --- a/chain/messagepool/messagepool.go +++ b/chain/messagepool/messagepool.go @@ -166,7 +166,7 @@ func New(api Provider, ds dtypes.MetadataDS) (*MessagePool, error) { } if err := mp.loadLocal(); err != nil { - return nil, xerrors.Errorf("loading local messages: %w", err) + log.Errorf("loading local messages: %+v", err) } go mp.repubLocal() @@ -192,14 +192,43 @@ func (mp *MessagePool) repubLocal() { select { case <-mp.repubTk.C: mp.lk.Lock() - msgs := make([]*types.SignedMessage, 0) + + msgsForAddr := make(map[address.Address][]*types.SignedMessage) for a := range mp.localAddrs { - msgs = append(msgs, mp.pendingFor(a)...) + msgsForAddr[a] = mp.pendingFor(a) } + mp.lk.Unlock() var errout error - for _, msg := range msgs { + outputMsgs := []*types.SignedMessage{} + + for a, msgs := range msgsForAddr { + a, err := mp.api.StateGetActor(a, nil) + if err != nil { + errout = multierr.Append(errout, xerrors.Errorf("could not get actor state: %w", err)) + continue + } + + curNonce := a.Nonce + for _, m := range msgs { + if m.Message.Nonce < curNonce { + continue + } + if m.Message.Nonce != curNonce { + break + } + outputMsgs = append(outputMsgs, m) + curNonce++ + } + + } + + if len(outputMsgs) != 0 { + log.Infow("republishing local messages", "n", len(outputMsgs)) + } + + for _, msg := range outputMsgs { msgb, err := msg.Serialize() if err != nil { errout = multierr.Append(errout, xerrors.Errorf("could not serialize: %w", err)) @@ -683,7 +712,7 @@ func (mp *MessagePool) loadLocal() error { continue // todo: drop the message from local cache (if above certain confidence threshold) } - return xerrors.Errorf("adding local message: %w", err) + log.Errorf("adding local message: %+v", err) } } diff --git a/chain/stmgr/stmgr.go b/chain/stmgr/stmgr.go index 079a51ad1..bd3e16032 100644 --- a/chain/stmgr/stmgr.go +++ b/chain/stmgr/stmgr.go @@ -138,7 +138,7 @@ func (sm *StateManager) computeTipSetState(ctx context.Context, blks []*types.Bl return cid.Undef, cid.Undef, xerrors.Errorf("failed to get network actor: %w", err) } reward := vm.MiningReward(netact.Balance) - for _, b := range blks { + for tsi, b := range blks { netact, err = vmi.StateTree().GetActor(actors.NetworkAddress) if err != nil { return cid.Undef, cid.Undef, xerrors.Errorf("failed to get network actor: %w", err) @@ -171,10 +171,10 @@ func (sm *StateManager) computeTipSetState(ctx context.Context, blks []*types.Bl } ret, err := vmi.ApplyMessage(ctx, postSubmitMsg) if err != nil { - return cid.Undef, cid.Undef, xerrors.Errorf("submit election post message invocation failed: %w", err) + return cid.Undef, cid.Undef, xerrors.Errorf("submit election post message for block %s (miner %s) invocation failed: %w", b.Cid(), b.Miner, err) } if ret.ExitCode != 0 { - return cid.Undef, cid.Undef, xerrors.Errorf("submit election post invocation returned nonzero exit code: %d", ret.ExitCode) + return cid.Undef, cid.Undef, xerrors.Errorf("submit election post invocation returned nonzero exit code: %d (err = %s, block = %s, miner = %s, tsi = %d)", ret.ExitCode, ret.ActorErr, b.Cid(), b.Miner, tsi) } } diff --git a/chain/store/store.go b/chain/store/store.go index b371ec6e1..83f957264 100644 --- a/chain/store/store.go +++ b/chain/store/store.go @@ -155,6 +155,8 @@ func (cs *ChainStore) SubHeadChanges(ctx context.Context) chan []*HeadChange { go func() { defer close(out) + var unsubOnce sync.Once + for { select { case val, ok := <-subch: @@ -170,7 +172,9 @@ func (cs *ChainStore) SubHeadChanges(ctx context.Context) chan []*HeadChange { case <-ctx.Done(): } case <-ctx.Done(): - go cs.bestTips.Unsub(subch) + unsubOnce.Do(func() { + go cs.bestTips.Unsub(subch) + }) } } }() @@ -490,6 +494,7 @@ func (cs *ChainStore) expandTipset(b *types.BlockHeader) (*types.TipSet, error) return types.NewTipSet(all) } + inclMiners := map[address.Address]bool{b.Miner: true} for _, bhc := range tsets { if bhc == b.Cid() { continue @@ -500,8 +505,14 @@ func (cs *ChainStore) expandTipset(b *types.BlockHeader) (*types.TipSet, error) return nil, xerrors.Errorf("failed to load block (%s) for tipset expansion: %w", bhc, err) } + if inclMiners[h.Miner] { + log.Warnf("Have multiple blocks from miner %s at height %d in our tipset cache", h.Miner, h.Height) + continue + } + if types.CidArrsEqual(h.Parents, b.Parents) { all = append(all, h) + inclMiners[h.Miner] = true } } diff --git a/chain/sync.go b/chain/sync.go index 9d9e799f1..b65341825 100644 --- a/chain/sync.go +++ b/chain/sync.go @@ -492,7 +492,16 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) err } winnerCheck := async.Err(func() error { - _, tpow, err := stmgr.GetPower(ctx, syncer.sm, baseTs, h.Miner) + slashedAt, err := stmgr.GetMinerSlashed(ctx, syncer.sm, baseTs, h.Miner) + if err != nil { + return xerrors.Errorf("failed to check if block miner was slashed: %w", err) + } + + if slashedAt != 0 { + return xerrors.Errorf("received block was from miner slashed at height %d", slashedAt) + } + + mpow, tpow, err := stmgr.GetPower(ctx, syncer.sm, baseTs, h.Miner) if err != nil { return xerrors.Errorf("failed getting power: %w", err) } @@ -502,8 +511,10 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) err return xerrors.Errorf("failed to get sector size for block miner: %w", err) } + snum := types.BigDiv(mpow, types.NewInt(ssize)) + for _, t := range h.EPostProof.Candidates { - if !types.IsTicketWinner(t.Partial, ssize, tpow) { + if !types.IsTicketWinner(t.Partial, ssize, snum.Uint64(), tpow) { return xerrors.Errorf("miner created a block but was not a winner") } } @@ -930,6 +941,12 @@ func (syncer *Syncer) syncFork(ctx context.Context, from *types.TipSet, to *type } for cur := 0; cur < len(tips); { + if nts.Height() == 0 { + if !syncer.Genesis.Equals(nts) { + return nil, xerrors.Errorf("somehow synced chain that linked back to a different genesis (bad genesis: %s)", nts.Key()) + } + return nil, xerrors.Errorf("synced chain forked at genesis, refusing to sync") + } if nts.Equals(tips[cur]) { return tips[:cur+1], nil diff --git a/chain/sync_test.go b/chain/sync_test.go index 30c770195..f9c62b93e 100644 --- a/chain/sync_test.go +++ b/chain/sync_test.go @@ -28,6 +28,7 @@ func init() { build.InsecurePoStValidation = true os.Setenv("TRUST_PARAMS", "1") build.SectorSizes = []uint64{1024} + build.MinimumMinerPower = 1024 } const source = 0 diff --git a/chain/types/bigint.go b/chain/types/bigint.go index 266f2a8af..612fd34dc 100644 --- a/chain/types/bigint.go +++ b/chain/types/bigint.go @@ -237,3 +237,7 @@ func (bi *BigInt) UnmarshalCBOR(br io.Reader) error { return nil } + +func (bi *BigInt) IsZero() bool { + return bi.Int.Sign() == 0 +} diff --git a/chain/types/bitfield.go b/chain/types/bitfield.go index b4687f5e8..20e63dd95 100644 --- a/chain/types/bitfield.go +++ b/chain/types/bitfield.go @@ -34,6 +34,38 @@ func BitFieldFromSet(setBits []uint64) BitField { return res } +func MergeBitFields(a, b BitField) (BitField, error) { + ra, err := a.rle.RunIterator() + if err != nil { + return BitField{}, err + } + + rb, err := b.rle.RunIterator() + if err != nil { + return BitField{}, err + } + + merge, err := rlepluslazy.Sum(ra, rb) + if err != nil { + return BitField{}, err + } + + mergebytes, err := rlepluslazy.EncodeRuns(merge, nil) + if err != nil { + return BitField{}, err + } + + rle, err := rlepluslazy.FromBuf(mergebytes) + if err != nil { + return BitField{}, err + } + + return BitField{ + rle: rle, + bits: make(map[uint64]struct{}), + }, nil +} + func (bf BitField) sum() (rlepluslazy.RunIterator, error) { if len(bf.bits) == 0 { return bf.rle.RunIterator() @@ -86,7 +118,26 @@ func (bf BitField) All() ([]uint64, error) { return nil, err } - return res, err + return res, nil +} + +func (bf BitField) AllMap() (map[uint64]bool, error) { + + runs, err := bf.sum() + if err != nil { + return nil, err + } + + res, err := rlepluslazy.SliceFromRuns(runs) + if err != nil { + return nil, err + } + + out := make(map[uint64]bool) + for _, i := range res { + out[i] = true + } + return out, nil } func (bf BitField) MarshalCBOR(w io.Writer) error { diff --git a/chain/types/blockheader.go b/chain/types/blockheader.go index 7ba5ef436..e44ca54b4 100644 --- a/chain/types/blockheader.go +++ b/chain/types/blockheader.go @@ -174,9 +174,9 @@ var blocksPerEpoch = NewInt(build.BlocksPerEpoch) const sha256bits = 256 -func IsTicketWinner(partialTicket []byte, ssizeI uint64, totpow BigInt) bool { +func IsTicketWinner(partialTicket []byte, ssizeI uint64, snum uint64, totpow BigInt) bool { ssize := NewInt(ssizeI) - + ssampled := ElectionPostChallengeCount(snum) /* Need to check that (h(vrfout) + 1) / (max(h) + 1) <= e * sectorSize / totalPower @@ -185,23 +185,42 @@ func IsTicketWinner(partialTicket []byte, ssizeI uint64, totpow BigInt) bool { (h(vrfout) + 1) * totalPower <= e * sectorSize * 2^256 in 2^256 space, it is equivalent to: h(vrfout) * totalPower < e * sectorSize * 2^256 + + Because of SectorChallengeRatioDiv sampling for proofs + we need to scale this appropriately. + + Let c = ceil(numSectors/SectorChallengeRatioDiv) + (c is the number of tickets a miner requests) + Accordingly we check + (h(vrfout) + 1) / 2^256 <= e * sectorSize / totalPower * snum / c + or + h(vrfout) * totalPower * c < e * sectorSize * 2^256 * snum */ h := sha256.Sum256(partialTicket) lhs := BigFromBytes(h[:]).Int lhs = lhs.Mul(lhs, totpow.Int) + lhs = lhs.Mul(lhs, new(big.Int).SetUint64(ssampled)) // rhs = sectorSize * 2^256 // rhs = sectorSize << 256 rhs := new(big.Int).Lsh(ssize.Int, sha256bits) - rhs = rhs.Mul(rhs, big.NewInt(build.SectorChallengeRatioDiv)) + rhs = rhs.Mul(rhs, new(big.Int).SetUint64(snum)) rhs = rhs.Mul(rhs, blocksPerEpoch.Int) // h(vrfout) * totalPower < e * sectorSize * 2^256? return lhs.Cmp(rhs) < 0 } +func ElectionPostChallengeCount(sectors uint64) uint64 { + if sectors == 0 { + return 0 + } + // ceil(sectors / build.SectorChallengeRatioDiv) + return (sectors-1)/build.SectorChallengeRatioDiv + 1 +} + func (t *Ticket) Equals(ot *Ticket) bool { return bytes.Equal(t.VRFProof, ot.VRFProof) } diff --git a/chain/types/cbor_gen.go b/chain/types/cbor_gen.go index 9a359cd45..5bf2ffce8 100644 --- a/chain/types/cbor_gen.go +++ b/chain/types/cbor_gen.go @@ -23,22 +23,22 @@ func (t *BlockHeader) MarshalCBOR(w io.Writer) error { return err } - // t.t.Miner (address.Address) (struct) + // t.Miner (address.Address) (struct) if err := t.Miner.MarshalCBOR(w); err != nil { return err } - // t.t.Ticket (types.Ticket) (struct) + // t.Ticket (types.Ticket) (struct) if err := t.Ticket.MarshalCBOR(w); err != nil { return err } - // t.t.EPostProof (types.EPostProof) (struct) + // t.EPostProof (types.EPostProof) (struct) if err := t.EPostProof.MarshalCBOR(w); err != nil { return err } - // t.t.Parents ([]cid.Cid) (slice) + // t.Parents ([]cid.Cid) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Parents)))); err != nil { return err } @@ -48,45 +48,45 @@ func (t *BlockHeader) MarshalCBOR(w io.Writer) error { } } - // t.t.ParentWeight (types.BigInt) (struct) + // t.ParentWeight (types.BigInt) (struct) if err := t.ParentWeight.MarshalCBOR(w); err != nil { return err } - // t.t.Height (uint64) (uint64) + // t.Height (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Height))); err != nil { return err } - // t.t.ParentStateRoot (cid.Cid) (struct) + // t.ParentStateRoot (cid.Cid) (struct) if err := cbg.WriteCid(w, t.ParentStateRoot); err != nil { return xerrors.Errorf("failed to write cid field t.ParentStateRoot: %w", err) } - // t.t.ParentMessageReceipts (cid.Cid) (struct) + // t.ParentMessageReceipts (cid.Cid) (struct) if err := cbg.WriteCid(w, t.ParentMessageReceipts); err != nil { return xerrors.Errorf("failed to write cid field t.ParentMessageReceipts: %w", err) } - // t.t.Messages (cid.Cid) (struct) + // t.Messages (cid.Cid) (struct) if err := cbg.WriteCid(w, t.Messages); err != nil { return xerrors.Errorf("failed to write cid field t.Messages: %w", err) } - // t.t.BLSAggregate (types.Signature) (struct) + // t.BLSAggregate (types.Signature) (struct) if err := t.BLSAggregate.MarshalCBOR(w); err != nil { return err } - // t.t.Timestamp (uint64) (uint64) + // t.Timestamp (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Timestamp))); err != nil { return err } - // t.t.BlockSig (types.Signature) (struct) + // t.BlockSig (types.Signature) (struct) if err := t.BlockSig.MarshalCBOR(w); err != nil { return err } @@ -108,7 +108,7 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Miner (address.Address) (struct) + // t.Miner (address.Address) (struct) { @@ -117,7 +117,7 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Ticket (types.Ticket) (struct) + // t.Ticket (types.Ticket) (struct) { @@ -138,7 +138,7 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error { } } - // t.t.EPostProof (types.EPostProof) (struct) + // t.EPostProof (types.EPostProof) (struct) { @@ -147,7 +147,7 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Parents ([]cid.Cid) (slice) + // t.Parents ([]cid.Cid) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -173,7 +173,7 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error { t.Parents[i] = c } - // t.t.ParentWeight (types.BigInt) (struct) + // t.ParentWeight (types.BigInt) (struct) { @@ -182,7 +182,7 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Height (uint64) (uint64) + // t.Height (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -192,7 +192,7 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Height = uint64(extra) - // t.t.ParentStateRoot (cid.Cid) (struct) + // t.ParentStateRoot (cid.Cid) (struct) { @@ -204,7 +204,7 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error { t.ParentStateRoot = c } - // t.t.ParentMessageReceipts (cid.Cid) (struct) + // t.ParentMessageReceipts (cid.Cid) (struct) { @@ -216,7 +216,7 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error { t.ParentMessageReceipts = c } - // t.t.Messages (cid.Cid) (struct) + // t.Messages (cid.Cid) (struct) { @@ -228,7 +228,7 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error { t.Messages = c } - // t.t.BLSAggregate (types.Signature) (struct) + // t.BLSAggregate (types.Signature) (struct) { @@ -237,7 +237,7 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Timestamp (uint64) (uint64) + // t.Timestamp (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -247,7 +247,7 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Timestamp = uint64(extra) - // t.t.BlockSig (types.Signature) (struct) + // t.BlockSig (types.Signature) (struct) { @@ -280,7 +280,7 @@ func (t *Ticket) MarshalCBOR(w io.Writer) error { return err } - // t.t.VRFProof ([]uint8) (slice) + // t.VRFProof ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.VRFProof)))); err != nil { return err } @@ -305,7 +305,7 @@ func (t *Ticket) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.VRFProof ([]uint8) (slice) + // t.VRFProof ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -334,7 +334,7 @@ func (t *EPostProof) MarshalCBOR(w io.Writer) error { return err } - // t.t.Proof ([]uint8) (slice) + // t.Proof ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Proof)))); err != nil { return err } @@ -342,7 +342,7 @@ func (t *EPostProof) MarshalCBOR(w io.Writer) error { return err } - // t.t.PostRand ([]uint8) (slice) + // t.PostRand ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.PostRand)))); err != nil { return err } @@ -350,7 +350,7 @@ func (t *EPostProof) MarshalCBOR(w io.Writer) error { return err } - // t.t.Candidates ([]types.EPostTicket) (slice) + // t.Candidates ([]types.EPostTicket) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Candidates)))); err != nil { return err } @@ -377,7 +377,7 @@ func (t *EPostProof) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Proof ([]uint8) (slice) + // t.Proof ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -394,7 +394,7 @@ func (t *EPostProof) UnmarshalCBOR(r io.Reader) error { if _, err := io.ReadFull(br, t.Proof); err != nil { return err } - // t.t.PostRand ([]uint8) (slice) + // t.PostRand ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -411,7 +411,7 @@ func (t *EPostProof) UnmarshalCBOR(r io.Reader) error { if _, err := io.ReadFull(br, t.PostRand); err != nil { return err } - // t.t.Candidates ([]types.EPostTicket) (slice) + // t.Candidates ([]types.EPostTicket) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -450,7 +450,7 @@ func (t *EPostTicket) MarshalCBOR(w io.Writer) error { return err } - // t.t.Partial ([]uint8) (slice) + // t.Partial ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Partial)))); err != nil { return err } @@ -458,12 +458,12 @@ func (t *EPostTicket) MarshalCBOR(w io.Writer) error { return err } - // t.t.SectorID (uint64) (uint64) + // t.SectorID (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SectorID))); err != nil { return err } - // t.t.ChallengeIndex (uint64) (uint64) + // t.ChallengeIndex (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.ChallengeIndex))); err != nil { return err } @@ -485,7 +485,7 @@ func (t *EPostTicket) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Partial ([]uint8) (slice) + // t.Partial ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -502,7 +502,7 @@ func (t *EPostTicket) UnmarshalCBOR(r io.Reader) error { if _, err := io.ReadFull(br, t.Partial); err != nil { return err } - // t.t.SectorID (uint64) (uint64) + // t.SectorID (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -512,7 +512,7 @@ func (t *EPostTicket) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.SectorID = uint64(extra) - // t.t.ChallengeIndex (uint64) (uint64) + // t.ChallengeIndex (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -534,42 +534,42 @@ func (t *Message) MarshalCBOR(w io.Writer) error { return err } - // t.t.To (address.Address) (struct) + // t.To (address.Address) (struct) if err := t.To.MarshalCBOR(w); err != nil { return err } - // t.t.From (address.Address) (struct) + // t.From (address.Address) (struct) if err := t.From.MarshalCBOR(w); err != nil { return err } - // t.t.Nonce (uint64) (uint64) + // t.Nonce (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Nonce))); err != nil { return err } - // t.t.Value (types.BigInt) (struct) + // t.Value (types.BigInt) (struct) if err := t.Value.MarshalCBOR(w); err != nil { return err } - // t.t.GasPrice (types.BigInt) (struct) + // t.GasPrice (types.BigInt) (struct) if err := t.GasPrice.MarshalCBOR(w); err != nil { return err } - // t.t.GasLimit (types.BigInt) (struct) + // t.GasLimit (types.BigInt) (struct) if err := t.GasLimit.MarshalCBOR(w); err != nil { return err } - // t.t.Method (uint64) (uint64) + // t.Method (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Method))); err != nil { return err } - // t.t.Params ([]uint8) (slice) + // t.Params ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Params)))); err != nil { return err } @@ -594,7 +594,7 @@ func (t *Message) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.To (address.Address) (struct) + // t.To (address.Address) (struct) { @@ -603,7 +603,7 @@ func (t *Message) UnmarshalCBOR(r io.Reader) error { } } - // t.t.From (address.Address) (struct) + // t.From (address.Address) (struct) { @@ -612,7 +612,7 @@ func (t *Message) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Nonce (uint64) (uint64) + // t.Nonce (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -622,7 +622,7 @@ func (t *Message) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Nonce = uint64(extra) - // t.t.Value (types.BigInt) (struct) + // t.Value (types.BigInt) (struct) { @@ -631,7 +631,7 @@ func (t *Message) UnmarshalCBOR(r io.Reader) error { } } - // t.t.GasPrice (types.BigInt) (struct) + // t.GasPrice (types.BigInt) (struct) { @@ -640,7 +640,7 @@ func (t *Message) UnmarshalCBOR(r io.Reader) error { } } - // t.t.GasLimit (types.BigInt) (struct) + // t.GasLimit (types.BigInt) (struct) { @@ -649,7 +649,7 @@ func (t *Message) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Method (uint64) (uint64) + // t.Method (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -659,7 +659,7 @@ func (t *Message) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Method = uint64(extra) - // t.t.Params ([]uint8) (slice) + // t.Params ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -688,12 +688,12 @@ func (t *SignedMessage) MarshalCBOR(w io.Writer) error { return err } - // t.t.Message (types.Message) (struct) + // t.Message (types.Message) (struct) if err := t.Message.MarshalCBOR(w); err != nil { return err } - // t.t.Signature (types.Signature) (struct) + // t.Signature (types.Signature) (struct) if err := t.Signature.MarshalCBOR(w); err != nil { return err } @@ -715,7 +715,7 @@ func (t *SignedMessage) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Message (types.Message) (struct) + // t.Message (types.Message) (struct) { @@ -724,7 +724,7 @@ func (t *SignedMessage) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Signature (types.Signature) (struct) + // t.Signature (types.Signature) (struct) { @@ -745,13 +745,13 @@ func (t *MsgMeta) MarshalCBOR(w io.Writer) error { return err } - // t.t.BlsMessages (cid.Cid) (struct) + // t.BlsMessages (cid.Cid) (struct) if err := cbg.WriteCid(w, t.BlsMessages); err != nil { return xerrors.Errorf("failed to write cid field t.BlsMessages: %w", err) } - // t.t.SecpkMessages (cid.Cid) (struct) + // t.SecpkMessages (cid.Cid) (struct) if err := cbg.WriteCid(w, t.SecpkMessages); err != nil { return xerrors.Errorf("failed to write cid field t.SecpkMessages: %w", err) @@ -775,7 +775,7 @@ func (t *MsgMeta) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.BlsMessages (cid.Cid) (struct) + // t.BlsMessages (cid.Cid) (struct) { @@ -787,7 +787,7 @@ func (t *MsgMeta) UnmarshalCBOR(r io.Reader) error { t.BlsMessages = c } - // t.t.SecpkMessages (cid.Cid) (struct) + // t.SecpkMessages (cid.Cid) (struct) { @@ -811,12 +811,12 @@ func (t *SignedVoucher) MarshalCBOR(w io.Writer) error { return err } - // t.t.TimeLock (uint64) (uint64) + // t.TimeLock (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.TimeLock))); err != nil { return err } - // t.t.SecretPreimage ([]uint8) (slice) + // t.SecretPreimage ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.SecretPreimage)))); err != nil { return err } @@ -824,32 +824,32 @@ func (t *SignedVoucher) MarshalCBOR(w io.Writer) error { return err } - // t.t.Extra (types.ModVerifyParams) (struct) + // t.Extra (types.ModVerifyParams) (struct) if err := t.Extra.MarshalCBOR(w); err != nil { return err } - // t.t.Lane (uint64) (uint64) + // t.Lane (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Lane))); err != nil { return err } - // t.t.Nonce (uint64) (uint64) + // t.Nonce (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Nonce))); err != nil { return err } - // t.t.Amount (types.BigInt) (struct) + // t.Amount (types.BigInt) (struct) if err := t.Amount.MarshalCBOR(w); err != nil { return err } - // t.t.MinCloseHeight (uint64) (uint64) + // t.MinCloseHeight (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.MinCloseHeight))); err != nil { return err } - // t.t.Merges ([]types.Merge) (slice) + // t.Merges ([]types.Merge) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Merges)))); err != nil { return err } @@ -859,7 +859,7 @@ func (t *SignedVoucher) MarshalCBOR(w io.Writer) error { } } - // t.t.Signature (types.Signature) (struct) + // t.Signature (types.Signature) (struct) if err := t.Signature.MarshalCBOR(w); err != nil { return err } @@ -881,7 +881,7 @@ func (t *SignedVoucher) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.TimeLock (uint64) (uint64) + // t.TimeLock (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -891,7 +891,7 @@ func (t *SignedVoucher) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.TimeLock = uint64(extra) - // t.t.SecretPreimage ([]uint8) (slice) + // t.SecretPreimage ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -908,7 +908,7 @@ func (t *SignedVoucher) UnmarshalCBOR(r io.Reader) error { if _, err := io.ReadFull(br, t.SecretPreimage); err != nil { return err } - // t.t.Extra (types.ModVerifyParams) (struct) + // t.Extra (types.ModVerifyParams) (struct) { @@ -929,7 +929,7 @@ func (t *SignedVoucher) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Lane (uint64) (uint64) + // t.Lane (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -939,7 +939,7 @@ func (t *SignedVoucher) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Lane = uint64(extra) - // t.t.Nonce (uint64) (uint64) + // t.Nonce (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -949,7 +949,7 @@ func (t *SignedVoucher) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Nonce = uint64(extra) - // t.t.Amount (types.BigInt) (struct) + // t.Amount (types.BigInt) (struct) { @@ -958,7 +958,7 @@ func (t *SignedVoucher) UnmarshalCBOR(r io.Reader) error { } } - // t.t.MinCloseHeight (uint64) (uint64) + // t.MinCloseHeight (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -968,7 +968,7 @@ func (t *SignedVoucher) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.MinCloseHeight = uint64(extra) - // t.t.Merges ([]types.Merge) (slice) + // t.Merges ([]types.Merge) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -995,7 +995,7 @@ func (t *SignedVoucher) UnmarshalCBOR(r io.Reader) error { t.Merges[i] = v } - // t.t.Signature (types.Signature) (struct) + // t.Signature (types.Signature) (struct) { @@ -1028,17 +1028,17 @@ func (t *ModVerifyParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.Actor (address.Address) (struct) + // t.Actor (address.Address) (struct) if err := t.Actor.MarshalCBOR(w); err != nil { return err } - // t.t.Method (uint64) (uint64) + // t.Method (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Method))); err != nil { return err } - // t.t.Data ([]uint8) (slice) + // t.Data ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Data)))); err != nil { return err } @@ -1063,7 +1063,7 @@ func (t *ModVerifyParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Actor (address.Address) (struct) + // t.Actor (address.Address) (struct) { @@ -1072,7 +1072,7 @@ func (t *ModVerifyParams) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Method (uint64) (uint64) + // t.Method (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1082,7 +1082,7 @@ func (t *ModVerifyParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Method = uint64(extra) - // t.t.Data ([]uint8) (slice) + // t.Data ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1111,12 +1111,12 @@ func (t *Merge) MarshalCBOR(w io.Writer) error { return err } - // t.t.Lane (uint64) (uint64) + // t.Lane (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Lane))); err != nil { return err } - // t.t.Nonce (uint64) (uint64) + // t.Nonce (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Nonce))); err != nil { return err } @@ -1138,7 +1138,7 @@ func (t *Merge) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Lane (uint64) (uint64) + // t.Lane (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1148,7 +1148,7 @@ func (t *Merge) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Lane = uint64(extra) - // t.t.Nonce (uint64) (uint64) + // t.Nonce (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1170,24 +1170,24 @@ func (t *Actor) MarshalCBOR(w io.Writer) error { return err } - // t.t.Code (cid.Cid) (struct) + // t.Code (cid.Cid) (struct) if err := cbg.WriteCid(w, t.Code); err != nil { return xerrors.Errorf("failed to write cid field t.Code: %w", err) } - // t.t.Head (cid.Cid) (struct) + // t.Head (cid.Cid) (struct) if err := cbg.WriteCid(w, t.Head); err != nil { return xerrors.Errorf("failed to write cid field t.Head: %w", err) } - // t.t.Nonce (uint64) (uint64) + // t.Nonce (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Nonce))); err != nil { return err } - // t.t.Balance (types.BigInt) (struct) + // t.Balance (types.BigInt) (struct) if err := t.Balance.MarshalCBOR(w); err != nil { return err } @@ -1209,7 +1209,7 @@ func (t *Actor) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Code (cid.Cid) (struct) + // t.Code (cid.Cid) (struct) { @@ -1221,7 +1221,7 @@ func (t *Actor) UnmarshalCBOR(r io.Reader) error { t.Code = c } - // t.t.Head (cid.Cid) (struct) + // t.Head (cid.Cid) (struct) { @@ -1233,7 +1233,7 @@ func (t *Actor) UnmarshalCBOR(r io.Reader) error { t.Head = c } - // t.t.Nonce (uint64) (uint64) + // t.Nonce (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1243,7 +1243,7 @@ func (t *Actor) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Nonce = uint64(extra) - // t.t.Balance (types.BigInt) (struct) + // t.Balance (types.BigInt) (struct) { @@ -1264,12 +1264,12 @@ func (t *MessageReceipt) MarshalCBOR(w io.Writer) error { return err } - // t.t.ExitCode (uint8) (uint8) + // t.ExitCode (uint8) (uint8) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.ExitCode))); err != nil { return err } - // t.t.Return ([]uint8) (slice) + // t.Return ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Return)))); err != nil { return err } @@ -1277,7 +1277,7 @@ func (t *MessageReceipt) MarshalCBOR(w io.Writer) error { return err } - // t.t.GasUsed (types.BigInt) (struct) + // t.GasUsed (types.BigInt) (struct) if err := t.GasUsed.MarshalCBOR(w); err != nil { return err } @@ -1299,7 +1299,7 @@ func (t *MessageReceipt) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.ExitCode (uint8) (uint8) + // t.ExitCode (uint8) (uint8) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1312,7 +1312,7 @@ func (t *MessageReceipt) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("integer in input was too large for uint8 field") } t.ExitCode = uint8(extra) - // t.t.Return ([]uint8) (slice) + // t.Return ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1329,7 +1329,7 @@ func (t *MessageReceipt) UnmarshalCBOR(r io.Reader) error { if _, err := io.ReadFull(br, t.Return); err != nil { return err } - // t.t.GasUsed (types.BigInt) (struct) + // t.GasUsed (types.BigInt) (struct) { @@ -1350,12 +1350,12 @@ func (t *BlockMsg) MarshalCBOR(w io.Writer) error { return err } - // t.t.Header (types.BlockHeader) (struct) + // t.Header (types.BlockHeader) (struct) if err := t.Header.MarshalCBOR(w); err != nil { return err } - // t.t.BlsMessages ([]cid.Cid) (slice) + // t.BlsMessages ([]cid.Cid) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.BlsMessages)))); err != nil { return err } @@ -1365,7 +1365,7 @@ func (t *BlockMsg) MarshalCBOR(w io.Writer) error { } } - // t.t.SecpkMessages ([]cid.Cid) (slice) + // t.SecpkMessages ([]cid.Cid) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.SecpkMessages)))); err != nil { return err } @@ -1392,7 +1392,7 @@ func (t *BlockMsg) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Header (types.BlockHeader) (struct) + // t.Header (types.BlockHeader) (struct) { @@ -1413,7 +1413,7 @@ func (t *BlockMsg) UnmarshalCBOR(r io.Reader) error { } } - // t.t.BlsMessages ([]cid.Cid) (slice) + // t.BlsMessages ([]cid.Cid) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1439,7 +1439,7 @@ func (t *BlockMsg) UnmarshalCBOR(r io.Reader) error { t.BlsMessages[i] = c } - // t.t.SecpkMessages ([]cid.Cid) (slice) + // t.SecpkMessages ([]cid.Cid) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1477,12 +1477,12 @@ func (t *SignedStorageAsk) MarshalCBOR(w io.Writer) error { return err } - // t.t.Ask (types.StorageAsk) (struct) + // t.Ask (types.StorageAsk) (struct) if err := t.Ask.MarshalCBOR(w); err != nil { return err } - // t.t.Signature (types.Signature) (struct) + // t.Signature (types.Signature) (struct) if err := t.Signature.MarshalCBOR(w); err != nil { return err } @@ -1504,7 +1504,7 @@ func (t *SignedStorageAsk) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Ask (types.StorageAsk) (struct) + // t.Ask (types.StorageAsk) (struct) { @@ -1525,7 +1525,7 @@ func (t *SignedStorageAsk) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Signature (types.Signature) (struct) + // t.Signature (types.Signature) (struct) { @@ -1558,32 +1558,32 @@ func (t *StorageAsk) MarshalCBOR(w io.Writer) error { return err } - // t.t.Price (types.BigInt) (struct) + // t.Price (types.BigInt) (struct) if err := t.Price.MarshalCBOR(w); err != nil { return err } - // t.t.MinPieceSize (uint64) (uint64) + // t.MinPieceSize (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.MinPieceSize))); err != nil { return err } - // t.t.Miner (address.Address) (struct) + // t.Miner (address.Address) (struct) if err := t.Miner.MarshalCBOR(w); err != nil { return err } - // t.t.Timestamp (uint64) (uint64) + // t.Timestamp (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Timestamp))); err != nil { return err } - // t.t.Expiry (uint64) (uint64) + // t.Expiry (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Expiry))); err != nil { return err } - // t.t.SeqNo (uint64) (uint64) + // t.SeqNo (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.SeqNo))); err != nil { return err } @@ -1605,7 +1605,7 @@ func (t *StorageAsk) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Price (types.BigInt) (struct) + // t.Price (types.BigInt) (struct) { @@ -1614,7 +1614,7 @@ func (t *StorageAsk) UnmarshalCBOR(r io.Reader) error { } } - // t.t.MinPieceSize (uint64) (uint64) + // t.MinPieceSize (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1624,7 +1624,7 @@ func (t *StorageAsk) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.MinPieceSize = uint64(extra) - // t.t.Miner (address.Address) (struct) + // t.Miner (address.Address) (struct) { @@ -1633,7 +1633,7 @@ func (t *StorageAsk) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Timestamp (uint64) (uint64) + // t.Timestamp (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1643,7 +1643,7 @@ func (t *StorageAsk) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Timestamp = uint64(extra) - // t.t.Expiry (uint64) (uint64) + // t.Expiry (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1653,7 +1653,7 @@ func (t *StorageAsk) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Expiry = uint64(extra) - // t.t.SeqNo (uint64) (uint64) + // t.SeqNo (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1675,7 +1675,7 @@ func (t *ExpTipSet) MarshalCBOR(w io.Writer) error { return err } - // t.t.Cids ([]cid.Cid) (slice) + // t.Cids ([]cid.Cid) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Cids)))); err != nil { return err } @@ -1685,7 +1685,7 @@ func (t *ExpTipSet) MarshalCBOR(w io.Writer) error { } } - // t.t.Blocks ([]*types.BlockHeader) (slice) + // t.Blocks ([]*types.BlockHeader) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Blocks)))); err != nil { return err } @@ -1695,7 +1695,7 @@ func (t *ExpTipSet) MarshalCBOR(w io.Writer) error { } } - // t.t.Height (uint64) (uint64) + // t.Height (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Height))); err != nil { return err } @@ -1717,7 +1717,7 @@ func (t *ExpTipSet) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Cids ([]cid.Cid) (slice) + // t.Cids ([]cid.Cid) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1743,7 +1743,7 @@ func (t *ExpTipSet) UnmarshalCBOR(r io.Reader) error { t.Cids[i] = c } - // t.t.Blocks ([]*types.BlockHeader) (slice) + // t.Blocks ([]*types.BlockHeader) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -1770,7 +1770,7 @@ func (t *ExpTipSet) UnmarshalCBOR(r io.Reader) error { t.Blocks[i] = &v } - // t.t.Height (uint64) (uint64) + // t.Height (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { diff --git a/chain/types/tipset.go b/chain/types/tipset.go index 1ed15289e..e8d830bc5 100644 --- a/chain/types/tipset.go +++ b/chain/types/tipset.go @@ -10,6 +10,7 @@ import ( "github.com/ipfs/go-cid" logging "github.com/ipfs/go-log" cbg "github.com/whyrusleeping/cbor-gen" + "golang.org/x/xerrors" ) var log = logging.Logger("types") @@ -95,6 +96,10 @@ func tipsetSortFunc(blks []*BlockHeader) func(i, j int) bool { } func NewTipSet(blks []*BlockHeader) (*TipSet, error) { + if len(blks) == 0 { + return nil, xerrors.Errorf("NewTipSet called with zero length array of blocks") + } + sort.Slice(blks, tipsetSortFunc(blks)) var ts TipSet diff --git a/chain/types/vmcontext.go b/chain/types/vmcontext.go index 5e2963483..39667d2a4 100644 --- a/chain/types/vmcontext.go +++ b/chain/types/vmcontext.go @@ -40,10 +40,15 @@ type VMContext interface { ChargeGas(uint64) aerrors.ActorError GetRandomness(height uint64) ([]byte, aerrors.ActorError) GetBalance(address.Address) (BigInt, aerrors.ActorError) + Sys() *VMSyscalls Context() context.Context } +type VMSyscalls struct { + ValidatePoRep func(context.Context, address.Address, uint64, []byte, []byte, []byte, []byte, []byte, uint64) (bool, aerrors.ActorError) +} + type storageWrapper struct { s Storage } diff --git a/chain/vm/mkactor.go b/chain/vm/mkactor.go index 1e1885825..3419f9f3c 100644 --- a/chain/vm/mkactor.go +++ b/chain/vm/mkactor.go @@ -48,7 +48,7 @@ func makeActor(st *state.StateTree, addr address.Address) (*types.Actor, aerrors case address.SECP256K1: return NewSecp256k1AccountActor(st, addr) case address.ID: - return nil, aerrors.New(1, "no actor with given ID") + return nil, aerrors.Newf(1, "no actor with given ID: %s", addr) case address.Actor: return nil, aerrors.Newf(1, "no such actor: %s", addr) default: diff --git a/chain/vm/syscalls.go b/chain/vm/syscalls.go new file mode 100644 index 000000000..92f9ea269 --- /dev/null +++ b/chain/vm/syscalls.go @@ -0,0 +1,14 @@ +package vm + +import ( + "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/types" +) + +// Actual type is defined in chain/types/vmcontext.go because the VMContext interface is there + +func DefaultSyscalls() *types.VMSyscalls { + return &types.VMSyscalls{ + ValidatePoRep: actors.ValidatePoRep, + } +} diff --git a/chain/vm/vm.go b/chain/vm/vm.go index 1eed0f895..7c1c5a802 100644 --- a/chain/vm/vm.go +++ b/chain/vm/vm.go @@ -54,6 +54,8 @@ type VMContext struct { gasAvailable types.BigInt gasUsed types.BigInt + sys *types.VMSyscalls + // root cid of the state of the actor this invocation will be on sroot cid.Cid @@ -75,6 +77,10 @@ func (vmc *VMContext) GetRandomness(height uint64) ([]byte, aerrors.ActorError) return res, nil } +func (vmc *VMContext) Sys() *types.VMSyscalls { + return vmc.sys +} + // Storage interface func (vmc *VMContext) Put(i cbg.CBORMarshaler) (cid.Cid, aerrors.ActorError) { @@ -284,6 +290,7 @@ func (vm *VM) makeVMContext(ctx context.Context, sroot cid.Cid, msg *types.Messa msg: msg, origin: origin, height: vm.blockHeight, + sys: vm.Syscalls, gasUsed: usedGas, gasAvailable: msg.GasLimit, @@ -304,6 +311,8 @@ type VM struct { blockMiner address.Address inv *invoker rand Rand + + Syscalls *types.VMSyscalls } func NewVM(base cid.Cid, height uint64, r Rand, maddr address.Address, cbs blockstore.Blockstore) (*VM, error) { @@ -323,6 +332,7 @@ func NewVM(base cid.Cid, height uint64, r Rand, maddr address.Address, cbs block blockMiner: maddr, inv: newInvoker(), rand: r, + Syscalls: DefaultSyscalls(), }, nil } diff --git a/chain/vm/vm_test.go b/chain/vm/vm_test.go index 862bb4acf..6ec007576 100644 --- a/chain/vm/vm_test.go +++ b/chain/vm/vm_test.go @@ -9,10 +9,12 @@ import ( "github.com/filecoin-project/lotus/chain/types" ) +const HalvingPeriodEpochs = 6 * 365 * 24 * 60 * 2 + func TestBlockReward(t *testing.T) { coffer := types.FromFil(build.MiningRewardTotal).Int sum := new(big.Int) - N := build.HalvingPeriodEpochs + N := HalvingPeriodEpochs for i := 0; i < N; i++ { a := MiningReward(types.BigInt{coffer}) sum = sum.Add(sum, a.Int) diff --git a/cli/auth.go b/cli/auth.go index 121f39463..d957881b6 100644 --- a/cli/auth.go +++ b/cli/auth.go @@ -6,7 +6,7 @@ import ( "gopkg.in/urfave/cli.v2" - "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/lotus/api/apistruct" ) var authCmd = &cli.Command{ @@ -42,18 +42,18 @@ var authCreateAdminToken = &cli.Command{ perm := cctx.String("perm") idx := 0 - for i, p := range api.AllPermissions { + for i, p := range apistruct.AllPermissions { if perm == p { idx = i + 1 } } if idx == 0 { - return fmt.Errorf("--perm flag has to be one of: %s", api.AllPermissions) + return fmt.Errorf("--perm flag has to be one of: %s", apistruct.AllPermissions) } // slice on [:idx] so for example: 'sign' gives you [read, write, sign] - token, err := napi.AuthNew(ctx, api.AllPermissions[:idx]) + token, err := napi.AuthNew(ctx, apistruct.AllPermissions[:idx]) if err != nil { return err } diff --git a/cli/client.go b/cli/client.go index 0f1fdc991..61848951a 100644 --- a/cli/client.go +++ b/cli/client.go @@ -236,7 +236,7 @@ var clientRetrieveCmd = &cli.Command{ } if err := api.ClientRetrieve(ctx, offers[0].Order(payer), cctx.Args().Get(1)); err != nil { - return err + return xerrors.Errorf("Retrieval Failed: %w", err) } fmt.Println("Success") diff --git a/cli/params.go b/cli/params.go index df7e240ec..11a956120 100644 --- a/cli/params.go +++ b/cli/params.go @@ -1,6 +1,7 @@ package cli import ( + "github.com/docker/go-units" "github.com/filecoin-project/lotus/build" "golang.org/x/xerrors" "gopkg.in/urfave/cli.v2" @@ -10,13 +11,18 @@ var fetchParamCmd = &cli.Command{ Name: "fetch-params", Usage: "Fetch proving parameters", Flags: []cli.Flag{ - &cli.Uint64Flag{ + &cli.StringFlag{ Name: "proving-params", - Usage: "download params used creating proofs for given size", + Usage: "download params used creating proofs for given size, i.e. 32GiB", }, }, Action: func(cctx *cli.Context) error { - err := build.GetParams(cctx.Uint64("proving-params")) + sectorSizeInt, err := units.FromHumanSize(cctx.String("proving-params")) + if err != nil { + return err + } + sectorSize := uint64(sectorSizeInt) + err = build.GetParams(sectorSize) if err != nil { return xerrors.Errorf("fetching proof parameters: %w", err) } diff --git a/cli/utils.go b/cli/utils.go new file mode 100644 index 000000000..09121f264 --- /dev/null +++ b/cli/utils.go @@ -0,0 +1,24 @@ +package cli + +import ( + "fmt" + "math/big" + + "github.com/filecoin-project/lotus/chain/types" +) + +var Units = []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB"} + +func SizeStr(size types.BigInt) string { + r := new(big.Rat).SetInt(size.Int) + den := big.NewRat(1, 1024) + + var i int + for f, _ := r.Float64(); f >= 1024 && 1 < len(Units); f, _ = r.Float64() { + i++ + r = r.Mul(r, den) + } + + f, _ := r.Float64() + return fmt.Sprintf("%.3g %s", f, Units[i]) +} diff --git a/cli/utils_test.go b/cli/utils_test.go new file mode 100644 index 000000000..473e31923 --- /dev/null +++ b/cli/utils_test.go @@ -0,0 +1,27 @@ +package cli + +import ( + "testing" + + types "github.com/filecoin-project/lotus/chain/types" + "github.com/stretchr/testify/assert" +) + +func TestSizeStr(t *testing.T) { + cases := []struct { + in uint64 + out string + }{ + {0, "0 B"}, + {1, "1 B"}, + {1024, "1 KiB"}, + {2000, "1.95 KiB"}, + {5 << 20, "5 MiB"}, + {11 << 60, "11 EiB"}, + } + + for _, c := range cases { + assert.Equal(t, c.out, SizeStr(types.NewInt(c.in)), "input %+v, produced wrong result", c) + } + +} diff --git a/cli/version.go b/cli/version.go index f451b4514..cf4ad2932 100644 --- a/cli/version.go +++ b/cli/version.go @@ -19,7 +19,11 @@ var versionCmd = &cli.Command{ ctx := ReqContext(cctx) // TODO: print more useful things - fmt.Println(api.Version(ctx)) + v, err := api.Version(ctx) + if err != nil { + return err + } + fmt.Println(v) cli.VersionPrinter(cctx) return nil }, diff --git a/cmd/lotus-bench/main.go b/cmd/lotus-bench/main.go index 7964186f2..54aa6c6b4 100644 --- a/cmd/lotus-bench/main.go +++ b/cmd/lotus-bench/main.go @@ -4,14 +4,18 @@ import ( "bytes" "context" "crypto/sha256" + "encoding/json" "fmt" + "github.com/docker/go-units" "io/ioutil" + "math/big" "math/rand" "os" "path/filepath" "time" ffi "github.com/filecoin-project/filecoin-ffi" + lcli "github.com/filecoin-project/lotus/cli" "github.com/ipfs/go-datastore" logging "github.com/ipfs/go-log" "github.com/mitchellh/go-homedir" @@ -20,6 +24,8 @@ import ( "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/address" + "github.com/filecoin-project/lotus/chain/types" + "github.com/filecoin-project/lotus/genesis" "github.com/filecoin-project/lotus/lib/sectorbuilder" ) @@ -60,56 +66,91 @@ func main() { Value: "~/.lotus-bench", Usage: "Path to the storage directory that will store sectors long term", }, - &cli.Uint64Flag{ + &cli.StringFlag{ Name: "sector-size", - Value: 1024, + Value: "1GiB", + Usage: "size of the sectors in bytes, i.e. 32GiB", }, &cli.BoolFlag{ Name: "no-gpu", Usage: "disable gpu usage for the benchmark run", }, + &cli.StringFlag{ + Name: "miner-addr", + Usage: "pass miner address (only necessary if using existing sectorbuilder)", + Value: "t0101", + }, + &cli.StringFlag{ + Name: "benchmark-existing-sectorbuilder", + Usage: "pass a directory to run election-post timings on an existing sectorbuilder", + }, + &cli.BoolFlag{ + Name: "json-out", + Usage: "output results in json format", + }, }, Action: func(c *cli.Context) error { if c.Bool("no-gpu") { os.Setenv("BELLMAN_NO_GPU", "1") } - sdir, err := homedir.Expand(c.String("storage-dir")) - if err != nil { - return err - } - os.MkdirAll(sdir, 0775) + robench := c.String("benchmark-existing-sectorbuilder") - tsdir, err := ioutil.TempDir(sdir, "bench") - if err != nil { - return err - } - defer func() { - if err := os.RemoveAll(tsdir); err != nil { - log.Warn("remove all: ", err) + var sbdir string + + if robench == "" { + sdir, err := homedir.Expand(c.String("storage-dir")) + if err != nil { + return err } - }() - maddr, err := address.NewFromString("t0101") + os.MkdirAll(sdir, 0775) + + tsdir, err := ioutil.TempDir(sdir, "bench") + if err != nil { + return err + } + defer func() { + if err := os.RemoveAll(tsdir); err != nil { + log.Warn("remove all: ", err) + } + }() + sbdir = tsdir + } else { + exp, err := homedir.Expand(robench) + if err != nil { + return err + } + sbdir = exp + } + + maddr, err := address.NewFromString(c.String("miner-addr")) if err != nil { return err } - sectorSize := c.Uint64("sector-size") + sectorSizeInt, err := units.FromHumanSize(c.String("sector-size")) + if err != nil { + return err + } + sectorSize := uint64(sectorSizeInt) mds := datastore.NewMapDatastore() cfg := §orbuilder.Config{ Miner: maddr, SectorSize: sectorSize, WorkerThreads: 2, - CacheDir: filepath.Join(tsdir, "cache"), - SealedDir: filepath.Join(tsdir, "sealed"), - StagedDir: filepath.Join(tsdir, "staged"), - UnsealedDir: filepath.Join(tsdir, "unsealed"), + CacheDir: filepath.Join(sbdir, "cache"), + SealedDir: filepath.Join(sbdir, "sealed"), + StagedDir: filepath.Join(sbdir, "staged"), + UnsealedDir: filepath.Join(sbdir, "unsealed"), } - for _, d := range []string{cfg.CacheDir, cfg.SealedDir, cfg.StagedDir, cfg.UnsealedDir} { - if err := os.MkdirAll(d, 0775); err != nil { - return err + + if robench == "" { + for _, d := range []string{cfg.CacheDir, cfg.SealedDir, cfg.StagedDir, cfg.UnsealedDir} { + if err := os.MkdirAll(d, 0775); err != nil { + return err + } } } @@ -126,7 +167,7 @@ func main() { var sealTimings []SealingResult var sealedSectors []ffi.PublicSectorInfo numSectors := uint64(1) - for i := uint64(1); i <= numSectors; i++ { + for i := uint64(1); i <= numSectors && robench == ""; i++ { start := time.Now() log.Info("Writing piece into sector...") @@ -207,6 +248,34 @@ func main() { var challenge [32]byte rand.Read(challenge[:]) + if robench != "" { + // TODO: this assumes we only ever benchmark a preseal + // sectorbuilder directory... we need a better way to handle + // this in other cases + + fdata, err := ioutil.ReadFile(filepath.Join(sbdir, "pre-seal-"+maddr.String()+".json")) + if err != nil { + return err + } + + var genmm map[string]genesis.GenesisMiner + if err := json.Unmarshal(fdata, &genmm); err != nil { + return err + } + + genm, ok := genmm[maddr.String()] + if !ok { + return xerrors.Errorf("preseal file didnt have expected miner in it") + } + + for _, s := range genm.Sectors { + sealedSectors = append(sealedSectors, ffi.PublicSectorInfo{ + CommR: s.CommR, + SectorID: s.SectorID, + }) + } + } + log.Info("generating election post candidates") sinfos := sectorbuilder.NewSortedPublicSectorInfo(sealedSectors) candidates, err := sb.GenerateEPostCandidates(sinfos, challenge, []uint64{}) @@ -255,7 +324,7 @@ func main() { } verifypost2 := time.Now() - benchout := BenchResults{ + bo := BenchResults{ SectorSize: cfg.SectorSize, SealingResults: sealTimings, @@ -266,17 +335,28 @@ func main() { VerifyEPostHot: verifypost2.Sub(verifypost1), } // TODO: optionally write this as json to a file - fmt.Println("results") - fmt.Printf("seal: addPiece: %s\n", benchout.SealingResults[0].AddPiece) // TODO: average across multiple sealings - fmt.Printf("seal: preCommit: %s\n", benchout.SealingResults[0].PreCommit) - fmt.Printf("seal: Commit: %s\n", benchout.SealingResults[0].Commit) - fmt.Printf("seal: Verify: %s\n", benchout.SealingResults[0].Verify) - fmt.Printf("unseal: %s\n", benchout.SealingResults[0].Unseal) - fmt.Printf("generate candidates: %s\n", benchout.PostGenerateCandidates) - fmt.Printf("compute epost proof (cold): %s\n", benchout.PostEProofCold) - fmt.Printf("compute epost proof (hot): %s\n", benchout.PostEProofHot) - fmt.Printf("verify epost proof (cold): %s\n", benchout.VerifyEPostCold) - fmt.Printf("verify epost proof (hot): %s\n", benchout.VerifyEPostHot) + if c.Bool("json-out") { + data, err := json.MarshalIndent(bo, "", " ") + if err != nil { + return err + } + + fmt.Println(string(data)) + } else { + fmt.Printf("results (%d)\n", sectorSize) + if robench == "" { + fmt.Printf("seal: addPiece: %s (%s)\n", bo.SealingResults[0].AddPiece, bps(bo.SectorSize, bo.SealingResults[0].AddPiece)) // TODO: average across multiple sealings + fmt.Printf("seal: preCommit: %s (%s)\n", bo.SealingResults[0].PreCommit, bps(bo.SectorSize, bo.SealingResults[0].PreCommit)) + fmt.Printf("seal: commit: %s (%s)\n", bo.SealingResults[0].Commit, bps(bo.SectorSize, bo.SealingResults[0].Commit)) + fmt.Printf("seal: verify: %s\n", bo.SealingResults[0].Verify) + fmt.Printf("unseal: %s (%s)\n", bo.SealingResults[0].Unseal, bps(bo.SectorSize, bo.SealingResults[0].Unseal)) + } + fmt.Printf("generate candidates: %s (%s)\n", bo.PostGenerateCandidates, bps(bo.SectorSize*uint64(len(bo.SealingResults)), bo.PostGenerateCandidates)) + fmt.Printf("compute epost proof (cold): %s\n", bo.PostEProofCold) + fmt.Printf("compute epost proof (hot): %s\n", bo.PostEProofHot) + fmt.Printf("verify epost proof (cold): %s\n", bo.VerifyEPostCold) + fmt.Printf("verify epost proof (hot): %s\n", bo.VerifyEPostHot) + } return nil }, } @@ -286,3 +366,10 @@ func main() { return } } + +func bps(data uint64, d time.Duration) string { + bdata := new(big.Int).SetUint64(data) + bdata = bdata.Mul(bdata, big.NewInt(time.Second.Nanoseconds())) + bps := bdata.Div(bdata, big.NewInt(d.Nanoseconds())) + return lcli.SizeStr(types.BigInt{bps}) + "/s" +} diff --git a/cmd/lotus-fountain/main.go b/cmd/lotus-fountain/main.go index 014834664..8538a0af8 100644 --- a/cmd/lotus-fountain/main.go +++ b/cmd/lotus-fountain/main.go @@ -100,7 +100,7 @@ var runCmd = &cli.Command{ IPRate: time.Minute, IPBurst: 5, WalletRate: 15 * time.Minute, - WalletBurst: 1, + WalletBurst: 2, }), minerLimiter: NewLimiter(LimiterConfig{ TotalRate: time.Second, @@ -108,7 +108,7 @@ var runCmd = &cli.Command{ IPRate: 10 * time.Minute, IPBurst: 2, WalletRate: 1 * time.Hour, - WalletBurst: 1, + WalletBurst: 2, }), } @@ -150,7 +150,7 @@ func (h *handler) send(w http.ResponseWriter, r *http.Request) { // Limit based on wallet address limiter := h.limiter.GetWalletLimiter(to.String()) if !limiter.Allow() { - http.Error(w, http.StatusText(http.StatusTooManyRequests), http.StatusTooManyRequests) + http.Error(w, http.StatusText(http.StatusTooManyRequests)+": wallet limit", http.StatusTooManyRequests) return } @@ -170,13 +170,13 @@ func (h *handler) send(w http.ResponseWriter, r *http.Request) { limiter = h.limiter.GetIPLimiter(reqIP) if !limiter.Allow() { - http.Error(w, http.StatusText(http.StatusTooManyRequests), http.StatusTooManyRequests) + http.Error(w, http.StatusText(http.StatusTooManyRequests)+": IP limit", http.StatusTooManyRequests) return } // General limiter to allow throttling all messages that can make it into the mpool if !h.limiter.Allow() { - http.Error(w, http.StatusText(http.StatusTooManyRequests), http.StatusTooManyRequests) + http.Error(w, http.StatusText(http.StatusTooManyRequests)+": global limit", http.StatusTooManyRequests) return } @@ -221,20 +221,20 @@ func (h *handler) mkminer(w http.ResponseWriter, r *http.Request) { // Limit based on wallet address limiter := h.minerLimiter.GetWalletLimiter(owner.String()) if !limiter.Allow() { - http.Error(w, http.StatusText(http.StatusTooManyRequests), http.StatusTooManyRequests) + http.Error(w, http.StatusText(http.StatusTooManyRequests)+": wallet limit", http.StatusTooManyRequests) return } // Limit based on IP limiter = h.minerLimiter.GetIPLimiter(r.RemoteAddr) if !limiter.Allow() { - http.Error(w, http.StatusText(http.StatusTooManyRequests), http.StatusTooManyRequests) + http.Error(w, http.StatusText(http.StatusTooManyRequests)+": IP limit", http.StatusTooManyRequests) return } // General limiter owner allow throttling all messages that can make it into the mpool if !h.minerLimiter.Allow() { - http.Error(w, http.StatusText(http.StatusTooManyRequests), http.StatusTooManyRequests) + http.Error(w, http.StatusText(http.StatusTooManyRequests)+": global limit", http.StatusTooManyRequests) return } diff --git a/cmd/lotus-fountain/site/miner.html b/cmd/lotus-fountain/site/miner.html index 124809c72..0fc88e792 100644 --- a/cmd/lotus-fountain/site/miner.html +++ b/cmd/lotus-fountain/site/miner.html @@ -17,8 +17,6 @@ diff --git a/cmd/lotus-seed/main.go b/cmd/lotus-seed/main.go index f3350ec2e..754030ade 100644 --- a/cmd/lotus-seed/main.go +++ b/cmd/lotus-seed/main.go @@ -179,7 +179,7 @@ var aggregateSectorDirsCmd = &cli.Command{ return err } - if err := os.MkdirAll(cctx.String("dest"), 0755); err != nil { + if err := os.MkdirAll(destdir, 0755); err != nil { return err } @@ -204,6 +204,7 @@ var aggregateSectorDirsCmd = &cli.Command{ return err } + var aggrGenMiner genesis.GenesisMiner var highestSectorID uint64 for _, dir := range cctx.Args().Slice() { dir, err := homedir.Expand(dir) @@ -244,6 +245,8 @@ var aggregateSectorDirsCmd = &cli.Command{ } } + aggrGenMiner = mergeGenMiners(aggrGenMiner, genm) + opts := badger.DefaultOptions opts.ReadOnly = true mds, err := badger.NewDatastore(filepath.Join(dir, "badger"), &opts) @@ -265,7 +268,7 @@ var aggregateSectorDirsCmd = &cli.Command{ return err } - if err := agsb.ImportFrom(sb); err != nil { + if err := agsb.ImportFrom(sb, false); err != nil { return xerrors.Errorf("importing sectors from %q failed: %w", dir, err) } } @@ -274,6 +277,10 @@ var aggregateSectorDirsCmd = &cli.Command{ return err } + if err := seed.WriteGenesisMiner(maddr, destdir, &aggrGenMiner); err != nil { + return err + } + return nil }, } diff --git a/cmd/lotus-seed/seed/seed.go b/cmd/lotus-seed/seed/seed.go index c54a953f5..1fa9cc65e 100644 --- a/cmd/lotus-seed/seed/seed.go +++ b/cmd/lotus-seed/seed/seed.go @@ -2,11 +2,11 @@ package seed import ( "context" + "crypto/rand" "crypto/sha256" "encoding/json" "fmt" "io/ioutil" - "math/rand" "os" "path/filepath" @@ -53,7 +53,6 @@ func PreSeal(maddr address.Address, ssize uint64, offset uint64, sectors int, sb return nil, err } - r := rand.New(rand.NewSource(101)) size := sectorbuilder.UserBytesForSectorSize(ssize) var sealedSectors []*genesis.PreSeal @@ -63,7 +62,7 @@ func PreSeal(maddr address.Address, ssize uint64, offset uint64, sectors int, sb return nil, err } - pi, err := sb.AddPiece(size, sid, r, nil) + pi, err := sb.AddPiece(size, sid, rand.Reader, nil) if err != nil { return nil, err } @@ -143,7 +142,6 @@ func createDeals(m *genesis.GenesisMiner, k *wallet.Key, maddr address.Address, proposal := &actors.StorageDealProposal{ PieceRef: pref, // just one deal so this == CommP PieceSize: sectorbuilder.UserBytesForSectorSize(ssize), - PieceSerialization: actors.SerializationUnixFSv0, Client: k.Address, Provider: maddr, ProposalExpiration: 9000, // TODO: allow setting @@ -153,20 +151,12 @@ func createDeals(m *genesis.GenesisMiner, k *wallet.Key, maddr address.Address, ProposerSignature: nil, } + // TODO: pretty sure we don't even need to sign this if err := api.SignWith(context.TODO(), wallet.KeyWallet(k).Sign, k.Address, proposal); err != nil { return err } - deal := &actors.StorageDeal{ - Proposal: *proposal, - CounterSignature: nil, - } - - if err := api.SignWith(context.TODO(), wallet.KeyWallet(k).Sign, k.Address, deal); err != nil { - return err - } - - sector.Deal = *deal + sector.Deal = *proposal } return nil diff --git a/cmd/lotus-shed/base16.go b/cmd/lotus-shed/base16.go new file mode 100644 index 000000000..e1b5a6502 --- /dev/null +++ b/cmd/lotus-shed/base16.go @@ -0,0 +1,52 @@ +package main + +import ( + "encoding/hex" + "fmt" + "io" + "io/ioutil" + "os" + "strings" + + "gopkg.in/urfave/cli.v2" +) + +var base16Cmd = &cli.Command{ + Name: "base16", + Description: "standard hex", + Flags: []cli.Flag{ + &cli.BoolFlag{ + Name: "decode", + Value: false, + Usage: "Decode the value", + }, + }, + Action: func(cctx *cli.Context) error { + var input io.Reader + + if cctx.Args().Len() == 0 { + input = os.Stdin + } else { + input = strings.NewReader(cctx.Args().First()) + } + + bytes, err := ioutil.ReadAll(input) + if err != nil { + return nil + } + + if cctx.Bool("decode") { + decoded, err := hex.DecodeString(strings.TrimSpace(string(bytes))) + if err != nil { + return err + } + + fmt.Println(string(decoded)) + } else { + encoded := hex.EncodeToString(bytes) + fmt.Println(encoded) + } + + return nil + }, +} diff --git a/cmd/lotus-shed/base32.go b/cmd/lotus-shed/base32.go new file mode 100644 index 000000000..ff7fab858 --- /dev/null +++ b/cmd/lotus-shed/base32.go @@ -0,0 +1,53 @@ +package main + +import ( + "fmt" + "io" + "io/ioutil" + "os" + "strings" + + "gopkg.in/urfave/cli.v2" + + "github.com/multiformats/go-base32" +) + +var base32Cmd = &cli.Command{ + Name: "base32", + Description: "multiformats base32", + Flags: []cli.Flag{ + &cli.BoolFlag{ + Name: "decode", + Value: false, + Usage: "Decode the multiformats base32", + }, + }, + Action: func(cctx *cli.Context) error { + var input io.Reader + + if cctx.Args().Len() == 0 { + input = os.Stdin + } else { + input = strings.NewReader(cctx.Args().First()) + } + + bytes, err := ioutil.ReadAll(input) + if err != nil { + return nil + } + + if cctx.Bool("decode") { + decoded, err := base32.RawStdEncoding.DecodeString(strings.TrimSpace(string(bytes))) + if err != nil { + return err + } + + fmt.Println(string(decoded)) + } else { + encoded := base32.RawStdEncoding.EncodeToString(bytes) + fmt.Println(encoded) + } + + return nil + }, +} diff --git a/cmd/lotus-shed/keyinfo.go b/cmd/lotus-shed/keyinfo.go new file mode 100644 index 000000000..d3716d576 --- /dev/null +++ b/cmd/lotus-shed/keyinfo.go @@ -0,0 +1,84 @@ +package main + +import ( + "encoding/hex" + "encoding/json" + "io" + "io/ioutil" + "os" + "strings" + "text/template" + + "gopkg.in/urfave/cli.v2" + + "github.com/filecoin-project/lotus/chain/types" + "github.com/filecoin-project/lotus/chain/wallet" +) + +type walletInfo struct { + Type string + Address string + PublicKey string +} + +func (wi walletInfo) String() string { + bs, _ := json.Marshal(wi) + return string(bs) +} + +var keyinfoCmd = &cli.Command{ + Name: "keyinfo", + Description: "decode a keyinfo", + Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "format", + Value: "{{.Address}}", + Usage: "Format to output", + }, + }, + Action: func(cctx *cli.Context) error { + format := cctx.String("format") + + var input io.Reader + + if cctx.Args().Len() == 0 { + input = os.Stdin + } else { + input = strings.NewReader(cctx.Args().First()) + } + + bytes, err := ioutil.ReadAll(input) + + data, err := hex.DecodeString(strings.TrimSpace(string(bytes))) + if err != nil { + return err + } + + var ki types.KeyInfo + if err := json.Unmarshal(data, &ki); err != nil { + return err + } + + key, err := wallet.NewKey(ki) + if err != nil { + return err + } + + bs, err := json.Marshal(key) + if err != nil { + return err + } + + var wi walletInfo + if err := json.Unmarshal(bs, &wi); err != nil { + return err + } + + tmpl, err := template.New("").Parse(format) + if err != nil { + return err + } + + return tmpl.Execute(os.Stdout, wi) + }, +} diff --git a/cmd/lotus-shed/main.go b/cmd/lotus-shed/main.go new file mode 100644 index 000000000..e48b48b9b --- /dev/null +++ b/cmd/lotus-shed/main.go @@ -0,0 +1,36 @@ +package main + +import ( + "os" + + logging "github.com/ipfs/go-log" + "gopkg.in/urfave/cli.v2" + + "github.com/filecoin-project/lotus/build" +) + +var log = logging.Logger("lotus-shed") + +func main() { + logging.SetLogLevel("*", "INFO") + + local := []*cli.Command{ + base32Cmd, + base16Cmd, + keyinfoCmd, + peerkeyCmd, + } + + app := &cli.App{ + Name: "lotus-shed", + Usage: "A place for all the lotus tools", + Version: build.Version, + Commands: local, + } + + if err := app.Run(os.Args); err != nil { + log.Warnf("%+v", err) + os.Exit(1) + return + } +} diff --git a/cmd/lotus-shed/peerkey.go b/cmd/lotus-shed/peerkey.go new file mode 100644 index 000000000..328ad455d --- /dev/null +++ b/cmd/lotus-shed/peerkey.go @@ -0,0 +1,105 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" + "strings" + + "gopkg.in/urfave/cli.v2" + + "github.com/filecoin-project/lotus/chain/types" + "github.com/filecoin-project/lotus/node/modules/lp2p" + "github.com/libp2p/go-libp2p-core/peer" +) + +type keystore struct { + set bool + info types.KeyInfo +} + +func (ks *keystore) Put(name string, info types.KeyInfo) error { + ks.info = info + ks.set = true + + return nil +} + +func (ks *keystore) Get(name string) (types.KeyInfo, error) { + if !ks.set { + return types.KeyInfo{}, types.ErrKeyInfoNotFound + } + + return ks.info, nil +} + +func (ks *keystore) Delete(name string) error { + panic("Implement me") + + return nil +} + +func (ks *keystore) List() ([]string, error) { + panic("Implement me") + + return []string{}, nil +} + +var peerkeyCmd = &cli.Command{ + Name: "peerkey", + Description: "create libp2p host key", + Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "output", + Value: ".peerkey", + Usage: "Output file format", + }, + &cli.BoolFlag{ + Name: "silent", + Value: false, + Usage: "Do not print peerid at end", + }, + }, + Action: func(cctx *cli.Context) error { + output := cctx.String("output") + ks := keystore{} + + sk, err := lp2p.PrivKey(&ks) + if err != nil { + return err + } + + bs, err := json.Marshal(ks.info) + if err != nil { + return err + } + + peerid, err := peer.IDFromPrivateKey(sk) + if err != nil { + return err + } + + output = strings.ReplaceAll(output, "", peerid.String()) + + f, err := os.Create(output) + if err != nil { + return err + } + + defer func() { + if err := f.Close(); err != nil { + log.Warnf("failed to close output file: %w", err) + } + }() + + if _, err := f.Write(bs); err != nil { + return err + } + + if !cctx.Bool("silent") { + fmt.Println(peerid.String()) + } + + return nil + }, +} diff --git a/cmd/lotus-storage-miner/info.go b/cmd/lotus-storage-miner/info.go index 154d38fa0..58c459e44 100644 --- a/cmd/lotus-storage-miner/info.go +++ b/cmd/lotus-storage-miner/info.go @@ -43,7 +43,7 @@ var infoCmd = &cli.Command{ return err } - fmt.Printf("Sector Size: %s\n", sizeStr(types.NewInt(sizeByte))) + fmt.Printf("Sector Size: %s\n", lcli.SizeStr(types.NewInt(sizeByte))) pow, err := api.StateMinerPower(ctx, maddr, nil) if err != nil { @@ -51,7 +51,7 @@ var infoCmd = &cli.Command{ } percI := types.BigDiv(types.BigMul(pow.MinerPower, types.NewInt(1000)), pow.TotalPower) - fmt.Printf("Power: %s / %s (%0.4f%%)\n", sizeStr(pow.MinerPower), sizeStr(pow.TotalPower), float64(percI.Int64())/100000*10000) + fmt.Printf("Power: %s / %s (%0.4f%%)\n", lcli.SizeStr(pow.MinerPower), lcli.SizeStr(pow.TotalPower), float64(percI.Int64())/100000*10000) // TODO: indicate whether the post worker is in use wstat, err := nodeApi.WorkerStats(ctx) @@ -110,18 +110,6 @@ var infoCmd = &cli.Command{ }, } -var Units = []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB"} - -func sizeStr(size types.BigInt) string { - size = types.BigMul(size, types.NewInt(100)) - i := 0 - for types.BigCmp(size, types.NewInt(102400)) >= 0 && i < len(Units)-1 { - size = types.BigDiv(size, types.NewInt(1024)) - i++ - } - return fmt.Sprintf("%s.%s %s", types.BigDiv(size, types.NewInt(100)), types.BigMod(size, types.NewInt(100)), Units[i]) -} - func sectorsInfo(ctx context.Context, napi api.StorageMiner) (map[string]int, error) { sectors, err := napi.SectorsList(ctx) if err != nil { diff --git a/cmd/lotus-storage-miner/init.go b/cmd/lotus-storage-miner/init.go index c396f2def..204103522 100644 --- a/cmd/lotus-storage-miner/init.go +++ b/cmd/lotus-storage-miner/init.go @@ -1,6 +1,7 @@ package main import ( + "bytes" "context" "crypto/rand" "encoding/json" @@ -75,12 +76,21 @@ var initCmd = &cli.Command{ Name: "nosync", Usage: "don't check full-node sync status", }, + &cli.BoolFlag{ + Name: "symlink-imported-sectors", + Usage: "attempt to symlink to presealed sectors instead of copying them into place", + }, }, Action: func(cctx *cli.Context) error { log.Info("Initializing lotus storage miner") ssize := cctx.Uint64("sector-size") + symlink := cctx.Bool("symlink-imported-sectors") + if symlink { + log.Info("will attempt to symlink to imported sectors") + } + log.Info("Checking proof parameters") if err := build.GetParams(ssize); err != nil { return xerrors.Errorf("fetching proof parameters: %w", err) @@ -152,7 +162,9 @@ var initCmd = &cli.Command{ return err } - oldmds, err := badger.NewDatastore(filepath.Join(pssb, "badger"), nil) + bopts := badger.DefaultOptions + bopts.ReadOnly = true + oldmds, err := badger.NewDatastore(filepath.Join(pssb, "badger"), &bopts) if err != nil { return err } @@ -181,7 +193,7 @@ var initCmd = &cli.Command{ return xerrors.Errorf("failed to open up sectorbuilder: %w", err) } - if err := nsb.ImportFrom(oldsb); err != nil { + if err := nsb.ImportFrom(oldsb, symlink); err != nil { return err } if err := lr.Close(); err != nil { @@ -267,7 +279,7 @@ func migratePreSealMeta(ctx context.Context, api lapi.FullNode, presealDir strin return err } - proposalCid, err := sector.Deal.Proposal.Cid() + proposalCid, err := sector.Deal.Cid() if err != nil { return err } @@ -275,7 +287,7 @@ func migratePreSealMeta(ctx context.Context, api lapi.FullNode, presealDir strin dealKey := datastore.NewKey(deals.ProviderDsPrefix).ChildString(proposalCid.String()) deal := &deals.MinerDeal{ - Proposal: sector.Deal.Proposal, + Proposal: sector.Deal, ProposalCid: proposalCid, State: lapi.DealComplete, Ref: proposalCid, // TODO: This is super wrong, but there @@ -298,7 +310,7 @@ func migratePreSealMeta(ctx context.Context, api lapi.FullNode, presealDir strin return nil } -func findMarketDealID(ctx context.Context, api lapi.FullNode, deal actors.StorageDeal) (uint64, error) { +func findMarketDealID(ctx context.Context, api lapi.FullNode, deal actors.StorageDealProposal) (uint64, error) { // TODO: find a better way // (this is only used by genesis miners) @@ -308,11 +320,7 @@ func findMarketDealID(ctx context.Context, api lapi.FullNode, deal actors.Storag } for k, v := range deals { - eq, err := cborutil.Equals(&v.Deal, &deal) - if err != nil { - return 0, err - } - if eq { + if bytes.Equal(v.PieceRef, deal.PieceRef) { return strconv.ParseUint(k, 10, 64) } } diff --git a/cmd/lotus-storage-miner/run.go b/cmd/lotus-storage-miner/run.go index 814e93686..72826d585 100644 --- a/cmd/lotus-storage-miner/run.go +++ b/cmd/lotus-storage-miner/run.go @@ -15,6 +15,7 @@ import ( "gopkg.in/urfave/cli.v2" "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/lotus/api/apistruct" "github.com/filecoin-project/lotus/build" lcli "github.com/filecoin-project/lotus/cli" "github.com/filecoin-project/lotus/lib/auth" @@ -131,7 +132,7 @@ var runCmd = &cli.Command{ mux := mux.NewRouter() rpcServer := jsonrpc.NewServer() - rpcServer.Register("Filecoin", api.PermissionedStorMinerAPI(minerapi)) + rpcServer.Register("Filecoin", apistruct.PermissionedStorMinerAPI(minerapi)) mux.Handle("/rpc/v0", rpcServer) mux.PathPrefix("/remote").HandlerFunc(minerapi.(*impl.StorageMinerAPI).ServeRemote) diff --git a/cmd/lotus/daemon.go b/cmd/lotus/daemon.go index ce2cc64b9..c8d1b6b7e 100644 --- a/cmd/lotus/daemon.go +++ b/cmd/lotus/daemon.go @@ -47,6 +47,11 @@ var DaemonCmd = &cli.Command{ Name: "genesis", Usage: "genesis file to use for first node run", }, + &cli.StringFlag{ + Name: "genesis-timestamp", + Hidden: true, + Usage: "set the timestamp for the genesis block that will be created", + }, &cli.BoolFlag{ Name: "bootstrap", Value: true, @@ -84,7 +89,7 @@ var DaemonCmd = &cli.Command{ if cctx.String(preSealedSectorsFlag) == "" { return xerrors.Errorf("must also pass file with miner preseal info to `--%s`", preSealedSectorsFlag) } - genesis = node.Override(new(modules.Genesis), testing.MakeGenesis(cctx.String(makeGenFlag), cctx.String(preSealedSectorsFlag))) + genesis = node.Override(new(modules.Genesis), testing.MakeGenesis(cctx.String(makeGenFlag), cctx.String(preSealedSectorsFlag), cctx.String("genesis-timestamp"))) } var api api.FullNode diff --git a/cmd/lotus/rpc.go b/cmd/lotus/rpc.go index 3b203fff2..5178e1b6c 100644 --- a/cmd/lotus/rpc.go +++ b/cmd/lotus/rpc.go @@ -3,6 +3,7 @@ package main import ( "context" "encoding/json" + "github.com/filecoin-project/lotus/api/apistruct" "net/http" _ "net/http/pprof" "os" @@ -26,7 +27,7 @@ var log = logging.Logger("main") func serveRPC(a api.FullNode, stop node.StopFunc, addr multiaddr.Multiaddr) error { rpcServer := jsonrpc.NewServer() - rpcServer.Register("Filecoin", api.PermissionedFullAPI(a)) + rpcServer.Register("Filecoin", apistruct.PermissionedFullAPI(a)) ah := &auth.Handler{ Verify: a.AuthVerify, @@ -70,7 +71,7 @@ func handleImport(a *impl.FullNodeAPI) func(w http.ResponseWriter, r *http.Reque w.WriteHeader(404) return } - if !api.HasPerm(r.Context(), api.PermWrite) { + if !apistruct.HasPerm(r.Context(), apistruct.PermWrite) { w.WriteHeader(401) json.NewEncoder(w).Encode(struct{ Error string }{"unauthorized: missing write permission"}) return diff --git a/extern/filecoin-ffi b/extern/filecoin-ffi index 16a8b663e..e32f5efc8 160000 --- a/extern/filecoin-ffi +++ b/extern/filecoin-ffi @@ -1 +1 @@ -Subproject commit 16a8b663ec61339d3d8736e85eddd3e4a1c190b7 +Subproject commit e32f5efc808b92560f9d7f92a5d312b5ac403b7d diff --git a/gen/main.go b/gen/main.go index 8fd251eb7..52fcf4665 100644 --- a/gen/main.go +++ b/gen/main.go @@ -49,7 +49,7 @@ func main() { os.Exit(1) } - err = gen.WriteTupleEncodersToFile("./api/cbor_gen.go", "api", + err = gen.WriteMapEncodersToFile("./api/cbor_gen.go", "api", api.PaymentInfo{}, api.SealedRef{}, api.SealedRefs{}, @@ -96,6 +96,7 @@ func main() { actors.SubmitFallbackPoStParams{}, actors.PaymentVerifyParams{}, actors.UpdatePeerIDParams{}, + actors.DeclareFaultsParams{}, actors.MultiSigActorState{}, actors.MultiSigConstructorParams{}, actors.MultiSigProposeParams{}, @@ -122,7 +123,6 @@ func main() { actors.StorageMarketState{}, actors.WithdrawBalanceParams{}, actors.StorageDealProposal{}, - actors.StorageDeal{}, actors.PublishStorageDealsParams{}, actors.PublishStorageDealResponse{}, actors.ActivateStorageDealsParams{}, @@ -154,7 +154,7 @@ func main() { os.Exit(1) } - err = gen.WriteTupleEncodersToFile("./storage/cbor_gen.go", "storage", + err = gen.WriteMapEncodersToFile("./storage/cbor_gen.go", "storage", storage.SealTicket{}, storage.SealSeed{}, storage.Piece{}, diff --git a/genesis/types.go b/genesis/types.go index e8a208452..712c116cc 100644 --- a/genesis/types.go +++ b/genesis/types.go @@ -10,7 +10,7 @@ type PreSeal struct { CommR [32]byte CommD [32]byte SectorID uint64 - Deal actors.StorageDeal + Deal actors.StorageDealProposal } type GenesisMiner struct { diff --git a/go.mod b/go.mod index 32b469d60..942e2f284 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/GeertJohan/go.rice v1.0.0 github.com/Gurpartap/async v0.0.0-20180927173644-4f7f499dd9ee github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect + github.com/docker/go-units v0.4.0 github.com/fatih/color v1.7.0 // indirect github.com/filecoin-project/chain-validation v0.0.3 github.com/filecoin-project/filecoin-ffi v0.0.0-20191204125133-ebb3e13addf1 @@ -86,7 +87,7 @@ require ( github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 // indirect github.com/stretchr/testify v1.4.0 github.com/whyrusleeping/bencher v0.0.0-20190829221104-bb6607aa8bba - github.com/whyrusleeping/cbor-gen v0.0.0-20191208220313-d43e400b4942 + github.com/whyrusleeping/cbor-gen v0.0.0-20191209162422-1c55bd7cf8aa github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 github.com/whyrusleeping/pubsub v0.0.0-20131020042734-02de8aa2db3d go.opencensus.io v0.22.1 diff --git a/go.sum b/go.sum index c6c110dab..45d7afb48 100644 --- a/go.sum +++ b/go.sum @@ -68,6 +68,8 @@ github.com/dgraph-io/badger v1.6.0-rc1/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhY github.com/dgryski/go-farm v0.0.0-20190104051053-3adb47b1fb0f/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= +github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= +github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= @@ -586,8 +588,8 @@ github.com/whyrusleeping/cbor-gen v0.0.0-20190910031516-c1cbffdb01bb/go.mod h1:x github.com/whyrusleeping/cbor-gen v0.0.0-20190917003517-d78d67427694/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY= github.com/whyrusleeping/cbor-gen v0.0.0-20191116002219-891f55cd449d h1:NRa/Vs7+b91GdXrp0AqsG7pspWV6CLk5Gk7i46L4tGo= github.com/whyrusleeping/cbor-gen v0.0.0-20191116002219-891f55cd449d/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY= -github.com/whyrusleeping/cbor-gen v0.0.0-20191208220313-d43e400b4942 h1:EIKesTogdQi76lVOmZleTRQtNNIXSy037QVBVMZ8rug= -github.com/whyrusleeping/cbor-gen v0.0.0-20191208220313-d43e400b4942/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY= +github.com/whyrusleeping/cbor-gen v0.0.0-20191209162422-1c55bd7cf8aa h1:iuIvC21JR4TcHtdCtkXz2jG8KCAK9ZJQQQxbDkFxkNE= +github.com/whyrusleeping/cbor-gen v0.0.0-20191209162422-1c55bd7cf8aa/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f/go.mod h1:p9UJB6dDgdPgMJZs7UjUOdulKyRr9fqkS+6JKAInPy8= github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 h1:EKhdznlJHPMoKr0XTrX+IlJs1LH3lyx2nfr1dOlZ79k= diff --git a/lib/auth/handler.go b/lib/auth/handler.go index 67fc1ac9b..b6112ce8c 100644 --- a/lib/auth/handler.go +++ b/lib/auth/handler.go @@ -5,8 +5,10 @@ import ( "net/http" "strings" - "github.com/filecoin-project/lotus/api" logging "github.com/ipfs/go-log" + + "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/lotus/api/apistruct" ) var log = logging.Logger("auth") @@ -42,7 +44,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - ctx = api.WithPerm(ctx, allow) + ctx = apistruct.WithPerm(ctx, allow) } h.Next(w, r.WithContext(ctx)) diff --git a/lib/sectorbuilder/files.go b/lib/sectorbuilder/files.go index 373741cc8..62eeeceb1 100644 --- a/lib/sectorbuilder/files.go +++ b/lib/sectorbuilder/files.go @@ -31,12 +31,7 @@ func (sb *SectorBuilder) stagedSectorFile(sectorID uint64) (*os.File, error) { func (sb *SectorBuilder) SealedSectorPath(sectorID uint64) (string, error) { path := filepath.Join(sb.sealedDir, sb.SectorName(sectorID)) - e, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0644) - if err != nil { - return "", err - } - - return path, e.Close() + return path, nil } func (sb *SectorBuilder) sectorCacheDir(sectorID uint64) (string, error) { diff --git a/lib/sectorbuilder/sectorbuilder.go b/lib/sectorbuilder/sectorbuilder.go index 7a5d744ab..84b505fce 100644 --- a/lib/sectorbuilder/sectorbuilder.go +++ b/lib/sectorbuilder/sectorbuilder.go @@ -3,7 +3,9 @@ package sectorbuilder import ( "fmt" "io" + "io/ioutil" "os" + "path/filepath" "strconv" "sync" "sync/atomic" @@ -16,6 +18,7 @@ import ( "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/address" + "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/node/modules/dtypes" ) @@ -480,6 +483,14 @@ func (sb *SectorBuilder) SealPreCommit(sectorID uint64, ticket SealTicket, piece return RawSealPreCommitOutput{}, xerrors.Errorf("getting sealed sector path: %w", err) } + e, err := os.OpenFile(sealedPath, os.O_RDWR|os.O_CREATE, 0644) + if err != nil { + return RawSealPreCommitOutput{}, xerrors.Errorf("ensuring sealed file exists: %w", err) + } + if err := e.Close(); err != nil { + return RawSealPreCommitOutput{}, err + } + var sum uint64 for _, piece := range pieces { sum += piece.Size @@ -506,8 +517,6 @@ func (sb *SectorBuilder) SealPreCommit(sectorID uint64, ticket SealTicket, piece return RawSealPreCommitOutput{}, xerrors.Errorf("presealing sector %d (%s): %w", sectorID, stagedPath, err) } - log.Infof("PRECOMMIT FFI RSPCO %v", rspco) - return RawSealPreCommitOutput(rspco), nil } @@ -623,7 +632,7 @@ func (sb *SectorBuilder) GenerateEPostCandidates(sectorInfo SortedPublicSectorIn return nil, err } - challengeCount := ElectionPostChallengeCount(uint64(len(sectorInfo.Values()))) + challengeCount := types.ElectionPostChallengeCount(uint64(len(sectorInfo.Values()))) proverID := addressToProverID(sb.Miner) return sectorbuilder.GenerateCandidates(sb.ssize, proverID, challengeSeed, challengeCount, privsectors) @@ -674,29 +683,24 @@ func (sb *SectorBuilder) Stop() { close(sb.stopping) } -func ElectionPostChallengeCount(sectors uint64) uint64 { - // ceil(sectors / build.SectorChallengeRatioDiv) - return (sectors + build.SectorChallengeRatioDiv - 1) / build.SectorChallengeRatioDiv -} - func fallbackPostChallengeCount(sectors uint64) uint64 { - challengeCount := ElectionPostChallengeCount(sectors) + challengeCount := types.ElectionPostChallengeCount(sectors) if challengeCount > build.MaxFallbackPostChallengeCount { return build.MaxFallbackPostChallengeCount } return challengeCount } -func (sb *SectorBuilder) ImportFrom(osb *SectorBuilder) error { - if err := dcopy.Copy(osb.cacheDir, sb.cacheDir); err != nil { +func (sb *SectorBuilder) ImportFrom(osb *SectorBuilder, symlink bool) error { + if err := migrate(osb.cacheDir, sb.cacheDir, symlink); err != nil { return err } - if err := dcopy.Copy(osb.sealedDir, sb.sealedDir); err != nil { + if err := migrate(osb.sealedDir, sb.sealedDir, symlink); err != nil { return err } - if err := dcopy.Copy(osb.stagedDir, sb.stagedDir); err != nil { + if err := migrate(osb.stagedDir, sb.stagedDir, symlink); err != nil { return err } @@ -722,3 +726,58 @@ func (sb *SectorBuilder) SetLastSectorID(id uint64) error { sb.lastID = id return nil } + +func migrate(from, to string, symlink bool) error { + st, err := os.Stat(from) + if err != nil { + return err + } + + if st.IsDir() { + return migrateDir(from, to, symlink) + } + return migrateFile(from, to, symlink) +} + +func migrateDir(from, to string, symlink bool) error { + tost, err := os.Stat(to) + if err != nil { + if !os.IsNotExist(err) { + return err + } + + if err := os.MkdirAll(to, 0755); err != nil { + return err + } + } else if !tost.IsDir() { + return xerrors.Errorf("target %q already exists and is a file (expected directory)") + } + + dirents, err := ioutil.ReadDir(from) + if err != nil { + return err + } + + for _, inf := range dirents { + n := inf.Name() + if inf.IsDir() { + if err := migrate(filepath.Join(from, n), filepath.Join(to, n), symlink); err != nil { + return err + } + } else { + if err := migrate(filepath.Join(from, n), filepath.Join(to, n), symlink); err != nil { + return err + } + } + } + + return nil +} + +func migrateFile(from, to string, symlink bool) error { + if symlink { + return os.Symlink(from, to) + } + + return dcopy.Copy(from, to) +} diff --git a/lib/sectorbuilder/simple.go b/lib/sectorbuilder/simple.go index 0c9231092..457c4b2e1 100644 --- a/lib/sectorbuilder/simple.go +++ b/lib/sectorbuilder/simple.go @@ -8,6 +8,7 @@ import ( "go.opencensus.io/trace" "github.com/filecoin-project/lotus/chain/address" + "github.com/filecoin-project/lotus/chain/types" ) func (sb *SectorBuilder) SectorSize() uint64 { @@ -36,7 +37,7 @@ func NewSortedPublicSectorInfo(sectors []sectorbuilder.PublicSectorInfo) SortedP } func VerifyElectionPost(ctx context.Context, sectorSize uint64, sectorInfo SortedPublicSectorInfo, challengeSeed []byte, proof []byte, candidates []EPostCandidate, proverID address.Address) (bool, error) { - challengeCount := ElectionPostChallengeCount(uint64(len(sectorInfo.Values()))) + challengeCount := types.ElectionPostChallengeCount(uint64(len(sectorInfo.Values()))) return verifyPost(ctx, sectorSize, sectorInfo, challengeCount, challengeSeed, proof, candidates, proverID) } diff --git a/lib/statestore/store.go b/lib/statestore/store.go index 994938223..a334b60b8 100644 --- a/lib/statestore/store.go +++ b/lib/statestore/store.go @@ -8,6 +8,7 @@ import ( "github.com/ipfs/go-datastore" "github.com/ipfs/go-datastore/query" cbg "github.com/whyrusleeping/cbor-gen" + "go.uber.org/multierr" "golang.org/x/xerrors" "github.com/filecoin-project/lotus/lib/cborutil" @@ -139,6 +140,8 @@ func (st *StateStore) List(out interface{}) error { outT := reflect.TypeOf(out).Elem().Elem() rout := reflect.ValueOf(out) + var errs error + for { res, ok := res.NextSync() if !ok { @@ -151,7 +154,8 @@ func (st *StateStore) List(out interface{}) error { elem := reflect.New(outT) err := cborutil.ReadCborRPC(bytes.NewReader(res.Value), elem.Interface()) if err != nil { - return err + errs = multierr.Append(errs, xerrors.Errorf("decoding state for key '%s': %w", res.Key, err)) + continue } rout.Elem().Set(reflect.Append(rout.Elem(), elem.Elem())) diff --git a/lotuspond/front/src/StorageNode.js b/lotuspond/front/src/StorageNode.js index c5c917778..d86c83549 100644 --- a/lotuspond/front/src/StorageNode.js +++ b/lotuspond/front/src/StorageNode.js @@ -15,6 +15,7 @@ let sealCodes = [ "PreCommitting", "PreCommitted", "Committing", + "CommitWait", "Proving", "SealFailed", diff --git a/lotuspond/spawn.go b/lotuspond/spawn.go index f3534ece1..2146554b6 100644 --- a/lotuspond/spawn.go +++ b/lotuspond/spawn.go @@ -17,6 +17,10 @@ import ( "github.com/filecoin-project/lotus/cmd/lotus-seed/seed" ) +func init() { + build.SectorSizes = []uint64{1024} +} + func (api *api) Spawn() (nodeInfo, error) { dir, err := ioutil.TempDir(os.TempDir(), "lotus-") if err != nil { @@ -36,7 +40,7 @@ func (api *api) Spawn() (nodeInfo, error) { } sbroot := filepath.Join(dir, "preseal") - genm, err := seed.PreSeal(genMiner, build.SectorSizes[0], 0, 1, sbroot, []byte("8")) + genm, err := seed.PreSeal(genMiner, build.SectorSizes[0], 0, 2, sbroot, []byte("8")) if err != nil { return nodeInfo{}, xerrors.Errorf("preseal failed: %w", err) } diff --git a/miner/miner.go b/miner/miner.go index ee59f5d59..98def0e07 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -170,8 +170,6 @@ eventLoop: } lastBase = *base - log.Infof("Time delta between now and our mining base: %ds", uint64(time.Now().Unix())-base.ts.MinTimestamp()) - blks := make([]*types.BlockMsg, 0) for _, addr := range addrs { @@ -272,6 +270,8 @@ func (m *Miner) mineOne(ctx context.Context, addr address.Address, base *MiningB return nil, nil } + log.Infof("Time delta between now and our mining base: %ds", uint64(time.Now().Unix())-base.ts.MinTimestamp()) + ticket, err := m.computeTicket(ctx, addr, base) if err != nil { return nil, xerrors.Errorf("scratching ticket failed: %w", err) diff --git a/node/builder.go b/node/builder.go index 4ab041eaf..96599df8c 100644 --- a/node/builder.go +++ b/node/builder.go @@ -217,7 +217,6 @@ func Online() Option { Override(RunBlockSyncKey, modules.RunBlockSync), Override(RunPeerMgrKey, modules.RunPeerMgr), Override(HandleIncomingBlocksKey, modules.HandleIncomingBlocks), - Override(HeadMetricsKey, metrics.SendHeadNotifs("")), Override(new(*discovery.Local), discovery.NewLocal), Override(new(discovery.PeerResolver), modules.RetrievalResolver), @@ -313,7 +312,9 @@ func ConfigFullNode(c interface{}) Option { return Options( ConfigCommon(&cfg.Common), - Override(HeadMetricsKey, metrics.SendHeadNotifs(cfg.Metrics.Nickname)), + If(cfg.Metrics.HeadNotifs, + Override(HeadMetricsKey, metrics.SendHeadNotifs(cfg.Metrics.Nickname)), + ), If(cfg.Metrics.PubsubTracing, Override(new(*pubsub.PubSub), lp2p.GossipSub(lp2p.PubsubTracer())), ), diff --git a/node/config/def.go b/node/config/def.go index 80b6f199f..5010b9e88 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -42,6 +42,7 @@ type Libp2p struct { type Metrics struct { Nickname string + HeadNotifs bool PubsubTracing bool } diff --git a/node/hello/hello.go b/node/hello/hello.go index 171579899..d8f70691a 100644 --- a/node/hello/hello.go +++ b/node/hello/hello.go @@ -2,8 +2,7 @@ package hello import ( "context" - - "go.uber.org/fx" + "time" "github.com/ipfs/go-cid" cbor "github.com/ipfs/go-ipld-cbor" @@ -32,6 +31,9 @@ type Message struct { HeaviestTipSet []cid.Cid HeaviestTipSetWeight types.BigInt GenesisHash cid.Cid + + TArrial int64 + TSent int64 } type NewStreamFunc func(context.Context, peer.ID, ...protocol.ID) (inet.Stream, error) @@ -43,13 +45,7 @@ type Service struct { pmgr *peermgr.PeerMgr } -type MaybePeerMgr struct { - fx.In - - Mgr *peermgr.PeerMgr `optional:"true"` -} - -func NewHelloService(h host.Host, cs *store.ChainStore, syncer *chain.Syncer, pmgr MaybePeerMgr) *Service { +func NewHelloService(h host.Host, cs *store.ChainStore, syncer *chain.Syncer, pmgr peermgr.MaybePeerMgr) *Service { if pmgr.Mgr == nil { log.Warn("running without peer manager") } @@ -68,9 +64,12 @@ func (hs *Service) HandleStream(s inet.Stream) { var hmsg Message if err := cborutil.ReadCborRPC(s, &hmsg); err != nil { - log.Infow("failed to read hello message", "error", err) + log.Infow("failed to read hello message, diconnecting", "error", err) + s.Conn().Close() return } + arrived := time.Now() + log.Debugw("genesis from hello", "tipset", hmsg.HeaviestTipSet, "peer", s.Conn().RemotePeer(), @@ -81,6 +80,16 @@ func (hs *Service) HandleStream(s inet.Stream) { s.Conn().Close() return } + go func() { + sent := time.Now() + msg := &Message{ + TArrial: arrived.UnixNano(), + TSent: sent.UnixNano(), + } + if err := cborutil.WriteCborRPC(s, msg); err != nil { + log.Debugf("error while responding to latency: %v", err) + } + }() ts, err := hs.syncer.FetchTipSet(context.Background(), s.Conn().RemotePeer(), hmsg.HeaviestTipSet) if err != nil { @@ -93,6 +102,7 @@ func (hs *Service) HandleStream(s inet.Stream) { if hs.pmgr != nil { hs.pmgr.AddFilecoinPeer(s.Conn().RemotePeer()) } + } func (hs *Service) SayHello(ctx context.Context, pid peer.ID) error { @@ -120,9 +130,34 @@ func (hs *Service) SayHello(ctx context.Context, pid peer.ID) error { } log.Info("Sending hello message: ", hts.Cids(), hts.Height(), gen.Cid()) + t0 := time.Now() if err := cborutil.WriteCborRPC(s, hmsg); err != nil { return err } + go func() { + hmsg = &Message{} + s.SetReadDeadline(time.Now().Add(10 * time.Second)) + err := cborutil.ReadCborRPC(s, hmsg) // ignore error + ok := err == nil + + t3 := time.Now() + lat := t3.Sub(t0) + // add to peer tracker + if hs.pmgr != nil { + hs.pmgr.SetPeerLatency(pid, lat) + } + + if ok { + if hmsg.TArrial != 0 && hmsg.TSent != 0 { + t1 := time.Unix(0, hmsg.TArrial) + t2 := time.Unix(0, hmsg.TSent) + offset := t0.Sub(t1) + t3.Sub(t2) + offset /= 2 + log.Infow("time offset", "offset", offset.Seconds(), "peerid", pid.String()) + } + } + }() + return nil } diff --git a/node/impl/common.go b/node/impl/common.go index f8037ca1d..990a46a8a 100644 --- a/node/impl/common.go +++ b/node/impl/common.go @@ -2,7 +2,6 @@ package impl import ( "context" - "github.com/gbrlsnchs/jwt/v3" "github.com/libp2p/go-libp2p-core/host" "github.com/libp2p/go-libp2p-core/network" diff --git a/node/impl/full/state.go b/node/impl/full/state.go index 04037c079..2aa14a2e5 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -148,7 +148,7 @@ func (a *StateAPI) stateForTs(ctx context.Context, ts *types.TipSet) (*state.Sta func (a *StateAPI) StateGetActor(ctx context.Context, actor address.Address, ts *types.TipSet) (*types.Actor, error) { state, err := a.stateForTs(ctx, ts) if err != nil { - return nil, err + return nil, xerrors.Errorf("computing tipset state failed: %w", err) } return state.GetActor(actor) diff --git a/node/impl/storminer.go b/node/impl/storminer.go index 2b3a0352e..d7eba489a 100644 --- a/node/impl/storminer.go +++ b/node/impl/storminer.go @@ -3,6 +3,7 @@ package impl import ( "context" "encoding/json" + "github.com/filecoin-project/lotus/api/apistruct" "io" "mime" "net/http" @@ -33,7 +34,7 @@ type StorageMinerAPI struct { } func (sm *StorageMinerAPI) ServeRemote(w http.ResponseWriter, r *http.Request) { - if !api.HasPerm(r.Context(), api.PermAdmin) { + if !apistruct.HasPerm(r.Context(), apistruct.PermAdmin) { w.WriteHeader(401) json.NewEncoder(w).Encode(struct{ Error string }{"unauthorized: missing write permission"}) return @@ -167,7 +168,7 @@ func (sm *StorageMinerAPI) SectorsStatus(ctx context.Context, sid uint64) (api.S Deals: deals, Ticket: info.Ticket.SB(), Seed: info.Seed.SB(), - Retries: info.Nonce, + Retries: info.Nonce, LastErr: info.LastErr, }, nil diff --git a/node/modules/core.go b/node/modules/core.go index 5eab490eb..186ad9936 100644 --- a/node/modules/core.go +++ b/node/modules/core.go @@ -3,10 +3,10 @@ package modules import ( "context" "crypto/rand" + "github.com/filecoin-project/lotus/api/apistruct" "io" "io/ioutil" - "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/lib/addrutil" @@ -57,7 +57,7 @@ func APISecret(keystore types.KeyStore, lr repo.LockedRepo) (*dtypes.APIAlg, err // TODO: make this configurable p := jwtPayload{ - Allow: api.AllPermissions, + Allow: apistruct.AllPermissions, } cliToken, err := jwt.Sign(&p, jwt.NewHS256(key.PrivateKey)) diff --git a/node/modules/lp2p/pnet.go b/node/modules/lp2p/pnet.go index 3fe8e89df..f182be125 100644 --- a/node/modules/lp2p/pnet.go +++ b/node/modules/lp2p/pnet.go @@ -8,7 +8,7 @@ import ( pnet "github.com/libp2p/go-libp2p-pnet" ) -var LotusKey = "/key/swarm/psk/1.0.0/\n/base16/\n20c72398e6299c7bbc1b501fdcc8abe4f89f798e9b93b2d2bc02e3c29b6a088e" +var LotusKey = "/key/swarm/psk/1.0.0/\n/base16/\n20c72388e6299c7bbc1b501fdcc8abe4f89f798e9b93b2d2bc02e3c29b6a088e" type PNetFingerprint []byte diff --git a/node/modules/testing/genesis.go b/node/modules/testing/genesis.go index 4a379a129..5efe22382 100644 --- a/node/modules/testing/genesis.go +++ b/node/modules/testing/genesis.go @@ -68,7 +68,7 @@ func MakeGenesisMem(out io.Writer, gmc *gen.GenMinerCfg) func(bs dtypes.ChainBlo } } -func MakeGenesis(outFile, presealInfo string) func(bs dtypes.ChainBlockstore, w *wallet.Wallet) modules.Genesis { +func MakeGenesis(outFile, presealInfo, timestamp string) func(bs dtypes.ChainBlockstore, w *wallet.Wallet) modules.Genesis { return func(bs dtypes.ChainBlockstore, w *wallet.Wallet) modules.Genesis { return func() (*types.BlockHeader, error) { glog.Warn("Generating new random genesis block, note that this SHOULD NOT happen unless you are setting up new network") @@ -87,6 +87,7 @@ func MakeGenesis(outFile, presealInfo string) func(bs dtypes.ChainBlockstore, w return nil, err } + var fakePeerIDs []peer.ID minerAddresses := make([]address.Address, 0, len(preseals)) for s := range preseals { a, err := address.NewFromString(s) @@ -97,10 +98,11 @@ func MakeGenesis(outFile, presealInfo string) func(bs dtypes.ChainBlockstore, w return nil, xerrors.New("expected ID address") } minerAddresses = append(minerAddresses, a) + fakePeerIDs = append(fakePeerIDs, peer.ID("peer"+a.String())) } gmc := &gen.GenMinerCfg{ - PeerIDs: []peer.ID{"peer ID 1"}, + PeerIDs: fakePeerIDs, PreSeals: preseals, MinerAddrs: minerAddresses, } @@ -117,7 +119,18 @@ func MakeGenesis(outFile, presealInfo string) func(bs dtypes.ChainBlockstore, w addrs[miner.Worker] = types.FromFil(100000) } - b, err := gen.MakeGenesisBlock(bs, addrs, gmc, uint64(time.Now().Unix())) + ts := uint64(time.Now().Unix()) + if timestamp != "" { + t, err := time.Parse(time.RFC3339, timestamp) + if err != nil { + return nil, xerrors.Errorf("parsing input genesis timestamp: %w", err) + } + + glog.Infof("will use %s as the genesis timestamp", t) + ts = uint64(t.Unix()) + } + + b, err := gen.MakeGenesisBlock(bs, addrs, gmc, ts) if err != nil { return nil, err } diff --git a/node/node_test.go b/node/node_test.go index 0fe2ac7f9..c8ea659bf 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -43,6 +43,7 @@ func init() { _ = logging.SetLogLevel("*", "INFO") build.SectorSizes = []uint64{1024} + build.MinimumMinerPower = 1024 } func testStorageNode(ctx context.Context, t *testing.T, waddr address.Address, act address.Address, pk crypto.PrivKey, tnd test.TestNode, mn mocknet.Mocknet) test.TestStorageNode { @@ -237,7 +238,7 @@ func builder(t *testing.T, nFull int, storage []int) ([]test.TestNode, []test.Te t.Fatal(err) } - if err := sma.SectorBuilder.ImportFrom(osb); err != nil { + if err := sma.SectorBuilder.ImportFrom(osb, false); err != nil { t.Fatal(err) } diff --git a/paych/cbor_gen.go b/paych/cbor_gen.go index ef13863ad..b281bc755 100644 --- a/paych/cbor_gen.go +++ b/paych/cbor_gen.go @@ -22,12 +22,12 @@ func (t *VoucherInfo) MarshalCBOR(w io.Writer) error { return err } - // t.t.Voucher (types.SignedVoucher) (struct) + // t.Voucher (types.SignedVoucher) (struct) if err := t.Voucher.MarshalCBOR(w); err != nil { return err } - // t.t.Proof ([]uint8) (slice) + // t.Proof ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Proof)))); err != nil { return err } @@ -52,7 +52,7 @@ func (t *VoucherInfo) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Voucher (types.SignedVoucher) (struct) + // t.Voucher (types.SignedVoucher) (struct) { @@ -73,7 +73,7 @@ func (t *VoucherInfo) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Proof ([]uint8) (slice) + // t.Proof ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -102,27 +102,27 @@ func (t *ChannelInfo) MarshalCBOR(w io.Writer) error { return err } - // t.t.Channel (address.Address) (struct) + // t.Channel (address.Address) (struct) if err := t.Channel.MarshalCBOR(w); err != nil { return err } - // t.t.Control (address.Address) (struct) + // t.Control (address.Address) (struct) if err := t.Control.MarshalCBOR(w); err != nil { return err } - // t.t.Target (address.Address) (struct) + // t.Target (address.Address) (struct) if err := t.Target.MarshalCBOR(w); err != nil { return err } - // t.t.Direction (uint64) (uint64) + // t.Direction (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Direction))); err != nil { return err } - // t.t.Vouchers ([]*paych.VoucherInfo) (slice) + // t.Vouchers ([]*paych.VoucherInfo) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Vouchers)))); err != nil { return err } @@ -132,7 +132,7 @@ func (t *ChannelInfo) MarshalCBOR(w io.Writer) error { } } - // t.t.NextLane (uint64) (uint64) + // t.NextLane (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.NextLane))); err != nil { return err } @@ -154,7 +154,7 @@ func (t *ChannelInfo) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Channel (address.Address) (struct) + // t.Channel (address.Address) (struct) { @@ -163,7 +163,7 @@ func (t *ChannelInfo) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Control (address.Address) (struct) + // t.Control (address.Address) (struct) { @@ -172,7 +172,7 @@ func (t *ChannelInfo) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Target (address.Address) (struct) + // t.Target (address.Address) (struct) { @@ -181,7 +181,7 @@ func (t *ChannelInfo) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Direction (uint64) (uint64) + // t.Direction (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -191,7 +191,7 @@ func (t *ChannelInfo) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Direction = uint64(extra) - // t.t.Vouchers ([]*paych.VoucherInfo) (slice) + // t.Vouchers ([]*paych.VoucherInfo) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -218,7 +218,7 @@ func (t *ChannelInfo) UnmarshalCBOR(r io.Reader) error { t.Vouchers[i] = &v } - // t.t.NextLane (uint64) (uint64) + // t.NextLane (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { diff --git a/peermgr/peermgr.go b/peermgr/peermgr.go index 624fcfcc5..22879141e 100644 --- a/peermgr/peermgr.go +++ b/peermgr/peermgr.go @@ -6,6 +6,7 @@ import ( "time" "github.com/filecoin-project/lotus/node/modules/dtypes" + "go.uber.org/fx" host "github.com/libp2p/go-libp2p-core/host" net "github.com/libp2p/go-libp2p-core/network" @@ -22,6 +23,12 @@ const ( MinFilPeers = 8 ) +type MaybePeerMgr struct { + fx.In + + Mgr *PeerMgr `optional:"true"` +} + type PeerMgr struct { bootstrappers []peer.AddrInfo @@ -30,7 +37,7 @@ type PeerMgr struct { //peerLeads map[peer.ID]time.Time // TODO: unused peersLk sync.Mutex - peers map[peer.ID]struct{} + peers map[peer.ID]time.Duration maxFilPeers int minFilPeers int @@ -49,7 +56,7 @@ func NewPeerMgr(h host.Host, dht *dht.IpfsDHT, bootstrap dtypes.BootstrapPeers) dht: dht, bootstrappers: bootstrap, - peers: make(map[peer.ID]struct{}), + peers: make(map[peer.ID]time.Duration), maxFilPeers: MaxFilPeers, minFilPeers: MinFilPeers, @@ -69,7 +76,23 @@ func NewPeerMgr(h host.Host, dht *dht.IpfsDHT, bootstrap dtypes.BootstrapPeers) func (pmgr *PeerMgr) AddFilecoinPeer(p peer.ID) { pmgr.peersLk.Lock() defer pmgr.peersLk.Unlock() - pmgr.peers[p] = struct{}{} + pmgr.peers[p] = time.Duration(0) +} + +func (pmgr *PeerMgr) GetPeerLatency(p peer.ID) (time.Duration, bool) { + pmgr.peersLk.Lock() + defer pmgr.peersLk.Unlock() + dur, ok := pmgr.peers[p] + return dur, ok +} + +func (pmgr *PeerMgr) SetPeerLatency(p peer.ID, latency time.Duration) { + pmgr.peersLk.Lock() + defer pmgr.peersLk.Unlock() + if _, ok := pmgr.peers[p]; ok { + pmgr.peers[p] = latency + } + } func (pmgr *PeerMgr) Disconnect(p peer.ID) { diff --git a/retrieval/cbor_gen.go b/retrieval/cbor_gen.go index 9881a370f..f7a6279a9 100644 --- a/retrieval/cbor_gen.go +++ b/retrieval/cbor_gen.go @@ -21,7 +21,7 @@ func (t *RetParams) MarshalCBOR(w io.Writer) error { return err } - // t.t.Unixfs0 (retrieval.Unixfs0Offer) (struct) + // t.Unixfs0 (retrieval.Unixfs0Offer) (struct) if err := t.Unixfs0.MarshalCBOR(w); err != nil { return err } @@ -43,7 +43,7 @@ func (t *RetParams) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Unixfs0 (retrieval.Unixfs0Offer) (struct) + // t.Unixfs0 (retrieval.Unixfs0Offer) (struct) { @@ -76,7 +76,7 @@ func (t *Query) MarshalCBOR(w io.Writer) error { return err } - // t.t.Piece (cid.Cid) (struct) + // t.Piece (cid.Cid) (struct) if err := cbg.WriteCid(w, t.Piece); err != nil { return xerrors.Errorf("failed to write cid field t.Piece: %w", err) @@ -100,7 +100,7 @@ func (t *Query) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Piece (cid.Cid) (struct) + // t.Piece (cid.Cid) (struct) { @@ -124,17 +124,17 @@ func (t *QueryResponse) MarshalCBOR(w io.Writer) error { return err } - // t.t.Status (retrieval.QueryResponseStatus) (uint64) + // t.Status (retrieval.QueryResponseStatus) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Status))); err != nil { return err } - // t.t.Size (uint64) (uint64) + // t.Size (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Size))); err != nil { return err } - // t.t.MinPrice (types.BigInt) (struct) + // t.MinPrice (types.BigInt) (struct) if err := t.MinPrice.MarshalCBOR(w); err != nil { return err } @@ -156,7 +156,7 @@ func (t *QueryResponse) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Status (retrieval.QueryResponseStatus) (uint64) + // t.Status (retrieval.QueryResponseStatus) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -166,7 +166,7 @@ func (t *QueryResponse) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Status = QueryResponseStatus(extra) - // t.t.Size (uint64) (uint64) + // t.Size (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -176,7 +176,7 @@ func (t *QueryResponse) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Size = uint64(extra) - // t.t.MinPrice (types.BigInt) (struct) + // t.MinPrice (types.BigInt) (struct) { @@ -197,12 +197,12 @@ func (t *Unixfs0Offer) MarshalCBOR(w io.Writer) error { return err } - // t.t.Offset (uint64) (uint64) + // t.Offset (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Offset))); err != nil { return err } - // t.t.Size (uint64) (uint64) + // t.Size (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Size))); err != nil { return err } @@ -224,7 +224,7 @@ func (t *Unixfs0Offer) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Offset (uint64) (uint64) + // t.Offset (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -234,7 +234,7 @@ func (t *Unixfs0Offer) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Offset = uint64(extra) - // t.t.Size (uint64) (uint64) + // t.Size (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -256,18 +256,18 @@ func (t *DealProposal) MarshalCBOR(w io.Writer) error { return err } - // t.t.Payment (api.PaymentInfo) (struct) + // t.Payment (api.PaymentInfo) (struct) if err := t.Payment.MarshalCBOR(w); err != nil { return err } - // t.t.Ref (cid.Cid) (struct) + // t.Ref (cid.Cid) (struct) if err := cbg.WriteCid(w, t.Ref); err != nil { return xerrors.Errorf("failed to write cid field t.Ref: %w", err) } - // t.t.Params (retrieval.RetParams) (struct) + // t.Params (retrieval.RetParams) (struct) if err := t.Params.MarshalCBOR(w); err != nil { return err } @@ -289,7 +289,7 @@ func (t *DealProposal) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Payment (api.PaymentInfo) (struct) + // t.Payment (api.PaymentInfo) (struct) { @@ -298,7 +298,7 @@ func (t *DealProposal) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Ref (cid.Cid) (struct) + // t.Ref (cid.Cid) (struct) { @@ -310,7 +310,7 @@ func (t *DealProposal) UnmarshalCBOR(r io.Reader) error { t.Ref = c } - // t.t.Params (retrieval.RetParams) (struct) + // t.Params (retrieval.RetParams) (struct) { @@ -331,12 +331,12 @@ func (t *DealResponse) MarshalCBOR(w io.Writer) error { return err } - // t.t.Status (uint64) (uint64) + // t.Status (uint64) (uint64) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.Status))); err != nil { return err } - // t.t.Message (string) (string) + // t.Message (string) (string) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len(t.Message)))); err != nil { return err } @@ -361,7 +361,7 @@ func (t *DealResponse) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Status (uint64) (uint64) + // t.Status (uint64) (uint64) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -371,7 +371,7 @@ func (t *DealResponse) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("wrong type for uint64 field") } t.Status = uint64(extra) - // t.t.Message (string) (string) + // t.Message (string) (string) { sval, err := cbg.ReadString(br) @@ -393,7 +393,7 @@ func (t *Block) MarshalCBOR(w io.Writer) error { return err } - // t.t.Prefix ([]uint8) (slice) + // t.Prefix ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Prefix)))); err != nil { return err } @@ -401,7 +401,7 @@ func (t *Block) MarshalCBOR(w io.Writer) error { return err } - // t.t.Data ([]uint8) (slice) + // t.Data ([]uint8) (slice) if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.Data)))); err != nil { return err } @@ -426,7 +426,7 @@ func (t *Block) UnmarshalCBOR(r io.Reader) error { return fmt.Errorf("cbor input had wrong number of fields") } - // t.t.Prefix ([]uint8) (slice) + // t.Prefix ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -443,7 +443,7 @@ func (t *Block) UnmarshalCBOR(r io.Reader) error { if _, err := io.ReadFull(br, t.Prefix); err != nil { return err } - // t.t.Data ([]uint8) (slice) + // t.Data ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { diff --git a/retrieval/client.go b/retrieval/client.go index 405320a46..cfbfdfb05 100644 --- a/retrieval/client.go +++ b/retrieval/client.go @@ -100,7 +100,7 @@ type clientStream struct { func (c *Client) RetrieveUnixfs(ctx context.Context, root cid.Cid, size uint64, total types.BigInt, miner peer.ID, client, minerAddr address.Address, out io.Writer) error { s, err := c.h.NewStream(ctx, miner, ProtocolID) if err != nil { - return err + return xerrors.Errorf("failed to open stream to miner for retrieval query: %w", err) } defer s.Close() @@ -149,7 +149,6 @@ func (c *Client) RetrieveUnixfs(ctx context.Context, root cid.Cid, size uint64, cst.offset += toFetch } - log.Info("RETRIEVE SUCCESSFUL") return nil } @@ -173,13 +172,12 @@ func (cst *clientStream) doOneExchange(ctx context.Context, toFetch uint64, out } if err := cborutil.WriteCborRPC(cst.stream, deal); err != nil { - return err + return xerrors.Errorf("sending incremental retrieval request: %w", err) } var resp DealResponse if err := cborutil.ReadCborRPC(cst.peeker, &resp); err != nil { - log.Error(err) - return err + return xerrors.Errorf("reading retrieval response: %w", err) } if resp.Status != Accepted { diff --git a/scripts/deploy-devnet.sh b/scripts/deploy-devnet.sh deleted file mode 100755 index c1b82933c..000000000 --- a/scripts/deploy-devnet.sh +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env bash - -############ -## Settings -GENESIS_HOST=root@147.75.80.29 -BOOTSTRAPPERS=( root@147.75.80.17 ) - -############ - -read -p "You are about to deploy new DevNet, killing bootstrap nodes. Proceed? (y/n)? " r -case "$r" in - y|Y ) echo "Proceding";; - n|N ) exit 0;; - * ) exit 1;; -esac - -log() { - echo -e "\e[33m$1\e[39m" -} - -rm -f build/bootstrap/*.pi - -log '> Generating genesis' - -make - -GENPATH=$(mktemp -d) - -log 'staring temp daemon' - -./lotus --repo="${GENPATH}" daemon --lotus-make-random-genesis="${GENPATH}/devnet.car" & -GDPID=$! - -sleep 3 - -log 'Extracting genesis miner prvate key' - -ADDR=$(./lotus --repo="${GENPATH}" wallet list) -./lotus --repo="${GENPATH}" wallet export "$ADDR" > "${GENPATH}/wallet.key" - -kill "$GDPID" - -wait - -log '> Creating genesis binary' -cp "${GENPATH}/devnet.car" build/genesis/devnet.car -rm -f build/bootstrap/*.pi - -make - -log '> Deploying and starting genesis miner' - -ssh $GENESIS_HOST 'systemctl stop lotus-daemon' & -ssh $GENESIS_HOST 'systemctl stop lotus-storage-miner' & - -wait - -ssh $GENESIS_HOST 'rm -rf .lotus' & -ssh $GENESIS_HOST 'rm -rf .lotusstorage' & - -scp -C lotus "${GENESIS_HOST}":/usr/local/bin/lotus & -scp -C lotus-storage-miner "${GENESIS_HOST}":/usr/local/bin/lotus-storage-miner & - -wait - -log 'Initializing genesis miner repo' - -ssh $GENESIS_HOST 'systemctl start lotus-daemon' - -scp scripts/bootstrap.toml "${GENESIS_HOST}:.lotus/config.toml" & -ssh < "${GENPATH}/wallet.key" $GENESIS_HOST '/usr/local/bin/lotus wallet import' & -wait - -ssh $GENESIS_HOST "echo -e '[Metrics]\nNickname=\"Boot-genesis\"' >> .lotus/config.toml" - -ssh $GENESIS_HOST 'systemctl restart lotus-daemon' - -log 'Starting genesis mining' - -ssh $GENESIS_HOST '/usr/local/bin/lotus-storage-miner init --genesis-miner --actor=t0101' -ssh $GENESIS_HOST 'systemctl start lotus-storage-miner' - - -log 'Getting genesis addr info' - -ssh $GENESIS_HOST 'lotus net listen' | grep -v '/10' | grep -v '/127' > build/bootstrap/root.pi - -log '> Creating bootstrap binaries' -make - - -for host in "${BOOTSTRAPPERS[@]}" -do - ./scripts/deploy-bootstrapper.sh $host -done - -log 'Updating genesis node with bootstrapable binaries' - -ssh "$GENESIS_HOST" 'systemctl stop lotus-daemon' & -ssh "$GENESIS_HOST" 'systemctl stop lotus-storage-miner' & -wait - -scp -C lotus "${GENESIS_HOST}":/usr/local/bin/lotus & -scp -C lotus-storage-miner "${GENESIS_HOST}":/usr/local/bin/lotus-storage-miner & -wait - -ssh "$GENESIS_HOST" 'systemctl start lotus-daemon' & -ssh "$GENESIS_HOST" 'systemctl start lotus-storage-miner' & -wait diff --git a/scripts/init-network.sh b/scripts/init-network.sh new file mode 100755 index 000000000..873417f7f --- /dev/null +++ b/scripts/init-network.sh @@ -0,0 +1,117 @@ +#!/usr/bin/env bash + +set -xeo + +NUM_SECTORS=2 +SECTOR_SIZE=1024 + + +sdt0111=$(mktemp -d) +sdt0222=$(mktemp -d) +sdt0333=$(mktemp -d) + +staging=$(mktemp -d) + +make debug + +./lotus-seed --sectorbuilder-dir="${sdt0111}" pre-seal --miner-addr=t0111 --sector-offset=0 --sector-size=${SECTOR_SIZE} --num-sectors=${NUM_SECTORS} & +./lotus-seed --sectorbuilder-dir="${sdt0222}" pre-seal --miner-addr=t0222 --sector-offset=0 --sector-size=${SECTOR_SIZE} --num-sectors=${NUM_SECTORS} & +./lotus-seed --sectorbuilder-dir="${sdt0333}" pre-seal --miner-addr=t0333 --sector-offset=0 --sector-size=${SECTOR_SIZE} --num-sectors=${NUM_SECTORS} & + +wait + +./lotus-seed aggregate-manifests "${sdt0111}/pre-seal-t0111.json" "${sdt0222}/pre-seal-t0222.json" "${sdt0333}/pre-seal-t0333.json" > "${staging}/genesis.json" + +lotus_path=$(mktemp -d) + +./lotus --repo="${lotus_path}" daemon --lotus-make-random-genesis="${staging}/devnet.car" --genesis-presealed-sectors="${staging}/genesis.json" --bootstrap=false & +lpid=$! + +sleep 3 + +kill "$lpid" + +wait + +cp "${staging}/devnet.car" build/genesis/devnet.car + +make debug + +ldt0111=$(mktemp -d) +ldt0222=$(mktemp -d) +ldt0333=$(mktemp -d) + +sdlist=( "$sdt0111" "$sdt0222" "$sdt0333" ) +ldlist=( "$ldt0111" "$ldt0222" "$ldt0333" ) + +for (( i=0; i<${#sdlist[@]}; i++ )); do + preseal=${sdlist[$i]} + fullpath=$(find ${preseal} -type f -iname 'pre-seal-*.json') + filefull=$(basename ${fullpath}) + filename=${filefull%%.*} + mineraddr=$(echo $filename | sed 's/pre-seal-//g') + + wallet_raw=$(jq -rc ".${mineraddr}.Key" < ${preseal}/${filefull}) + wallet_b16=$(./lotus-shed base16 "${wallet_raw}") + wallet_adr=$(./lotus-shed keyinfo --format="{{.Address}}" "${wallet_b16}") + wallet_adr_enc=$(./lotus-shed base32 "wallet-${wallet_adr}") + + mkdir -p "${ldlist[$i]}/keystore" + cat > "${ldlist[$i]}/keystore/${wallet_adr_enc}" < cbg.ByteArrayMaxLen { - return fmt.Errorf("t.Pad0: byte array too large (%d)", extra) + if name != "CommD" { + return fmt.Errorf("expected struct map entry %s to be CommD", name) } - if maj != cbg.MajByteString { - return fmt.Errorf("expected byte array") - } - t.Pad0 = make([]byte, extra) - if _, err := io.ReadFull(br, t.Pad0); err != nil { - return err - } - // t.t.CommD ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -458,7 +738,20 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error { if _, err := io.ReadFull(br, t.CommD); err != nil { return err } - // t.t.CommR ([]uint8) (slice) + // t.CommR ([]uint8) (slice) + + { + sval, err := cbg.ReadString(br) + if err != nil { + return err + } + + name = string(sval) + } + + if name != "CommR" { + return fmt.Errorf("expected struct map entry %s to be CommR", name) + } maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -475,24 +768,20 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error { if _, err := io.ReadFull(br, t.CommR); err != nil { return err } - // t.t.Pad1 ([]uint8) (slice) + // t.Proof ([]uint8) (slice) - maj, extra, err = cbg.CborReadHeader(br) - if err != nil { - return err + { + sval, err := cbg.ReadString(br) + if err != nil { + return err + } + + name = string(sval) } - if extra > cbg.ByteArrayMaxLen { - return fmt.Errorf("t.Pad1: byte array too large (%d)", extra) + if name != "Proof" { + return fmt.Errorf("expected struct map entry %s to be Proof", name) } - if maj != cbg.MajByteString { - return fmt.Errorf("expected byte array") - } - t.Pad1 = make([]byte, extra) - if _, err := io.ReadFull(br, t.Pad1); err != nil { - return err - } - // t.t.Proof ([]uint8) (slice) maj, extra, err = cbg.CborReadHeader(br) if err != nil { @@ -509,7 +798,20 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error { if _, err := io.ReadFull(br, t.Proof); err != nil { return err } - // t.t.Ticket (storage.SealTicket) (struct) + // t.Ticket (storage.SealTicket) (struct) + + { + sval, err := cbg.ReadString(br) + if err != nil { + return err + } + + name = string(sval) + } + + if name != "Ticket" { + return fmt.Errorf("expected struct map entry %s to be Ticket", name) + } { @@ -518,7 +820,20 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error { } } - // t.t.PreCommitMessage (cid.Cid) (struct) + // t.PreCommitMessage (cid.Cid) (struct) + + { + sval, err := cbg.ReadString(br) + if err != nil { + return err + } + + name = string(sval) + } + + if name != "PreCommitMessage" { + return fmt.Errorf("expected struct map entry %s to be PreCommitMessage", name) + } { @@ -542,7 +857,20 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error { } } - // t.t.Seed (storage.SealSeed) (struct) + // t.Seed (storage.SealSeed) (struct) + + { + sval, err := cbg.ReadString(br) + if err != nil { + return err + } + + name = string(sval) + } + + if name != "Seed" { + return fmt.Errorf("expected struct map entry %s to be Seed", name) + } { @@ -551,7 +879,20 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error { } } - // t.t.CommitMessage (cid.Cid) (struct) + // t.CommitMessage (cid.Cid) (struct) + + { + sval, err := cbg.ReadString(br) + if err != nil { + return err + } + + name = string(sval) + } + + if name != "CommitMessage" { + return fmt.Errorf("expected struct map entry %s to be CommitMessage", name) + } { @@ -575,7 +916,57 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error { } } - // t.t.LastErr (string) (string) + // t.FaultReportMsg (cid.Cid) (struct) + + { + sval, err := cbg.ReadString(br) + if err != nil { + return err + } + + name = string(sval) + } + + if name != "FaultReportMsg" { + return fmt.Errorf("expected struct map entry %s to be FaultReportMsg", name) + } + + { + + pb, err := br.PeekByte() + if err != nil { + return err + } + if pb == cbg.CborNull[0] { + var nbuf [1]byte + if _, err := br.Read(nbuf[:]); err != nil { + return err + } + } else { + + c, err := cbg.ReadCid(br) + if err != nil { + return xerrors.Errorf("failed to read cid field t.FaultReportMsg: %w", err) + } + + t.FaultReportMsg = &c + } + + } + // t.LastErr (string) (string) + + { + sval, err := cbg.ReadString(br) + if err != nil { + return err + } + + name = string(sval) + } + + if name != "LastErr" { + return fmt.Errorf("expected struct map entry %s to be LastErr", name) + } { sval, err := cbg.ReadString(br) diff --git a/storage/garbage.go b/storage/garbage.go index 18a50a405..9432d7336 100644 --- a/storage/garbage.go +++ b/storage/garbage.go @@ -20,7 +20,7 @@ func (m *Miner) pledgeSector(ctx context.Context, sectorID uint64, existingPiece return nil, nil } - deals := make([]actors.StorageDeal, len(sizes)) + deals := make([]actors.StorageDealProposal, len(sizes)) for i, size := range sizes { release := m.sb.RateLimit() commP, err := sectorbuilder.GeneratePieceCommitment(io.LimitReader(rand.New(rand.NewSource(42)), int64(size)), size) @@ -33,7 +33,6 @@ func (m *Miner) pledgeSector(ctx context.Context, sectorID uint64, existingPiece sdp := actors.StorageDealProposal{ PieceRef: commP[:], PieceSize: size, - PieceSerialization: actors.SerializationUnixFSv0, Client: m.worker, Provider: m.maddr, ProposalExpiration: math.MaxUint64, @@ -47,14 +46,7 @@ func (m *Miner) pledgeSector(ctx context.Context, sectorID uint64, existingPiece return nil, xerrors.Errorf("signing storage deal failed: ", err) } - storageDeal := actors.StorageDeal{ - Proposal: sdp, - } - if err := api.SignWith(ctx, m.api.WalletSign, m.worker, &storageDeal); err != nil { - return nil, xerrors.Errorf("signing storage deal failed: ", err) - } - - deals[i] = storageDeal + deals[i] = sdp } params, aerr := actors.SerializeParams(&actors.PublishStorageDealsParams{ diff --git a/storage/miner.go b/storage/miner.go index 7026ce1f8..5d07908de 100644 --- a/storage/miner.go +++ b/storage/miner.go @@ -105,7 +105,7 @@ func (m *Miner) Run(ctx context.Context) error { go fps.run(ctx) if err := m.sectorStateLoop(ctx); err != nil { - log.Error(err) + log.Errorf("%+v", err) return xerrors.Errorf("failed to startup sector state loop: %w", err) } diff --git a/storage/sector_states.go b/storage/sector_states.go index b61fadd60..ffad0119e 100644 --- a/storage/sector_states.go +++ b/storage/sector_states.go @@ -227,9 +227,63 @@ func (m *Miner) handleCommitWait(ctx context.Context, sector SectorInfo) *sector if mw.Receipt.ExitCode != 0 { log.Errorf("UNHANDLED: submitting sector proof failed (exit=%d, msg=%s) (t:%x; s:%x(%d); p:%x)", mw.Receipt.ExitCode, sector.CommitMessage, sector.Ticket.TicketBytes, sector.Seed.TicketBytes, sector.Seed.BlockHeight, sector.Proof) - return sector.upd().fatal(xerrors.New("UNHANDLED: submitting sector proof failed")) + return sector.upd().fatal(xerrors.Errorf("UNHANDLED: submitting sector proof failed (exit: %d)", mw.Receipt.ExitCode)) } return sector.upd().to(api.Proving).state(func(info *SectorInfo) { }) } + +func (m *Miner) handleFaulty(ctx context.Context, sector SectorInfo) *sectorUpdate { + // TODO: check if the fault has already been reported, and that this sector is even valid + + // TODO: coalesce faulty sector reporting + bf := types.NewBitField() + bf.Set(sector.SectorID) + + fp := &actors.DeclareFaultsParams{bf} + _ = fp + enc, aerr := actors.SerializeParams(nil) + if aerr != nil { + return sector.upd().fatal(xerrors.Errorf("failed to serialize declare fault params: %w", aerr)) + } + + msg := &types.Message{ + To: m.maddr, + From: m.worker, + Method: actors.MAMethods.DeclareFaults, + Params: enc, + Value: types.NewInt(0), // TODO: need to ensure sufficient collateral + GasLimit: types.NewInt(1000000 /* i dont know help */), + GasPrice: types.NewInt(1), + } + + smsg, err := m.api.MpoolPushMessage(ctx, msg) + if err != nil { + return sector.upd().to(api.FailedUnrecoverable).error(xerrors.Errorf("failed to push declare faults message to network: %w", err)) + } + + return sector.upd().to(api.FaultReported).state(func(info *SectorInfo) { + c := smsg.Cid() + info.FaultReportMsg = &c + }) +} + +func (m *Miner) handleFaultReported(ctx context.Context, sector SectorInfo) *sectorUpdate { + if sector.FaultReportMsg == nil { + return sector.upd().to(api.FailedUnrecoverable).error(xerrors.Errorf("entered fault reported state without a FaultReportMsg cid")) + } + + mw, err := m.api.StateWaitMsg(ctx, *sector.FaultReportMsg) + if err != nil { + return sector.upd().to(api.CommitFailed).error(xerrors.Errorf("failed to wait for fault declaration: %w", err)) + } + + if mw.Receipt.ExitCode != 0 { + log.Errorf("UNHANDLED: declaring sector fault failed (exit=%d, msg=%s) (id: %d)", mw.Receipt.ExitCode, *sector.FaultReportMsg, sector.SectorID) + return sector.upd().fatal(xerrors.Errorf("UNHANDLED: submitting fault declaration failed (exit %d)", mw.Receipt.ExitCode)) + } + + return sector.upd().to(api.FaultedFinal).state(func(info *SectorInfo) {}) + +} diff --git a/storage/sector_types.go b/storage/sector_types.go index dccc885dc..3c328b9c0 100644 --- a/storage/sector_types.go +++ b/storage/sector_types.go @@ -56,10 +56,8 @@ type SectorInfo struct { Pieces []Piece // PreCommit - Pad0 []byte // TODO: legacy placeholder, remove CommD []byte CommR []byte - Pad1 []byte // TODO: legacy placeholder, remove Proof []byte Ticket SealTicket @@ -71,6 +69,9 @@ type SectorInfo struct { // Committing CommitMessage *cid.Cid + // Faults + FaultReportMsg *cid.Cid + // Debug LastErr string } diff --git a/storage/sectorblocks/blockstore.go b/storage/sectorblocks/blockstore.go index de6039ff5..b0807ef3a 100644 --- a/storage/sectorblocks/blockstore.go +++ b/storage/sectorblocks/blockstore.go @@ -2,6 +2,8 @@ package sectorblocks import ( "context" + "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/lotus/storage" "io/ioutil" blocks "github.com/ipfs/go-block-format" @@ -72,11 +74,22 @@ func (s *SectorBlockStore) Get(c cid.Cid) (blocks.Block, error) { return nil, blockstore.ErrNotFound } - best := refs[0] // TODO: better strategy (e.g. look for already unsealed) - - si, err := s.sectorBlocks.Miner.GetSectorInfo(best.SectorID) - if err != nil { - return nil, xerrors.Errorf("getting sector info: %w", err) + // TODO: better strategy (e.g. look for already unsealed) + var best api.SealedRef + var bestSi storage.SectorInfo + for _, r := range refs { + si, err := s.sectorBlocks.Miner.GetSectorInfo(r.SectorID) + if err != nil { + return nil, xerrors.Errorf("getting sector info: %w", err) + } + if si.State == api.Proving { + best = r + bestSi = si + break + } + } + if bestSi.State == api.UndefinedSectorState { + return nil, xerrors.New("no sealed sector found") } log.Infof("reading block %s from sector %d(+%d;%d)", c, best.SectorID, best.Offset, best.Size) @@ -85,8 +98,8 @@ func (s *SectorBlockStore) Get(c cid.Cid) (blocks.Block, error) { best.SectorID, best.Offset, best.Size, - si.Ticket.TicketBytes, - si.CommD, + bestSi.Ticket.TicketBytes, + bestSi.CommD, ) if err != nil { return nil, xerrors.Errorf("unsealing block: %w", err) diff --git a/storage/sectors.go b/storage/sectors.go index 251c10331..d52dc70b6 100644 --- a/storage/sectors.go +++ b/storage/sectors.go @@ -65,7 +65,7 @@ func (m *Miner) UpdateSectorState(ctx context.Context, sector uint64, snonce uin func (m *Miner) sectorStateLoop(ctx context.Context) error { trackedSectors, err := m.ListSectors() if err != nil { - return err + log.Errorf("loading sector list: %+v", err) } go func() { @@ -100,7 +100,7 @@ func (m *Miner) sectorStateLoop(ctx context.Context) error { ps, err := m.api.StateMinerProvingSet(ctx, m.maddr, curTs) if err != nil { - return err + return xerrors.Errorf("getting miner proving set: %w", err) } for _, ocs := range ps { if _, ok := trackedByID[ocs.SectorID]; ok { @@ -247,13 +247,19 @@ func (m *Miner) onSectorUpdated(ctx context.Context, update sectorUpdate) { // Handled failure modes case api.SealFailed: - log.Warn("sector %d entered unimplemented state 'SealFailed'", update.id) + log.Warnf("sector %d entered unimplemented state 'SealFailed'", update.id) case api.PreCommitFailed: - log.Warn("sector %d entered unimplemented state 'PreCommitFailed'", update.id) + log.Warnf("sector %d entered unimplemented state 'PreCommitFailed'", update.id) case api.SealCommitFailed: - log.Warn("sector %d entered unimplemented state 'SealCommitFailed'", update.id) + log.Warnf("sector %d entered unimplemented state 'SealCommitFailed'", update.id) case api.CommitFailed: - log.Warn("sector %d entered unimplemented state 'CommitFailed'", update.id) + log.Warnf("sector %d entered unimplemented state 'CommitFailed'", update.id) + + // Faults + case api.Faulty: + m.handleSectorUpdate(ctx, sector, m.handleFaulty) + case api.FaultReported: + m.handleSectorUpdate(ctx, sector, m.handleFaultReported) // Fatal errors case api.UndefinedSectorState: diff --git a/storage/sectors_test.go b/storage/sectors_test.go new file mode 100644 index 000000000..858e3876e --- /dev/null +++ b/storage/sectors_test.go @@ -0,0 +1,56 @@ +package storage + +import ( + "bytes" + "testing" + + "gotest.tools/assert" + + "github.com/filecoin-project/lotus/lib/cborutil" +) + +func TestSectorInfoSelialization(t *testing.T) { + si := &SectorInfo{ + State: 123, + SectorID: 234, + Nonce: 345, + Pieces: []Piece{{ + DealID: 1234, + Size: 5, + CommP: []byte{3}, + }}, + CommD: []byte{32, 4}, + CommR: nil, + Proof: nil, + Ticket: SealTicket{ + BlockHeight: 345, + TicketBytes: []byte{87, 78, 7, 87}, + }, + PreCommitMessage: nil, + Seed: SealSeed{}, + CommitMessage: nil, + FaultReportMsg: nil, + LastErr: "hi", + } + + b, err := cborutil.Dump(si) + if err != nil { + t.Fatal(err) + } + + var si2 SectorInfo + if err := cborutil.ReadCborRPC(bytes.NewReader(b), &si); err != nil { + return + } + + assert.Equal(t, si.State, si2.State) + assert.Equal(t, si.Nonce, si2.Nonce) + assert.Equal(t, si.SectorID, si2.SectorID) + + assert.Equal(t, si.Pieces, si2.Pieces) + assert.Equal(t, si.CommD, si2.CommD) + assert.Equal(t, si.Ticket, si2.Ticket) + + assert.Equal(t, si, si2) + +} diff --git a/tools/stats/chain.dashboard.json b/tools/stats/chain.dashboard.json index 9effbf85f..be923cc33 100644 --- a/tools/stats/chain.dashboard.json +++ b/tools/stats/chain.dashboard.json @@ -14,7 +14,7 @@ "type": "grafana", "id": "grafana", "name": "Grafana", - "version": "6.4.2" + "version": "6.5.0-pre" }, { "type": "panel", @@ -60,6 +60,457 @@ "id": null, "links": [], "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_INFLUXDB}", + "decimals": 2, + "fill": 3, + "fillGradient": 0, + "gridPos": { + "h": 16, + "w": 24, + "x": 0, + "y": 0 + }, + "hideTimeOverride": false, + "id": 38, + "interval": "", + "legend": { + "alignAsTable": true, + "avg": false, + "current": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "sort": "current", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_miner", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "miner" + ], + "type": "tag" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "chain.election", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT moving_average(count(\"value\"), 10) FROM \"chain.election\" WHERE $timeFilter -10m GROUP BY time($__interval), \"miner\" fill(null)", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "count" + }, + { + "params": [ + "20" + ], + "type": "moving_average" + } + ] + ], + "tags": [] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Blocks Won", + "tooltip": { + "shared": true, + "sort": 2, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 2, + "format": "none", + "label": "", + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "decimals": null, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "cacheTimeout": null, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_INFLUXDB}", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 4, + "w": 8, + "x": 0, + "y": 16 + }, + "id": 22, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "/.*/", + "color": "rgb(31, 120, 193)" + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "groupBy": [], + "measurement": "chain.power", + "orderByTime": "ASC", + "policy": "default", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + } + ] + ], + "tags": [] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Total Power", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 2, + "format": "bytes", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "${DS_INFLUXDB}", + "format": "s", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 4, + "w": 8, + "x": 8, + "y": 16 + }, + "id": 12, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": true, + "ymax": null, + "ymin": 0 + }, + "tableColumn": "", + "targets": [ + { + "groupBy": [], + "measurement": "chain.blocktime", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT difference(mean(\"value\")) FROM \"chain.blocktime\" WHERE $timeFilter GROUP BY time($__interval) fill(null)", + "rawQuery": false, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "difference" + } + ] + ], + "tags": [] + } + ], + "thresholds": "", + "timeFrom": null, + "timeShift": null, + "title": "Avg Blocktime", + "type": "singlestat", + "valueFontSize": "100%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "${DS_INFLUXDB}", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 4, + "w": 8, + "x": 16, + "y": 16 + }, + "id": 6, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": true, + "ymax": null, + "ymin": 0 + }, + "tableColumn": "", + "targets": [ + { + "groupBy": [], + "measurement": "chain.block_count", + "orderByTime": "ASC", + "policy": "default", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + } + ] + ], + "tags": [] + } + ], + "thresholds": "", + "timeFrom": null, + "timeShift": null, + "title": "Blocks In Tipset", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, { "cacheTimeout": null, "colorBackground": false, @@ -83,7 +534,7 @@ "h": 3, "w": 4, "x": 0, - "y": 0 + "y": 20 }, "id": 4, "interval": null, @@ -181,7 +632,7 @@ "h": 3, "w": 4, "x": 4, - "y": 0 + "y": 20 }, "id": 14, "interval": null, @@ -261,104 +712,6 @@ ], "valueName": "current" }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "#299c46", - "rgba(237, 129, 40, 0.89)", - "#d44a3a" - ], - "datasource": "${DS_INFLUXDB}", - "format": "decbytes", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "gridPos": { - "h": 3, - "w": 4, - "x": 8, - "y": 0 - }, - "id": 22, - "interval": null, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "options": {}, - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": true, - "ymax": null, - "ymin": 0 - }, - "tableColumn": "", - "targets": [ - { - "groupBy": [], - "measurement": "chain.power", - "orderByTime": "ASC", - "policy": "default", - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "value" - ], - "type": "field" - } - ] - ], - "tags": [] - } - ], - "thresholds": "", - "timeFrom": null, - "timeShift": null, - "title": "Total Power", - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "current" - }, { "cacheTimeout": null, "colorBackground": false, @@ -380,8 +733,8 @@ "gridPos": { "h": 3, "w": 4, - "x": 12, - "y": 0 + "x": 8, + "y": 20 }, "id": 32, "interval": null, @@ -495,8 +848,8 @@ "gridPos": { "h": 3, "w": 4, - "x": 16, - "y": 0 + "x": 12, + "y": 20 }, "id": 20, "interval": null, @@ -610,8 +963,8 @@ "gridPos": { "h": 3, "w": 4, - "x": 20, - "y": 0 + "x": 16, + "y": 20 }, "id": 8, "interval": null, @@ -704,6 +1057,124 @@ ], "valueName": "avg" }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "${DS_INFLUXDB}", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 20, + "y": 20 + }, + "id": 10, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "pluginVersion": "6.4.2", + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": true, + "ymax": null, + "ymin": 0 + }, + "tableColumn": "", + "targets": [ + { + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "0" + ], + "type": "fill" + } + ], + "measurement": "chain.message_count", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT sum(\"value\") FROM (SELECT \"value\" FROM \"chain.message_count\" GROUP BY \"height\") WHERE $timeFilter GROUP BY time($__interval) fill(0)", + "rawQuery": true, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + } + ], + "thresholds": "", + "timeFrom": null, + "timeShift": null, + "title": "Avg Messages in Tipset", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, { "cacheTimeout": null, "colorBackground": false, @@ -727,7 +1198,7 @@ "h": 3, "w": 4, "x": 0, - "y": 3 + "y": 23 }, "id": 16, "interval": "", @@ -810,73 +1281,71 @@ "valueName": "current" }, { + "aliasColors": {}, + "bars": false, "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "#299c46", - "rgba(237, 129, 40, 0.89)", - "#d44a3a" - ], + "dashLength": 10, + "dashes": false, "datasource": "${DS_INFLUXDB}", - "format": "none", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, + "fill": 1, + "fillGradient": 0, "gridPos": { "h": 3, - "w": 4, + "w": 16, "x": 4, - "y": 3 + "y": 23 }, - "id": 6, - "interval": null, + "id": 2, + "legend": { + "alignAsTable": true, + "avg": true, + "current": false, + "hideEmpty": false, + "hideZero": false, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, "links": [], - "mappingType": 1, - "mappingTypes": [ + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [ { - "name": "value to text", - "value": 1 + "alias": "chain.height.difference", + "yaxis": 2 }, { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "options": {}, - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ + "alias": "Null Blocks", + "yaxis": 2 + }, { - "from": "null", - "text": "N/A", - "to": "null" + "alias": "Block Time", + "color": "rgb(31, 120, 193)" } ], - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": true, - "ymax": null, - "ymin": 0 - }, - "tableColumn": "", + "spaceLength": 10, + "stack": false, + "steppedLine": false, "targets": [ { + "alias": "Block Time", "groupBy": [], - "measurement": "chain.block_count", + "measurement": "chain.blocktime", "orderByTime": "ASC", "policy": "default", + "query": "SELECT difference(\"value\") FROM \"chain.blocktime\" WHERE $timeFilter", + "rawQuery": true, "refId": "A", "resultFormat": "time_series", "select": [ @@ -886,26 +1355,87 @@ "value" ], "type": "field" + }, + { + "params": [], + "type": "difference" + } + ] + ], + "tags": [] + }, + { + "alias": "Null Blocks", + "groupBy": [], + "measurement": "chain.height", + "orderByTime": "ASC", + "policy": "default", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "difference" + }, + { + "params": [ + "-1" + ], + "type": "math" } ] ], "tags": [] } ], - "thresholds": "", + "thresholds": [], "timeFrom": null, + "timeRegions": [], "timeShift": null, - "title": "Blocks In Tipset", - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ + "title": "", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ { - "op": "=", - "text": "N/A", - "value": "null" + "format": "s", + "label": "Time delta", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "decimals": 0, + "format": "short", + "label": "# null blocks", + "logBase": 1, + "max": null, + "min": "0", + "show": true } ], - "valueName": "current" + "yaxis": { + "align": false, + "alignLevel": null + } }, { "cacheTimeout": null, @@ -928,8 +1458,8 @@ "gridPos": { "h": 3, "w": 4, - "x": 8, - "y": 3 + "x": 20, + "y": 23 }, "id": 30, "interval": null, @@ -1005,381 +1535,6 @@ ], "valueName": "current" }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "#299c46", - "rgba(237, 129, 40, 0.89)", - "#d44a3a" - ], - "datasource": "${DS_INFLUXDB}", - "format": "s", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "gridPos": { - "h": 3, - "w": 4, - "x": 16, - "y": 3 - }, - "id": 12, - "interval": null, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "options": {}, - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": true, - "ymax": null, - "ymin": 0 - }, - "tableColumn": "", - "targets": [ - { - "groupBy": [], - "measurement": "chain.blocktime", - "orderByTime": "ASC", - "policy": "default", - "query": "SELECT difference(mean(\"value\")) FROM \"chain.blocktime\" WHERE $timeFilter GROUP BY time($__interval) fill(null)", - "rawQuery": false, - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "value" - ], - "type": "field" - }, - { - "params": [], - "type": "difference" - } - ] - ], - "tags": [] - } - ], - "thresholds": "", - "timeFrom": null, - "timeShift": null, - "title": "Avg Blocktime", - "type": "singlestat", - "valueFontSize": "100%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "avg" - }, - { - "cacheTimeout": null, - "colorBackground": false, - "colorValue": false, - "colors": [ - "#299c46", - "rgba(237, 129, 40, 0.89)", - "#d44a3a" - ], - "datasource": "${DS_INFLUXDB}", - "format": "none", - "gauge": { - "maxValue": 100, - "minValue": 0, - "show": false, - "thresholdLabels": false, - "thresholdMarkers": true - }, - "gridPos": { - "h": 3, - "w": 4, - "x": 20, - "y": 3 - }, - "id": 10, - "interval": null, - "links": [], - "mappingType": 1, - "mappingTypes": [ - { - "name": "value to text", - "value": 1 - }, - { - "name": "range to text", - "value": 2 - } - ], - "maxDataPoints": 100, - "nullPointMode": "connected", - "nullText": null, - "options": {}, - "pluginVersion": "6.4.2", - "postfix": "", - "postfixFontSize": "50%", - "prefix": "", - "prefixFontSize": "50%", - "rangeMaps": [ - { - "from": "null", - "text": "N/A", - "to": "null" - } - ], - "sparkline": { - "fillColor": "rgba(31, 118, 189, 0.18)", - "full": false, - "lineColor": "rgb(31, 120, 193)", - "show": true, - "ymax": null, - "ymin": 0 - }, - "tableColumn": "", - "targets": [ - { - "groupBy": [ - { - "params": [ - "$__interval" - ], - "type": "time" - }, - { - "params": [ - "0" - ], - "type": "fill" - } - ], - "measurement": "chain.message_count", - "orderByTime": "ASC", - "policy": "default", - "query": "SELECT mean(\"value\") FROM (SELECT \"value\" FROM \"chain.message_count\" GROUP BY \"height\") WHERE $timeFilter GROUP BY time($__interval) fill(0)", - "rawQuery": true, - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "value" - ], - "type": "field" - }, - { - "params": [], - "type": "mean" - } - ] - ], - "tags": [] - } - ], - "thresholds": "", - "timeFrom": null, - "timeShift": null, - "title": "Avg Messages in Tipset", - "type": "singlestat", - "valueFontSize": "80%", - "valueMaps": [ - { - "op": "=", - "text": "N/A", - "value": "null" - } - ], - "valueName": "avg" - }, - { - "aliasColors": {}, - "bars": false, - "cacheTimeout": null, - "dashLength": 10, - "dashes": false, - "datasource": "${DS_INFLUXDB}", - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 4, - "w": 24, - "x": 0, - "y": 6 - }, - "id": 2, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "hideEmpty": false, - "hideZero": false, - "max": true, - "min": false, - "rightSide": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "options": { - "dataLinks": [] - }, - "percentage": false, - "pointradius": 2, - "points": false, - "renderer": "flot", - "seriesOverrides": [ - { - "alias": "chain.height.difference", - "yaxis": 2 - }, - { - "alias": "Null Blocks", - "yaxis": 2 - } - ], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "alias": "Block Time", - "groupBy": [], - "measurement": "chain.blocktime", - "orderByTime": "ASC", - "policy": "default", - "query": "SELECT difference(\"value\") FROM \"chain.blocktime\" WHERE $timeFilter", - "rawQuery": true, - "refId": "A", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "value" - ], - "type": "field" - }, - { - "params": [], - "type": "difference" - } - ] - ], - "tags": [] - }, - { - "alias": "Null Blocks", - "groupBy": [], - "measurement": "chain.height", - "orderByTime": "ASC", - "policy": "default", - "refId": "B", - "resultFormat": "time_series", - "select": [ - [ - { - "params": [ - "value" - ], - "type": "field" - }, - { - "params": [], - "type": "difference" - }, - { - "params": [ - "-1" - ], - "type": "math" - } - ] - ], - "tags": [] - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Tipsets", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "s", - "label": "Time between tipsets", - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "decimals": 0, - "format": "short", - "label": "Number of Null blocks", - "logBase": 1, - "max": null, - "min": "0", - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, { "columns": [], "datasource": "${DS_INFLUXDB}", @@ -1388,7 +1543,7 @@ "h": 16, "w": 4, "x": 0, - "y": 10 + "y": 26 }, "id": 28, "options": {}, @@ -1472,15 +1627,15 @@ "dashLength": 10, "dashes": false, "datasource": "${DS_INFLUXDB}", - "fill": 5, + "fill": 4, "fillGradient": 0, "gridPos": { "h": 8, "w": 12, "x": 4, - "y": 10 + "y": 26 }, - "id": 26, + "id": 40, "interval": "", "legend": { "alignAsTable": true, @@ -1613,7 +1768,7 @@ "h": 16, "w": 8, "x": 16, - "y": 10 + "y": 26 }, "id": 18, "options": {}, @@ -1710,7 +1865,7 @@ "h": 8, "w": 12, "x": 4, - "y": 18 + "y": 34 }, "id": 24, "legend": { @@ -1735,7 +1890,12 @@ "pointradius": 2, "points": false, "renderer": "flot", - "seriesOverrides": [], + "seriesOverrides": [ + { + "alias": "/.*/", + "color": "rgb(31, 120, 193)" + } + ], "spaceLength": 10, "stack": false, "steppedLine": false, @@ -1830,7 +1990,7 @@ "h": 9, "w": 12, "x": 0, - "y": 26 + "y": 42 }, "id": 34, "legend": { @@ -1856,7 +2016,7 @@ "renderer": "flot", "seriesOverrides": [], "spaceLength": 10, - "stack": false, + "stack": true, "steppedLine": false, "targets": [ { @@ -1890,6 +2050,8 @@ "measurement": "chain.message_count", "orderByTime": "ASC", "policy": "default", + "query": "SELECT moving_average(count(\"value\"), 2) FROM \"chain.message_count\" WHERE $timeFilter -4m GROUP BY time($__interval), \"actor\", \"method\" fill(null)", + "rawQuery": true, "refId": "A", "resultFormat": "time_series", "select": [ @@ -1956,25 +2118,29 @@ "dashLength": 10, "dashes": false, "datasource": "${DS_INFLUXDB}", + "decimals": 2, "fill": 1, "fillGradient": 0, "gridPos": { "h": 9, "w": 12, "x": 12, - "y": 26 + "y": 42 }, "id": 36, + "interval": "", "legend": { "alignAsTable": true, - "avg": false, + "avg": true, "current": false, - "max": false, + "max": true, "min": false, "rightSide": true, "show": true, + "sort": "avg", + "sortDesc": true, "total": false, - "values": false + "values": true }, "lines": true, "linewidth": 1, @@ -1988,7 +2154,7 @@ "renderer": "flot", "seriesOverrides": [], "spaceLength": 10, - "stack": false, + "stack": true, "steppedLine": false, "targets": [ { @@ -2000,6 +2166,12 @@ ], "type": "time" }, + { + "params": [ + "exitcode" + ], + "type": "tag" + }, { "params": [ "actor" @@ -2012,12 +2184,6 @@ ], "type": "tag" }, - { - "params": [ - "exitcode" - ], - "type": "tag" - }, { "params": [ "null" @@ -2028,6 +2194,8 @@ "measurement": "chain.message_count", "orderByTime": "ASC", "policy": "default", + "query": "SELECT moving_average(count(\"value\"), 10) FROM \"chain.message_count\" WHERE $timeFilter -10m GROUP BY time($__interval), \"exitcode\", \"actor\", \"method\" fill(null)", + "rawQuery": true, "refId": "A", "resultFormat": "time_series", "select": [ @@ -2041,6 +2209,12 @@ { "params": [], "type": "count" + }, + { + "params": [ + 10 + ], + "type": "moving_average" } ] ], @@ -2067,6 +2241,7 @@ }, "yaxes": [ { + "decimals": null, "format": "short", "label": "", "logBase": 1, @@ -2089,7 +2264,7 @@ } } ], - "refresh": "5s", + "refresh": "30s", "schemaVersion": 20, "style": "dark", "tags": [], @@ -2117,5 +2292,5 @@ "timezone": "", "title": "Chain", "uid": "z6FtI92Zz", - "version": 12 + "version": 8 } \ No newline at end of file diff --git a/tools/stats/metrics.go b/tools/stats/metrics.go index 8d63f1c6d..652002ca1 100644 --- a/tools/stats/metrics.go +++ b/tools/stats/metrics.go @@ -14,6 +14,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/address" "github.com/filecoin-project/lotus/chain/types" + "github.com/multiformats/go-multihash" _ "github.com/influxdata/influxdb1-client" models "github.com/influxdata/influxdb1-client/models" @@ -124,8 +125,11 @@ func RecordTipsetPoints(ctx context.Context, api api.FullNode, pl *PointList, ti if err != nil { return err } + p := NewPoint("chain.election", 1) + p.AddTag("miner", blockheader.Miner.String()) + pl.AddPoint(p) - p := NewPoint("chain.blockheader_size", len(bs)) + p = NewPoint("chain.blockheader_size", len(bs)) pl.AddPoint(p) } @@ -212,7 +216,13 @@ func RecordTipsetMessagesPoints(ctx context.Context, api api.FullNode, pl *Point } p = NewPoint("chain.message_count", 1) - p.AddTag("actor", actor.Code.String()) + + dm, err := multihash.Decode(actor.Code.Hash()) + if err != nil { + continue + } + + p.AddTag("actor", string(dm.Digest)) p.AddTag("method", fmt.Sprintf("%d", msg.Message.Method)) p.AddTag("exitcode", fmt.Sprintf("%d", recp[i].ExitCode)) pl.AddPoint(p)