Skip to content

Commit

Permalink
Add some actors policy setters for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Sep 23, 2020
1 parent 7d39542 commit 77797c5
Show file tree
Hide file tree
Showing 14 changed files with 134 additions and 90 deletions.
15 changes: 7 additions & 8 deletions build/params_2k.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ package build
import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"

"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
"github.com/filecoin-project/lotus/chain/actors/builtin/verifreg"
)

const UpgradeBreezeHeight = -1
Expand All @@ -20,11 +21,9 @@ var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
}

func init() {
power0.ConsensusMinerMinPower = big.NewInt(2048)
miner0.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
abi.RegisteredSealProof_StackedDrg2KiBV1: {},
}
verifreg0.MinVerifiedDealSize = big.NewInt(256)
miner.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1)
power.SetConsensusMinerMinPower(big.NewInt(2048))
verifreg.SetMinVerifiedDealSize(big.NewInt(256))

BuildType |= Build2k
}
Expand Down
12 changes: 5 additions & 7 deletions build/params_testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/specs-actors/actors/builtin"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
)

var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
Expand All @@ -23,11 +21,11 @@ const BreezeGasTampingDuration = 120
const UpgradeSmokeHeight = 51000

func init() {
power0.ConsensusMinerMinPower = big.NewInt(10 << 40)
miner0.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
abi.RegisteredSealProof_StackedDrg32GiBV1: {},
abi.RegisteredSealProof_StackedDrg64GiBV1: {},
}
power.SetConsensusMinerMinPower(abi.NewStoragePower(10 << 40))
miner.SetSupportedProofTypes(
abi.RegisteredSealProof_StackedDrg32GiBV1,
abi.RegisteredSealProof_StackedDrg64GiBV1,
)
}

const BlockDelaySecs = uint64(builtin.EpochDurationSeconds)
Expand Down
37 changes: 37 additions & 0 deletions chain/actors/builtin/miner/policy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package miner

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

miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
)

// SetSupportedProofTypes sets supported proof types, across all actor versions.
// This should only be used for testing.
func SetSupportedProofTypes(types ...abi.RegisteredSealProof) {
newTypes := make(map[abi.RegisteredSealProof]struct{}, len(types))
for _, t := range types {
newTypes[t] = struct{}{}
}
// Set for all miner versions.
miner0.SupportedProofTypes = newTypes
}

// AddSupportedProofTypes sets supported proof types, across all actor versions.
// This should only be used for testing.
func AddSupportedProofTypes(types ...abi.RegisteredSealProof) {
newTypes := make(map[abi.RegisteredSealProof]struct{}, len(types))
for _, t := range types {
newTypes[t] = struct{}{}
}
// Set for all miner versions.
miner0.SupportedProofTypes = newTypes
}

// SetPreCommitChallengeDelay sets the pre-commit challenge delay across all
// actors versions. Use for testing.
func SetPreCommitChallengeDelay(delay abi.ChainEpoch) {
// Set for all miner versions.
miner0.PreCommitChallengeDelay = delay
PreCommitChallengeDelay = delay
}
14 changes: 14 additions & 0 deletions chain/actors/builtin/power/policy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package power

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

power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
)

// SetConsensusMinerMinPower sets the minimum power of an individual miner must
// meet for leader election, across all actor versions. This should only be used
// for testing.
func SetConsensusMinerMinPower(p abi.StoragePower) {
power0.ConsensusMinerMinPower = p
}
13 changes: 13 additions & 0 deletions chain/actors/builtin/verifreg/policy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package verifreg

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

verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
)

// SetMinVerifiedDealSize sets the minimum size of a verified deal. This should
// only be used for testing.
func SetMinVerifiedDealSize(size abi.StoragePower) {
verifreg0.MinVerifiedDealSize = size
}
7 changes: 3 additions & 4 deletions chain/gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/crypto"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
block "github.com/ipfs/go-block-format"
"github.com/ipfs/go-blockservice"
"github.com/ipfs/go-cid"
Expand All @@ -28,6 +27,7 @@ import (

"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/beacon"
genesis2 "github.com/filecoin-project/lotus/chain/gen/genesis"
"github.com/filecoin-project/lotus/chain/stmgr"
Expand Down Expand Up @@ -121,9 +121,8 @@ var DefaultRemainderAccountActor = genesis.Actor{
}

func NewGeneratorWithSectors(numSectors int) (*ChainGen, error) {
miner0.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
abi.RegisteredSealProof_StackedDrg2KiBV1: {},
}
// TODO: we really shouldn't modify a global variable here.
miner.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1)

mr := repo.NewMemory(nil)
lr, err := mr.Lock(repo.StorageMiner)
Expand Down
14 changes: 6 additions & 8 deletions chain/gen/gen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@ import (

"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"

"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
"github.com/filecoin-project/lotus/chain/actors/builtin/verifreg"
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
)

func init() {
miner0.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
abi.RegisteredSealProof_StackedDrg2KiBV1: {},
}
power0.ConsensusMinerMinPower = big.NewInt(2048)
verifreg0.MinVerifiedDealSize = big.NewInt(256)
miner.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1)
power.SetConsensusMinerMinPower(big.NewInt(2048))
verifreg.SetMinVerifiedDealSize(big.NewInt(256))
}

func testGeneration(t testing.TB, n int, msgs int, sectors int) {
Expand Down
14 changes: 6 additions & 8 deletions chain/stmgr/forks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import (
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/specs-actors/actors/builtin"
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
"github.com/filecoin-project/specs-actors/actors/runtime"
"golang.org/x/xerrors"

"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/aerrors"
lotusinit "github.com/filecoin-project/lotus/chain/actors/builtin/init"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
"github.com/filecoin-project/lotus/chain/actors/builtin/verifreg"
"github.com/filecoin-project/lotus/chain/gen"
"github.com/filecoin-project/lotus/chain/stmgr"
. "github.com/filecoin-project/lotus/chain/stmgr"
Expand All @@ -34,11 +34,9 @@ import (
)

func init() {
miner0.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
abi.RegisteredSealProof_StackedDrg2KiBV1: {},
}
power0.ConsensusMinerMinPower = big.NewInt(2048)
verifreg0.MinVerifiedDealSize = big.NewInt(256)
miner.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1)
power.SetConsensusMinerMinPower(big.NewInt(2048))
verifreg.SetMinVerifiedDealSize(big.NewInt(256))
}

const testForkHeight = 40
Expand Down
14 changes: 6 additions & 8 deletions chain/store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/crypto"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"

"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
"github.com/filecoin-project/lotus/chain/actors/builtin/verifreg"
"github.com/filecoin-project/lotus/chain/gen"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
Expand All @@ -22,11 +22,9 @@ import (
)

func init() {
miner0.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
abi.RegisteredSealProof_StackedDrg2KiBV1: {},
}
power0.ConsensusMinerMinPower = big.NewInt(2048)
verifreg0.MinVerifiedDealSize = big.NewInt(256)
miner.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1)
power.SetConsensusMinerMinPower(big.NewInt(2048))
verifreg.SetMinVerifiedDealSize(big.NewInt(256))
}

func BenchmarkGetRandomness(b *testing.B) {
Expand Down
14 changes: 6 additions & 8 deletions chain/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"

"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
"github.com/filecoin-project/lotus/chain/actors/builtin/verifreg"
"github.com/filecoin-project/lotus/chain/gen"
"github.com/filecoin-project/lotus/chain/gen/slashfilter"
"github.com/filecoin-project/lotus/chain/store"
Expand All @@ -43,11 +43,9 @@ func init() {
if err != nil {
panic(err)
}
miner0.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
abi.RegisteredSealProof_StackedDrg2KiBV1: {},
}
power0.ConsensusMinerMinPower = big.NewInt(2048)
verifreg0.MinVerifiedDealSize = big.NewInt(256)
miner.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1)
power.SetConsensusMinerMinPower(big.NewInt(2048))
verifreg.SetMinVerifiedDealSize(big.NewInt(256))
}

const source = 0
Expand Down
35 changes: 15 additions & 20 deletions cli/paych_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,34 @@ import (
"testing"
"time"

"github.com/filecoin-project/lotus/build"
"github.com/stretchr/testify/require"
"github.com/urfave/cli/v2"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
verifreg0 "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"

cbor "github.com/ipfs/go-ipld-cbor"
"github.com/multiformats/go-multiaddr"

"github.com/filecoin-project/lotus/chain/events"

"github.com/filecoin-project/lotus/api/apibstore"
"github.com/filecoin-project/lotus/chain/actors/adt"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
cbor "github.com/ipfs/go-ipld-cbor"
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
"github.com/filecoin-project/lotus/chain/actors/builtin/verifreg"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/chain/types"

"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/api/apibstore"
"github.com/filecoin-project/lotus/api/test"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/events"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/wallet"
builder "github.com/filecoin-project/lotus/node/test"
"github.com/stretchr/testify/require"
"github.com/urfave/cli/v2"
)

func init() {
power0.ConsensusMinerMinPower = big.NewInt(2048)
miner0.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
abi.RegisteredSealProof_StackedDrg2KiBV1: {},
}
verifreg0.MinVerifiedDealSize = big.NewInt(256)
power.SetConsensusMinerMinPower(big.NewInt(2048))
miner.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1)
verifreg.SetMinVerifiedDealSize(big.NewInt(256))
}

// TestPaymentChannels does a basic test to exercise the payment channel CLI
Expand Down
4 changes: 2 additions & 2 deletions cmd/lotus-bench/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import (
"github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper"
"github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper/basicfs"
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
"github.com/filecoin-project/specs-storage/storage"

lapi "github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/genesis"
)
Expand Down Expand Up @@ -76,7 +76,7 @@ func main() {

log.Info("Starting lotus-bench")

miner.SupportedProofTypes[abi.RegisteredSealProof_StackedDrg2KiBV1] = struct{}{}
miner.AddSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1)

app := &cli.App{
Name: "lotus-bench",
Expand Down
6 changes: 2 additions & 4 deletions lotuspond/spawn.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,22 @@ import (
"sync/atomic"
"time"

"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/types"

"golang.org/x/xerrors"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
genesis2 "github.com/filecoin-project/lotus/chain/gen/genesis"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"

"github.com/filecoin-project/lotus/chain/gen"
"github.com/filecoin-project/lotus/cmd/lotus-seed/seed"
"github.com/filecoin-project/lotus/genesis"
)

func init() {
miner.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
abi.RegisteredSealProof_StackedDrg2KiBV1: {},
}
miner.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1)
}

func (api *api) Spawn() (nodeInfo, error) {
Expand Down
Loading

0 comments on commit 77797c5

Please sign in to comment.