From 89b19af43fb483e753e4b76d3091b1ca032850c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 29 Apr 2020 20:06:05 +0200 Subject: [PATCH] specs-actors v0.3 --- chain/gen/genesis/miners.go | 14 ++++++++++---- chain/vm/runtime_test.go | 2 +- cmd/lotus-fountain/main.go | 23 ++++++++++++++++------- cmd/lotus-shed/bitfield.go | 2 +- cmd/lotus-storage-miner/init.go | 13 +++++++++---- go.mod | 4 ++-- go.sum | 8 ++++---- storage/wdpost_run.go | 4 ++-- storage/wdpost_sched.go | 23 +++++++++++++---------- 9 files changed, 58 insertions(+), 35 deletions(-) diff --git a/chain/gen/genesis/miners.go b/chain/gen/genesis/miners.go index 7120effaa..07a2d0fbf 100644 --- a/chain/gen/genesis/miners.go +++ b/chain/gen/genesis/miners.go @@ -12,6 +12,7 @@ import ( "golang.org/x/xerrors" "github.com/filecoin-project/go-address" + "github.com/filecoin-project/sector-storage/ffiwrapper" "github.com/filecoin-project/specs-actors/actors/abi" "github.com/filecoin-project/specs-actors/actors/abi/big" "github.com/filecoin-project/specs-actors/actors/builtin" @@ -49,13 +50,18 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid for i, m := range miners { // Create miner through power actor + spt, err := ffiwrapper.SealProofTypeFromSectorSize(m.SectorSize) + if err != nil { + return cid.Undef, err + } + var maddr address.Address { constructorParams := &power.CreateMinerParams{ - Owner: m.Worker, - Worker: m.Worker, - SectorSize: m.SectorSize, - Peer: m.PeerId, + Owner: m.Worker, + Worker: m.Worker, + Peer: m.PeerId, + SealProofType: spt, } params := mustEnc(constructorParams) diff --git a/chain/vm/runtime_test.go b/chain/vm/runtime_test.go index d6b2429e5..b5c75c177 100644 --- a/chain/vm/runtime_test.go +++ b/chain/vm/runtime_test.go @@ -13,7 +13,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors/aerrors" ) -type NotAVeryGoodMarshaler struct {} +type NotAVeryGoodMarshaler struct{} func (*NotAVeryGoodMarshaler) MarshalCBOR(writer io.Writer) error { return xerrors.Errorf("no") diff --git a/cmd/lotus-fountain/main.go b/cmd/lotus-fountain/main.go index 2d9979c49..b2275b9ca 100644 --- a/cmd/lotus-fountain/main.go +++ b/cmd/lotus-fountain/main.go @@ -11,15 +11,17 @@ import ( "time" rice "github.com/GeertJohan/go.rice" - "github.com/filecoin-project/specs-actors/actors/abi" - "github.com/filecoin-project/specs-actors/actors/builtin" - "github.com/filecoin-project/specs-actors/actors/builtin/power" "github.com/ipfs/go-cid" logging "github.com/ipfs/go-log/v2" "github.com/libp2p/go-libp2p-core/peer" "golang.org/x/xerrors" "gopkg.in/urfave/cli.v2" + "github.com/filecoin-project/sector-storage/ffiwrapper" + "github.com/filecoin-project/specs-actors/actors/abi" + "github.com/filecoin-project/specs-actors/actors/builtin" + "github.com/filecoin-project/specs-actors/actors/builtin/power" + "github.com/filecoin-project/go-address" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" @@ -281,11 +283,18 @@ func (h *handler) mkminer(w http.ResponseWriter, r *http.Request) { } log.Infof("%s: push funds %s", owner, smsg.Cid()) + spt, err := ffiwrapper.SealProofTypeFromSectorSize(abi.SectorSize(ssize)) + if err != nil { + w.WriteHeader(400) + w.Write([]byte("sealprooftype: " + err.Error())) + return + } + params, err := actors.SerializeParams(&power.CreateMinerParams{ - Owner: owner, - Worker: owner, - SectorSize: abi.SectorSize(ssize), - Peer: h.defaultMinerPeer, + Owner: owner, + Worker: owner, + SealProofType: spt, + Peer: h.defaultMinerPeer, }) if err != nil { w.WriteHeader(400) diff --git a/cmd/lotus-shed/bitfield.go b/cmd/lotus-shed/bitfield.go index 44d79fcd6..e1b6d03a6 100644 --- a/cmd/lotus-shed/bitfield.go +++ b/cmd/lotus-shed/bitfield.go @@ -151,7 +151,7 @@ var bitFieldStatCmd = &cli.Command{ return xerrors.Errorf("getting run iterator: %w", err) } - fmt.Printf("Raw length: %d bits (%d bytes)\n", len(dec) * 8, len(dec)) + fmt.Printf("Raw length: %d bits (%d bytes)\n", len(dec)*8, len(dec)) var ones, zeros, oneRuns, zeroRuns, invalid uint64 diff --git a/cmd/lotus-storage-miner/init.go b/cmd/lotus-storage-miner/init.go index f7bdb4edd..6a6d83e2f 100644 --- a/cmd/lotus-storage-miner/init.go +++ b/cmd/lotus-storage-miner/init.go @@ -621,11 +621,16 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID, return address.Undef, err } + spt, err := ffiwrapper.SealProofTypeFromSectorSize(abi.SectorSize(ssize)) + if err != nil { + return address.Undef, err + } + params, err := actors.SerializeParams(&power.CreateMinerParams{ - Owner: owner, - Worker: worker, - SectorSize: abi.SectorSize(ssize), - Peer: peerid, + Owner: owner, + Worker: worker, + SealProofType: spt, + Peer: peerid, }) if err != nil { return address.Undef, err diff --git a/go.mod b/go.mod index 557b9879d..1575ec2a8 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/davidlazar/go-crypto v0.0.0-20190912175916-7055855a373f // indirect github.com/docker/go-units v0.4.0 github.com/drand/drand v0.7.2 - github.com/filecoin-project/chain-validation v0.0.6-0.20200429002049-f137de961672 + github.com/filecoin-project/chain-validation v0.0.6-0.20200429044622-fe33361958f5 github.com/filecoin-project/filecoin-ffi v0.0.0-20200427223233-a0014b17f124 github.com/filecoin-project/go-address v0.0.2-0.20200218010043-eb9bb40ed5be github.com/filecoin-project/go-amt-ipld/v2 v2.0.1-0.20200131012142-05d80eeccc5e @@ -27,7 +27,7 @@ require ( github.com/filecoin-project/go-statestore v0.1.0 github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b github.com/filecoin-project/sector-storage v0.0.0-20200425102315-c19a25449861 - github.com/filecoin-project/specs-actors v0.2.1-0.20200428232403-f0282340f59a + github.com/filecoin-project/specs-actors v0.3.0 github.com/filecoin-project/specs-storage v0.0.0-20200417134612-61b2d91a6102 github.com/filecoin-project/storage-fsm v0.0.0-20200427182014-01487d5ad3c8 github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1 diff --git a/go.sum b/go.sum index 793ccc7a9..e5e74a459 100644 --- a/go.sum +++ b/go.sum @@ -127,8 +127,8 @@ github.com/fatih/color v1.8.0/go.mod h1:3l45GVGkyrnYNl9HoIjnp2NnNWvh6hLAqD8yTfGj github.com/fd/go-nat v1.0.0/go.mod h1:BTBu/CKvMmOMUPkKVef1pngt2WFH/lg7E6yQnulfp6E= github.com/filecoin-project/chain-validation v0.0.3 h1:luT/8kJ0WdMIqQ9Bm31W4JkuYCW0wUb26AvnD4WK59M= github.com/filecoin-project/chain-validation v0.0.3/go.mod h1:NCEGFjcWRjb8akWFSOXvU6n2efkWIqAeOKU6o5WBGQw= -github.com/filecoin-project/chain-validation v0.0.6-0.20200429002049-f137de961672 h1:RmZN2ZpsvXIAzxqVNoJwl+s+c2LSrGnu/ftfcq6babo= -github.com/filecoin-project/chain-validation v0.0.6-0.20200429002049-f137de961672/go.mod h1:YELmfkVO2elLyNa5RgKSo+qPywQu9V811L4Dyod4D2g= +github.com/filecoin-project/chain-validation v0.0.6-0.20200429044622-fe33361958f5 h1:riq69riV59q8AaMGlCOwYr96L30/BRSzz6aNBa1u8aY= +github.com/filecoin-project/chain-validation v0.0.6-0.20200429044622-fe33361958f5/go.mod h1:Lk9OjM6bsvk1KlTwkQN+RGOusGPqmaxcllvaz119xtc= github.com/filecoin-project/go-address v0.0.0-20191219011437-af739c490b4f/go.mod h1:rCbpXPva2NKF9/J4X6sr7hbKBgQCxyFtRj7KOZqoIms= github.com/filecoin-project/go-address v0.0.0-20200107215422-da8eea2842b5/go.mod h1:SAOwJoakQ8EPjwNIsiakIQKsoKdkcbx8U3IapgCg9R0= github.com/filecoin-project/go-address v0.0.2-0.20200218010043-eb9bb40ed5be h1:TooKBwR/g8jG0hZ3lqe9S5sy2vTUcLOZLlz3M5wGn2E= @@ -175,8 +175,8 @@ github.com/filecoin-project/specs-actors v0.0.0-20200210130641-2d1fbd8672cf/go.m github.com/filecoin-project/specs-actors v0.0.0-20200409043918-e569f4a2f504/go.mod h1:mdJraXq5vMy0+/FqVQIrnNlpQ/Em6zeu06G/ltQ0/lA= github.com/filecoin-project/specs-actors v0.2.0 h1:bKxloHLegeYJttIJbQjl4/tdsKOUtYtpiZsEfB4eOnI= github.com/filecoin-project/specs-actors v0.2.0/go.mod h1:nQYnFbQ7Y0bHZyq6HDEuVlCPR+U3z5Q3wMOQ+2aiV+Y= -github.com/filecoin-project/specs-actors v0.2.1-0.20200428232403-f0282340f59a h1:ElQ8+0qeXtBXwxDkSLH1pen+qxXkSySbIsg5ysQ7coc= -github.com/filecoin-project/specs-actors v0.2.1-0.20200428232403-f0282340f59a/go.mod h1:nQYnFbQ7Y0bHZyq6HDEuVlCPR+U3z5Q3wMOQ+2aiV+Y= +github.com/filecoin-project/specs-actors v0.3.0 h1:QxgAuTrZr5TPqjyprZk0nTYW5o0JWpzbb5v+4UHHvN0= +github.com/filecoin-project/specs-actors v0.3.0/go.mod h1:nQYnFbQ7Y0bHZyq6HDEuVlCPR+U3z5Q3wMOQ+2aiV+Y= github.com/filecoin-project/specs-storage v0.0.0-20200410185809-9fbaaa08f275/go.mod h1:xJ1/xl9+8zZeSSSFmDC3Wr6uusCTxyYPI0VeNVSFmPE= github.com/filecoin-project/specs-storage v0.0.0-20200417134612-61b2d91a6102 h1:T3f/zkuvgtgqcXrb0NO3BicuveGOxxUAMPa/Yif2kuE= github.com/filecoin-project/specs-storage v0.0.0-20200417134612-61b2d91a6102/go.mod h1:xJ1/xl9+8zZeSSSFmDC3Wr6uusCTxyYPI0VeNVSFmPE= diff --git a/storage/wdpost_run.go b/storage/wdpost_run.go index 1aa9977d6..f75e91cab 100644 --- a/storage/wdpost_run.go +++ b/storage/wdpost_run.go @@ -97,12 +97,12 @@ func (s *WindowPoStScheduler) runPost(ctx context.Context, di miner.DeadlineInfo return nil, err } - firstPartition, _, err := miner.PartitionsForDeadline(deadlines, di.Index) + firstPartition, _, err := miner.PartitionsForDeadline(deadlines, s.partitionSectors, di.Index) if err != nil { return nil, xerrors.Errorf("getting partitions for deadline: %w", err) } - partitionCount, _, err := miner.DeadlineCount(deadlines, di.Index) + partitionCount, _, err := miner.DeadlineCount(deadlines, s.partitionSectors, di.Index) if err != nil { return nil, xerrors.Errorf("getting deadline partition count: %w", err) } diff --git a/storage/wdpost_sched.go b/storage/wdpost_sched.go index d67b22bf0..75fe673c8 100644 --- a/storage/wdpost_sched.go +++ b/storage/wdpost_sched.go @@ -8,7 +8,6 @@ import ( "golang.org/x/xerrors" "github.com/filecoin-project/go-address" - "github.com/filecoin-project/sector-storage/ffiwrapper" "github.com/filecoin-project/specs-actors/actors/abi" "github.com/filecoin-project/specs-actors/actors/builtin/miner" "github.com/filecoin-project/specs-storage/storage" @@ -21,9 +20,10 @@ import ( const StartConfidence = 4 // TODO: config type WindowPoStScheduler struct { - api storageMinerApi - prover storage.Prover - proofType abi.RegisteredProof + api storageMinerApi + prover storage.Prover + proofType abi.RegisteredProof + partitionSectors uint64 actor address.Address worker address.Address @@ -44,17 +44,20 @@ func NewWindowedPoStScheduler(api storageMinerApi, sb storage.Prover, actor addr return nil, xerrors.Errorf("getting sector size: %w", err) } - spt, err := ffiwrapper.SealProofTypeFromSectorSize(mi.SectorSize) + rt, err := mi.SealProofType.RegisteredWindowPoStProof() if err != nil { return nil, err } - rt, err := spt.RegisteredWindowPoStProof() - if err != nil { - return nil, err - } + return &WindowPoStScheduler{ + api: api, + prover: sb, + proofType: rt, + partitionSectors: mi.WindowPoStPartitionSectors, - return &WindowPoStScheduler{api: api, prover: sb, actor: actor, worker: worker, proofType: rt}, nil + actor: actor, + worker: worker, + }, nil } func deadlineEquals(a, b *miner.DeadlineInfo) bool {