Skip to content

Optimize OpTxpool 2718 bytes encoding #16308

@mattsse

Description

@mattsse

Describe the feature

we currently do during validation:

let mut encoded = Vec::with_capacity(valid_tx.transaction().encoded_length());
let tx = valid_tx.transaction().clone_into_consensus();
tx.encode_2718(&mut encoded);

because we need this to check for sufficient funds to cover the L1 DA fee

but we currently throw this away after validation.
instead we could obtain this from the tx itself, which would then just call:

/// Returns lazily computed EIP-2718 encoded bytes of the transaction.
pub fn encoded_2718(&self) -> &Bytes {
self.encoded_2718.get_or_init(|| self.inner.transaction().encoded_2718().into())
}

then we'd already have the bytes stored for building.

to do this we need a way to call this generically, because rn this is restricted to:

Tx: EthPoolTransaction + MaybeInteropTransaction,

so need a trait function that returns

fn encoded_2718(&self) -> Cow<Bytes>

we can add this to the existing OpPooledTx

pub trait OpPooledTx:

and update the restriction in the implementation to OpPooledTx

Additional context

No response

Metadata

Metadata

Assignees

Labels

A-op-rethRelated to Optimism and op-rethC-enhancementNew feature or requestD-good-first-issueNice and easy! A great choice to get started

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions