Skip to content

Fix maxFeePerGas < maxPriorityFeePerGas transaction issue#1139

Merged
master-malwyl merged 2 commits intomasterfrom
st/txn-gas-fix
Feb 12, 2025
Merged

Fix maxFeePerGas < maxPriorityFeePerGas transaction issue#1139
master-malwyl merged 2 commits intomasterfrom
st/txn-gas-fix

Conversation

@shawntobin
Copy link
Contributor

resolves #1136

Replaced legacy gas calculation that sometimes caused maxFeePerGas to be less than maxPriorityFeePerGas.

Previous code used web3.eth.getGasPrice() to calculate maxFeePerGas, which isn't suitable anymore for EIP-1559 transactions. Now fetching 'baseFeePerGas' instead.

resolves #1136

Replaced legacy gas calculation which sometimes caused maxFeePerGas to be less than maxPriorityFeePerGas.
@master-malwyl
Copy link
Contributor

One minor suggestion: we might want to add an explicit error case if both 'pending' and 'latest' blocks fail to return baseFeePerGas:

let block = await web3.eth.getBlock('pending');

// in case pending block doesn't return anything
if (!block || !block.baseFeePerGas) {
  block = await web3.eth.getBlock('latest');
  if (!block || !block.baseFeePerGas) {
    throw new Error('Unable to fetch baseFeePerGas from network');
  }
}

This would make debugging easier if we ever hit an edge case where the network isn't returning proper EIP-1559 data.

Otherwise, the changes look good and should fix the issues reported in #1136.

- Cleaner format + error message
@master-malwyl master-malwyl merged commit e7d5629 into master Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't withdraw star from lockup

2 participants