Care about nullblocks in handleStateForks

This commit is contained in:
Łukasz Magiera 2019-12-19 21:00:59 +01:00
parent d21e24c270
commit 6ce4cf12f7
3 changed files with 26 additions and 12 deletions

View File

@ -9,7 +9,7 @@ import (
) )
type update struct { type update struct {
start uint64 start uint64
method interface{} method interface{}
} }
@ -31,7 +31,7 @@ func withUpdates(updates ...update) interface{} {
} }
} }
return reflect.ValueOf(notFound(vmctx)).Call([]reflect.Value{}) return reflect.ValueOf(notFound(vmctx)).Call([]reflect.Value{args[1]})
}) })
return out.Interface() return out.Interface()

View File

@ -3,15 +3,21 @@ package stmgr
import ( import (
"context" "context"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/build"
) )
func (sm *StateManager) handleStateForks(ctx context.Context, pstate cid.Cid, height uint64) (cid.Cid, error) { func (sm *StateManager) handleStateForks(ctx context.Context, pstate cid.Cid, height, parentH uint64) (_ cid.Cid, err error) {
switch height { for i := parentH; i < height; i++ {
case build.ForkNoPowerEPSUpdates: // TODO: +1? switch i {
return sm.forkNoPowerEPS(ctx, pstate) case build.ForkNoPowerEPSUpdates:
default: pstate, err = sm.forkNoPowerEPS(ctx, pstate)
return pstate, nil if err != nil {
return cid.Undef, xerrors.Errorf("executing state fork in epoch %d: %w", i, err)
}
}
} }
return pstate, nil
} }

View File

@ -119,9 +119,17 @@ func (sm *StateManager) computeTipSetState(ctx context.Context, blks []*types.Bl
} }
} }
pstate, err := sm.handleStateForks(ctx, blks[0].ParentStateRoot, blks[0].Height) pstate := blks[0].ParentStateRoot
if err != nil { if len(blks[0].Parents) > 0 { // don't support forks on genesis
return cid.Undef, cid.Undef, xerrors.Errorf("error handling state forks: %w", err) parent, err := sm.cs.GetBlock(blks[0].Parents[0])
if err != nil {
return cid.Undef, cid.Undef, xerrors.Errorf("getting parent block: %w", err)
}
pstate, err = sm.handleStateForks(ctx, blks[0].ParentStateRoot, blks[0].Height, parent.Height)
if err != nil {
return cid.Undef, cid.Undef, xerrors.Errorf("error handling state forks: %w", err)
}
} }
cids := make([]cid.Cid, len(blks)) cids := make([]cid.Cid, len(blks))