9
9
adt8 "github.com/filecoin-project/go-state-types/builtin/v8/util/adt"
10
10
market9 "github.com/filecoin-project/go-state-types/builtin/v9/market"
11
11
adt9 "github.com/filecoin-project/go-state-types/builtin/v9/util/adt"
12
+ "github.com/filecoin-project/go-state-types/builtin/v9/verifreg"
12
13
"github.com/ipfs/go-cid"
13
14
typegen "github.com/whyrusleeping/cbor-gen"
14
15
"golang.org/x/xerrors"
@@ -32,9 +33,42 @@ func migrateMarket(ctx context.Context, adtStore adt8.Store, dealAllocationTuple
32
33
return cid .Undef , xerrors .Errorf ("failed to flush pending deal allocations map: %w" , err )
33
34
}
34
35
36
+ dealStates8 , err := adt9 .AsArray (adtStore , marketStateV8 .States , market8 .StatesAmtBitwidth )
37
+ if err != nil {
38
+ return cid .Undef , xerrors .Errorf ("failed to load v8 states array: %w" , err )
39
+ }
40
+
41
+ emptyStatesArrayCid , err := adt9 .StoreEmptyArray (adtStore , market9 .StatesAmtBitwidth )
42
+ if err != nil {
43
+ return cid .Undef , xerrors .Errorf ("failed to create empty states array: %w" , err )
44
+ }
45
+
46
+ dealStates9 , err := adt9 .AsArray (adtStore , emptyStatesArrayCid , market9 .StatesAmtBitwidth )
47
+ if err != nil {
48
+ return cid .Undef , xerrors .Errorf ("failed to load v9 states array: %w" , err )
49
+ }
50
+
51
+ var dealState8 market8.DealState
52
+ err = dealStates8 .ForEach (& dealState8 , func (i int64 ) error {
53
+ return dealStates9 .Set (uint64 (i ), & market9.DealState {
54
+ SectorStartEpoch : dealState8 .SectorStartEpoch ,
55
+ LastUpdatedEpoch : dealState8 .LastUpdatedEpoch ,
56
+ SlashEpoch : dealState8 .SlashEpoch ,
57
+ VerifiedClaim : verifreg .NoAllocationID ,
58
+ })
59
+ })
60
+ if err != nil {
61
+ return cid .Undef , xerrors .Errorf ("failed to iterate over v8 states: %w" , err )
62
+ }
63
+
64
+ dealStates9Root , err := dealStates9 .Root ()
65
+ if err != nil {
66
+ return cid .Undef , xerrors .Errorf ("failed to flush dealStates 9: %w" , err )
67
+ }
68
+
35
69
marketStateV9 := market9.State {
36
70
Proposals : marketStateV8 .Proposals ,
37
- States : marketStateV8 . States ,
71
+ States : dealStates9Root ,
38
72
PendingProposals : marketStateV8 .PendingProposals ,
39
73
EscrowTable : marketStateV8 .EscrowTable ,
40
74
LockedTable : marketStateV8 .LockedTable ,
0 commit comments