Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add L1 Security gas parameters to transaction receipt #4764

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

maxandron
Copy link

Related discussion #3775

Premise

On layer 2 optimistic chains, such as Optimism and Base, there is an additional gas fee representing the cost of communicating the transaction to layer 1.

Layer 2 providers return additional fields when calling eth_getTransactionReceipt

Ethers currently doesn't parse these fields, so they are ignored and require implementing the call to eth_getTransactionReceipt manually.

This PR adds support for three variables: l1Fee, l1GasPrice, and l1GasUsed to the getTransactionReceipt.

@dvir1994
Copy link

Nice! Including these fields will really help with Layer 2 transactions 👍

@RealJohnnyTime
Copy link

Great addition!

@ricmoo
Copy link
Member

ricmoo commented Jun 25, 2024

The properties need to be all marked as ?, since other chains won't have them. There is definitely a need to allow some way to allow more expressive and network-specific properties on transactions and blocks though. I'll look into this and get these properties accessible.

@ricmoo ricmoo added enhancement New feature or improvement. on-deck This Enhancement or Bug is currently being worked on. v6 Issues regarding v6 labels Jun 25, 2024
@maxandron
Copy link
Author

maxandron commented Jun 26, 2024

@ricmoo

There are two options I see to improve usability:

  1. Let these properties have a default of 0n if they do not exist (this is what I implemented in my codebase to make it easy to work with multiple chains without considering whether they exist or not)
  2. The other option is to convert the type definitions into type instead of interface -> then we can create mutually exclusive properties (all L1 gas properties exist, or all don't exist)
    2.1. Using types instead of interfaces, we can add a boolean that will be false if they do not exist and true if they do

I rather like option one and adding proper documentation to let users know that on chains without L1 fees, these will be set to 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement. on-deck This Enhancement or Bug is currently being worked on. v6 Issues regarding v6
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants