Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/synthetic po rep #6161

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ api-diff:
api-perm:
cd venus-devtool && $(GO) run ./compatible/apis/*.go perm > ../venus-shared/compatible-checks/api-perm.txt

compatible-actor: actor-templates actor-sources actor-render
compatible-actor: actor-templates actor-sources actor-render actor-replica

actor-templates:
cd venus-devtool && $(GO) run ./compatible/actors/*.go templates --dst ../venus-shared/actors/ > ../venus-shared/compatible-checks/actor-templates.txt
Expand Down
2 changes: 1 addition & 1 deletion cmd/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ var newMinerCmd = &cmds.Command{
return fmt.Errorf("getting network version: %v", err)
}

spt, err := miner.SealProofTypeFromSectorSize(ssize, nv)
spt, err := miner.SealProofTypeFromSectorSize(ssize, nv, false)
if err != nil {
return fmt.Errorf("getting seal proof type: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/seed.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ var preSealCmd = &cmds.Command{
nv = network.Version(ver)
}

spt, err := miner.SealProofTypeFromSectorSize(sectorSize, nv)
spt, err := miner.SealProofTypeFromSectorSize(sectorSize, nv, false)
if err != nil {
return err
}
Expand Down
Binary file modified fixtures/assets/genesis-car/butterflynet.car
Binary file not shown.
12 changes: 6 additions & 6 deletions fixtures/networks/butterfly.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ func ButterflySnapNet() *NetworkConf {
return &NetworkConf{
Bootstrap: config.BootstrapConfig{
Addresses: []string{
"/dns4/bootstrap-0.butterfly.fildev.network/tcp/1347/p2p/12D3KooWD5mtdmjHQ1Puj9Md7SEfoa7kWMpwqUhAKsyYsBP56LQC",
"/dns4/bootstrap-1.butterfly.fildev.network/tcp/1347/p2p/12D3KooWEoYPkm6o87ES6AppFY7d7WHJUQg7XVPRAyQZjEU31efQ",
"/dns4/bootstrap-0.butterfly.fildev.network/tcp/1347/p2p/12D3KooWMH8fFcfL6K7dwRo2wqa4UjdM5pxg9DAnoWPrVRx4Dioj",
"/dns4/bootstrap-1.butterfly.fildev.network/tcp/1347/p2p/12D3KooWArCrw1TLyJ5r37pYvHgv9kkXNC8tu2t1Sx7hyoCHpRje",
},
Period: "30s",
},
Network: config.NetworkParamsConfig{
DevNet: true,
NetworkType: types.NetworkButterfly,
GenesisNetworkVersion: network.Version18,
GenesisNetworkVersion: network.Version20,
ReplaceProofTypes: []abi.RegisteredSealProof{
abi.RegisteredSealProof_StackedDrg512MiBV1,
abi.RegisteredSealProof_StackedDrg32GiBV1,
Expand Down Expand Up @@ -53,9 +53,9 @@ func ButterflySnapNet() *NetworkConf {
UpgradeSkyrHeight: -19,
UpgradeSharkHeight: -20,
UpgradeHyggeHeight: -21,
UpgradeLightningHeight: 50,
UpgradeThunderHeight: 50 + 360,
UpgradeWatermelonHeight: 999999999999999,
UpgradeLightningHeight: -22,
UpgradeThunderHeight: -23,
UpgradeWatermelonHeight: 900,
},
DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1},
AddressNetwork: address.Testnet,
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/
github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.1.12/go.mod h1:n/kujdC9JphvYTrmaD1+vJpvDPy/DwzckoMzP0nBKWI=
github.com/filecoin-project/go-state-types v0.11.1/go.mod h1:SyNPwTsU7I22gL2r0OAPcImvLoTVfgRwdK/Y5rR1zz8=
github.com/filecoin-project/go-state-types v0.11.2-0.20230712101859-8f37624fa540/go.mod h1:SyNPwTsU7I22gL2r0OAPcImvLoTVfgRwdK/Y5rR1zz8=
github.com/filecoin-project/go-state-types v0.12.1 h1:/1ip/jXIP4QzWd3hlaQ7RGp1DHKKYG3+NOhd/r08UJY=
github.com/filecoin-project/go-state-types v0.12.1/go.mod h1:KOBGyvCalT8uHBS7KSKOVbjsilD90bBZHgLAqrzz6gU=
github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig=
Expand Down
2 changes: 1 addition & 1 deletion pkg/gen/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ func MakeGenesisBlock(ctx context.Context, rep repo.Repo, bs bstore.Blockstore,
}

// setup Storage Miners
stateroot, err = SetupStorageMiners(ctx, cs, stateroot, template.Miners, template.NetworkVersion, para)
stateroot, err = SetupStorageMiners(ctx, cs, stateroot, template.Miners, template.NetworkVersion, para, false)
if err != nil {
return nil, fmt.Errorf("setup miners failed: %w", err)
}
Expand Down
11 changes: 9 additions & 2 deletions pkg/gen/genesis/miners.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,14 @@ func mkFakedSigSyscalls(sys vmcontext.SyscallsImpl) vmcontext.SyscallsImpl {
}

// Note: Much of this is brittle, if the methodNum / param / return changes, it will break things
func SetupStorageMiners(ctx context.Context, cs *chain.Store, sroot cid.Cid, miners []Miner, nv network.Version, para *config.ForkUpgradeConfig) (cid.Cid, error) {
func SetupStorageMiners(ctx context.Context,
cs *chain.Store,
sroot cid.Cid,
miners []Miner,
nv network.Version,
para *config.ForkUpgradeConfig,
synthetic bool,
) (cid.Cid, error) {
cst := cbor.NewCborStore(cs.Blockstore())
av, err := actorstypes.VersionForNetwork(nv)
if err != nil {
Expand Down Expand Up @@ -147,7 +154,7 @@ func SetupStorageMiners(ctx context.Context, cs *chain.Store, sroot cid.Cid, min
i := i
m := m

spt, err := miner.SealProofTypeFromSectorSize(m.SectorSize, nv)
spt, err := miner.SealProofTypeFromSectorSize(m.SectorSize, nv, synthetic)
if err != nil {
return cid.Undef, err
}
Expand Down
11 changes: 10 additions & 1 deletion venus-devtool/compatible/actors/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ var replicaCmd = &cli.Command{
if strings.Contains(dir, "builtin") && strings.HasSuffix(file, ".go") {
pf := file[:strings.LastIndex(file, ".go")]
if strings.Contains(dir, pf) {
fmt.Println("path:", path)
return true
}
}
Expand All @@ -183,6 +182,15 @@ var replicaCmd = &cli.Command{
return true
}

// skip aerrors/error.go or aerrors/wrap.go
if strings.Contains(path, "aerrors/error.go") || strings.Contains(path, "aerrors/wrap.go") {
return true
}

if strings.Contains(path, "builtin/registry.go") {
return true
}

if strings.HasSuffix(path, "main.go") || strings.Contains(path, "template") ||
strings.Contains(path, "message") {
return true
Expand Down Expand Up @@ -219,6 +227,7 @@ var replicaCmd = &cli.Command{
{"\"github.com/filecoin-project/lotus/chain/types\"", "\"github.com/filecoin-project/venus/venus-shared/actors/types\""},
{"\"github.com/filecoin-project/lotus/blockstore\"", "blockstore \"github.com/filecoin-project/venus/pkg/util/blockstoreutil\""},
{"golang.org/x/xerrors", "fmt"},
{"xerrors.Errorf", "fmt.Errorf"},
}

for _, file := range files {
Expand Down
9 changes: 9 additions & 0 deletions venus-devtool/compatible/actors/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"os"
"path/filepath"
"strings"

"github.com/filecoin-project/venus/venus-devtool/util"
)

const (
Expand Down Expand Up @@ -155,6 +157,13 @@ func fetchOne(srcDir, dstDir string, rel string, replacers [][2]string) error {

data = filterSamePkg(data)

if !strings.HasSuffix(dstPath, ".template") && !strings.HasSuffix(dstPath, ".md") {
data, err = util.FmtFile("", data)
if err != nil {
return err
}
}

_, err = io.Copy(fdst, bytes.NewReader(data))
if err != nil {
return fmt.Errorf("copy to dst file: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion venus-devtool/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/filecoin-project/go-fil-markets v1.28.3
github.com/filecoin-project/go-jsonrpc v0.3.1
github.com/filecoin-project/go-state-types v0.12.1
github.com/filecoin-project/lotus v1.23.4-0.20230829140627-a9396624a71f
github.com/filecoin-project/lotus v1.23.4-0.20230919170504-4fd6eb6e8743
github.com/filecoin-project/venus v0.0.0-00010101000000-000000000000
github.com/google/uuid v1.3.0
github.com/ipfs/go-block-format v0.1.2
Expand Down
6 changes: 3 additions & 3 deletions venus-devtool/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ github.com/filecoin-project/go-state-types v0.1.0/go.mod h1:ezYnPf0bNkTsDibL/psS
github.com/filecoin-project/go-state-types v0.1.4/go.mod h1:xCA/WfKlC2zcn3fUmDv4IrzznwS98X5XW/irUP3Lhxg=
github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.11.1/go.mod h1:SyNPwTsU7I22gL2r0OAPcImvLoTVfgRwdK/Y5rR1zz8=
github.com/filecoin-project/go-state-types v0.11.2-0.20230712101859-8f37624fa540/go.mod h1:SyNPwTsU7I22gL2r0OAPcImvLoTVfgRwdK/Y5rR1zz8=
github.com/filecoin-project/go-state-types v0.12.1 h1:/1ip/jXIP4QzWd3hlaQ7RGp1DHKKYG3+NOhd/r08UJY=
github.com/filecoin-project/go-state-types v0.12.1/go.mod h1:KOBGyvCalT8uHBS7KSKOVbjsilD90bBZHgLAqrzz6gU=
github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig=
Expand All @@ -232,8 +232,8 @@ github.com/filecoin-project/go-statestore v0.2.0 h1:cRRO0aPLrxKQCZ2UOQbzFGn4WDNd
github.com/filecoin-project/go-statestore v0.2.0/go.mod h1:8sjBYbS35HwPzct7iT4lIXjLlYyPor80aU7t7a/Kspo=
github.com/filecoin-project/kubo-api-client v0.0.1 h1:IR1b+sm+VYxSRvbgECVv9SbhIgygcXcSoN1Q7xsHDXg=
github.com/filecoin-project/kubo-api-client v0.0.1/go.mod h1:c36PPMIVOkKfHDwDG5U05gUlPRY9wNuh/BePwo0e+6Y=
github.com/filecoin-project/lotus v1.23.4-0.20230829140627-a9396624a71f h1:rIEL7rnRE+VU3UEoGHKFbbb1m+dZ/ZSFgW0UNc7pUOQ=
github.com/filecoin-project/lotus v1.23.4-0.20230829140627-a9396624a71f/go.mod h1:56nGHg5UYutBuPOQZUfs0aJpdZTt4qFXcxkhQ4y9hrw=
github.com/filecoin-project/lotus v1.23.4-0.20230919170504-4fd6eb6e8743 h1:mtKLJQQ/d7REL39TwH1pbMOIf5LS4RtZsv3E96vus5M=
github.com/filecoin-project/lotus v1.23.4-0.20230919170504-4fd6eb6e8743/go.mod h1:56nGHg5UYutBuPOQZUfs0aJpdZTt4qFXcxkhQ4y9hrw=
github.com/filecoin-project/pubsub v1.0.0 h1:ZTmT27U07e54qV1mMiQo4HDr0buo8I1LDHBYLXlsNXM=
github.com/filecoin-project/pubsub v1.0.0/go.mod h1:GkpB33CcUtUNrLPhJgfdy4FDx4OMNR9k+46DHx/Lqrg=
github.com/filecoin-project/specs-actors v0.9.13/go.mod h1:TS1AW/7LbG+615j4NsjMK1qlpAwaFsG9w0V2tg2gSao=
Expand Down
2 changes: 2 additions & 0 deletions venus-shared/actors/actor_cids.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// FETCHED FROM LOTUS: actor_cids.go

package actors

import (
Expand Down
Binary file modified venus-shared/actors/builtin-actors-code/v12.tar.zst
Binary file not shown.
29 changes: 23 additions & 6 deletions venus-shared/actors/builtin/miner/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ type Partition interface {

type SectorOnChainInfo = minertypes.SectorOnChainInfo

func PreferredSealProofTypeFromWindowPoStType(nver network.Version, proof abi.RegisteredPoStProof) (abi.RegisteredSealProof, error) {
func PreferredSealProofTypeFromWindowPoStType(nver network.Version, proof abi.RegisteredPoStProof, configWantSynthetic bool) (abi.RegisteredSealProof, error) {
// We added support for the new proofs in network version 7, and removed support for the old
// ones in network version 8.
if nver < network.Version7 {
Expand All @@ -244,17 +244,34 @@ func PreferredSealProofTypeFromWindowPoStType(nver network.Version, proof abi.Re
}
}

if nver < MinSyntheticPoRepVersion || !configWantSynthetic {
switch proof {
case abi.RegisteredPoStProof_StackedDrgWindow2KiBV1, abi.RegisteredPoStProof_StackedDrgWindow2KiBV1_1:
return abi.RegisteredSealProof_StackedDrg2KiBV1_1, nil
case abi.RegisteredPoStProof_StackedDrgWindow8MiBV1, abi.RegisteredPoStProof_StackedDrgWindow8MiBV1_1:
return abi.RegisteredSealProof_StackedDrg8MiBV1_1, nil
case abi.RegisteredPoStProof_StackedDrgWindow512MiBV1, abi.RegisteredPoStProof_StackedDrgWindow512MiBV1_1:
return abi.RegisteredSealProof_StackedDrg512MiBV1_1, nil
case abi.RegisteredPoStProof_StackedDrgWindow32GiBV1, abi.RegisteredPoStProof_StackedDrgWindow32GiBV1_1:
return abi.RegisteredSealProof_StackedDrg32GiBV1_1, nil
case abi.RegisteredPoStProof_StackedDrgWindow64GiBV1, abi.RegisteredPoStProof_StackedDrgWindow64GiBV1_1:
return abi.RegisteredSealProof_StackedDrg64GiBV1_1, nil
default:
return -1, fmt.Errorf("unrecognized window post type: %d", proof)
}
}

switch proof {
case abi.RegisteredPoStProof_StackedDrgWindow2KiBV1, abi.RegisteredPoStProof_StackedDrgWindow2KiBV1_1:
return abi.RegisteredSealProof_StackedDrg2KiBV1_1, nil
return abi.RegisteredSealProof_StackedDrg2KiBV1_1_Feat_SyntheticPoRep, nil
case abi.RegisteredPoStProof_StackedDrgWindow8MiBV1, abi.RegisteredPoStProof_StackedDrgWindow8MiBV1_1:
return abi.RegisteredSealProof_StackedDrg8MiBV1_1, nil
return abi.RegisteredSealProof_StackedDrg8MiBV1_1_Feat_SyntheticPoRep, nil
case abi.RegisteredPoStProof_StackedDrgWindow512MiBV1, abi.RegisteredPoStProof_StackedDrgWindow512MiBV1_1:
return abi.RegisteredSealProof_StackedDrg512MiBV1_1, nil
return abi.RegisteredSealProof_StackedDrg512MiBV1_1_Feat_SyntheticPoRep, nil
case abi.RegisteredPoStProof_StackedDrgWindow32GiBV1, abi.RegisteredPoStProof_StackedDrgWindow32GiBV1_1:
return abi.RegisteredSealProof_StackedDrg32GiBV1_1, nil
return abi.RegisteredSealProof_StackedDrg32GiBV1_1_Feat_SyntheticPoRep, nil
case abi.RegisteredPoStProof_StackedDrgWindow64GiBV1, abi.RegisteredPoStProof_StackedDrgWindow64GiBV1_1:
return abi.RegisteredSealProof_StackedDrg64GiBV1_1, nil
return abi.RegisteredSealProof_StackedDrg64GiBV1_1_Feat_SyntheticPoRep, nil
default:
return -1, fmt.Errorf("unrecognized window post type: %d", proof)
}
Expand Down
29 changes: 23 additions & 6 deletions venus-shared/actors/builtin/miner/actor.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ type Partition interface {

type SectorOnChainInfo = minertypes.SectorOnChainInfo

func PreferredSealProofTypeFromWindowPoStType(nver network.Version, proof abi.RegisteredPoStProof) (abi.RegisteredSealProof, error) {
func PreferredSealProofTypeFromWindowPoStType(nver network.Version, proof abi.RegisteredPoStProof, configWantSynthetic bool) (abi.RegisteredSealProof, error) {
// We added support for the new proofs in network version 7, and removed support for the old
// ones in network version 8.
if nver < network.Version7 {
Expand All @@ -176,17 +176,34 @@ func PreferredSealProofTypeFromWindowPoStType(nver network.Version, proof abi.Re
}
}

if nver < MinSyntheticPoRepVersion || !configWantSynthetic {
switch proof {
case abi.RegisteredPoStProof_StackedDrgWindow2KiBV1, abi.RegisteredPoStProof_StackedDrgWindow2KiBV1_1:
return abi.RegisteredSealProof_StackedDrg2KiBV1_1, nil
case abi.RegisteredPoStProof_StackedDrgWindow8MiBV1, abi.RegisteredPoStProof_StackedDrgWindow8MiBV1_1:
return abi.RegisteredSealProof_StackedDrg8MiBV1_1, nil
case abi.RegisteredPoStProof_StackedDrgWindow512MiBV1, abi.RegisteredPoStProof_StackedDrgWindow512MiBV1_1:
return abi.RegisteredSealProof_StackedDrg512MiBV1_1, nil
case abi.RegisteredPoStProof_StackedDrgWindow32GiBV1, abi.RegisteredPoStProof_StackedDrgWindow32GiBV1_1:
return abi.RegisteredSealProof_StackedDrg32GiBV1_1, nil
case abi.RegisteredPoStProof_StackedDrgWindow64GiBV1, abi.RegisteredPoStProof_StackedDrgWindow64GiBV1_1:
return abi.RegisteredSealProof_StackedDrg64GiBV1_1, nil
default:
return -1, fmt.Errorf("unrecognized window post type: %d", proof)
}
}

switch proof {
case abi.RegisteredPoStProof_StackedDrgWindow2KiBV1, abi.RegisteredPoStProof_StackedDrgWindow2KiBV1_1:
return abi.RegisteredSealProof_StackedDrg2KiBV1_1, nil
return abi.RegisteredSealProof_StackedDrg2KiBV1_1_Feat_SyntheticPoRep, nil
case abi.RegisteredPoStProof_StackedDrgWindow8MiBV1, abi.RegisteredPoStProof_StackedDrgWindow8MiBV1_1:
return abi.RegisteredSealProof_StackedDrg8MiBV1_1, nil
return abi.RegisteredSealProof_StackedDrg8MiBV1_1_Feat_SyntheticPoRep, nil
case abi.RegisteredPoStProof_StackedDrgWindow512MiBV1, abi.RegisteredPoStProof_StackedDrgWindow512MiBV1_1:
return abi.RegisteredSealProof_StackedDrg512MiBV1_1, nil
return abi.RegisteredSealProof_StackedDrg512MiBV1_1_Feat_SyntheticPoRep, nil
case abi.RegisteredPoStProof_StackedDrgWindow32GiBV1, abi.RegisteredPoStProof_StackedDrgWindow32GiBV1_1:
return abi.RegisteredSealProof_StackedDrg32GiBV1_1, nil
return abi.RegisteredSealProof_StackedDrg32GiBV1_1_Feat_SyntheticPoRep, nil
case abi.RegisteredPoStProof_StackedDrgWindow64GiBV1, abi.RegisteredPoStProof_StackedDrgWindow64GiBV1_1:
return abi.RegisteredSealProof_StackedDrg64GiBV1_1, nil
return abi.RegisteredSealProof_StackedDrg64GiBV1_1_Feat_SyntheticPoRep, nil
default:
return -1, fmt.Errorf("unrecognized window post type: %d", proof)
}
Expand Down
4 changes: 3 additions & 1 deletion venus-shared/actors/builtin/miner/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
package miner

import (
cbg "github.com/whyrusleeping/cbor-gen"

"github.com/filecoin-project/go-state-types/abi"

"github.com/filecoin-project/venus/venus-shared/actors/adt"
cbg "github.com/whyrusleeping/cbor-gen"
)

func DiffPreCommits(pre, cur State) (*PreCommitChanges, error) {
Expand Down
38 changes: 32 additions & 6 deletions venus-shared/actors/builtin/miner/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/filecoin-project/go-state-types/network"
)

var MinSyntheticPoRepVersion = network.Version21

func AllPartSectors(mas State, sget func(Partition) (bitfield.BitField, error)) (bitfield.BitField, error) {
var parts []bitfield.BitField

Expand All @@ -33,7 +35,7 @@ func AllPartSectors(mas State, sget func(Partition) (bitfield.BitField, error))

// SealProofTypeFromSectorSize returns preferred seal proof type for creating
// new miner actors and new sectors
func SealProofTypeFromSectorSize(ssize abi.SectorSize, nv network.Version) (abi.RegisteredSealProof, error) {
func SealProofTypeFromSectorSize(ssize abi.SectorSize, nv network.Version, synthetic bool) (abi.RegisteredSealProof, error) {
switch {
case nv < network.Version7:
switch ssize {
Expand All @@ -51,25 +53,49 @@ func SealProofTypeFromSectorSize(ssize abi.SectorSize, nv network.Version) (abi.
return 0, fmt.Errorf("unsupported sector size for miner: %v", ssize)
}
case nv >= network.Version7:
var v abi.RegisteredSealProof
switch ssize {
case 2 << 10:
return abi.RegisteredSealProof_StackedDrg2KiBV1_1, nil
v = abi.RegisteredSealProof_StackedDrg2KiBV1_1
case 8 << 20:
return abi.RegisteredSealProof_StackedDrg8MiBV1_1, nil
v = abi.RegisteredSealProof_StackedDrg8MiBV1_1
case 512 << 20:
return abi.RegisteredSealProof_StackedDrg512MiBV1_1, nil
v = abi.RegisteredSealProof_StackedDrg512MiBV1_1
case 32 << 30:
return abi.RegisteredSealProof_StackedDrg32GiBV1_1, nil
v = abi.RegisteredSealProof_StackedDrg32GiBV1_1
case 64 << 30:
return abi.RegisteredSealProof_StackedDrg64GiBV1_1, nil
v = abi.RegisteredSealProof_StackedDrg64GiBV1_1
default:
return 0, fmt.Errorf("unsupported sector size for miner: %v", ssize)
}

if nv >= MinSyntheticPoRepVersion && synthetic {
return toSynthetic(v)
} else {
return v, nil
}
}

return 0, fmt.Errorf("unsupported network version")
}

func toSynthetic(in abi.RegisteredSealProof) (abi.RegisteredSealProof, error) {
switch in {
case abi.RegisteredSealProof_StackedDrg2KiBV1_1:
return abi.RegisteredSealProof_StackedDrg2KiBV1_1_Feat_SyntheticPoRep, nil
case abi.RegisteredSealProof_StackedDrg8MiBV1_1:
return abi.RegisteredSealProof_StackedDrg8MiBV1_1_Feat_SyntheticPoRep, nil
case abi.RegisteredSealProof_StackedDrg512MiBV1_1:
return abi.RegisteredSealProof_StackedDrg512MiBV1_1_Feat_SyntheticPoRep, nil
case abi.RegisteredSealProof_StackedDrg32GiBV1_1:
return abi.RegisteredSealProof_StackedDrg32GiBV1_1_Feat_SyntheticPoRep, nil
case abi.RegisteredSealProof_StackedDrg64GiBV1_1:
return abi.RegisteredSealProof_StackedDrg64GiBV1_1_Feat_SyntheticPoRep, nil
default:
return 0, fmt.Errorf("unsupported conversion to synthetic: %v", in)
}
}

// WindowPoStProofTypeFromSectorSize returns preferred post proof type for creating
// new miner actors and new sectors
func WindowPoStProofTypeFromSectorSize(ssize abi.SectorSize, nv network.Version) (abi.RegisteredPoStProof, error) {
Expand Down
3 changes: 2 additions & 1 deletion venus-shared/actors/builtin/multisig/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
package multisig

import (
cbg "github.com/whyrusleeping/cbor-gen"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
cbg "github.com/whyrusleeping/cbor-gen"

"github.com/filecoin-project/venus/venus-shared/actors/adt"
)
Expand Down
Loading
Loading