From 3623925f6655a0aab5a2571097127b5ed4f8d36c Mon Sep 17 00:00:00 2001 From: laser Date: Tue, 26 Nov 2019 17:46:17 -0800 Subject: [PATCH] replace go-bls-sigs and go-sectorbuilder with filecoin-ffi - remove old submodules and add new submodule - update build tooling to consume new unified static library - update consumers of old libs to use new package --- .gitmodules | 10 +++----- Makefile | 39 +++++++++--------------------- chain/actors/actor_miner.go | 5 ++-- chain/address/address.go | 2 +- chain/address/address_test.go | 2 +- chain/gen/gen.go | 7 +++--- chain/gen/mining.go | 2 +- chain/stmgr/stmgr.go | 2 +- chain/stmgr/utils.go | 5 ++-- chain/sync.go | 2 +- chain/types/signature_cgo.go | 2 +- chain/wallet/wallet.go | 2 +- extern/filecoin-ffi | 1 + extern/go-bls-sigs | 1 - extern/go-sectorbuilder | 1 - go.mod | 10 +++----- go.sum | 12 ++++++--- lib/padreader/padreader.go | 2 +- lib/sectorbuilder/sectorbuilder.go | 35 +++++++++++---------------- storage/post.go | 5 ++-- 20 files changed, 62 insertions(+), 85 deletions(-) create mode 160000 extern/filecoin-ffi delete mode 160000 extern/go-bls-sigs delete mode 160000 extern/go-sectorbuilder diff --git a/.gitmodules b/.gitmodules index d8e0ccfa6..c50b68575 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,4 @@ -[submodule "extern/go-bls-sigs"] - path = extern/go-bls-sigs - url = https://github.com/filecoin-project/go-bls-sigs.git -[submodule "extern/go-sectorbuilder"] - path = extern/go-sectorbuilder - url = https://github.com/filecoin-project/go-sectorbuilder +[submodule "extern/filecoin-ffi"] + path = extern/filecoin-ffi + url = git@github.com:filecoin-project/filecoin-ffi + branch = master diff --git a/Makefile b/Makefile index 9574fc5f3..af80fb0e6 100644 --- a/Makefile +++ b/Makefile @@ -12,37 +12,21 @@ MODULES:= CLEAN:= -## BLS +## FFI -BLS_PATH:=extern/go-bls-sigs/ -BLS_DEPS:=libbls_signatures.a libbls_signatures.pc libbls_signatures.h -BLS_DEPS:=$(addprefix $(BLS_PATH),$(BLS_DEPS)) +FFI_PATH:=extern/filecoin-ffi/ +FFI_DEPS:=libfilecoin.a filecoin.pc filecoin.h +FFI_DEPS:=$(addprefix $(FFI_PATH),$(FFI_DEPS)) -$(BLS_DEPS): build/.bls-install ; +$(FFI_DEPS): build/.filecoin-install ; -build/.bls-install: $(BLS_PATH) - $(MAKE) -C $(BLS_PATH) $(BLS_DEPS:$(BLS_PATH)%=%) +build/.filecoin-install: $(FFI_PATH) + $(MAKE) -C $(FFI_PATH) $(FFI_DEPS:$(FFI_PATH)%=%) @touch $@ -MODULES+=$(BLS_PATH) -BUILD_DEPS+=build/.bls-install -CLEAN+=build/.bls-install - -## SECTOR BUILDER - -SECTOR_BUILDER_PATH:=extern/go-sectorbuilder/ -SECTOR_BUILDER_DEPS:=libsector_builder_ffi.a sector_builder_ffi.pc sector_builder_ffi.h -SECTOR_BUILDER_DEPS:=$(addprefix $(SECTOR_BUILDER_PATH),$(SECTOR_BUILDER_DEPS)) - -$(SECTOR_BUILDER_DEPS): build/.sector-builder-install ; - -build/.sector-builder-install: $(SECTOR_BUILDER_PATH) - $(MAKE) -C $(SECTOR_BUILDER_PATH) $(SECTOR_BUILDER_DEPS:$(SECTOR_BUILDER_PATH)%=%) - @touch $@ - -MODULES+=$(SECTOR_BUILDER_PATH) -BUILD_DEPS+=build/.sector-builder-install -CLEAN+=build/.sector-builder-install +MODULES+=$(FFI_PATH) +BUILD_DEPS+=build/.filecoin-install +CLEAN+=build/.filecoin-install $(MODULES): build/.update-modules ; @@ -123,8 +107,7 @@ stats: clean: rm -rf $(CLEAN) - -$(MAKE) -C $(BLS_PATH) clean - -$(MAKE) -C $(SECTOR_BUILDER_PATH) clean + -$(MAKE) -C $(FFI_PATH) clean .PHONY: clean dist-clean: diff --git a/chain/actors/actor_miner.go b/chain/actors/actor_miner.go index efbec6a82..6661f7bc0 100644 --- a/chain/actors/actor_miner.go +++ b/chain/actors/actor_miner.go @@ -5,6 +5,7 @@ import ( "context" "encoding/binary" "fmt" + ffi "github.com/filecoin-project/filecoin-ffi" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors/aerrors" @@ -455,13 +456,13 @@ func (sma StorageMinerActor) SubmitFallbackPoSt(act *types.Actor, vmctx types.VM return nil, aerrors.HandleExternalError(lerr, "could not load proving set node") } - var sectorInfos []sectorbuilder.PublicSectorInfo + var sectorInfos []ffi.PublicSectorInfo if err := pss.ForEach(func(id uint64, v *cbg.Deferred) error { var comms [][]byte if err := cbor.DecodeInto(v.Raw, &comms); err != nil { return xerrors.New("could not decode comms") } - si := sectorbuilder.PublicSectorInfo{ + si := ffi.PublicSectorInfo{ SectorID: id, } commR := comms[0] diff --git a/chain/address/address.go b/chain/address/address.go index 4264371d3..c2c6c5943 100644 --- a/chain/address/address.go +++ b/chain/address/address.go @@ -7,7 +7,7 @@ import ( "io" "strconv" - "github.com/filecoin-project/go-bls-sigs" + bls "github.com/filecoin-project/filecoin-ffi" "github.com/filecoin-project/go-leb128" cbor "github.com/ipfs/go-ipld-cbor" "github.com/minio/blake2b-simd" diff --git a/chain/address/address_test.go b/chain/address/address_test.go index 1c666ee7c..33e69312f 100644 --- a/chain/address/address_test.go +++ b/chain/address/address_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/filecoin-project/go-bls-sigs" + "github.com/filecoin-project/filecoin-ffi" "github.com/filecoin-project/go-leb128" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/chain/gen/gen.go b/chain/gen/gen.go index e8c662040..5121bdc7b 100644 --- a/chain/gen/gen.go +++ b/chain/gen/gen.go @@ -6,6 +6,7 @@ import ( "crypto/sha256" "encoding/binary" "fmt" + ffi "github.com/filecoin-project/filecoin-ffi" "sync/atomic" "github.com/ipfs/go-blockservice" @@ -414,7 +415,7 @@ type ElectionPoStProver interface { } type eppProvider struct { - sectors []sectorbuilder.PublicSectorInfo + sectors []ffi.PublicSectorInfo } func (epp *eppProvider) GenerateCandidates(ctx context.Context, _ sectorbuilder.SortedPublicSectorInfo, eprand []byte) ([]sectorbuilder.EPostCandidate, error) { @@ -455,11 +456,11 @@ func IsRoundWinner(ctx context.Context, ts *types.TipSet, round int64, miner add } log.Warningf("Proving set for miner %s: %s", miner, pset) - var sinfos []sectorbuilder.PublicSectorInfo + var sinfos []ffi.PublicSectorInfo for _, s := range pset { var commRa [32]byte copy(commRa[:], s.CommR) - sinfos = append(sinfos, sectorbuilder.PublicSectorInfo{ + sinfos = append(sinfos, ffi.PublicSectorInfo{ SectorID: s.SectorID, CommR: commRa, }) diff --git a/chain/gen/mining.go b/chain/gen/mining.go index 5789de2a2..a2548c5ab 100644 --- a/chain/gen/mining.go +++ b/chain/gen/mining.go @@ -4,7 +4,7 @@ import ( "context" amt "github.com/filecoin-project/go-amt-ipld" - bls "github.com/filecoin-project/go-bls-sigs" + bls "github.com/filecoin-project/filecoin-ffi" cid "github.com/ipfs/go-cid" hamt "github.com/ipfs/go-hamt-ipld" cbg "github.com/whyrusleeping/cbor-gen" diff --git a/chain/stmgr/stmgr.go b/chain/stmgr/stmgr.go index ad23f55f5..a1a656d7f 100644 --- a/chain/stmgr/stmgr.go +++ b/chain/stmgr/stmgr.go @@ -15,7 +15,7 @@ import ( cbg "github.com/whyrusleeping/cbor-gen" "golang.org/x/xerrors" - bls "github.com/filecoin-project/go-bls-sigs" + bls "github.com/filecoin-project/filecoin-ffi" "github.com/ipfs/go-cid" hamt "github.com/ipfs/go-hamt-ipld" logging "github.com/ipfs/go-log" diff --git a/chain/stmgr/utils.go b/chain/stmgr/utils.go index 39017cb2d..1a1a46ad0 100644 --- a/chain/stmgr/utils.go +++ b/chain/stmgr/utils.go @@ -2,6 +2,7 @@ package stmgr import ( "context" + ffi "github.com/filecoin-project/filecoin-ffi" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/actors" @@ -185,11 +186,11 @@ func GetSectorsForElectionPost(ctx context.Context, sm *StateManager, ts *types. return nil, xerrors.Errorf("failed to get sector set for miner: %w", err) } - var uselessOtherArray []sectorbuilder.PublicSectorInfo + var uselessOtherArray []ffi.PublicSectorInfo for _, s := range sectors { var uselessBuffer [32]byte copy(uselessBuffer[:], s.CommR) - uselessOtherArray = append(uselessOtherArray, sectorbuilder.PublicSectorInfo{ + uselessOtherArray = append(uselessOtherArray, ffi.PublicSectorInfo{ SectorID: s.SectorID, CommR: uselessBuffer, }) diff --git a/chain/sync.go b/chain/sync.go index 6254872c7..baecf3002 100644 --- a/chain/sync.go +++ b/chain/sync.go @@ -11,7 +11,7 @@ import ( "github.com/Gurpartap/async" amt "github.com/filecoin-project/go-amt-ipld" - "github.com/filecoin-project/go-bls-sigs" + bls "github.com/filecoin-project/filecoin-ffi" "github.com/hashicorp/go-multierror" "github.com/ipfs/go-cid" dstore "github.com/ipfs/go-datastore" diff --git a/chain/types/signature_cgo.go b/chain/types/signature_cgo.go index 901cab944..4b5a262f6 100644 --- a/chain/types/signature_cgo.go +++ b/chain/types/signature_cgo.go @@ -5,7 +5,7 @@ package types import ( "fmt" - bls "github.com/filecoin-project/go-bls-sigs" + bls "github.com/filecoin-project/filecoin-ffi" "github.com/filecoin-project/lotus/chain/address" "github.com/filecoin-project/lotus/lib/crypto" "github.com/minio/blake2b-simd" diff --git a/chain/wallet/wallet.go b/chain/wallet/wallet.go index eeb1af1cb..9dec1864e 100644 --- a/chain/wallet/wallet.go +++ b/chain/wallet/wallet.go @@ -7,7 +7,7 @@ import ( "strings" "sync" - "github.com/filecoin-project/go-bls-sigs" + bls "github.com/filecoin-project/filecoin-ffi" logging "github.com/ipfs/go-log" "github.com/minio/blake2b-simd" diff --git a/extern/filecoin-ffi b/extern/filecoin-ffi new file mode 160000 index 000000000..3de4c1567 --- /dev/null +++ b/extern/filecoin-ffi @@ -0,0 +1 @@ +Subproject commit 3de4c1567da6cea906a95b87a179c85dbec16c6d diff --git a/extern/go-bls-sigs b/extern/go-bls-sigs deleted file mode 160000 index 1c177e24f..000000000 --- a/extern/go-bls-sigs +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1c177e24fd71669a1c8cc2e0ce4ba6e247e34d77 diff --git a/extern/go-sectorbuilder b/extern/go-sectorbuilder deleted file mode 160000 index e75744852..000000000 --- a/extern/go-sectorbuilder +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e757448529bd87318e9b52b93661f6cda1a76a42 diff --git a/go.mod b/go.mod index 5fb9e2754..d3e0ea533 100644 --- a/go.mod +++ b/go.mod @@ -11,10 +11,9 @@ require ( github.com/btcsuite/btcd v0.0.0-20190807005414-4063feeff79a // indirect github.com/fatih/color v1.7.0 // indirect github.com/filecoin-project/chain-validation v0.0.0-20191106200742-11986803c0f7 + github.com/filecoin-project/filecoin-ffi v0.0.0-00010101000000-000000000000 github.com/filecoin-project/go-amt-ipld v0.0.0-20191122035745-59b9dfc0efc7 - github.com/filecoin-project/go-bls-sigs v0.0.0-20190718224239-4bc4b8a7bbf8 github.com/filecoin-project/go-leb128 v0.0.0-20190212224330-8d79a5489543 - github.com/filecoin-project/go-sectorbuilder v0.0.0-00010101000000-000000000000 github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1 github.com/go-ole/go-ole v1.2.4 // indirect github.com/google/go-cmp v0.3.1 // indirect @@ -43,7 +42,7 @@ require ( github.com/ipfs/go-ipfs-routing v0.1.0 github.com/ipfs/go-ipld-cbor v0.0.3 github.com/ipfs/go-ipld-format v0.0.2 - github.com/ipfs/go-log v0.0.2-0.20190920042044-a609c1ae5144 + github.com/ipfs/go-log v1.0.0 github.com/ipfs/go-merkledag v0.2.4 github.com/ipfs/go-unixfs v0.2.2-0.20190827150610-868af2e9e5cb github.com/ipld/go-ipld-prime v0.0.2-0.20191025154717-8dff1cbec43b @@ -89,7 +88,6 @@ require ( github.com/smartystreets/assertions v1.0.1 // indirect github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337 // indirect github.com/stretchr/testify v1.4.0 - github.com/urfave/cli v1.20.0 github.com/whyrusleeping/bencher v0.0.0-20190829221104-bb6607aa8bba github.com/whyrusleeping/cbor-gen v0.0.0-20191116002219-891f55cd449d github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 @@ -113,6 +111,4 @@ require ( replace github.com/golangci/golangci-lint => github.com/golangci/golangci-lint v1.18.0 -replace github.com/filecoin-project/go-bls-sigs => ./extern/go-bls-sigs - -replace github.com/filecoin-project/go-sectorbuilder => ./extern/go-sectorbuilder +replace github.com/filecoin-project/filecoin-ffi => ./extern/filecoin-ffi diff --git a/go.sum b/go.sum index d9f303a61..dc802c681 100644 --- a/go.sum +++ b/go.sum @@ -78,12 +78,11 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/fd/go-nat v1.0.0/go.mod h1:BTBu/CKvMmOMUPkKVef1pngt2WFH/lg7E6yQnulfp6E= github.com/filecoin-project/chain-validation v0.0.0-20191106200742-11986803c0f7 h1:Ags/z6ZubzKonQ9PsY9fO439yGdVg07qpdxfv/AEUno= github.com/filecoin-project/chain-validation v0.0.0-20191106200742-11986803c0f7/go.mod h1:0/0/QUNqpF/jVzLHFncGeT3NvGPODBhGzQlNgzmoZew= -github.com/filecoin-project/go-amt-ipld v0.0.0-20190919045431-3650716fff16 h1:NzojcJU1VbS6zdLG13JMYis/cQy/MrN3rxmZRq56jKA= -github.com/filecoin-project/go-amt-ipld v0.0.0-20190919045431-3650716fff16/go.mod h1:lKjJYPg2kwbav5f78i5YA8kGccnZn18IySbpneXvaQs= github.com/filecoin-project/go-amt-ipld v0.0.0-20191122035745-59b9dfc0efc7 h1:lKSMm8Go6qI7+Dk3rWCNIh57wBOqVNJ21re/p7D58gc= github.com/filecoin-project/go-amt-ipld v0.0.0-20191122035745-59b9dfc0efc7/go.mod h1:lKjJYPg2kwbav5f78i5YA8kGccnZn18IySbpneXvaQs= github.com/filecoin-project/go-leb128 v0.0.0-20190212224330-8d79a5489543 h1:aMJGfgqe1QDhAVwxRg5fjCRF533xHidiKsugk7Vvzug= github.com/filecoin-project/go-leb128 v0.0.0-20190212224330-8d79a5489543/go.mod h1:mjrHv1cDGJWDlGmC0eDc1E5VJr8DmL9XMUcaFwiuKg8= +github.com/filecoin-project/go-sectorbuilder v0.0.0-20191125152826-0aeff9f9485d/go.mod h1:NulUuak/mLUOIX+p5p6E9fCaR9VekiU1wpTgUB+DPgw= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1 h1:EzDjxMg43q1tA2c0MV3tNbaontnHLplHyFF6M5KiVP0= @@ -220,8 +219,8 @@ github.com/ipfs/go-ipld-format v0.0.1/go.mod h1:kyJtbkDALmFHv3QR6et67i35QzO3S0dC github.com/ipfs/go-ipld-format v0.0.2 h1:OVAGlyYT6JPZ0pEfGntFPS40lfrDmaDbQwNHEY2G9Zs= github.com/ipfs/go-ipld-format v0.0.2/go.mod h1:4B6+FM2u9OJ9zCV+kSbgFAZlOrv1Hqbf0INGQgiKf9k= github.com/ipfs/go-log v0.0.1/go.mod h1:kL1d2/hzSpI0thNYjiKfjanbVNU+IIGA/WnNESY9leM= -github.com/ipfs/go-log v0.0.2-0.20190920042044-a609c1ae5144 h1:5WM8S1nwquWQ3zEuNhK82NE5Di6Pd41qz9JxxvxTAIA= -github.com/ipfs/go-log v0.0.2-0.20190920042044-a609c1ae5144/go.mod h1:azGN5dH7ailfREknDDNYB0Eq4qZ/4I4Y3gO0ivjJNyM= +github.com/ipfs/go-log v1.0.0 h1:BW3LQIiZzpNyolt84yvKNCd3FU+AK4VDw1hnHR+1aiI= +github.com/ipfs/go-log v1.0.0/go.mod h1:JO7RzlMK6rA+CIxFMLOuB6Wf5b81GDiKElL7UPSIKjA= github.com/ipfs/go-merkledag v0.1.0/go.mod h1:SQiXrtSts3KGNmgOzMICy5c0POOpUNQLvB3ClKnBAlk= github.com/ipfs/go-merkledag v0.2.3/go.mod h1:SQiXrtSts3KGNmgOzMICy5c0POOpUNQLvB3ClKnBAlk= github.com/ipfs/go-merkledag v0.2.4 h1:ZSHQSe9BENfixUjT+MaLeHEeZGxrZQfgo3KT3SLosF8= @@ -417,6 +416,7 @@ github.com/marten-seemann/qtls v0.2.3 h1:0yWJ43C62LsZt08vuQJDK1uC1czUc3FJeCLPoNA github.com/marten-seemann/qtls v0.2.3/go.mod h1:xzjG7avBwGGbdZ8dTGxlBnLArsVKLvwmjgmPuiQEcYk= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= +github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= @@ -635,6 +635,7 @@ golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190611141213-3f473d35a33a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -667,6 +668,7 @@ golang.org/x/sys v0.0.0-20190526052359-791d8a0f4d09/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190610200419-93c9922d18ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456 h1:ng0gs1AKnRRuEMZoTLLlbOd+C17zUDepwGQBb/n+JVg= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190922100055-0a153f010e69 h1:rOhMmluY6kLMhdnrivzec6lLgaVbMHMn2ISQXJeJ5EM= golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -709,6 +711,7 @@ google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZi google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -723,6 +726,7 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD gopkg.in/urfave/cli.v2 v2.0.0-20180128182452-d3ae77c26ac8 h1:Ggy3mWN4l3PUFPfSG0YB3n5fVYggzysUmiUQ89SnX6Y= gopkg.in/urfave/cli.v2 v2.0.0-20180128182452-d3ae77c26ac8/go.mod h1:cKXr3E0k4aosgycml1b5z33BVV6hai1Kh7uDgFOkbcs= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/lib/padreader/padreader.go b/lib/padreader/padreader.go index 135e35b57..179ae305b 100644 --- a/lib/padreader/padreader.go +++ b/lib/padreader/padreader.go @@ -4,7 +4,7 @@ import ( "io" "math/bits" - sectorbuilder "github.com/filecoin-project/go-sectorbuilder" + sectorbuilder "github.com/filecoin-project/filecoin-ffi" ) func PaddedSize(size uint64) uint64 { diff --git a/lib/sectorbuilder/sectorbuilder.go b/lib/sectorbuilder/sectorbuilder.go index 1b43cc974..ea6e43977 100644 --- a/lib/sectorbuilder/sectorbuilder.go +++ b/lib/sectorbuilder/sectorbuilder.go @@ -8,7 +8,7 @@ import ( "strconv" "sync" - sectorbuilder "github.com/filecoin-project/go-sectorbuilder" + sectorbuilder "github.com/filecoin-project/filecoin-ffi" "github.com/ipfs/go-datastore" logging "github.com/ipfs/go-log" "go.opencensus.io/trace" @@ -26,16 +26,9 @@ var LastSectorIdKey = datastore.NewKey("/sectorbuilder/last") var log = logging.Logger("sectorbuilder") -type SectorSealingStatus = sectorbuilder.SectorSealingStatus - -type StagedSectorMetadata = sectorbuilder.StagedSectorMetadata - type SortedPublicSectorInfo = sectorbuilder.SortedPublicSectorInfo type SortedPrivateSectorInfo = sectorbuilder.SortedPrivateSectorInfo -type PrivateSectorInfo = sectorbuilder.SectorPrivateInfo -type PublicSectorInfo = sectorbuilder.SectorPublicInfo - type SealTicket = sectorbuilder.SealTicket type SealSeed = sectorbuilder.SealSeed @@ -174,7 +167,7 @@ func (sb *SectorBuilder) AddPiece(pieceSize uint64, sectorId uint64, file io.Rea return PublicPieceInfo{}, err } - _, _, commP, err := sectorbuilder.StandaloneWriteWithAlignment(f, pieceSize, stagedFile, existingPieceSizes) + _, _, commP, err := sectorbuilder.WriteWithAlignment(f, pieceSize, stagedFile, existingPieceSizes) if err != nil { return PublicPieceInfo{}, err } @@ -199,7 +192,7 @@ func (sb *SectorBuilder) ReadPieceFromSealedSector(pieceKey string) ([]byte, err defer ret() panic("fixme") - //return sectorbuilder.StandaloneUnseal(sb.handle, pieceKey) + //return sectorbuilder.Unseal(sb.handle, pieceKey) } func (sb *SectorBuilder) SealPreCommit(sectorID uint64, ticket SealTicket, pieces []PublicPieceInfo) (RawSealPreCommitOutput, error) { @@ -227,7 +220,7 @@ func (sb *SectorBuilder) SealPreCommit(sectorID uint64, ticket SealTicket, piece stagedPath := sb.stagedSectorPath(sectorID) - rspco, err := sectorbuilder.StandaloneSealPreCommit( + rspco, err := sectorbuilder.SealPreCommit( sb.ssize, PoRepProofPartitions, cacheDir, @@ -254,7 +247,7 @@ func (sb *SectorBuilder) SealCommit(sectorID uint64, ticket SealTicket, seed Sea return nil, err } - proof, err = sectorbuilder.StandaloneSealCommit( + proof, err = sectorbuilder.SealCommit( sb.ssize, PoRepProofPartitions, cacheDir, @@ -266,7 +259,7 @@ func (sb *SectorBuilder) SealCommit(sectorID uint64, ticket SealTicket, seed Sea rspco, ) if err != nil { - return nil, xerrors.Errorf("StandaloneSealCommit: %w", err) + return nil, xerrors.Errorf("SealCommit: %w", err) } return proof, nil @@ -297,7 +290,7 @@ func (sb *SectorBuilder) ComputeElectionPoSt(sectorInfo SortedPublicSectorInfo, } proverID := addressToProverID(sb.Miner) - return sectorbuilder.StandaloneGeneratePoSt(sb.ssize, proverID, privsects, cseed, winners) + return sectorbuilder.GeneratePoSt(sb.ssize, proverID, privsects, cseed, winners) } func (sb *SectorBuilder) GenerateEPostCandidates(sectorInfo SortedPublicSectorInfo, challengeSeed [CommLen]byte, faults []uint64) ([]EPostCandidate, error) { @@ -309,11 +302,11 @@ func (sb *SectorBuilder) GenerateEPostCandidates(sectorInfo SortedPublicSectorIn challengeCount := challangeCount(uint64(len(sectorInfo.Values()))) proverID := addressToProverID(sb.Miner) - return sectorbuilder.StandaloneGenerateCandidates(sb.ssize, proverID, challengeSeed, challengeCount, privsectors) + return sectorbuilder.GenerateCandidates(sb.ssize, proverID, challengeSeed, challengeCount, privsectors) } func (sb *SectorBuilder) pubSectorToPriv(sectorInfo SortedPublicSectorInfo) (SortedPrivateSectorInfo, error) { - var out []PrivateSectorInfo + var out []sectorbuilder.PrivateSectorInfo for _, s := range sectorInfo.Values() { cachePath, err := sb.sectorCacheDir(s.SectorID) if err != nil { @@ -325,7 +318,7 @@ func (sb *SectorBuilder) pubSectorToPriv(sectorInfo SortedPublicSectorInfo) (Sor return SortedPrivateSectorInfo{}, xerrors.Errorf("getting sealed path for sector %d: %w", s.SectorID, err) } - out = append(out, PrivateSectorInfo{ + out = append(out, sectorbuilder.PrivateSectorInfo{ SectorID: s.SectorID, CommR: s.CommR, CacheDirPath: cachePath, @@ -352,12 +345,12 @@ func VerifySeal(sectorSize uint64, commR, commD []byte, proverID address.Address return sectorbuilder.VerifySeal(sectorSize, commRa, commDa, proverIDa, ticketa, seeda, sectorID, proof) } -func NewSortedPrivateSectorInfo(sectors []PrivateSectorInfo) SortedPrivateSectorInfo { - return sectorbuilder.NewSortedSectorPrivateInfo(sectors...) +func NewSortedPrivateSectorInfo(sectors []sectorbuilder.PrivateSectorInfo) SortedPrivateSectorInfo { + return sectorbuilder.NewSortedPrivateSectorInfo(sectors...) } -func NewSortedPublicSectorInfo(sectors []PublicSectorInfo) SortedPublicSectorInfo { - return sectorbuilder.NewSortedSectorPublicInfo(sectors...) +func NewSortedPublicSectorInfo(sectors []sectorbuilder.PublicSectorInfo) SortedPublicSectorInfo { + return sectorbuilder.NewSortedPublicSectorInfo(sectors...) } func VerifyPost(ctx context.Context, sectorSize uint64, sectorInfo SortedPublicSectorInfo, challengeSeed []byte, proof []byte, winners []EPostCandidate, proverID address.Address) (bool, error) { diff --git a/storage/post.go b/storage/post.go index 270a66751..072b9615c 100644 --- a/storage/post.go +++ b/storage/post.go @@ -2,6 +2,7 @@ package storage import ( "context" + ffi "github.com/filecoin-project/filecoin-ffi" "time" "github.com/ipfs/go-cid" @@ -166,12 +167,12 @@ func (p *post) preparePost(ctx context.Context) error { func (p *post) sortedSectorInfo() sectorbuilder.SortedPrivateSectorInfo { panic("NYI") - sbsi := make([]sectorbuilder.PrivateSectorInfo, len(p.sset)) + sbsi := make([]ffi.PrivateSectorInfo, len(p.sset)) for k, sector := range p.sset { var commR [sectorbuilder.CommLen]byte copy(commR[:], sector.CommR) - sbsi[k] = sectorbuilder.PrivateSectorInfo{ + sbsi[k] = ffi.PrivateSectorInfo{ SectorID: sector.SectorID, CommR: commR, }