Skip to content

beacon/engine, rpc: add PremarshaledJSON for execution payload envelopes#33969

Draft
jrhea wants to merge 2 commits intoethereum:masterfrom
jrhea:json-premarshal-blobsbundle
Draft

beacon/engine, rpc: add PremarshaledJSON for execution payload envelopes#33969
jrhea wants to merge 2 commits intoethereum:masterfrom
jrhea:json-premarshal-blobsbundle

Conversation

@jrhea
Copy link
Contributor

@jrhea jrhea commented Mar 6, 2026

Adds a PremarshaledJSON fast path for ExecutionPayloadEnvelope that bypasses encoding/json's reflection and re-validation, which are expensive for large payloads with many blobs.

goos: darwin
goarch: arm64
pkg: github.com/ethereum/go-ethereum/eth/catalyst
cpu: Apple M4 Max
BenchmarkGetPayloadV5WithBlobs/blobs=21/enc=none-16                                   10         101667408 ns/op               101.5 ms/op      12892132 B/op       4355 allocs/op
BenchmarkGetPayloadV5WithBlobs/blobs=21/enc=json-16                                    8         131135370 ns/op               131.0 ms/op      37107522 B/op       7197 allocs/op
BenchmarkGetPayloadV5WithBlobs/blobs=21/enc=json_premarshaled-16                      10         106992271 ns/op               106.9 ms/op      18620180 B/op      4403 allocs/op
BenchmarkGetPayloadV5WithBlobs/blobs=21/enc=rlp-16                                    10         104075679 ns/op               104.0 ms/op      29606241 B/op      4378 allocs/op
BenchmarkGetPayloadV5WithBlobs/blobs=72/enc=none-16                                   10         101948704 ns/op               101.8 ms/op      44432680 B/op     12788 allocs/op
BenchmarkGetPayloadV5WithBlobs/blobs=72/enc=json-16                                    6         174747340 ns/op               174.7 ms/op      143662510 B/op    22277 allocs/op
BenchmarkGetPayloadV5WithBlobs/blobs=72/enc=json_premarshaled-16                      10         115809462 ns/op               115.7 ms/op      64227073 B/op     12810 allocs/op
BenchmarkGetPayloadV5WithBlobs/blobs=72/enc=rlp-16                                    10         108373650 ns/op               108.3 ms/op      106355096 B/op    12806 allocs/op

Note: This PR uses @MariusVanDerWijden's benchmarks from #33944. I will rebase when his PR gets merged.

TODO Maybe?:

The PremarshaledJSON method in premarshal.go is currently hand-written. If ExecutionPayloadEnvelope changes, the code must be updated manually. To make this sustainable, gencodec could be extended to emit PremarshaledJSON() alongside MarshalJSON().

@jrhea jrhea force-pushed the json-premarshal-blobsbundle branch 2 times, most recently from 61a5354 to 7f4a3c0 Compare March 6, 2026 14:40
@jrhea jrhea force-pushed the json-premarshal-blobsbundle branch from 7f4a3c0 to bc84b4e Compare March 6, 2026 14:46
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