This repository has been archived by the owner on Jun 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement nv16 migration according to FIP31 (#1583)
* actor manifest data structure and cbor marshaler/unmarshaler * implement manifest.Load * system actor v8 state * implement nv16 migration * make gen * check manifest version when loading * move system actor migration to its own file * fix system actor state for tests * update determinism check sum * lint * initialize system actor state to undefined * fix migration tests * lint * fix migrated code cids so that state is checkable * initialize system actor with empty state * properly initialize system actor state in test vm * make determinism-gen * document builtina actors data type * add comment about manifest data being in the blockstore * kill space * keep deferredCodeCids structure around * make test nv16 specific * normalize system actor state construction * follow the pattern in testing vm construction * fix lint
- Loading branch information
Showing
14 changed files
with
575 additions
and
288 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package manifest | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
adt8 "github.com/filecoin-project/specs-actors/v8/actors/util/adt" | ||
|
||
"github.com/ipfs/go-cid" | ||
) | ||
|
||
type Manifest struct { | ||
Version uint64 // this is really u32, but cbor-gen can't deal with it | ||
Data cid.Cid | ||
|
||
entries map[string]cid.Cid | ||
} | ||
|
||
type ManifestEntry struct { | ||
Name string | ||
Code cid.Cid | ||
} | ||
|
||
type ManifestData struct { | ||
Entries []ManifestEntry | ||
} | ||
|
||
func (m *Manifest) Load(ctx context.Context, store adt8.Store) error { | ||
if m.Version != 1 { | ||
return fmt.Errorf("unknown manifest version %d", m.Version) | ||
} | ||
|
||
data := ManifestData{} | ||
if err := store.Get(ctx, m.Data, &data); err != nil { | ||
return err | ||
} | ||
|
||
m.entries = make(map[string]cid.Cid) | ||
for _, e := range data.Entries { | ||
m.entries[e.Name] = e.Code | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (m *Manifest) Get(name string) (cid.Cid, bool) { | ||
c, ok := m.entries[name] | ||
return c, ok | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package system | ||
|
||
import ( | ||
"context" | ||
|
||
cid "github.com/ipfs/go-cid" | ||
xerrors "golang.org/x/xerrors" | ||
|
||
"github.com/filecoin-project/specs-actors/v8/actors/builtin/manifest" | ||
"github.com/filecoin-project/specs-actors/v8/actors/util/adt" | ||
) | ||
|
||
type State struct { | ||
BuiltinActors cid.Cid // ManifestData | ||
} | ||
|
||
func ConstructState(store adt.Store) (*State, error) { | ||
empty, err := store.Put(context.TODO(), &manifest.ManifestData{}) | ||
if err != nil { | ||
return nil, xerrors.Errorf("failed to create empty manifest: %w", err) | ||
} | ||
|
||
return &State{BuiltinActors: empty}, nil | ||
} |
Oops, something went wrong.