Skip to content

Commit

Permalink
feat(fip0081): implement pledge calc change + ramp w/ migration test
Browse files Browse the repository at this point in the history
Closes: #12494
  • Loading branch information
rvagg committed Oct 3, 2024
1 parent 8eb3534 commit 49d6c8a
Show file tree
Hide file tree
Showing 51 changed files with 604 additions and 71 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Add `EthGetBlockReceipts` RPC method to retrieve transaction receipts for a spec
* [Checkpoint TipSets finalized by F3](https://github.com/filecoin-project/lotus/pull/12460): Once a decision is made by F3, the TipSet is check-pointed in `ChainStore`. As part of this change, any missing TipSets are asynchronously synced as required by the `ChainStore` checkpointing mechanism.
* Add an environment variable, `F3_INITIAL_POWERTABLE_CID` to allow specifying the initial power table used by F3 ([filecoin-project/lotus#12502](https://github.com/filecoin-project/lotus/pull/12502)). This may be used to help a lotus node re-sync the F3 chain when syncing from a snapshot after the F3 upgrade epoch. The precise CID to use here won't be known until the F3 is officially "live".
* Added `StateMinerInitialPledgeForSector` RPC method and deprecated existing `StateMinerInitialPledgeCollateral` method. Since ProveCommitSectors3 and ProveReplicaUpdates3, sector onboarding no longer includes an explicit notion of "deals", and precommit messages no longer contain deal information. This makes the existing `StateMinerInitialPledgeCollateral` unable to properly calculate pledge requirements with only the precommit. `StateMinerInitialPledgeForSector` is a new simplified calculator that simply takes duration, sector size, and verified size and estimates pledge based on current network conditions. Please note that the `StateMinerInitialPledgeCollateral` method will be removed entirely in the next non-patch release. ([filecoin-project/lotus#12384](https://github.com/filecoin-project/lotus/pull/12384)
* Implement [FIP-0081](https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0081.md) and its migration for NV24. Initial pledge collateral will now be calculated using a 70% / 30% split between "simple" and "baseline" in the initial consensus pledge contribution to collateral calculation. The change in this calculation will begin at NV24 activation and ramp up from the current split of 100% / 0% to the eventual 70% / 30% over the course of a year so as to minimise impact on existing operations. ([filecoin-project/lotus#12526](https://github.com/filecoin-project/lotus/pull/12526)

## Improvements

Expand Down
5 changes: 5 additions & 0 deletions build/buildconstants/params_2k.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ var UpgradeWaffleHeight = abi.ChainEpoch(-26)

var UpgradeTuktukHeight = abi.ChainEpoch(200)

// FIP-0081: for the power actor state for pledge calculations.
// UpgradeTuktukPowerRampDurationEpochs ends up in the power actor state after
// Tuktuk migration. along with a RampStartEpoch matching the upgrade height.
var UpgradeTuktukPowerRampDurationEpochs uint64 = 200

// This fix upgrade only ran on calibrationnet
const UpgradeWatermelonFixHeight = -100

Expand Down
7 changes: 7 additions & 0 deletions build/buildconstants/params_butterfly.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/abi"
"github.com/filecoin-project/go-state-types/network"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"

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

var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
Expand Down Expand Up @@ -58,6 +60,11 @@ const UpgradeWaffleHeight = -27
// ??????
const UpgradeTuktukHeight = 999999999999999

// FIP-0081: for the power actor state for pledge calculations.
// UpgradeTuktukPowerRampDurationEpochs ends up in the power actor state after
// Tuktuk migration. along with a RampStartEpoch matching the upgrade height.
var UpgradeTuktukPowerRampDurationEpochs = uint64(builtin.EpochsInYear)

// This fix upgrade only ran on calibrationnet
const UpgradeWatermelonFixHeight = -100

Expand Down
10 changes: 10 additions & 0 deletions build/buildconstants/params_calibnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/network"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"

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

var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
Expand Down Expand Up @@ -100,6 +102,14 @@ const UpgradeWaffleHeight = 1779094
// ??????
const UpgradeTuktukHeight = 999999999999999

// FIP-0081: for the power actor state for pledge calculations.
// UpgradeTuktukPowerRampDurationEpochs ends up in the power actor state after
// Tuktuk migration. along with a RampStartEpoch matching the upgrade height.
//
// For calibrationnet, we set this to 3 days so we can observe and confirm the
// ramp behavior before mainnet upgrade.
var UpgradeTuktukPowerRampDurationEpochs = uint64(builtin.EpochsInDay * 3)

var SupportedProofTypes = []abi.RegisteredSealProof{
abi.RegisteredSealProof_StackedDrg32GiBV1,
abi.RegisteredSealProof_StackedDrg64GiBV1,
Expand Down
7 changes: 7 additions & 0 deletions build/buildconstants/params_interop.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/network"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"

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

var NetworkBundle = "caterpillarnet"
Expand Down Expand Up @@ -56,6 +58,11 @@ var UpgradeWaffleHeight = abi.ChainEpoch(-27)

const UpgradeTuktukHeight = 50

// FIP-0081: for the power actor state for pledge calculations.
// UpgradeTuktukPowerRampDurationEpochs ends up in the power actor state after
// Tuktuk migration. along with a RampStartEpoch matching the upgrade height.
var UpgradeTuktukPowerRampDurationEpochs = uint64(builtin.EpochsInYear)

// This fix upgrade only ran on calibrationnet
const UpgradeWatermelonFixHeight = -1

Expand Down
9 changes: 8 additions & 1 deletion build/buildconstants/params_mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/network"
builtin2 "github.com/filecoin-project/specs-actors/v2/actors/builtin"

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

var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
Expand Down Expand Up @@ -110,6 +112,11 @@ const UpgradeWaffleHeight abi.ChainEpoch = 4154640
// ??????
var UpgradeTuktukHeight = abi.ChainEpoch(9999999999)

// FIP-0081: for the power actor state for pledge calculations.
// UpgradeTuktukPowerRampDurationEpochs ends up in the power actor state after
// Tuktuk migration. along with a RampStartEpoch matching the upgrade height.
var UpgradeTuktukPowerRampDurationEpochs = uint64(builtin.EpochsInYear)

// This fix upgrade only ran on calibrationnet
const UpgradeWatermelonFixHeight abi.ChainEpoch = -1

Expand Down Expand Up @@ -174,7 +181,7 @@ var WhitelistedBlock = cid.MustParse("bafy2bzaceapyg2uyzk7vueh3xccxkuwbz3nxewjyg
var F3ManifestServerID = MustParseID("12D3KooWENMwUF9YxvQxar7uBWJtZkA6amvK4xWmKXfSiHUo2Qq7")

// The initial F3 power table CID.
var F3InitialPowerTableCID cid.Cid = cid.Undef
var F3InitialPowerTableCID = cid.Undef

const F3Enabled = true
const F3BootstrapEpoch abi.ChainEpoch = -1
Expand Down
2 changes: 2 additions & 0 deletions build/buildconstants/params_testground.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ var (
UpgradeWaffleHeight abi.ChainEpoch = -29
UpgradeTuktukHeight abi.ChainEpoch = -30

UpgradeTuktukPowerRampDurationEpochs uint64 = 0

DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
UpgradePhoenixHeight: DrandQuicknet,
Expand Down
1 change: 1 addition & 0 deletions chain/actors/builtin/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var (
const (
EpochDurationSeconds = builtin.EpochDurationSeconds
EpochsInDay = builtin.EpochsInDay
EpochsInYear = builtin.EpochsInYear
SecondsInDay = builtin.SecondsInDay
)

Expand Down
1 change: 1 addition & 0 deletions chain/actors/builtin/builtin.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var (
const (
EpochDurationSeconds = builtin.EpochDurationSeconds
EpochsInDay = builtin.EpochsInDay
EpochsInYear = builtin.EpochsInYear
SecondsInDay = builtin.SecondsInDay
)

Expand Down
12 changes: 12 additions & 0 deletions chain/actors/builtin/power/actor.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ type State interface {
// MinerCounts returns the number of miners. Participating is the number
// with power above the minimum miner threshold.
MinerCounts() (participating, total uint64, err error)
// RampStartEpoch returns the epoch at which the FIP0081 pledge calculation
// change begins. At and before RampStartEpoch, we use the old calculation. At
// RampStartEpoch + RampDurationEpochs, we use 70% old rules + 30% new
// calculation.
//
// This method always returns 0 prior to actors version 15.
RampStartEpoch() int64
// RampDurationEpochs returns the number of epochs over which the new FIP0081
// pledge calculation is ramped up.
//
// This method always returns 0 prior to actors version 15.
RampDurationEpochs() uint64
MinerPower(address.Address) (Claim, bool, error)
MinerNominalPowerMeetsConsensusMinimum(address.Address) (bool, error)
ListAllMiners() ([]address.Address, error)
Expand Down
12 changes: 12 additions & 0 deletions chain/actors/builtin/power/power.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ type State interface {
// MinerCounts returns the number of miners. Participating is the number
// with power above the minimum miner threshold.
MinerCounts() (participating, total uint64, err error)
// RampStartEpoch returns the epoch at which the FIP0081 pledge calculation
// change begins. At and before RampStartEpoch, we use the old calculation. At
// RampStartEpoch + RampDurationEpochs, we use 70% old rules + 30% new
// calculation.
//
// This method always returns 0 prior to actors version 15.
RampStartEpoch() int64
// RampDurationEpochs returns the number of epochs over which the new FIP0081
// pledge calculation is ramped up.
//
// This method always returns 0 prior to actors version 15.
RampDurationEpochs() uint64
MinerPower(address.Address) (Claim, bool, error)
MinerNominalPowerMeetsConsensusMinimum(address.Address) (bool, error)
ListAllMiners() ([]address.Address, error)
Expand Down
8 changes: 8 additions & 0 deletions chain/actors/builtin/power/state.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ func (s *state{{.v}}) MinerCounts() (uint64, uint64, error) {
return uint64(s.State.MinerAboveMinPowerCount), uint64(s.State.MinerCount), nil
}

func (s *state{{.v}}) RampStartEpoch() int64 {
return {{if (ge .v 15)}}s.State.RampStartEpoch{{else}}0{{end}}
}

func (s *state{{.v}}) RampDurationEpochs() uint64 {
return {{if (ge .v 15)}}s.State.RampDurationEpochs{{else}}0{{end}}
}

func (s *state{{.v}}) ListAllMiners() ([]address.Address, error) {
claims, err := s.claims()
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions chain/actors/builtin/power/v0.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions chain/actors/builtin/power/v10.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions chain/actors/builtin/power/v11.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions chain/actors/builtin/power/v12.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions chain/actors/builtin/power/v13.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions chain/actors/builtin/power/v14.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions chain/actors/builtin/power/v15.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions chain/actors/builtin/power/v2.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions chain/actors/builtin/power/v3.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions chain/actors/builtin/power/v4.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions chain/actors/builtin/power/v5.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions chain/actors/builtin/power/v6.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions chain/actors/builtin/power/v7.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 49d6c8a

Please sign in to comment.