From 47a83b422e3500714dea2445123a05133a57322b Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 30 Sep 2020 15:51:11 -0700 Subject: [PATCH] handle state forks in gas estimation --- chain/stmgr/call.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/chain/stmgr/call.go b/chain/stmgr/call.go index 2f049cae3..15cbac53e 100644 --- a/chain/stmgr/call.go +++ b/chain/stmgr/call.go @@ -28,14 +28,10 @@ func (sm *StateManager) Call(ctx context.Context, msg *types.Message, ts *types. bstate := ts.ParentState() bheight := ts.Height() - newState, err := sm.handleStateForks(ctx, bstate, bheight-1, nil, ts) + bstate, err := sm.handleStateForks(ctx, bstate, bheight-1, nil, ts) if err != nil { - return nil, fmt.Errorf("failed to handle fork") + return nil, fmt.Errorf("failed to handle fork: %w", err) } - if newState != bstate { - fmt.Println("IT WORKED!") - } - bstate = newState vmopt := &vm.VMOpts{ StateBase: bstate, @@ -117,6 +113,11 @@ func (sm *StateManager) CallWithGas(ctx context.Context, msg *types.Message, pri return nil, xerrors.Errorf("computing tipset state: %w", err) } + state, err = sm.handleStateForks(ctx, state, ts.Height(), nil, ts) + if err != nil { + return nil, fmt.Errorf("failed to handle fork: %w", err) + } + r := store.NewChainRand(sm.cs, ts.Cids()) if span.IsRecordingEvents() {