Skip to content

Commit

Permalink
fix: null rounds: pass correct timestamp to the FVM.
Browse files Browse the repository at this point in the history
  • Loading branch information
raulk committed Feb 6, 2023
1 parent 3d9c5e7 commit e95b3c5
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions chain/consensus/filcns/compute_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ func (t *TipSetExecutor) ApplyBlocks(ctx context.Context,
}()

ctx = blockstore.WithHotView(ctx)
makeVmWithBaseStateAndEpoch := func(base cid.Cid, e abi.ChainEpoch) (vm.Interface, error) {
makeVm := func(base cid.Cid, e abi.ChainEpoch, timestamp uint64) (vm.Interface, error) {
vmopt := &vm.VMOpts{
StateBase: base,
Epoch: e,
Timestamp: ts.MinTimestamp(),
Timestamp: timestamp,
Rand: r,
Bstore: sm.ChainStore().StateBlockstore(),
Actors: NewActorRegistry(),
Expand Down Expand Up @@ -141,10 +141,22 @@ func (t *TipSetExecutor) ApplyBlocks(ctx context.Context,
return nil
}

// May get filled with the genesis block header if there are null rounds
// for which to backfill cron execution.
var genesis *types.BlockHeader

// There were null rounds in between the current epoch and the parent epoch.
for i := parentEpoch; i < epoch; i++ {
var err error
if i > parentEpoch {
vmCron, err := makeVmWithBaseStateAndEpoch(pstate, i)
if genesis == nil {
var err error
if genesis, err = sm.ChainStore().GetGenesis(ctx); err != nil {
return cid.Undef, cid.Undef, xerrors.Errorf("failed to get genesis when backfilling null rounds: %w", err)
}
}

ts := genesis.Timestamp + build.BlockDelaySecs*(uint64(i+1))
vmCron, err := makeVm(pstate, i, ts)
if err != nil {
return cid.Undef, cid.Undef, xerrors.Errorf("making cron vm: %w", err)
}
Expand All @@ -171,7 +183,7 @@ func (t *TipSetExecutor) ApplyBlocks(ctx context.Context,
partDone()
partDone = metrics.Timer(ctx, metrics.VMApplyMessages)

vmi, err := makeVmWithBaseStateAndEpoch(pstate, epoch)
vmi, err := makeVm(pstate, epoch, ts.MinTimestamp())
if err != nil {
return cid.Undef, cid.Undef, xerrors.Errorf("making vm: %w", err)
}
Expand Down

0 comments on commit e95b3c5

Please sign in to comment.