Skip to content

Commit 52bfd13

Browse files
committed
fix(power15): apply adjustments from review
1 parent ca7f9a4 commit 52bfd13

File tree

3 files changed

+30
-17
lines changed

3 files changed

+30
-17
lines changed

builtin/v15/migration/top.go

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,37 @@ import (
1717
"golang.org/x/xerrors"
1818
)
1919

20-
// MigrateStateTree Migrates the filecoin state tree starting from the global state tree and upgrading all actor state.
20+
// MigrateStateTree migrates the Filecoin state tree starting from the global state tree and upgrading all actor states.
2121
// The store must support concurrent writes (even if the configured worker count is 1).
22-
func MigrateStateTree(ctx context.Context, store cbor.IpldStore, newManifestCID cid.Cid, actorsRootIn cid.Cid, priorEpoch abi.ChainEpoch, cfg migration.Config, log migration.Logger, cache migration.MigrationCache) (cid.Cid, error) {
22+
//
23+
// FIP-0081 constants for the power actor state for pledge calculations that apply only to this migration:
24+
//
25+
// - powerRampStartEpoch: Epoch at which the new pledge calculation starts.
26+
// - powerRampDurationEpochs: Number of epochs over which the new pledge calculation is ramped up.
27+
func MigrateStateTree(
28+
ctx context.Context,
29+
store cbor.IpldStore,
30+
newManifestCID cid.Cid,
31+
actorsRootIn cid.Cid,
32+
priorEpoch abi.ChainEpoch,
33+
powerRampStartEpoch int64,
34+
powerRampDurationEpochs uint64,
35+
cfg migration.Config,
36+
log migration.Logger,
37+
cache migration.MigrationCache,
38+
) (cid.Cid, error) {
2339
if cfg.MaxWorkers <= 0 {
2440
return cid.Undef, xerrors.Errorf("invalid migration config with %d workers", cfg.MaxWorkers)
2541
}
2642

27-
if cfg.PowerRampStartEpoch == 0 {
28-
return cid.Undef, xerrors.Errorf("PowerRampStartEpoch must be set")
43+
if powerRampStartEpoch == 0 {
44+
return cid.Undef, xerrors.Errorf("powerRampStartEpoch must be non-zero")
2945
}
30-
if cfg.PowerRampStartEpoch < 0 {
31-
return cid.Undef, xerrors.Errorf("PowerRampStartEpoch must be non-negative")
46+
if powerRampStartEpoch < 0 {
47+
return cid.Undef, xerrors.Errorf("powerRampStartEpoch must be non-negative")
3248
}
33-
if cfg.PowerRampDurationEpochs == 0 {
34-
return cid.Undef, xerrors.Errorf("PowerRampDurationEpochs must be set")
49+
if powerRampDurationEpochs == 0 {
50+
return cid.Undef, xerrors.Errorf("powerRampDurationEpochs must be non-zero")
3551
}
3652

3753
adtStore := adt15.WrapStore(ctx, store)
@@ -88,7 +104,7 @@ func MigrateStateTree(ctx context.Context, store cbor.IpldStore, newManifestCID
88104
if !ok {
89105
return cid.Undef, xerrors.Errorf("code cid for %s actor not found in new manifest", oldEntry.Name)
90106
}
91-
migrations[oldEntry.Code] = migration.CachedMigration(cache, migration.CodeMigrator{OutCodeCID: newCodeCID})
107+
migrations[oldEntry.Code] = migration.CodeMigrator{OutCodeCID: newCodeCID}
92108
}
93109

94110
// migrations that migrate both code and state, override entries in `migrations`
@@ -111,11 +127,11 @@ func MigrateStateTree(ctx context.Context, store cbor.IpldStore, newManifestCID
111127
return cid.Undef, xerrors.Errorf("code cid for power actor not found in new manifest")
112128
}
113129

114-
pm, err := newPowerMigrator(cfg.PowerRampStartEpoch, cfg.PowerRampDurationEpochs, power15Cid)
130+
pm, err := newPowerMigrator(powerRampStartEpoch, powerRampDurationEpochs, power15Cid)
115131
if err != nil {
116132
return cid.Undef, xerrors.Errorf("failed to create miner migrator: %w", err)
117133
}
118-
migrations[power14Cid] = migration.CachedMigration(cache, *pm)
134+
migrations[power14Cid] = *pm
119135

120136
if len(migrations)+len(deferredCodeIDs) != len(oldManifestData.Entries) {
121137
return cid.Undef, xerrors.Errorf("incomplete migration specification with %d code CIDs, need %d", len(migrations)+len(deferredCodeIDs), len(oldManifestData.Entries))

builtin/v15/miner/monies.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ func PreCommitDepositForPower(rewardEstimate, networkQAPowerEstimate smoothing.F
6666
return ExpectedRewardForPowerClampedAtAttoFIL(rewardEstimate, networkQAPowerEstimate, qaSectorPower, PreCommitDepositProjectionPeriod)
6767
}
6868

69-
// Computes the pledge requirement for committing new quality-adjusted power to the network, given
70-
// the current network total and baseline power, per-epoch reward, and circulating token supply.
69+
// InitialPledgeForPower computes the pledge requirement for committing new quality-adjusted power
70+
// to the network, given the current network total and baseline power, per-epoch reward, and
71+
// circulating token supply.
7172
// The pledge comprises two parts:
7273
// - storage pledge, aka IP base: a multiple of the reward expected to be earned by newly-committed power
7374
// - consensus pledge, aka additional IP: a pro-rata fraction of the circulating money supply

migration/util.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ type Config struct {
8787
ProgressLogPeriod time.Duration
8888
// The epoch at which the upgrade will run.
8989
UpgradeEpoch abi.ChainEpoch
90-
91-
// FIP-0081 constants for the power actor state for pledge calculations.
92-
PowerRampStartEpoch int64 // Epoch at which the new pledge calculation starts.
93-
PowerRampDurationEpochs uint64 // Number of epochs over which the new pledge calculation is ramped up.
9490
}
9591

9692
type Logger interface {

0 commit comments

Comments
 (0)