From 832e204ec4fd48758d88bfae080793a562e1218a Mon Sep 17 00:00:00 2001 From: Aayush Rajasekaran Date: Wed, 5 Jan 2022 13:52:51 -0500 Subject: [PATCH] Fix circsuypply calc around null blocks --- chain/consensus/filcns/compute_state.go | 5 ++++- chain/vm/vm.go | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/chain/consensus/filcns/compute_state.go b/chain/consensus/filcns/compute_state.go index 847d41d47..63d4e5d3d 100644 --- a/chain/consensus/filcns/compute_state.go +++ b/chain/consensus/filcns/compute_state.go @@ -169,7 +169,10 @@ func (t *TipSetExecutor) ApplyBlocks(ctx context.Context, sm *stmgr.StateManager } } - vmi.SetBlockHeight(i + 1) + if err = vmi.SetBlockHeight(ctx, i+1); err != nil { + return cid.Undef, cid.Undef, xerrors.Errorf("error advancing vm an epoch: %w", err) + } + pstate = newState } diff --git a/chain/vm/vm.go b/chain/vm/vm.go index d569dbbbf..f1823858f 100644 --- a/chain/vm/vm.go +++ b/chain/vm/vm.go @@ -827,8 +827,15 @@ func (vm *VM) StateTree() types.StateTree { return vm.cstate } -func (vm *VM) SetBlockHeight(h abi.ChainEpoch) { +func (vm *VM) SetBlockHeight(ctx context.Context, h abi.ChainEpoch) error { vm.blockHeight = h + ncirc, err := vm.circSupplyCalc(ctx, vm.blockHeight, vm.cstate) + if err != nil { + return err + } + + vm.baseCircSupply = ncirc + return nil } func (vm *VM) Invoke(act *types.Actor, rt *Runtime, method abi.MethodNum, params []byte) ([]byte, aerrors.ActorError) {