Skip to content

Comments

Replace AnyNetwork with AnyNetworkBare to remove WithOtherFields deserialization overhead#6398

Merged
incrypto32 merged 1 commit intomasterfrom
krishna/graph-network-no-with-other-fields
Feb 25, 2026
Merged

Replace AnyNetwork with AnyNetworkBare to remove WithOtherFields deserialization overhead#6398
incrypto32 merged 1 commit intomasterfrom
krishna/graph-network-no-with-other-fields

Conversation

@incrypto32
Copy link
Member

AnyNetwork wraps every RPC response (block, transaction, receipt) in WithOtherFields<T>, which uses #[serde(flatten)] to capture unknown JSON keys into a BTreeMap. This forces serde to buffer entire JSON objects into intermediate Value maps and re-serialize them to diff keys on every block and every transaction. graph-node never reads these extra fields.

Define AnyNetworkBare, a custom Network impl that uses the same AnyTxEnvelope/AnyReceiptEnvelope types (for L2/sidechain tx support) but without the WithOtherFields wrapper on response types. This eliminates the flatten buffering, BTreeMap allocation, and re-serialization from the deserialization hot path.

///
/// Uses `AnyTxEnvelope` (not `TxEnvelope`) to support non-standard transaction types from
/// L2s and sidechains. `TransactionRequest` retains `WithOtherFields` because upstream
/// `From` impls for `AnyTxEnvelope` only exist on `WithOtherFields<TransactionRequest>`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be worth to ask upstream to change that?

Copy link
Member Author

Choose a reason for hiding this comment

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

Upstream is right . AnyTxEnvelope can carry unknown tx type fields that a bare TransactionRequest has no place for. Just documenting why this one retains the wrapper.

…ve WithOtherFields overhead

AnyNetwork wraps every RPC response (block, transaction, receipt) in
WithOtherFields<T>, which uses #[serde(flatten)] to capture unknown JSON
keys into a BTreeMap. This forces serde to buffer entire JSON objects
into intermediate Value maps and re-serialize them to diff keys on every
block and every transaction. graph-node never reads these extra fields.

Define AnyNetworkBare, a custom Network impl that uses the same
AnyTxEnvelope/AnyReceiptEnvelope types (for L2/sidechain tx support)
but without the WithOtherFields wrapper on response types. This
eliminates the flatten buffering, BTreeMap allocation, and
re-serialization from the deserialization hot path.
@incrypto32 incrypto32 force-pushed the krishna/graph-network-no-with-other-fields branch from 072910d to 8666ef9 Compare February 25, 2026 08:31
@incrypto32 incrypto32 merged commit db95c7d into master Feb 25, 2026
6 checks passed
@incrypto32 incrypto32 deleted the krishna/graph-network-no-with-other-fields branch February 25, 2026 09:06
incrypto32 added a commit that referenced this pull request Feb 25, 2026
…ve WithOtherFields overhead (#6398)

AnyNetwork wraps every RPC response (block, transaction, receipt) in
WithOtherFields<T>, which uses #[serde(flatten)] to capture unknown JSON
keys into a BTreeMap. This forces serde to buffer entire JSON objects
into intermediate Value maps and re-serialize them to diff keys on every
block and every transaction. graph-node never reads these extra fields.

Define AnyNetworkBare, a custom Network impl that uses the same
AnyTxEnvelope/AnyReceiptEnvelope types (for L2/sidechain tx support)
but without the WithOtherFields wrapper on response types. This
eliminates the flatten buffering, BTreeMap allocation, and
re-serialization from the deserialization hot path.
incrypto32 added a commit that referenced this pull request Feb 25, 2026
…ve WithOtherFields overhead (#6398)

AnyNetwork wraps every RPC response (block, transaction, receipt) in
WithOtherFields<T>, which uses #[serde(flatten)] to capture unknown JSON
keys into a BTreeMap. This forces serde to buffer entire JSON objects
into intermediate Value maps and re-serialize them to diff keys on every
block and every transaction. graph-node never reads these extra fields.

Define AnyNetworkBare, a custom Network impl that uses the same
AnyTxEnvelope/AnyReceiptEnvelope types (for L2/sidechain tx support)
but without the WithOtherFields wrapper on response types. This
eliminates the flatten buffering, BTreeMap allocation, and
re-serialization from the deserialization hot path.
incrypto32 added a commit that referenced this pull request Feb 25, 2026
…ve WithOtherFields overhead (#6398)

AnyNetwork wraps every RPC response (block, transaction, receipt) in
WithOtherFields<T>, which uses #[serde(flatten)] to capture unknown JSON
keys into a BTreeMap. This forces serde to buffer entire JSON objects
into intermediate Value maps and re-serialize them to diff keys on every
block and every transaction. graph-node never reads these extra fields.

Define AnyNetworkBare, a custom Network impl that uses the same
AnyTxEnvelope/AnyReceiptEnvelope types (for L2/sidechain tx support)
but without the WithOtherFields wrapper on response types. This
eliminates the flatten buffering, BTreeMap allocation, and
re-serialization from the deserialization hot path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants