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

fix: ensure max_fee_per_blob_gas field handles Some(0) gracefully #1389

Merged
merged 4 commits into from
Sep 27, 2024

Conversation

zerosnacks
Copy link
Member

@zerosnacks zerosnacks commented Sep 27, 2024

Motivation

Closes: #1371

Solution

Related Foundry PR: foundry-rs/foundry#8963 that depends on this implementation

If max_fee_per_blob_gas is Some(0) or None we set it to a valid value next_block_blob_fee().

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@zerosnacks zerosnacks changed the title Zerosnacks/fix with max fee per blob gas fix: ensure max_fee_per_blob_gas field handles Some(0) gracefully Sep 27, 2024
// Nothing to fill if non-eip4844 tx or `max_fee_per_blob_gas` is already set to a valid
// value.
if tx.blob_sidecar().is_none()
|| tx.max_fee_per_blob_gas().is_some_and(|gas| gas >= BLOB_TX_MIN_BLOB_GASPRICE)
Copy link
Member Author

Choose a reason for hiding this comment

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

If the field is set to Some(0) (which happens because of serialization) we force setting it to .next_block_blob_fee() as 0 is always invalid as it is less than BLOB_TX_MIN_BLOB_GASPRICE (1).

@zerosnacks zerosnacks marked this pull request as ready for review September 27, 2024 15:43
Comment on lines +317 to +319
to: Some(address!("d8dA6BF26964aF9D7eEd9e03E53415D37aA96045").into()),
sidecar: Some(sidecar),
..Default::default()
Copy link
Member Author

Choose a reason for hiding this comment

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

Tests both cases, implicit Some(0) / None and explicit Some(0)

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm, this is effectively a safe guard to prevent user error, right?

@zerosnacks
Copy link
Member Author

lgtm, this is effectively a safe guard to prevent user error, right?

It is but it mostly enables you do not define the field and rely on the filler. What happens is that the transaction is serialized as 0 as the field is required. This is then interpreted as Some(0) rather than None that would previously then skip the filler.

@mattsse mattsse merged commit b65df90 into main Sep 27, 2024
26 checks passed
@mattsse mattsse deleted the zerosnacks/fix-with_max_fee_per_blob_gas branch September 27, 2024 17:11
lwedge99 pushed a commit to sentioxyz/alloy that referenced this pull request Oct 8, 2024
…alloy-rs#1389)

* max_fee_per_blob_gas with Some(0) will always fail because it is below BLOB_TX_MIN_BLOB_GASPRICE (1)

* add basic EIP-4844 test without defining max_fee_per_blob_gas

* test both cases, explicit Some(0) and implicit Some(0) / None

* fix clippy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

[Bug] recommended fillers fail to estimate eip4844 tx gas
2 participants