Skip to content

Commit

Permalink
Merge pull request #6182 from filecoin-project/opt/limit-partitions
Browse files Browse the repository at this point in the history
Opt/limit partitions
  • Loading branch information
simlecode authored Oct 12, 2023
2 parents d50e6a6 + e6fb8d7 commit a039bec
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 28 deletions.
18 changes: 10 additions & 8 deletions app/submodule/chain/miner_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,11 @@ func (msa *minerStateAPI) stateComputeDataCIDv1(ctx context.Context, maddr addre
}

ccmt := &types.Message{
To: market.Address,
From: maddr,
Value: types.NewInt(0),
Method: market.Methods.ComputeDataCommitment,
To: market.Address,
From: maddr,
Value: types.NewInt(0),
// Hard coded, because the method has since been deprecated
Method: 8,
Params: ccparams,
}
r, err := msa.API().StateCall(ctx, ccmt, tsk)
Expand Down Expand Up @@ -577,10 +578,11 @@ func (msa *minerStateAPI) stateComputeDataCIDv2(ctx context.Context, maddr addre
return cid.Undef, fmt.Errorf("computing params for ComputeDataCommitment: %w", err)
}
ccmt := &types.Message{
To: market.Address,
From: maddr,
Value: types.NewInt(0),
Method: market.Methods.ComputeDataCommitment,
To: market.Address,
From: maddr,
Value: types.NewInt(0),
// Hard coded, because the method has since been deprecated
Method: 8,
Params: ccparams,
}
r, err := msa.API().StateCall(ctx, ccmt, tsk)
Expand Down
18 changes: 9 additions & 9 deletions cmd/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
power2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/power"
power6 "github.com/filecoin-project/specs-actors/v6/actors/builtin/power"
cmds "github.com/ipfs/go-ipfs-cmds"
cbor "github.com/ipfs/go-ipld-cbor"
logging "github.com/ipfs/go-log/v2"
Expand Down Expand Up @@ -134,20 +134,20 @@ var newMinerCmd = &cmds.Command{
return fmt.Errorf("getting network version: %v", err)
}

spt, err := miner.SealProofTypeFromSectorSize(ssize, nv, false)
spt, err := miner.WindowPoStProofTypeFromSectorSize(ssize, nv)
if err != nil {
return fmt.Errorf("getting seal proof type: %v", err)
return fmt.Errorf("getting post proof type: %v", err)
}

peerID, err := env.(*node.Env).NetworkAPI.ID(ctx)
if err != nil {
return err
}
params, err := actors.SerializeParams(&power2.CreateMinerParams{
Owner: owner,
Worker: worker,
SealProofType: spt,
Peer: abi.PeerID(peerID),
params, err := actors.SerializeParams(&power6.CreateMinerParams{
Owner: owner,
Worker: worker,
WindowPoStProofType: spt,
Peer: abi.PeerID(peerID),
})
if err != nil {
return err
Expand Down Expand Up @@ -196,7 +196,7 @@ var newMinerCmd = &cmds.Command{
return fmt.Errorf("create miner failed: exit code %d", mw.Receipt.ExitCode)
}

var retval power2.CreateMinerReturn
var retval power6.CreateMinerReturn
if err := retval.UnmarshalCBOR(bytes.NewReader(mw.Receipt.Return)); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ require (
github.com/filecoin-project/go-fil-markets v1.27.0-rc1
github.com/filecoin-project/go-jsonrpc v0.1.5
github.com/filecoin-project/go-paramfetch v0.0.4
github.com/filecoin-project/go-state-types v0.12.3
github.com/filecoin-project/go-state-types v0.12.4
github.com/filecoin-project/pubsub v1.0.0
github.com/filecoin-project/specs-actors v0.9.15
github.com/filecoin-project/specs-actors/v2 v2.3.6
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,8 @@ github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd
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.3 h1:tPljjwrmLUT+b/H0R0yWZQVjVEso7ld9JBh4mpF6c8c=
github.com/filecoin-project/go-state-types v0.12.3/go.mod h1:iJTqGdWDvzXhuVf64Lw0hzt4TIoitMo0VgHdxdjNDZI=
github.com/filecoin-project/go-state-types v0.12.4 h1:F1yQRCgFGvg+UmBGWxskHcvNswjh061Ok/kOk0OWhQY=
github.com/filecoin-project/go-state-types v0.12.4/go.mod h1:iJTqGdWDvzXhuVf64Lw0hzt4TIoitMo0VgHdxdjNDZI=
github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig=
github.com/filecoin-project/go-statemachine v1.0.2-0.20220322104818-27f8fbb86dfd/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54=
github.com/filecoin-project/go-statemachine v1.0.2/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54=
Expand Down
4 changes: 2 additions & 2 deletions venus-devtool/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ require (
github.com/filecoin-project/go-data-transfer/v2 v2.0.0-rc7
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.3
github.com/filecoin-project/lotus v1.23.4-0.20230924140339-a0e38c905e78
github.com/filecoin-project/go-state-types v0.12.4
github.com/filecoin-project/lotus v1.23.4-0.20231011195010-a7f4976ab16f
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
8 changes: 4 additions & 4 deletions venus-devtool/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ github.com/filecoin-project/go-state-types v0.1.4/go.mod h1:xCA/WfKlC2zcn3fUmDv4
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.2-0.20230712101859-8f37624fa540/go.mod h1:SyNPwTsU7I22gL2r0OAPcImvLoTVfgRwdK/Y5rR1zz8=
github.com/filecoin-project/go-state-types v0.12.3 h1:tPljjwrmLUT+b/H0R0yWZQVjVEso7ld9JBh4mpF6c8c=
github.com/filecoin-project/go-state-types v0.12.3/go.mod h1:iJTqGdWDvzXhuVf64Lw0hzt4TIoitMo0VgHdxdjNDZI=
github.com/filecoin-project/go-state-types v0.12.4 h1:F1yQRCgFGvg+UmBGWxskHcvNswjh061Ok/kOk0OWhQY=
github.com/filecoin-project/go-state-types v0.12.4/go.mod h1:iJTqGdWDvzXhuVf64Lw0hzt4TIoitMo0VgHdxdjNDZI=
github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig=
github.com/filecoin-project/go-statemachine v1.0.3 h1:N07o6alys+V1tNoSTi4WuuoeNC4erS/6jE74+NsgQuk=
github.com/filecoin-project/go-statemachine v1.0.3/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54=
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.20230924140339-a0e38c905e78 h1:8NaW7uJs8QSbJZDtAL8SIkuR9tjIPyicBGQXFo3yjjI=
github.com/filecoin-project/lotus v1.23.4-0.20230924140339-a0e38c905e78/go.mod h1:qOWv/IuIQJFmtynCOwddh+cXOqU6GkFG8u4yRkLkU14=
github.com/filecoin-project/lotus v1.23.4-0.20231011195010-a7f4976ab16f h1:Z2wPfNmawGio2GZcBW4X4ewZGBuH9RGpmmL9lii89Fw=
github.com/filecoin-project/lotus v1.23.4-0.20231011195010-a7f4976ab16f/go.mod h1:Az8bI5Xpyk04IgonL4TywkqgCkTjtHeiMbPgRbAzXiA=
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
10 changes: 9 additions & 1 deletion venus-shared/actors/policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,8 @@ func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, e
if err != nil {
return 0, err
}
return int(uint64(maxSectors) / sectorsPerPart), nil

return min(miner12.PoStedPartitionsMax, int(uint64(maxSectors)/sectorsPerPart)), nil
}

func GetDefaultAggregationProof() abi.RegisteredAggregationProof {
Expand Down Expand Up @@ -889,3 +890,10 @@ func AggregatePreCommitNetworkFee(nwVer network.Version, aggregateSize int, base
return big.Zero(), fmt.Errorf("unsupported network version")
}
}

func min(a, b int) int {
if a < b {
return a
}
return b
}
10 changes: 9 additions & 1 deletion venus-shared/actors/policy/policy.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ func GetMaxPoStPartitions(nv network.Version, p abi.RegisteredPoStProof) (int, e
if err != nil {
return 0, err
}
return int(uint64(maxSectors) / sectorsPerPart), nil

return min(miner{{.latestVersion}}.PoStedPartitionsMax, int(uint64(maxSectors) / sectorsPerPart)), nil
}

func GetDefaultAggregationProof() abi.RegisteredAggregationProof {
Expand Down Expand Up @@ -343,3 +344,10 @@ func AggregatePreCommitNetworkFee(nwVer network.Version, aggregateSize int, base
return big.Zero(), fmt.Errorf("unsupported network version")
}
}

func min(a, b int) int {
if a < b {
return a
}
return b
}

0 comments on commit a039bec

Please sign in to comment.