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: Skeleton for nv23 #6354

Merged
merged 4 commits into from
Jun 18, 2024
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
1 change: 1 addition & 0 deletions app/submodule/chain/chaininfo_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ func (cia *chainInfoAPI) StateGetNetworkParams(ctx context.Context) (*types.Netw
UpgradeWatermelonHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeWatermelonHeight,
UpgradeDragonHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeDragonHeight,
UpgradePhoenixHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradePhoenixHeight,
UpgradeWaffleHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeWaffleHeight,
},
Eip155ChainID: cfg.NetworkParams.Eip155ChainID,
}
Expand Down
14 changes: 12 additions & 2 deletions app/submodule/chain/miner_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,18 @@ func (msa *minerStateAPI) StateMinerInfo(ctx context.Context, maddr address.Addr
ConsensusFaultElapsed: minfo.ConsensusFaultElapsed,
PendingOwnerAddress: minfo.PendingOwnerAddress,
Beneficiary: minfo.Beneficiary,
BeneficiaryTerm: &minfo.BeneficiaryTerm,
PendingBeneficiaryTerm: minfo.PendingBeneficiaryTerm,
BeneficiaryTerm: &types.BeneficiaryTerm{
Quota: minfo.BeneficiaryTerm.Quota,
UsedQuota: minfo.BeneficiaryTerm.UsedQuota,
Expiration: minfo.BeneficiaryTerm.Expiration,
},
PendingBeneficiaryTerm: &types.PendingBeneficiaryChange{
NewBeneficiary: minfo.PendingBeneficiaryTerm.NewBeneficiary,
NewQuota: minfo.PendingBeneficiaryTerm.NewQuota,
NewExpiration: minfo.PendingBeneficiaryTerm.NewExpiration,
ApprovedByBeneficiary: minfo.PendingBeneficiaryTerm.ApprovedByBeneficiary,
ApprovedByNominee: minfo.PendingBeneficiaryTerm.ApprovedByNominee,
},
}

if minfo.PendingWorkerKey != nil {
Expand Down
5 changes: 3 additions & 2 deletions fixtures/networks/butterfly.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ func ButterflySnapNet() *NetworkConf {
UpgradeWatermelonHeight: -24,
UpgradeWatermelonFixHeight: -100, // This fix upgrade only ran on calibrationnet
UpgradeWatermelonFix2Height: -101, // This fix upgrade only ran on calibrationnet
UpgradeDragonHeight: 5760,
UpgradeDragonHeight: -25,
UpgradeCalibrationDragonFixHeight: -102, // This fix upgrade only ran on calibrationnet
UpgradePhoenixHeight: -26,
UpgradeWaffleHeight: 400,
},
DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1},
AddressNetwork: address.Testnet,
Expand All @@ -70,7 +72,6 @@ func ButterflySnapNet() *NetworkConf {
},
}

nc.Network.ForkUpgradeParam.UpgradePhoenixHeight = nc.Network.ForkUpgradeParam.UpgradeDragonHeight + 120
nc.Network.DrandSchedule[nc.Network.ForkUpgradeParam.UpgradePhoenixHeight] = config.DrandQuicknet

return nc
Expand Down
1 change: 1 addition & 0 deletions fixtures/networks/calibration.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func Calibration() *NetworkConf {
UpgradeWatermelonFix2Height: 1108174, // 2023-11-21T13:00:00Z
UpgradeDragonHeight: 1427974, // 2024-03-11T14:00:00Z
UpgradeCalibrationDragonFixHeight: 1493854, // 2024-04-03T11:00:00Z
UpgradeWaffleHeight: 9999999999, //
},
DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1},
AddressNetwork: address.Testnet,
Expand Down
7 changes: 4 additions & 3 deletions fixtures/networks/forcenet.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func ForceNet() *NetworkConf {
Network: config.NetworkParamsConfig{
DevNet: true,
NetworkType: types.NetworkForce,
GenesisNetworkVersion: network.Version21,
GenesisNetworkVersion: network.Version22,
ReplaceProofTypes: []abi.RegisteredSealProof{
abi.RegisteredSealProof_StackedDrg8MiBV1,
abi.RegisteredSealProof_StackedDrg512MiBV1,
Expand Down Expand Up @@ -60,8 +60,10 @@ func ForceNet() *NetworkConf {
UpgradeWatermelonHeight: -24,
UpgradeWatermelonFixHeight: -100, // This fix upgrade only ran on calibrationnet
UpgradeWatermelonFix2Height: -101, // This fix upgrade only ran on calibrationnet
UpgradeDragonHeight: 20,
UpgradeDragonHeight: -25,
UpgradeCalibrationDragonFixHeight: -102, // This fix upgrade only ran on calibrationnet
UpgradePhoenixHeight: -26,
UpgradeWaffleHeight: 200,
},
DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: config.DrandMainnet},
AddressNetwork: address.Testnet,
Expand All @@ -71,7 +73,6 @@ func ForceNet() *NetworkConf {
ActorDebugging: true,
},
}
nc.Network.ForkUpgradeParam.UpgradePhoenixHeight = nc.Network.ForkUpgradeParam.UpgradeDragonHeight + 120
nc.Network.DrandSchedule[nc.Network.ForkUpgradeParam.UpgradePhoenixHeight] = config.DrandQuicknet

return nc
Expand Down
3 changes: 2 additions & 1 deletion fixtures/networks/integrationtestnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ func IntegrationNet() *NetworkConf {
UpgradeWatermelonHeight: 3431940,
UpgradeWatermelonFixHeight: -100, // This fix upgrade only ran on calibrationnet
UpgradeWatermelonFix2Height: -101, // This fix upgrade only ran on calibrationnet
UpgradeDragonHeight: 9999999999999,
UpgradeDragonHeight: 3855360,
UpgradeCalibrationDragonFixHeight: -102, // This fix upgrade only ran on calibrationnet
UpgradeWaffleHeight: 9999999999999,
},
DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 5, 51000: 1},
AddressNetwork: address.Testnet,
Expand Down
5 changes: 3 additions & 2 deletions fixtures/networks/interopnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ func InteropNet() *NetworkConf {
UpgradeWatermelonHeight: -24,
UpgradeWatermelonFixHeight: -100, // This fix upgrade only ran on calibrationnet
UpgradeWatermelonFix2Height: -101, // This fix upgrade only ran on calibrationnet
UpgradeDragonHeight: 50,
UpgradeDragonHeight: -25,
UpgradeCalibrationDragonFixHeight: -102, // This fix upgrade only ran on calibrationnet
UpgradePhoenixHeight: -26,
UpgradeWaffleHeight: 50,
},
DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1},
AddressNetwork: address.Testnet,
Expand All @@ -70,7 +72,6 @@ func InteropNet() *NetworkConf {
},
}

nc.Network.ForkUpgradeParam.UpgradePhoenixHeight = nc.Network.ForkUpgradeParam.UpgradeDragonHeight + 100
nc.Network.DrandSchedule[nc.Network.ForkUpgradeParam.UpgradePhoenixHeight] = config.DrandQuicknet

return nc
Expand Down
1 change: 1 addition & 0 deletions fixtures/networks/mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func Mainnet() *NetworkConf {
UpgradeWatermelonFix2Height: -101, // This fix upgrade only ran on calibrationnet
UpgradeDragonHeight: 3855360, // 2024-04-24T14:00:00Z
UpgradeCalibrationDragonFixHeight: -102, // This fix upgrade only ran on calibrationnet
UpgradeWaffleHeight: 999999999999, //
},
DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 5, 51000: 1},
AddressNetwork: address.Mainnet,
Expand Down
7 changes: 4 additions & 3 deletions fixtures/networks/net_2k.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func Net2k() *NetworkConf {
Network: config.NetworkParamsConfig{
DevNet: true,
NetworkType: types.Network2k,
GenesisNetworkVersion: network.Version21,
GenesisNetworkVersion: network.Version22,
ReplaceProofTypes: []abi.RegisteredSealProof{
abi.RegisteredSealProof_StackedDrg2KiBV1,
abi.RegisteredSealProof_StackedDrg8MiBV1,
Expand Down Expand Up @@ -54,8 +54,10 @@ func Net2k() *NetworkConf {
UpgradeWatermelonHeight: -24,
UpgradeWatermelonFixHeight: -100, // This fix upgrade only ran on calibrationnet
UpgradeWatermelonFix2Height: -101, // This fix upgrade only ran on calibrationnet
UpgradeDragonHeight: 20,
UpgradeDragonHeight: -25,
UpgradeCalibrationDragonFixHeight: -102, // This fix upgrade only ran on calibrationnet
UpgradePhoenixHeight: -26,
UpgradeWaffleHeight: 200,
},
DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1},
AddressNetwork: address.Testnet,
Expand All @@ -66,7 +68,6 @@ func Net2k() *NetworkConf {
},
}

nc.Network.ForkUpgradeParam.UpgradePhoenixHeight = nc.Network.ForkUpgradeParam.UpgradeDragonHeight + 120
nc.Network.DrandSchedule[nc.Network.ForkUpgradeParam.UpgradePhoenixHeight] = config.DrandQuicknet

return nc
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.28.2
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.13.1
github.com/filecoin-project/go-state-types v0.14.0-dev
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 @@ -302,8 +302,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.13.1 h1:4CivvlcHAIoAtFFVVlZtokynaMQu5XLXGoTKhQkfG1I=
github.com/filecoin-project/go-state-types v0.13.1/go.mod h1:cHpOPup9H1g2T29dKHAjC2sc7/Ef5ypjuW9A3I+e9yY=
github.com/filecoin-project/go-state-types v0.14.0-dev h1:bDwq1S28D7EC/uDmKU8vvNcdFw/YDsNq09pe3zeV5h4=
github.com/filecoin-project/go-state-types v0.14.0-dev/go.mod h1:cHpOPup9H1g2T29dKHAjC2sc7/Ef5ypjuW9A3I+e9yY=
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 Down
2 changes: 2 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ type ForkUpgradeConfig struct {
UpgradeDragonHeight abi.ChainEpoch `json:"upgradeDragonHeight"`
UpgradePhoenixHeight abi.ChainEpoch `json:"upgradePhoenixHeight"`
UpgradeCalibrationDragonFixHeight abi.ChainEpoch `json:"upgradeCalibrationDragonFixHeight"`
UpgradeWaffleHeight abi.ChainEpoch `json:"upgradeWaffleHeight"`
}

func IsNearUpgrade(epoch, upgradeEpoch abi.ChainEpoch) bool {
Expand Down Expand Up @@ -381,6 +382,7 @@ var DefaultForkUpgradeParam = &ForkUpgradeConfig{
UpgradePhoenixHeight: 3855360 + 120,
// This fix upgrade only ran on calibrationnet
UpgradeCalibrationDragonFixHeight: -3,
UpgradeWaffleHeight: 999999999999,
}

func newDefaultNetworkParamsConfig() *NetworkParamsConfig {
Expand Down
2 changes: 1 addition & 1 deletion pkg/constants/shared_vals.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const TestNetworkVersion = network.Version{{.latestNetworkVersion}}

/* inline-gen start */

const TestNetworkVersion = network.Version22
const TestNetworkVersion = network.Version23

/* inline-gen end */

Expand Down
123 changes: 123 additions & 0 deletions pkg/fork/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
nv19 "github.com/filecoin-project/go-state-types/builtin/v11/migration"
nv21 "github.com/filecoin-project/go-state-types/builtin/v12/migration"
nv22 "github.com/filecoin-project/go-state-types/builtin/v13/migration"
nv23 "github.com/filecoin-project/go-state-types/builtin/v14/migration"
nv17 "github.com/filecoin-project/go-state-types/builtin/v9/migration"
"github.com/filecoin-project/go-state-types/migration"
"github.com/filecoin-project/specs-actors/actors/migration/nv3"
Expand Down Expand Up @@ -432,6 +433,18 @@ func DefaultUpgradeSchedule(cf *ChainFork, upgradeHeight *config.ForkUpgradeConf
Network: network.Version22,
Migration: cf.upgradeActorsV13VerifregFix(calibnetv13BuggyVerifregCID1, calibnetv13CorrectManifestCID1),
},
{
Height: upgradeHeight.UpgradeWaffleHeight,
Network: network.Version23,
Migration: cf.UpgradeActorsV14,
PreMigrations: []PreMigration{{
PreMigration: cf.PreUpgradeActorsV14,
StartWithin: 120,
DontStartWithin: 15,
StopWithin: 10,
}},
Expensive: true,
},
}

for _, u := range updates {
Expand Down Expand Up @@ -3330,6 +3343,116 @@ func (c *ChainFork) upgradeActorsV13VerifregFix(oldBuggyVerifregCID, newManifest
}
}

func (c *ChainFork) PreUpgradeActorsV14(ctx context.Context, cache MigrationCache, root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet) error {
// Use half the CPUs for pre-migration, but leave at least 3.
workerCount := MigrationMaxWorkerCount
if workerCount <= 4 {
workerCount = 1
} else {
workerCount /= 2
}

nv := c.GetNetworkVersion(ctx, epoch)
_, lbRoot, err := c.cr.GetLookbackTipSetForRound(ctx, ts, epoch, nv)
if err != nil {
return fmt.Errorf("error getting lookback ts for premigration: %w", err)
}

config := migration.Config{
MaxWorkers: uint(workerCount),
ProgressLogPeriod: time.Minute * 5,
}

_, err = c.upgradeActorsV14Common(ctx, cache, lbRoot, epoch, config)
return err
}

func (c *ChainFork) UpgradeActorsV14(ctx context.Context,
cache MigrationCache,
root cid.Cid,
epoch abi.ChainEpoch,
ts *types.TipSet,
) (cid.Cid, error) {
// Use all the CPUs except 2.
workerCount := MigrationMaxWorkerCount - 3
if workerCount <= 0 {
workerCount = 1
}
config := migration.Config{
MaxWorkers: uint(workerCount),
JobQueueSize: 1000,
ResultQueueSize: 100,
ProgressLogPeriod: 10 * time.Second,
}
newRoot, err := c.upgradeActorsV14Common(ctx, cache, root, epoch, config)
if err != nil {
return cid.Undef, fmt.Errorf("migrating actors v14 state: %w", err)
}
return newRoot, nil
}

func (c *ChainFork) upgradeActorsV14Common(
ctx context.Context,
cache MigrationCache,
root cid.Cid,
epoch abi.ChainEpoch,
config migration.Config,
) (cid.Cid, error) {
writeStore := blockstoreutil.NewAutobatch(ctx, c.bs, units.GiB/4)
adtStore := adt.WrapStore(ctx, cbor.NewCborStore(writeStore))

// ensure that the manifest is loaded in the blockstore
if err := actors.LoadBundles(ctx, writeStore, actorstypes.Version14); err != nil {
return cid.Undef, fmt.Errorf("failed to load manifest bundle: %w", err)
}

// Load the state root.
var stateRoot vmstate.StateRoot
if err := adtStore.Get(ctx, root, &stateRoot); err != nil {
return cid.Undef, fmt.Errorf("failed to decode state root: %w", err)
}

if stateRoot.Version != vmstate.StateTreeVersion5 {
return cid.Undef, fmt.Errorf(
"expected state root version 5 for actors v14 upgrade, got %d",
stateRoot.Version,
)
}

manifest, ok := actors.GetManifest(actorstypes.Version14)
if !ok {
return cid.Undef, fmt.Errorf("no manifest CID for v14 upgrade")
}

// Perform the migration
newHamtRoot, err := nv23.MigrateStateTree(ctx, adtStore, manifest, stateRoot.Actors, epoch, config,
migrationLogger{}, cache)
if err != nil {
return cid.Undef, fmt.Errorf("upgrading to actors v14: %w", err)
}

// Persist the result.
newRoot, err := adtStore.Put(ctx, &vmstate.StateRoot{
Version: vmstate.StateTreeVersion5,
Actors: newHamtRoot,
Info: stateRoot.Info,
})
if err != nil {
return cid.Undef, fmt.Errorf("failed to persist new state root: %w", err)
}

// Persists the new tree and shuts down the flush worker
if err := writeStore.Flush(ctx); err != nil {
return cid.Undef, fmt.Errorf("writeStore flush failed: %w", err)
}

if err := writeStore.Shutdown(ctx); err != nil {
return cid.Undef, fmt.Errorf("writeStore shutdown failed: %w", err)
}

return newRoot, nil
}

func (c *ChainFork) GetForkUpgrade() *config.ForkUpgradeConfig {
return c.forkUpgrade
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/gen/genesis/miners.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (

builtintypes "github.com/filecoin-project/go-state-types/builtin"
minertypes "github.com/filecoin-project/go-state-types/builtin/v8/miner"
miner9 "github.com/filecoin-project/go-state-types/builtin/v9/miner"

"github.com/filecoin-project/venus/venus-shared/actors/builtin/power"
"github.com/filecoin-project/venus/venus-shared/actors/builtin/reward"
Expand Down Expand Up @@ -511,9 +512,10 @@ func SetupStorageMiners(ctx context.Context,
return cid.Undef, fmt.Errorf("getting current total power: %w", err)
}

pcd := types.PreCommitDepositForPower(smoothing9.FilterEstimate(rewardSmoothed), smoothing9.FilterEstimate(*tpow.QualityAdjPowerSmoothed), types.QAPowerMax(m.SectorSize))
pcd := miner9.PreCommitDepositForPower(smoothing9.FilterEstimate(rewardSmoothed),
smoothing9.FilterEstimate(*tpow.QualityAdjPowerSmoothed), types.QAPowerMax(m.SectorSize))

pledge := types.InitialPledgeForPower(
pledge := miner9.InitialPledgeForPower(
sectorWeight,
baselinePower,
smoothing9.FilterEstimate(rewardSmoothed),
Expand Down
2 changes: 1 addition & 1 deletion pkg/state/tree/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func VersionForNetwork(ver network.Version) (StateTreeVersion, error) {
return StateTreeVersion3, nil
case network.Version13, network.Version14, network.Version15, network.Version16, network.Version17:
return StateTreeVersion4, nil
case network.Version18, network.Version19, network.Version20, network.Version21, network.Version22:
case network.Version18, network.Version19, network.Version20, network.Version21, network.Version22, network.Version23:
return StateTreeVersion5, nil
default:
panic(fmt.Sprintf("unsupported network version %d", ver))
Expand Down
Loading
Loading