Skip to content

[Bug] Optimism network incompatible with ProviderBuilder::new constructor #2478

Open
@yash-atreya

Description

@yash-atreya

Component

provider, pubsub

What version of Alloy are you on?

1.0

Operating System

None

Describe the bug

Ref https://t.me/ethers_rs/44750

With the current ProviderBuilder::new constructor, custom networks such as op_alloy_network::Optimism are incompatible and won't compile.

let op = ProviderBuilder::new()
         .network::<Optimism>()
         .connect("http://..").await?; // Won't compile 

This is due to BlobGasFiller being inserted as part of RecommendedFillers when in the new constructor. The BlobGasFiller requires implementation of the TransactionBuilder4844 trait which isn't implemented and shouldn't be implemented by OpTransactionRequest.

The current workaround is pretty ugly:

let op_provider = ProviderBuilder::new()
        .disable_recommended_fillers()
        .fetch_chain_id()
        .with_gas_estimation()
        .with_cached_nonce_management()
        .network::<Optimism>()
        .connect(&anvil.endpoint())
        .await?;

Possible Solutions:

  1. Breaking - Remove the BlobGasFiller from RecommendedFillers. Document this and ask users to use .filler(BlobGasFiller).
  2. Non-breaking - Introduce new_with_network::<N>() constructor for the ProviderBuilder and implement the N::RecommendedFillers trait for the Optimism network in op-alloy. This makes the .network method redundant

Metadata

Metadata

Assignees

Labels

Type

Projects

Status

Ready for Review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions