Skip to content

fix(eips): preserve max_blobs_per_tx and blob_base_cost in BlobParams serde#3852

Closed
Aboudjem wants to merge 2 commits intoalloy-rs:mainfrom
Aboudjem:fix/eip7840-blobparams-serde-roundtrip
Closed

fix(eips): preserve max_blobs_per_tx and blob_base_cost in BlobParams serde#3852
Aboudjem wants to merge 2 commits intoalloy-rs:mainfrom
Aboudjem:fix/eip7840-blobparams-serde-roundtrip

Conversation

@Aboudjem
Copy link
Copy Markdown

Summary

Fixes #3103

The SerdeHelper for BlobParams was dropping two fields during serialization:

  • max_blobs_per_tx was silently discarded, then defaulted to max_blob_count on deserialization
  • blob_base_cost was silently discarded, then defaulted to 0 on deserialization

This broke serde roundtrips for any BlobParams where max_blobs_per_tx != max_blob_count or blob_base_cost != 0 (e.g. Osaka configuration).

Changes

  • Added max_blobs_per_tx and blob_base_cost as Option fields to SerdeHelper
  • Only serialize them when they differ from defaults (max_blob_count and 0 respectively), keeping backward-compatible JSON output for Cancun/Prague configs
  • Added roundtrip tests for all predefined configs (Cancun, Prague, Osaka, BPO1, BPO2), a custom config, and deserialization with missing fields

Test plan

  • cargo test -p alloy-eips --features serde -- eip7840 — 3 tests pass
  • Roundtrip test covers all predefined BlobParams variants
  • Custom config test verifies fields appear in JSON when non-default
  • Missing fields test verifies backward compatibility

🤖 Generated with Claude Code

…rams serde roundtrip

The `SerdeHelper` for `BlobParams` was dropping `max_blobs_per_tx` and
`blob_base_cost` during serialization, causing deserialization to always
default `max_blobs_per_tx` to `max_blob_count` and `blob_base_cost` to 0.

Add both fields as optional to the serde helper so they are preserved
when they differ from their defaults. This fixes the broken serde
roundtrip reported in alloy-rs#3103.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
BlobParams uses a custom serde impl with Option fields (via SerdeHelper)
that is incompatible with bincode's legacy format. Introduce a direct
BincBlobParams wrapper that serializes raw fields without Option, fixing
the test_chain_config_bincode_roundtrip test. Also fix rustfmt in eip7840.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
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.

these can be derived from the eips itself, and this isnt really necessary

@mattsse mattsse closed this Apr 8, 2026
@github-project-automation github-project-automation Bot moved this to Done in Alloy Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug] eip7840 BlobParams SerdeHelper drops two fields

2 participants