From 94438bf3cdc99d3290cde3fad41af825b753c85f Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 5 Nov 2020 21:14:38 +0100 Subject: [PATCH] Use TSK passed to GasEstimateGasLimit Signed-off-by: Jakub Sztandera --- node/impl/full/gas.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/node/impl/full/gas.go b/node/impl/full/gas.go index 5d21121ee14..13c344599d2 100644 --- a/node/impl/full/gas.go +++ b/node/impl/full/gas.go @@ -192,11 +192,19 @@ func gasEstimateGasPremium(cstore *store.ChainStore, nblocksincl uint64) (types. return premium, nil } -func (a *GasAPI) GasEstimateGasLimit(ctx context.Context, msgIn *types.Message, _ types.TipSetKey) (int64, error) { - return gasEstimateGasLimit(ctx, a.Chain, a.Stmgr, a.Mpool, msgIn) +func (a *GasAPI) GasEstimateGasLimit(ctx context.Context, msgIn *types.Message, tsk types.TipSetKey) (int64, error) { + ts, err := a.Chain.GetTipSetFromKey(tsk) + if err != nil { + return -1, xerrors.Errorf("getting tipset: %w", err) + } + return gasEstimateGasLimit(ctx, a.Chain, a.Stmgr, a.Mpool, msgIn, ts) } -func (m *GasModule) GasEstimateGasLimit(ctx context.Context, msgIn *types.Message, _ types.TipSetKey) (int64, error) { - return gasEstimateGasLimit(ctx, m.Chain, m.Stmgr, m.Mpool, msgIn) +func (m *GasModule) GasEstimateGasLimit(ctx context.Context, msgIn *types.Message, tsk types.TipSetKey) (int64, error) { + ts, err := m.Chain.GetTipSetFromKey(tsk) + if err != nil { + return -1, xerrors.Errorf("getting tipset: %w", err) + } + return gasEstimateGasLimit(ctx, m.Chain, m.Stmgr, m.Mpool, msgIn, ts) } func gasEstimateGasLimit( ctx context.Context, @@ -204,13 +212,13 @@ func gasEstimateGasLimit( smgr *stmgr.StateManager, mpool *messagepool.MessagePool, msgIn *types.Message, + currTs *types.TipSet, ) (int64, error) { msg := *msgIn msg.GasLimit = build.BlockGasLimit msg.GasFeeCap = types.NewInt(uint64(build.MinimumBaseFee) + 1) msg.GasPremium = types.NewInt(1) - currTs := cstore.GetHeaviestTipSet() fromA, err := smgr.ResolveToKeyAddress(ctx, msgIn.From, currTs) if err != nil { return -1, xerrors.Errorf("getting key address: %w", err)