Skip to content

chore: add EIP-1559 implementation for gas price#113

Merged
2-towns merged 16 commits into
mainfrom
feat/implements-EIP-1559-gas-calculation
May 28, 2025
Merged

chore: add EIP-1559 implementation for gas price#113
2-towns merged 16 commits into
mainfrom
feat/implements-EIP-1559-gas-calculation

Conversation

@2-towns
Copy link
Copy Markdown
Contributor

@2-towns 2-towns commented Apr 1, 2025

No description provided.

@arnetheduck
Copy link
Copy Markdown
Contributor

see also https://github.com/status-im/nim-eth/blob/master/eth/eip1559.nim

Copy link
Copy Markdown
Contributor

@emizzle emizzle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM. Should we include:

  1. Validation of maxPriorityFeePerGas. Maybe a warning if it's too low (< 500k) that the fee is low and it reduces the chances of the transaction being included in the block
  2. Tests on bounds of maxPriorityFeePerGas, so that we know what bounds are acceptable for users.

Comment thread ethers/providers/jsonrpc.nim Outdated
@2-towns 2-towns force-pushed the feat/implements-EIP-1559-gas-calculation branch from e80880e to d4fcb37 Compare May 19, 2025 08:53
Copy link
Copy Markdown
Contributor

@emizzle emizzle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, looking good. One minor request, a question, and a minor suggestion :) I'll approve now, and assume the minor request is updated (ProviderError -> JsonRpcError)

Comment thread ethers/signer.nim Outdated
Comment thread ethers/signer.nim
trace "EIP-1559 is supported", maxPriorityFeePerGas = maxPriorityFeePerGas, maxFeePerGas = maxFeePerGas
else:
populated.gasPrice = some(transaction.gasPrice |? (await signer.getGasPrice()))
trace "EIP-1559 is not supported", gasPrice = populated.gasPrice
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we set populated.maxFeePerGas = none(UInt256) just in case here? Thinking of a case where the transaction.maxFeePerGas was already populated but the block didn't have a baseFeePerGas value.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it just in case, but it should not have any impact. If the block doesn't have baseFeePerGas that means EIP-1559 is not supported so maxFeePerGas will not be used.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point. When the transaction is signed in the wallet, the first condition checked is whether or not transaction.maxFeePerGas has a value (see line 35 in signers/wallet/signing.nim), which ends up setting signable.txType = TxEip1559 and could have side effects later on.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may also want to set maxPriorityFeePerGas to none just in case. Just a suggestion.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you are right. I just updated the PR to set none to maxPriorityFeePerGas to avoid side effect. Thanks.

Comment thread ethers/providers/jsonrpc.nim Outdated
@2-towns 2-towns merged commit 30871c7 into main May 28, 2025
3 checks passed
@2-towns 2-towns deleted the feat/implements-EIP-1559-gas-calculation branch May 28, 2025 14:14
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.

3 participants