Skip to content

Commit

Permalink
feat: error if loading the incorrect init actor version
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmahmann committed Jun 23, 2024
1 parent dec8d30 commit 96d8e31
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions state.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import (
"bytes"
"context"
"fmt"
actorstypes "github.com/filecoin-project/go-state-types/actors"
"github.com/filecoin-project/go-state-types/manifest"
"github.com/filecoin-project/lotus/chain/actors"
"sync"
"sync/atomic"

Expand Down Expand Up @@ -202,6 +205,18 @@ func enumInit(ctx context.Context, bg *blockGetter, ts *lchtypes.TipSet, initFun
return err
}

if name, av, ok := actors.GetActorMetaByCode(initActor.Code); ok {
if name != manifest.InitKey {
return xerrors.Errorf("actor code is not init: %s", name)
}

if av != actorstypes.Version13 {
return xerrors.Errorf(
"the application is out of date with the network, please update to a later version," +
" or if this is the latest version file an issue to update the init actor version")
}
}

var initRoot _init13.State
// Try loading as a new-style state-tree (version/actors tuple).
if err := ast.Get(ctx, initActor.Head, &initRoot); err != nil {
Expand Down

0 comments on commit 96d8e31

Please sign in to comment.