From 72946f5371f820d7bbd5cc3137efb14c9f0eda56 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 10 Feb 2023 09:22:39 -0800 Subject: [PATCH] fix: stmgr: only apply tipset messages for CallWithGas --- chain/stmgr/call.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/chain/stmgr/call.go b/chain/stmgr/call.go index cb5fe6af69a..ea2758705fa 100644 --- a/chain/stmgr/call.go +++ b/chain/stmgr/call.go @@ -44,12 +44,12 @@ func (sm *StateManager) Call(ctx context.Context, msg *types.Message, ts *types. msg.Value = types.NewInt(0) } - return sm.callInternal(ctx, msg, nil, ts, cid.Undef, sm.GetNetworkVersion, false) + return sm.callInternal(ctx, msg, nil, ts, cid.Undef, sm.GetNetworkVersion, false, false) } // CallWithGas calculates the state for a given tipset, and then applies the given message on top of that state. func (sm *StateManager) CallWithGas(ctx context.Context, msg *types.Message, priorMsgs []types.ChainMsg, ts *types.TipSet) (*api.InvocResult, error) { - return sm.callInternal(ctx, msg, priorMsgs, ts, cid.Undef, sm.GetNetworkVersion, true) + return sm.callInternal(ctx, msg, priorMsgs, ts, cid.Undef, sm.GetNetworkVersion, true, true) } // CallAtStateAndVersion allows you to specify a message to execute on the given stateCid and network version. @@ -61,13 +61,13 @@ func (sm *StateManager) CallAtStateAndVersion(ctx context.Context, msg *types.Me return v } - return sm.callInternal(ctx, msg, nil, nil, stateCid, nvGetter, true) + return sm.callInternal(ctx, msg, nil, nil, stateCid, nvGetter, true, false) } // - If no tipset is specified, the first tipset without an expensive migration or one in its parent is used. // - If executing a message at a given tipset or its parent would trigger an expensive migration, the call will // fail with ErrExpensiveFork. -func (sm *StateManager) callInternal(ctx context.Context, msg *types.Message, priorMsgs []types.ChainMsg, ts *types.TipSet, stateCid cid.Cid, nvGetter rand.NetworkVersionGetter, checkGas bool) (*api.InvocResult, error) { +func (sm *StateManager) callInternal(ctx context.Context, msg *types.Message, priorMsgs []types.ChainMsg, ts *types.TipSet, stateCid cid.Cid, nvGetter rand.NetworkVersionGetter, checkGas, applyTsMessages bool) (*api.InvocResult, error) { ctx, span := trace.StartSpan(ctx, "statemanager.callInternal") defer span.End() @@ -112,6 +112,8 @@ func (sm *StateManager) callInternal(ctx context.Context, msg *types.Message, pr // don't want to apply miner messages after cron runs in a given epoch. if stateCid == cid.Undef { stateCid = ts.ParentState() + } + if applyTsMessages { tsMsgs, err := sm.cs.MessagesForTipset(ctx, ts) if err != nil { return nil, xerrors.Errorf("failed to lookup messages for parent tipset: %w", err)