From 8091bb3117366874fcd58059198fb13adf79f970 Mon Sep 17 00:00:00 2001 From: ZenGround0 Date: Wed, 30 Sep 2020 16:54:30 -0400 Subject: [PATCH 1/2] Run fork function after cron --- chain/stmgr/stmgr.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/chain/stmgr/stmgr.go b/chain/stmgr/stmgr.go index e800ce66597..b9810fab92e 100644 --- a/chain/stmgr/stmgr.go +++ b/chain/stmgr/stmgr.go @@ -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.Cid{}, cid.Cid{}, 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) @@ -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 } From fecc1ee0ef135352c3079c2ef1fe5f7ec355079f Mon Sep 17 00:00:00 2001 From: ZenGround0 Date: Fri, 2 Oct 2020 17:12:12 -0400 Subject: [PATCH 2/2] Review cleanup --- chain/stmgr/stmgr.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chain/stmgr/stmgr.go b/chain/stmgr/stmgr.go index b9810fab92e..90e43ebbcf9 100644 --- a/chain/stmgr/stmgr.go +++ b/chain/stmgr/stmgr.go @@ -212,7 +212,7 @@ 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 + return cid.Undef, cid.Undef, err } pstate, err = vmi.Flush(ctx)