core icon indicating copy to clipboard operation
core copied to clipboard

should consider minimum priority fee when calculating `maxPriorityFeePerGas`

Open egonspace opened this issue 1 year ago • 0 comments

In calculating maxPriorityFeePerGas as following code: https://github.com/MetaMask/core/blob/1dadf04f77211e3650d36be86aa0934750ec9a44/packages/gas-fee-controller/src/fetchGasEstimatesViaEthFeeHistory/calculateGasFeeEstimatesForPriorityLevels.ts#L75

const medianPriorityFee = medianOf(priorityFees);
  const adjustedPriorityFee = medianPriorityFee
    .mul(settings.priorityFeePercentageMultiplier)
    .divn(100);

If minimum priority fee in block history is same to the median value, then the tx having 97% of the median as maxPriorityFeePerGas may not be accepted by txpool.

For example, let's assume the following situation. priorityFees = [10, 10, 10, 10, 10, 11, 12, 13, 14] median is 10 (5th element) and adjustedPriorityFee = 9.7 (10 * 97%) So txpool may reject the tx because of the priorityFee less than min value.

Actually, some chain uses fixed priorityFee to have the all same effectivePriorityFeePerGas in block fee history so metamask fails to send a transaction without manual setting of gas.

Are you willing to improve this? How about to use median * 97% but at least set it to be greater than min?

egonspace avatar Jan 26 '24 07:01 egonspace