Skip to content

Commit

Permalink
feat: network: add nv17 and integrate the corresponding go state type (
Browse files Browse the repository at this point in the history
…#5329)

* feat: network: add nv17 and integrate the corresponding go state type

* fix: fix lint

* feat: Add a function for migration configuration

* chore: use fmt.Errorf replace to xerrors.Errorf

Co-authored-by: 一页素书 <2931107265@qq.com>
  • Loading branch information
simlecode and ta0li authored Sep 30, 2022
1 parent bd0f0cd commit a122811
Show file tree
Hide file tree
Showing 152 changed files with 4,069 additions and 1,077 deletions.
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,9 @@ run:
skip-dirs:
- pkg/constants$
- pkg/util/test$
- venus-shared/actors/adt$
- venus-shared/actors/aerrors$
- venus-shared/actors/builtin$
- venus-shared/actors/policy$
skip-files:
- ".*_gen\\.go$" # skip auto generated go files
5 changes: 3 additions & 2 deletions app/submodule/chain/chaininfo_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
actorstypes "github.com/filecoin-project/go-state-types/actors"
acrypto "github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/network"
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
Expand Down Expand Up @@ -669,7 +670,7 @@ func (cia *chainInfoAPI) StateGetNetworkParams(ctx context.Context) (*types.Netw

// StateActorCodeCIDs returns the CIDs of all the builtin actors for the given network version
func (cia *chainInfoAPI) StateActorCodeCIDs(ctx context.Context, nv network.Version) (map[string]cid.Cid, error) {
actorVersion, err := actors.VersionForNetwork(nv)
actorVersion, err := actorstypes.VersionForNetwork(nv)
if err != nil {
return nil, fmt.Errorf("invalid network version")
}
Expand Down Expand Up @@ -707,7 +708,7 @@ func (cia *chainInfoAPI) ChainGetGenesis(ctx context.Context) (*types.TipSet, er

// StateActorManifestCID returns the CID of the builtin actors manifest for the given network version
func (cia *chainInfoAPI) StateActorManifestCID(ctx context.Context, nv network.Version) (cid.Cid, error) {
actorVersion, err := actors.VersionForNetwork(nv)
actorVersion, err := actorstypes.VersionForNetwork(nv)
if err != nil {
return cid.Undef, fmt.Errorf("invalid network version")
}
Expand Down
24 changes: 14 additions & 10 deletions app/submodule/chain/miner_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/libp2p/go-libp2p/core/peer"
cbg "github.com/whyrusleeping/cbor-gen"

"github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/go-state-types/builtin/v9/miner"
market2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/market"
market5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/market"
"github.com/filecoin-project/venus/pkg/state/tree"
Expand Down Expand Up @@ -458,16 +458,20 @@ func (msa *minerStateAPI) StateMinerPreCommitDepositForPower(ctx context.Context

store := msa.ChainReader.Store(ctx)
var sectorWeight abi.StoragePower
if act, found, err := sTree.GetActor(ctx, market.Address); err != nil || !found {
return big.Int{}, fmt.Errorf("loading market actor %s: %v", maddr, err)
} else if s, err := market.Load(store, act); err != nil {
return big.Int{}, fmt.Errorf("loading market actor state %s: %v", maddr, err)
} else if w, vw, err := s.VerifyDealsForActivation(maddr, pci.DealIDs, ts.Height(), pci.Expiration); err != nil {
return big.Int{}, fmt.Errorf("verifying deals for activation: %v", err)
if msa.Fork.GetNetworkVersion(ctx, ts.Height()) <= network.Version16 {
if act, found, err := sTree.GetActor(ctx, market.Address); err != nil || !found {
return big.Int{}, fmt.Errorf("loading market actor %s: %v", maddr, err)
} else if s, err := market.Load(store, act); err != nil {
return big.Int{}, fmt.Errorf("loading market actor state %s: %v", maddr, err)
} else if w, vw, err := s.VerifyDealsForActivation(maddr, pci.DealIDs, ts.Height(), pci.Expiration); err != nil {
return big.Int{}, fmt.Errorf("verifying deals for activation: %v", err)
} else {
// NB: not exactly accurate, but should always lead us to *over* estimate, not under
duration := pci.Expiration - ts.Height()
sectorWeight = builtin.QAPowerForWeight(ssize, duration, w, vw)
}
} else {
// NB: not exactly accurate, but should always lead us to *over* estimate, not under
duration := pci.Expiration - ts.Height()
sectorWeight = builtin.QAPowerForWeight(ssize, duration, w, vw)
sectorWeight = miner.QAPowerMax(ssize)
}

var powerSmoothed builtin.FilterEstimate
Expand Down
2 changes: 1 addition & 1 deletion app/submodule/chain/v0api/chaininfo_v0api.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
v1api "github.com/filecoin-project/venus/venus-shared/api/chain/v1"

"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/builtin/v8/miner"
"github.com/filecoin-project/go-state-types/builtin/v9/miner"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/ipfs/go-cid"

Expand Down
5 changes: 3 additions & 2 deletions app/submodule/multisig/multisig_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/filecoin-project/go-state-types/big"
multisig2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/multisig"

Expand Down Expand Up @@ -39,7 +40,7 @@ func (a *multiSig) messageBuilder(ctx context.Context, from address.Address) (mu
if err != nil {
return nil, err
}
aver, err := actors.VersionForNetwork(nver)
aver, err := actorstypes.VersionForNetwork(nver)
if err != nil {
return nil, err
}
Expand All @@ -48,7 +49,7 @@ func (a *multiSig) messageBuilder(ctx context.Context, from address.Address) (mu

// MsigCreate creates a multisig wallet
// It takes the following params: <required number of senders>, <approving addresses>, <unlock duration>
//<initial balance>, <sender address of the create msg>, <gas price>
// <initial balance>, <sender address of the create msg>, <gas price>
func (a *multiSig) MsigCreate(ctx context.Context, req uint64, addrs []address.Address, duration abi.ChainEpoch, val types.BigInt, src address.Address, gp types.BigInt) (*types.MessagePrototype, error) {

mb, err := a.messageBuilder(ctx, src)
Expand Down
19 changes: 13 additions & 6 deletions cmd/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/filecoin-project/venus/venus-shared/actors/adt"
"github.com/filecoin-project/venus/venus-shared/actors/builtin/miner"
"github.com/filecoin-project/venus/venus-shared/actors/builtin/power"
"github.com/filecoin-project/venus/venus-shared/actors/policy"
"github.com/filecoin-project/venus/venus-shared/types"
"github.com/filecoin-project/venus/venus-shared/types/params"
)
Expand Down Expand Up @@ -54,7 +53,7 @@ var newMinerCmd = &cmds.Command{
cmds.BoolOption("create-worker-key", "Create separate worker key"),
cmds.StringOption("from", "Select which address to send actor creation message from"),
cmds.StringOption("gas-premium", "Set gas premium for initialization messages in AttoFIL").WithDefault("0"),
cmds.StringOption("sector-size", "specify sector size to use").WithDefault(units.BytesSize(float64(policy.GetDefaultSectorSize()))),
cmds.StringOption("sector-size", "specify sector size to use"),
},
Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error {
ctx := req.Context
Expand All @@ -64,10 +63,18 @@ var newMinerCmd = &cmds.Command{
return err
}

sectorSize, _ := req.Options["sector-size"].(string)
ssize, err := units.RAMInBytes(sectorSize)
ssize, err := abi.RegisteredSealProof_StackedDrg32GiBV1.SectorSize()
if err != nil {
return fmt.Errorf("failed to parse sector size: %v", err)
return fmt.Errorf("failed to calculate default sector size: %w", err)
}

sectorSize, ok := req.Options["sector-size"].(string)
if ok {
sectorSizeInt, err := units.RAMInBytes(sectorSize)
if err != nil {
return err
}
ssize = abi.SectorSize(sectorSizeInt)
}

gp, _ := req.Options["gas-premium"].(string)
Expand Down Expand Up @@ -128,7 +135,7 @@ var newMinerCmd = &cmds.Command{
return fmt.Errorf("getting network version: %v", err)
}

spt, err := miner.SealProofTypeFromSectorSize(abi.SectorSize(ssize), nv)
spt, err := miner.SealProofTypeFromSectorSize(ssize, nv)
if err != nil {
return fmt.Errorf("getting seal proof type: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/multisig.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ var msigInspectCmd = &cmds.Command{
}
paramStr = string(b)
}
fmt.Fprintf(w, "%d\t%s\t%d\t%s\t%s\t%s(%d)\t%s\n", txid, "pending", len(tx.Approved), target, types.FIL(tx.Value), method.Name, tx.Method, paramStr)
fmt.Fprintf(w, "%d\t%s\t%d\t%s\t%s\t%s(%d)\t%s\n", txid, "pending", len(tx.Approved), target, types.FIL(tx.Value), method.Num, tx.Method, paramStr)
}
}
if err := w.Flush(); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/network"
"github.com/ipfs/go-cid"
Expand All @@ -23,7 +24,6 @@ import (

"github.com/filecoin-project/venus/app/node"
"github.com/filecoin-project/venus/pkg/constants"
"github.com/filecoin-project/venus/venus-shared/actors"
"github.com/filecoin-project/venus/venus-shared/actors/builtin"
"github.com/filecoin-project/venus/venus-shared/types"
)
Expand Down Expand Up @@ -631,7 +631,7 @@ var stateSysActorCIDsCmd = &cmds.Command{
buf := new(bytes.Buffer)
buf.WriteString(fmt.Sprintf("Network Version: %d\n", nv))

actorVersion, err := actors.VersionForNetwork(nv)
actorVersion, err := actorstypes.VersionForNetwork(nv)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion extern/filecoin-ffi
42 changes: 21 additions & 21 deletions fixtures/networks/butterfly.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func ButterflySnapNet() *NetworkConf {
Network: config.NetworkParamsConfig{
DevNet: true,
NetworkType: types.NetworkButterfly,
GenesisNetworkVersion: network.Version15,
GenesisNetworkVersion: network.Version16,
ReplaceProofTypes: []abi.RegisteredSealProof{
abi.RegisteredSealProof_StackedDrg512MiBV1,
abi.RegisteredSealProof_StackedDrg32GiBV1,
Expand All @@ -32,27 +32,27 @@ func ButterflySnapNet() *NetworkConf {
MinVerifiedDealSize: 1 << 20,
PreCommitChallengeDelay: abi.ChainEpoch(150),
ForkUpgradeParam: &config.ForkUpgradeConfig{
UpgradeBreezeHeight: -1,
UpgradeSmokeHeight: -2,
UpgradeIgnitionHeight: -3,
UpgradeRefuelHeight: -4,
UpgradeAssemblyHeight: -5,
UpgradeTapeHeight: -6,
UpgradeLiftoffHeight: -7,
UpgradeKumquatHeight: -8,
UpgradeCalicoHeight: -9,
UpgradePersianHeight: -10,
UpgradeOrangeHeight: -12,
UpgradeTrustHeight: -13,
UpgradeNorwegianHeight: -14,
UpgradeTurboHeight: -15,
UpgradeHyperdriveHeight: -16,
UpgradeChocolateHeight: -17,
UpgradeOhSnapHeight: -18,
UpgradeSkyrHeight: 50,

BreezeGasTampingDuration: 120,
UpgradeClausHeight: -11,
UpgradeBreezeHeight: -1,
UpgradeSmokeHeight: -2,
UpgradeIgnitionHeight: -3,
UpgradeRefuelHeight: -4,
UpgradeAssemblyHeight: -5,
UpgradeTapeHeight: -6,
UpgradeLiftoffHeight: -7,
UpgradeKumquatHeight: -8,
UpgradeCalicoHeight: -9,
UpgradePersianHeight: -10,
UpgradeOrangeHeight: -11,
UpgradeClausHeight: -12,
UpgradeTrustHeight: -13,
UpgradeNorwegianHeight: -14,
UpgradeTurboHeight: -15,
UpgradeHyperdriveHeight: -16,
UpgradeChocolateHeight: -17,
UpgradeOhSnapHeight: -18,
UpgradeSkyrHeight: -19,
UpgradeV17Height: 99999999999999,
},
DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1},
AddressNetwork: address.Testnet,
Expand Down
36 changes: 18 additions & 18 deletions fixtures/networks/calibration.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,27 @@ func Calibration() *NetworkConf {
MinVerifiedDealSize: 1 << 20,
PreCommitChallengeDelay: abi.ChainEpoch(150),
ForkUpgradeParam: &config.ForkUpgradeConfig{
UpgradeBreezeHeight: -1,
UpgradeSmokeHeight: -2,
UpgradeIgnitionHeight: -3,
UpgradeRefuelHeight: -4,
UpgradeAssemblyHeight: 30,
UpgradeTapeHeight: 60,
UpgradeLiftoffHeight: -5,
UpgradeKumquatHeight: 90,
UpgradeCalicoHeight: 120,
UpgradePersianHeight: 100 + (120 * 1),
UpgradeOrangeHeight: 300,
UpgradeTrustHeight: 330,
UpgradeNorwegianHeight: 360,
UpgradeTurboHeight: 390,
UpgradeHyperdriveHeight: 420,
UpgradeSkyrHeight: 1044660, // 2022-06-16T17:30:00Z

BreezeGasTampingDuration: 120,
UpgradeBreezeHeight: -1,
UpgradeSmokeHeight: -2,
UpgradeIgnitionHeight: -3,
UpgradeRefuelHeight: -4,
UpgradeAssemblyHeight: 30,
UpgradeTapeHeight: 60,
UpgradeLiftoffHeight: -5,
UpgradeKumquatHeight: 90,
UpgradeCalicoHeight: 120,
UpgradePersianHeight: 100 + (120 * 1),
UpgradeClausHeight: 270,
UpgradeOrangeHeight: 300,
UpgradeTrustHeight: 330,
UpgradeNorwegianHeight: 360,
UpgradeTurboHeight: 390,
UpgradeHyperdriveHeight: 420,
UpgradeChocolateHeight: 312746,
UpgradeOhSnapHeight: 682006, // 2022-02-10T19:23:00Z
UpgradeOhSnapHeight: 682006, // 2022-02-10T19:23:00Z
UpgradeSkyrHeight: 1044660, // 2022-06-16T17:30:00Z
UpgradeV17Height: 99999999999999,
},
DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1},
AddressNetwork: address.Testnet,
Expand Down
1 change: 1 addition & 0 deletions fixtures/networks/forcenet.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func ForceNet() *NetworkConf {
UpgradeChocolateHeight: -17,
UpgradeOhSnapHeight: -18,
UpgradeSkyrHeight: -19,
UpgradeV17Height: 99999999999999,
},
DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: config.DrandMainnet},
AddressNetwork: address.Testnet,
Expand Down
38 changes: 19 additions & 19 deletions fixtures/networks/integrationtestnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,27 @@ func IntegrationNet() *NetworkConf {
MinVerifiedDealSize: 1 << 20,
PreCommitChallengeDelay: abi.ChainEpoch(150),
ForkUpgradeParam: &config.ForkUpgradeConfig{
UpgradeBreezeHeight: 41280,
UpgradeSmokeHeight: 51000,
UpgradeIgnitionHeight: 94000,
UpgradeRefuelHeight: 130800,
UpgradeAssemblyHeight: 138720,
UpgradeTapeHeight: 140760,
UpgradeLiftoffHeight: 148888,
UpgradeKumquatHeight: 170000,
UpgradeCalicoHeight: 265200,
UpgradePersianHeight: 265200 + (120 * 60),
UpgradeOrangeHeight: 336458,
UpgradeTrustHeight: 550321,
UpgradeNorwegianHeight: 665280,
UpgradeTurboHeight: 712320,
UpgradeHyperdriveHeight: 892800,
UpgradeChocolateHeight: 1231620,
UpgradeOhSnapHeight: 1594680,
UpgradeSkyrHeight: 99999999999999,

BreezeGasTampingDuration: 120,
UpgradeBreezeHeight: 41280,
UpgradeSmokeHeight: 51000,
UpgradeIgnitionHeight: 94000,
UpgradeRefuelHeight: 130800,
UpgradeAssemblyHeight: 138720,
UpgradeTapeHeight: 140760,
UpgradeLiftoffHeight: 148888,
UpgradeKumquatHeight: 170000,
UpgradeCalicoHeight: 265200,
UpgradePersianHeight: 265200 + (120 * 60),
UpgradeOrangeHeight: 336458,
UpgradeClausHeight: 343200,
UpgradeTrustHeight: 550321,
UpgradeNorwegianHeight: 665280,
UpgradeTurboHeight: 712320,
UpgradeHyperdriveHeight: 892800,
UpgradeChocolateHeight: 1231620,
UpgradeOhSnapHeight: 1594680,
UpgradeSkyrHeight: 1960320,
UpgradeV17Height: 99999999999999,
},
DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 5, 51000: 1},
AddressNetwork: address.Testnet,
Expand Down
Loading

0 comments on commit a122811

Please sign in to comment.