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 {
start uint64
start uint64
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()

View File

@ -3,15 +3,21 @@ package stmgr
import (
"context"
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/build"
)
func (sm *StateManager) handleStateForks(ctx context.Context, pstate cid.Cid, height uint64) (cid.Cid, error) {
switch height {
case build.ForkNoPowerEPSUpdates: // TODO: +1?
return sm.forkNoPowerEPS(ctx, pstate)
default:
return pstate, nil
func (sm *StateManager) handleStateForks(ctx context.Context, pstate cid.Cid, height, parentH uint64) (_ cid.Cid, err error) {
for i := parentH; i < height; i++ {
switch i {
case build.ForkNoPowerEPSUpdates:
pstate, err = sm.forkNoPowerEPS(ctx, pstate)
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)
if err != nil {
return cid.Undef, cid.Undef, xerrors.Errorf("error handling state forks: %w", err)
pstate := blks[0].ParentStateRoot
if len(blks[0].Parents) > 0 { // don't support forks on genesis
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))