Skip to content

Commit 96ca9c3

Browse files
committed
beacon/engine,eth/catalyst: hex marshal requests in engine api
1 parent 15bf90e commit 96ca9c3

File tree

3 files changed

+10
-96
lines changed

3 files changed

+10
-96
lines changed

beacon/engine/gen_epe.go

Lines changed: 0 additions & 78 deletions
This file was deleted.

beacon/engine/types.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,11 @@ type StatelessPayloadStatusV1 struct {
101101
ValidationError *string `json:"validationError"`
102102
}
103103

104-
//go:generate go run github.com/fjl/gencodec -type ExecutionPayloadEnvelope -field-override executionPayloadEnvelopeMarshaling -out gen_epe.go
105-
106104
type ExecutionPayloadEnvelope struct {
107105
ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"`
108106
BlockValue *big.Int `json:"blockValue" gencodec:"required"`
109107
BlobsBundle *BlobsBundleV1 `json:"blobsBundle"`
110-
Requests [][]byte `json:"executionRequests"`
108+
Requests []hexutil.Bytes `json:"executionRequests"`
111109
Override bool `json:"shouldOverrideBuilder"`
112110
Witness *hexutil.Bytes `json:"witness,omitempty"`
113111
}
@@ -118,12 +116,6 @@ type BlobsBundleV1 struct {
118116
Blobs []hexutil.Bytes `json:"blobs"`
119117
}
120118

121-
// JSON type overrides for ExecutionPayloadEnvelope.
122-
type executionPayloadEnvelopeMarshaling struct {
123-
BlockValue *hexutil.Big
124-
Requests []hexutil.Bytes
125-
}
126-
127119
type PayloadStatusV1 struct {
128120
Status string `json:"status"`
129121
Witness *hexutil.Bytes `json:"witness"`
@@ -208,7 +200,7 @@ func decodeTransactions(enc [][]byte) ([]*types.Transaction, error) {
208200
// and that the blockhash of the constructed block matches the parameters. Nil
209201
// Withdrawals value will propagate through the returned block. Empty
210202
// Withdrawals value must be passed via non-nil, length 0 value in data.
211-
func ExecutableDataToBlock(data ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests [][]byte) (*types.Block, error) {
203+
func ExecutableDataToBlock(data ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests []hexutil.Bytes) (*types.Block, error) {
212204
block, err := ExecutableDataToBlockNoHash(data, versionedHashes, beaconRoot, requests)
213205
if err != nil {
214206
return nil, err
@@ -222,7 +214,7 @@ func ExecutableDataToBlock(data ExecutableData, versionedHashes []common.Hash, b
222214
// ExecutableDataToBlockNoHash is analogous to ExecutableDataToBlock, but is used
223215
// for stateless execution, so it skips checking if the executable data hashes to
224216
// the requested hash (stateless has to *compute* the root hash, it's not given).
225-
func ExecutableDataToBlockNoHash(data ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests [][]byte) (*types.Block, error) {
217+
func ExecutableDataToBlockNoHash(data ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests []hexutil.Bytes) (*types.Block, error) {
226218
txs, err := decodeTransactions(data.Transactions)
227219
if err != nil {
228220
return nil, err
@@ -339,9 +331,9 @@ func BlockToExecutableData(block *types.Block, fees *big.Int, sidecars []*types.
339331
}
340332

341333
// Remove type byte in requests.
342-
var plainRequests [][]byte
334+
var plainRequests []hexutil.Bytes
343335
if requests != nil {
344-
plainRequests = make([][]byte, len(requests))
336+
plainRequests = make([]hexutil.Bytes, len(requests))
345337
for i, reqdata := range requests {
346338
plainRequests[i] = reqdata[1:]
347339
}

eth/catalyst/api.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ func (api *ConsensusAPI) NewPayloadV3(params engine.ExecutableData, versionedHas
594594

595595
// NewPayloadV4 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
596596
// NewPayloadV4 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
597-
func (api *ConsensusAPI) NewPayloadV4(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests [][]byte) (engine.PayloadStatusV1, error) {
597+
func (api *ConsensusAPI) NewPayloadV4(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests []hexutil.Bytes) (engine.PayloadStatusV1, error) {
598598
if params.Withdrawals == nil {
599599
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil withdrawals post-shanghai"))
600600
}
@@ -682,7 +682,7 @@ func (api *ConsensusAPI) NewPayloadWithWitnessV3(params engine.ExecutableData, v
682682

683683
// NewPayloadWithWitnessV4 is analogous to NewPayloadV4, only it also generates
684684
// and returns a stateless witness after running the payload.
685-
func (api *ConsensusAPI) NewPayloadWithWitnessV4(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests [][]byte) (engine.PayloadStatusV1, error) {
685+
func (api *ConsensusAPI) NewPayloadWithWitnessV4(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests []hexutil.Bytes) (engine.PayloadStatusV1, error) {
686686
if params.Withdrawals == nil {
687687
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil withdrawals post-shanghai"))
688688
}
@@ -770,7 +770,7 @@ func (api *ConsensusAPI) ExecuteStatelessPayloadV3(params engine.ExecutableData,
770770

771771
// ExecuteStatelessPayloadV4 is analogous to NewPayloadV4, only it operates in
772772
// a stateless mode on top of a provided witness instead of the local database.
773-
func (api *ConsensusAPI) ExecuteStatelessPayloadV4(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests [][]byte, opaqueWitness hexutil.Bytes) (engine.StatelessPayloadStatusV1, error) {
773+
func (api *ConsensusAPI) ExecuteStatelessPayloadV4(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests []hexutil.Bytes, opaqueWitness hexutil.Bytes) (engine.StatelessPayloadStatusV1, error) {
774774
if params.Withdrawals == nil {
775775
return engine.StatelessPayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil withdrawals post-shanghai"))
776776
}
@@ -797,7 +797,7 @@ func (api *ConsensusAPI) ExecuteStatelessPayloadV4(params engine.ExecutableData,
797797
return api.executeStatelessPayload(params, versionedHashes, beaconRoot, requests, opaqueWitness)
798798
}
799799

800-
func (api *ConsensusAPI) newPayload(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests [][]byte, witness bool) (engine.PayloadStatusV1, error) {
800+
func (api *ConsensusAPI) newPayload(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests []hexutil.Bytes, witness bool) (engine.PayloadStatusV1, error) {
801801
// The locking here is, strictly, not required. Without these locks, this can happen:
802802
//
803803
// 1. NewPayload( execdata-N ) is invoked from the CL. It goes all the way down to
@@ -927,7 +927,7 @@ func (api *ConsensusAPI) newPayload(params engine.ExecutableData, versionedHashe
927927
return engine.PayloadStatusV1{Status: engine.VALID, Witness: ow, LatestValidHash: &hash}, nil
928928
}
929929

930-
func (api *ConsensusAPI) executeStatelessPayload(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests [][]byte, opaqueWitness hexutil.Bytes) (engine.StatelessPayloadStatusV1, error) {
930+
func (api *ConsensusAPI) executeStatelessPayload(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests []hexutil.Bytes, opaqueWitness hexutil.Bytes) (engine.StatelessPayloadStatusV1, error) {
931931
log.Trace("Engine API request received", "method", "ExecuteStatelessPayload", "number", params.Number, "hash", params.BlockHash)
932932

933933
block, err := engine.ExecutableDataToBlockNoHash(params, versionedHashes, beaconRoot, requests)

0 commit comments

Comments
 (0)