Merge pull request #4739 from filecoin-project/feat/gas-estim-limit-ts

Use TSK passed to GasEstimateGasLimit
This commit is contained in:
Łukasz Magiera 2020-11-06 11:59:55 +01:00 committed by GitHub
commit 273da38bdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -192,11 +192,19 @@ func gasEstimateGasPremium(cstore *store.ChainStore, nblocksincl uint64) (types.
return premium, nil return premium, nil
} }
func (a *GasAPI) GasEstimateGasLimit(ctx context.Context, msgIn *types.Message, _ types.TipSetKey) (int64, error) { func (a *GasAPI) GasEstimateGasLimit(ctx context.Context, msgIn *types.Message, tsk types.TipSetKey) (int64, error) {
return gasEstimateGasLimit(ctx, a.Chain, a.Stmgr, a.Mpool, msgIn) ts, err := a.Chain.GetTipSetFromKey(tsk)
if err != nil {
return -1, xerrors.Errorf("getting tipset: %w", err)
} }
func (m *GasModule) GasEstimateGasLimit(ctx context.Context, msgIn *types.Message, _ types.TipSetKey) (int64, error) { return gasEstimateGasLimit(ctx, a.Chain, a.Stmgr, a.Mpool, msgIn, ts)
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( func gasEstimateGasLimit(
ctx context.Context, ctx context.Context,
@ -204,13 +212,13 @@ func gasEstimateGasLimit(
smgr *stmgr.StateManager, smgr *stmgr.StateManager,
mpool *messagepool.MessagePool, mpool *messagepool.MessagePool,
msgIn *types.Message, msgIn *types.Message,
currTs *types.TipSet,
) (int64, error) { ) (int64, error) {
msg := *msgIn msg := *msgIn
msg.GasLimit = build.BlockGasLimit msg.GasLimit = build.BlockGasLimit
msg.GasFeeCap = types.NewInt(uint64(build.MinimumBaseFee) + 1) msg.GasFeeCap = types.NewInt(uint64(build.MinimumBaseFee) + 1)
msg.GasPremium = types.NewInt(1) msg.GasPremium = types.NewInt(1)
currTs := cstore.GetHeaviestTipSet()
fromA, err := smgr.ResolveToKeyAddress(ctx, msgIn.From, currTs) fromA, err := smgr.ResolveToKeyAddress(ctx, msgIn.From, currTs)
if err != nil { if err != nil {
return -1, xerrors.Errorf("getting key address: %w", err) return -1, xerrors.Errorf("getting key address: %w", err)