Skip to content

Commit e154a3e

Browse files
committed
Use new go-state-types accessors
1 parent 57accc2 commit e154a3e

File tree

7 files changed

+35
-234
lines changed

7 files changed

+35
-234
lines changed

distributed.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package ffi
66
import (
77
"github.com/filecoin-project/filecoin-ffi/cgo"
88
"github.com/filecoin-project/go-state-types/abi"
9-
"github.com/filecoin-project/specs-actors/v5/actors/runtime/proof"
9+
"github.com/filecoin-project/go-state-types/proof"
1010
)
1111

1212
type FallbackChallenges struct {

go.mod

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ go 1.17
55
require (
66
github.com/filecoin-project/go-address v0.0.6
77
github.com/filecoin-project/go-fil-commcid v0.1.0
8-
github.com/filecoin-project/go-state-types v0.1.3
9-
github.com/filecoin-project/specs-actors v0.9.14
10-
github.com/filecoin-project/specs-actors/v5 v5.0.4
11-
github.com/filecoin-project/specs-actors/v7 v7.0.0-rc1.0.20220118005651-2470cb39827e
8+
github.com/filecoin-project/go-state-types v0.1.4-0.20220511200558-7a486892661a
129
github.com/ipfs/go-block-format v0.0.3
1310
github.com/ipfs/go-cid v0.1.0
1411
github.com/ipfs/go-ipfs-blockstore v1.1.2
@@ -27,7 +24,7 @@ require (
2724
github.com/ipfs/go-datastore v0.5.0 // indirect
2825
github.com/ipfs/go-ipfs-ds-help v1.1.0 // indirect
2926
github.com/ipfs/go-ipfs-util v0.0.2 // indirect
30-
github.com/ipfs/go-ipld-cbor v0.0.5 // indirect
27+
github.com/ipfs/go-ipld-cbor v0.0.6-0.20211211231443-5d9b9e1f6fa8 // indirect
3128
github.com/ipfs/go-ipld-format v0.2.0 // indirect
3229
github.com/ipfs/go-log v1.0.4 // indirect
3330
github.com/ipfs/go-log/v2 v2.0.5 // indirect
@@ -49,7 +46,7 @@ require (
4946
github.com/smartystreets/goconvey v1.6.4 // indirect
5047
github.com/spaolacci/murmur3 v1.1.0 // indirect
5148
github.com/warpfork/go-wish v0.0.0-20200122115046-b9ea61034e4a // indirect
52-
github.com/whyrusleeping/cbor-gen v0.0.0-20210713220151-be142a5ae1a8 // indirect
49+
github.com/whyrusleeping/cbor-gen v0.0.0-20220323183124-98fa8256a799 // indirect
5350
go.uber.org/atomic v1.6.0 // indirect
5451
go.uber.org/multierr v1.5.0 // indirect
5552
go.uber.org/zap v1.14.1 // indirect

go.sum

Lines changed: 7 additions & 206 deletions
Large diffs are not rendered by default.

proofs.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,22 @@ import (
1212
"os"
1313
"runtime"
1414

15+
"github.com/filecoin-project/go-state-types/proof"
16+
1517
"github.com/ipfs/go-cid"
1618
"github.com/pkg/errors"
1719
"golang.org/x/xerrors"
1820

1921
"github.com/filecoin-project/go-address"
2022
commcid "github.com/filecoin-project/go-fil-commcid"
2123
"github.com/filecoin-project/go-state-types/abi"
22-
proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof"
2324

2425
"github.com/filecoin-project/filecoin-ffi/cgo"
2526
)
2627

2728
// VerifySeal returns true if the sealing operation from which its inputs were
2829
// derived was valid, and false if not.
29-
func VerifySeal(info proof5.SealVerifyInfo) (bool, error) {
30+
func VerifySeal(info proof.SealVerifyInfo) (bool, error) {
3031
sp, err := toFilRegisteredSealProof(info.SealProof)
3132
if err != nil {
3233
return false, err
@@ -53,7 +54,7 @@ func VerifySeal(info proof5.SealVerifyInfo) (bool, error) {
5354
return cgo.VerifySeal(sp, &commR, &commD, &proverID, &randomness, &interactiveRandomness, uint64(info.SectorID.Number), cgo.AsSliceRefUint8(info.Proof))
5455
}
5556

56-
func VerifyAggregateSeals(aggregate proof5.AggregateSealVerifyProofAndInfos) (bool, error) {
57+
func VerifyAggregateSeals(aggregate proof.AggregateSealVerifyProofAndInfos) (bool, error) {
5758
if len(aggregate.Infos) == 0 {
5859
return false, xerrors.New("no seal verify infos")
5960
}
@@ -102,7 +103,7 @@ func VerifyAggregateSeals(aggregate proof5.AggregateSealVerifyProofAndInfos) (bo
102103

103104
// VerifyWinningPoSt returns true if the Winning PoSt-generation operation from which its
104105
// inputs were derived was valid, and false if not.
105-
func VerifyWinningPoSt(info proof5.WinningPoStVerifyInfo) (bool, error) {
106+
func VerifyWinningPoSt(info proof.WinningPoStVerifyInfo) (bool, error) {
106107
filPublicReplicaInfos, err := toFilPublicReplicaInfos(info.ChallengedSectors, "winning")
107108
if err != nil {
108109
return false, errors.Wrap(err, "failed to create public replica info array for FFI")
@@ -129,7 +130,7 @@ func VerifyWinningPoSt(info proof5.WinningPoStVerifyInfo) (bool, error) {
129130

130131
// VerifyWindowPoSt returns true if the Winning PoSt-generation operation from which its
131132
// inputs were derived was valid, and false if not.
132-
func VerifyWindowPoSt(info proof5.WindowPoStVerifyInfo) (bool, error) {
133+
func VerifyWindowPoSt(info proof.WindowPoStVerifyInfo) (bool, error) {
133134
filPublicReplicaInfos, err := toFilPublicReplicaInfos(info.ChallengedSectors, "window")
134135
if err != nil {
135136
return false, errors.Wrap(err, "failed to create public replica info array for FFI")
@@ -409,7 +410,7 @@ func SealCommitPhase2(
409410
}
410411

411412
// TODO AggregateSealProofs it only needs InteractiveRandomness out of the aggregateInfo.Infos
412-
func AggregateSealProofs(aggregateInfo proof5.AggregateSealVerifyProofAndInfos, proofs [][]byte) (out []byte, err error) {
413+
func AggregateSealProofs(aggregateInfo proof.AggregateSealVerifyProofAndInfos, proofs [][]byte) (out []byte, err error) {
413414
sp, err := toFilRegisteredSealProof(aggregateInfo.SealProof)
414415
if err != nil {
415416
return nil, err
@@ -539,7 +540,7 @@ func GenerateWinningPoSt(
539540
minerID abi.ActorID,
540541
privateSectorInfo SortedPrivateSectorInfo,
541542
randomness abi.PoStRandomness,
542-
) ([]proof5.PoStProof, error) {
543+
) ([]proof.PoStProof, error) {
543544
filReplicas, cleanup, err := toFilPrivateReplicaInfos(privateSectorInfo.Values(), "winning")
544545
if err != nil {
545546
return nil, errors.Wrap(err, "failed to create private replica info array for FFI")
@@ -569,7 +570,7 @@ func GenerateWindowPoSt(
569570
minerID abi.ActorID,
570571
privateSectorInfo SortedPrivateSectorInfo,
571572
randomness abi.PoStRandomness,
572-
) ([]proof5.PoStProof, []abi.SectorNumber, error) {
573+
) ([]proof.PoStProof, []abi.SectorNumber, error) {
573574
filReplicas, cleanup, err := toFilPrivateReplicaInfos(privateSectorInfo.Values(), "window")
574575
if err != nil {
575576
return nil, nil, errors.Wrap(err, "failed to create private replica info array for FFI")
@@ -689,7 +690,7 @@ func toFilPublicPieceInfos(src []abi.PieceInfo) ([]cgo.PublicPieceInfo, error) {
689690
return out, nil
690691
}
691692

692-
func toFilPublicReplicaInfos(src []proof5.SectorInfo, typ string) ([]cgo.PublicReplicaInfo, error) {
693+
func toFilPublicReplicaInfos(src []proof.SectorInfo, typ string) ([]cgo.PublicReplicaInfo, error) {
693694
out := make([]cgo.PublicReplicaInfo, len(src))
694695

695696
for idx := range out {
@@ -794,16 +795,16 @@ func fromFilPoStFaultySectors(ptr []uint64) []abi.SectorNumber {
794795
return snums
795796
}
796797

797-
func fromFilPoStProofs(src []cgo.PoStProofGo) ([]proof5.PoStProof, error) {
798-
out := make([]proof5.PoStProof, len(src))
798+
func fromFilPoStProofs(src []cgo.PoStProofGo) ([]proof.PoStProof, error) {
799+
out := make([]proof.PoStProof, len(src))
799800

800801
for idx := range out {
801802
pp, err := fromFilRegisteredPoStProof(src[idx].RegisteredProof)
802803
if err != nil {
803804
return nil, err
804805
}
805806

806-
out[idx] = proof5.PoStProof{
807+
out[idx] = proof.PoStProof{
807808
PoStProof: pp,
808809
ProofBytes: src[idx].Proof,
809810
}
@@ -812,7 +813,7 @@ func fromFilPoStProofs(src []cgo.PoStProofGo) ([]proof5.PoStProof, error) {
812813
return out, nil
813814
}
814815

815-
func toFilPoStProofs(src []proof5.PoStProof) ([]cgo.PoStProof, error) {
816+
func toFilPoStProofs(src []proof.PoStProof) ([]cgo.PoStProof, error) {
816817
out := make([]cgo.PoStProof, len(src))
817818
for idx := range out {
818819
pp, err := toFilRegisteredPoStProof(src[idx].PoStProof)

sector_update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/filecoin-project/filecoin-ffi/cgo"
88
commcid "github.com/filecoin-project/go-fil-commcid"
99
"github.com/filecoin-project/go-state-types/abi"
10-
"github.com/filecoin-project/specs-actors/v7/actors/runtime/proof"
10+
"github.com/filecoin-project/go-state-types/proof"
1111
"github.com/ipfs/go-cid"
1212
"github.com/pkg/errors"
1313
"golang.org/x/xerrors"

types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import (
66
"encoding/json"
77
"sort"
88

9+
"github.com/filecoin-project/go-state-types/proof"
10+
911
"github.com/filecoin-project/go-state-types/abi"
10-
"github.com/filecoin-project/specs-actors/actors/runtime/proof"
1112
"github.com/ipfs/go-cid"
1213
)
1314

workflows.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ import (
1515
"os"
1616
"path/filepath"
1717

18+
prooftypes "github.com/filecoin-project/go-state-types/proof"
19+
1820
"github.com/filecoin-project/go-state-types/abi"
19-
prf "github.com/filecoin-project/specs-actors/actors/runtime/proof"
2021
"github.com/ipfs/go-cid"
2122
)
2223

@@ -138,7 +139,7 @@ func WorkflowProofsLifecycle(t TestHelper) {
138139
t.RequireNoError(err)
139140

140141
// verify the 'ole proofy
141-
isValid, err := VerifySeal(prf.SealVerifyInfo{
142+
isValid, err := VerifySeal(prooftypes.SealVerifyInfo{
142143
SectorID: abi.SectorID{
143144
Miner: minerID,
144145
Number: sectorNum,
@@ -218,7 +219,7 @@ func WorkflowProofsLifecycle(t TestHelper) {
218219
// generate a PoSt over the proving set before importing, just to exercise
219220
// the new API
220221
privateInfo := NewSortedPrivateSectorInfo(PrivateSectorInfo{
221-
SectorInfo: prf.SectorInfo{
222+
SectorInfo: prooftypes.SectorInfo{
222223
SectorNumber: sectorNum,
223224
SealedCID: sealedCID,
224225
},
@@ -227,7 +228,7 @@ func WorkflowProofsLifecycle(t TestHelper) {
227228
SealedSectorPath: sealedSectorFile.Name(),
228229
})
229230

230-
provingSet := []prf.SectorInfo{{
231+
provingSet := []prooftypes.SectorInfo{{
231232
SealProof: sealProofType,
232233
SectorNumber: sectorNum,
233234
SealedCID: sealedCID,
@@ -237,15 +238,15 @@ func WorkflowProofsLifecycle(t TestHelper) {
237238
indicesInProvingSet, err := GenerateWinningPoStSectorChallenge(winningPostProofType, minerID, randomness[:], uint64(len(provingSet)))
238239
t.RequireNoError(err)
239240

240-
var challengedSectors []prf.SectorInfo
241+
var challengedSectors []prooftypes.SectorInfo
241242
for idx := range indicesInProvingSet {
242243
challengedSectors = append(challengedSectors, provingSet[indicesInProvingSet[idx]])
243244
}
244245

245246
proofs, err := GenerateWinningPoSt(minerID, privateInfo, randomness[:])
246247
t.RequireNoError(err)
247248

248-
isValid, err = VerifyWinningPoSt(prf.WinningPoStVerifyInfo{
249+
isValid, err = VerifyWinningPoSt(prooftypes.WinningPoStVerifyInfo{
249250
Randomness: randomness[:],
250251
Proofs: proofs,
251252
ChallengedSectors: challengedSectors,

0 commit comments

Comments
 (0)