Skip to content

Commit

Permalink
land all nv23 changes in master (#277)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
4 people authored Jun 24, 2024
1 parent cf50ca0 commit ac405c3
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion builtin/v14/migration/top.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import (
adt14 "github.com/filecoin-project/go-state-types/builtin/v14/util/adt"

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

"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/builtin"
"github.com/filecoin-project/go-state-types/manifest"
"github.com/filecoin-project/go-state-types/migration"

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

// The System Actor

newSystemCodeCID, ok := newManifest.Get(manifest.SystemKey)
if !ok {
return cid.Undef, xerrors.Errorf("code cid for system actor not found in new manifest")
Expand All @@ -95,6 +96,46 @@ func MigrateStateTree(ctx context.Context, store cbor.IpldStore, newManifestCID
return cid.Undef, xerrors.Errorf("failed to run migration: %w", err)
}

// FIP 0085. f090 multisig => unkeyed account actor
// Account state now points to id address requiring upgrade to release funds
f090Migration := func(actors *builtin.ActorTree) error {
f090ID, err := address.NewIDAddress(90)
if err != nil {
return xerrors.Errorf("failed to construct f090 id addr: %w", err)
}
f090OldAct, found, err := actorsOut.GetActorV5(f090ID)
if err != nil {
return xerrors.Errorf("failed to get old f090 actor: %w", err)
}
if !found {
return xerrors.Errorf("failed to find old f090 actor: %w", err)
}
f090NewSt := account14.State{Address: f090ID} // State points to ID addr
h, err := actors.Store.Put(ctx, &f090NewSt)
if err != nil {
return xerrors.Errorf("failed to write new f090 state: %w", err)
}

newAccountCodeCID, ok := newManifest.Get(manifest.AccountKey)
if !ok {
return xerrors.Errorf("invalid manifest missing account code cid")
}

return actorsOut.SetActorV5(f090ID, &builtin.ActorV5{
// unchanged
CallSeqNum: f090OldAct.CallSeqNum,
Balance: f090OldAct.Balance,
Address: f090OldAct.Address,

// changed
Code: newAccountCodeCID,
Head: h,
})
}
if err := f090Migration(actorsOut); err != nil {
return cid.Undef, err
}

outCid, err := actorsOut.Flush()
if err != nil {
return cid.Undef, xerrors.Errorf("failed to flush actorsOut: %w", err)
Expand Down

0 comments on commit ac405c3

Please sign in to comment.