Skip to content

Commit ac405c3

Browse files
jennijujuZenGround0rvagg
authored
land all nv23 changes in master (#277)
* Migrate f090 to safety (#259) * Migrate f090 to safety * Cleanup * Lint --------- Co-authored-by: zenground0 <[email protected]> * fix: propagate errors on migration (#264) * fix: use adtStore instead of plain Store to write new state (#265) * fix: put a pointer to the store for marshalability (#266) --------- Co-authored-by: ZenGround0 <[email protected]> Co-authored-by: zenground0 <[email protected]> Co-authored-by: Rod Vagg <[email protected]>
1 parent cf50ca0 commit ac405c3

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

builtin/v14/migration/top.go

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import (
66
adt14 "github.com/filecoin-project/go-state-types/builtin/v14/util/adt"
77

88
system13 "github.com/filecoin-project/go-state-types/builtin/v13/system"
9+
account14 "github.com/filecoin-project/go-state-types/builtin/v14/account"
910

1011
"github.com/filecoin-project/go-state-types/abi"
1112
"github.com/filecoin-project/go-state-types/builtin"
1213
"github.com/filecoin-project/go-state-types/manifest"
1314
"github.com/filecoin-project/go-state-types/migration"
1415

16+
"github.com/filecoin-project/go-address"
1517
"github.com/ipfs/go-cid"
1618
cbor "github.com/ipfs/go-ipld-cbor"
1719
"golang.org/x/xerrors"
@@ -78,7 +80,6 @@ func MigrateStateTree(ctx context.Context, store cbor.IpldStore, newManifestCID
7880
// migrations that migrate both code and state, override entries in `migrations`
7981

8082
// The System Actor
81-
8283
newSystemCodeCID, ok := newManifest.Get(manifest.SystemKey)
8384
if !ok {
8485
return cid.Undef, xerrors.Errorf("code cid for system actor not found in new manifest")
@@ -95,6 +96,46 @@ func MigrateStateTree(ctx context.Context, store cbor.IpldStore, newManifestCID
9596
return cid.Undef, xerrors.Errorf("failed to run migration: %w", err)
9697
}
9798

99+
// FIP 0085. f090 multisig => unkeyed account actor
100+
// Account state now points to id address requiring upgrade to release funds
101+
f090Migration := func(actors *builtin.ActorTree) error {
102+
f090ID, err := address.NewIDAddress(90)
103+
if err != nil {
104+
return xerrors.Errorf("failed to construct f090 id addr: %w", err)
105+
}
106+
f090OldAct, found, err := actorsOut.GetActorV5(f090ID)
107+
if err != nil {
108+
return xerrors.Errorf("failed to get old f090 actor: %w", err)
109+
}
110+
if !found {
111+
return xerrors.Errorf("failed to find old f090 actor: %w", err)
112+
}
113+
f090NewSt := account14.State{Address: f090ID} // State points to ID addr
114+
h, err := actors.Store.Put(ctx, &f090NewSt)
115+
if err != nil {
116+
return xerrors.Errorf("failed to write new f090 state: %w", err)
117+
}
118+
119+
newAccountCodeCID, ok := newManifest.Get(manifest.AccountKey)
120+
if !ok {
121+
return xerrors.Errorf("invalid manifest missing account code cid")
122+
}
123+
124+
return actorsOut.SetActorV5(f090ID, &builtin.ActorV5{
125+
// unchanged
126+
CallSeqNum: f090OldAct.CallSeqNum,
127+
Balance: f090OldAct.Balance,
128+
Address: f090OldAct.Address,
129+
130+
// changed
131+
Code: newAccountCodeCID,
132+
Head: h,
133+
})
134+
}
135+
if err := f090Migration(actorsOut); err != nil {
136+
return cid.Undef, err
137+
}
138+
98139
outCid, err := actorsOut.Flush()
99140
if err != nil {
100141
return cid.Undef, xerrors.Errorf("failed to flush actorsOut: %w", err)

0 commit comments

Comments
 (0)