handle state forks in gas estimation

This commit is contained in:
Steven Allen 2020-09-30 15:51:11 -07:00
parent 9705b25bbd
commit 47a83b422e

View File

@ -28,14 +28,10 @@ func (sm *StateManager) Call(ctx context.Context, msg *types.Message, ts *types.
bstate := ts.ParentState() bstate := ts.ParentState()
bheight := ts.Height() 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 { 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{ vmopt := &vm.VMOpts{
StateBase: bstate, 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) 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()) r := store.NewChainRand(sm.cs, ts.Cids())
if span.IsRecordingEvents() { if span.IsRecordingEvents() {