Skip to content

Commit

Permalink
Merge pull request #4114 from filecoin-project/fix/fork-after-cron
Browse files Browse the repository at this point in the history
Run fork function after cron for null block safety
  • Loading branch information
arajasek authored Oct 3, 2020
2 parents bd964b4 + fecc1ee commit 4631cee
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions chain/stmgr/stmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,18 @@ func (sm *StateManager) ApplyBlocks(ctx context.Context, parentEpoch abi.ChainEp
}

for i := parentEpoch; i < epoch; i++ {
if i > parentEpoch {
// run cron for null rounds if any
if err := runCron(); err != nil {
return cid.Undef, cid.Undef, err
}

pstate, err = vmi.Flush(ctx)
if err != nil {
return cid.Undef, cid.Undef, xerrors.Errorf("flushing vm: %w", err)
}
}

// handle state forks
// XXX: The state tree
newState, err := sm.handleStateForks(ctx, pstate, i, cb, ts)
Expand All @@ -223,18 +235,6 @@ func (sm *StateManager) ApplyBlocks(ctx context.Context, parentEpoch abi.ChainEp
}
}

if i > parentEpoch {
// run cron for null rounds if any
if err := runCron(); err != nil {
return cid.Cid{}, cid.Cid{}, err
}

newState, err = vmi.Flush(ctx)
if err != nil {
return cid.Undef, cid.Undef, xerrors.Errorf("flushing vm: %w", err)
}
}

vmi.SetBlockHeight(i + 1)
pstate = newState
}
Expand Down

0 comments on commit 4631cee

Please sign in to comment.