@@ -17,21 +17,37 @@ import (
17
17
"golang.org/x/xerrors"
18
18
)
19
19
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 .
21
21
// 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 ) {
23
39
if cfg .MaxWorkers <= 0 {
24
40
return cid .Undef , xerrors .Errorf ("invalid migration config with %d workers" , cfg .MaxWorkers )
25
41
}
26
42
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 " )
29
45
}
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" )
32
48
}
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 " )
35
51
}
36
52
37
53
adtStore := adt15 .WrapStore (ctx , store )
@@ -88,7 +104,7 @@ func MigrateStateTree(ctx context.Context, store cbor.IpldStore, newManifestCID
88
104
if ! ok {
89
105
return cid .Undef , xerrors .Errorf ("code cid for %s actor not found in new manifest" , oldEntry .Name )
90
106
}
91
- migrations [oldEntry .Code ] = migration .CachedMigration ( cache , migration. CodeMigrator {OutCodeCID : newCodeCID })
107
+ migrations [oldEntry .Code ] = migration.CodeMigrator {OutCodeCID : newCodeCID }
92
108
}
93
109
94
110
// migrations that migrate both code and state, override entries in `migrations`
@@ -111,11 +127,11 @@ func MigrateStateTree(ctx context.Context, store cbor.IpldStore, newManifestCID
111
127
return cid .Undef , xerrors .Errorf ("code cid for power actor not found in new manifest" )
112
128
}
113
129
114
- pm , err := newPowerMigrator (cfg . PowerRampStartEpoch , cfg . PowerRampDurationEpochs , power15Cid )
130
+ pm , err := newPowerMigrator (powerRampStartEpoch , powerRampDurationEpochs , power15Cid )
115
131
if err != nil {
116
132
return cid .Undef , xerrors .Errorf ("failed to create miner migrator: %w" , err )
117
133
}
118
- migrations [power14Cid ] = migration . CachedMigration ( cache , * pm )
134
+ migrations [power14Cid ] = * pm
119
135
120
136
if len (migrations )+ len (deferredCodeIDs ) != len (oldManifestData .Entries ) {
121
137
return cid .Undef , xerrors .Errorf ("incomplete migration specification with %d code CIDs, need %d" , len (migrations )+ len (deferredCodeIDs ), len (oldManifestData .Entries ))
0 commit comments