mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-23 08:19:27 +00:00
Adds a fast path for ExecutionPayloadEnvelope and BlobAndProofListV* that bypasses encoding/json's reflection and re-validation, which are expensive for large payloads with many blobs. Also hand-rolls the jsonrpcMessage wire encoding in the RPC codec to avoid a second re-validation pass when writing responses to the connection. Resolves #33814 --------- Co-authored-by: Marius van der Wijden <m.vanderwijden@live.de> Co-authored-by: Felix Lange <fjl@twurst.com>
69 lines
1.8 KiB
Go
69 lines
1.8 KiB
Go
// Copyright 2026 The go-ethereum Authors
|
|
// This file is part of the go-ethereum library.
|
|
//
|
|
// The go-ethereum library is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// The go-ethereum library is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Lesser General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
package engine
|
|
|
|
import (
|
|
"github.com/fjl/jsonw"
|
|
)
|
|
|
|
// MarshalJSON implements json.Marshaler.
|
|
func (list BlobAndProofListV1) MarshalJSON() ([]byte, error) {
|
|
var b jsonw.Buffer
|
|
b.Array(func() {
|
|
for _, item := range list {
|
|
marshalBlobAndProofV1(&b, item)
|
|
}
|
|
})
|
|
return b.Output(), nil
|
|
}
|
|
|
|
func marshalBlobAndProofV1(b *jsonw.Buffer, item *BlobAndProofV1) {
|
|
if item == nil {
|
|
b.Null()
|
|
} else {
|
|
b.Object(func() {
|
|
b.Key("blob")
|
|
b.HexBytes(item.Blob)
|
|
b.Key("proof")
|
|
b.HexBytes(item.Proof)
|
|
})
|
|
}
|
|
}
|
|
|
|
// MarshalJSON implements json.Marshaler.
|
|
func (list BlobAndProofListV2) MarshalJSON() ([]byte, error) {
|
|
var b jsonw.Buffer
|
|
b.Array(func() {
|
|
for _, item := range list {
|
|
marshalBlobAndProofV2(&b, item)
|
|
}
|
|
})
|
|
return b.Output(), nil
|
|
}
|
|
|
|
func marshalBlobAndProofV2(b *jsonw.Buffer, item *BlobAndProofV2) {
|
|
if item == nil {
|
|
b.Null()
|
|
} else {
|
|
b.Object(func() {
|
|
b.Key("blob")
|
|
b.HexBytes(item.Blob)
|
|
b.Key("proofs")
|
|
appendHexBytesArray(b, item.CellProofs)
|
|
})
|
|
}
|
|
}
|