diff --git a/beacon/engine/gen_epe.go b/beacon/engine/gen_epe.go deleted file mode 100644 index 039884e842fd..000000000000 --- a/beacon/engine/gen_epe.go +++ /dev/null @@ -1,78 +0,0 @@ -// Code generated by github.com/fjl/gencodec. DO NOT EDIT. - -package engine - -import ( - "encoding/json" - "errors" - "math/big" - - "github.com/ethereum/go-ethereum/common/hexutil" -) - -var _ = (*executionPayloadEnvelopeMarshaling)(nil) - -// MarshalJSON marshals as JSON. -func (e ExecutionPayloadEnvelope) MarshalJSON() ([]byte, error) { - type ExecutionPayloadEnvelope struct { - ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"` - BlockValue *hexutil.Big `json:"blockValue" gencodec:"required"` - BlobsBundle *BlobsBundleV1 `json:"blobsBundle"` - Requests []hexutil.Bytes `json:"executionRequests"` - Override bool `json:"shouldOverrideBuilder"` - Witness *hexutil.Bytes `json:"witness"` - } - var enc ExecutionPayloadEnvelope - enc.ExecutionPayload = e.ExecutionPayload - enc.BlockValue = (*hexutil.Big)(e.BlockValue) - enc.BlobsBundle = e.BlobsBundle - if e.Requests != nil { - enc.Requests = make([]hexutil.Bytes, len(e.Requests)) - for k, v := range e.Requests { - enc.Requests[k] = v - } - } - enc.Override = e.Override - enc.Witness = e.Witness - return json.Marshal(&enc) -} - -// UnmarshalJSON unmarshals from JSON. -func (e *ExecutionPayloadEnvelope) UnmarshalJSON(input []byte) error { - type ExecutionPayloadEnvelope struct { - ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"` - BlockValue *hexutil.Big `json:"blockValue" gencodec:"required"` - BlobsBundle *BlobsBundleV1 `json:"blobsBundle"` - Requests []hexutil.Bytes `json:"executionRequests"` - Override *bool `json:"shouldOverrideBuilder"` - Witness *hexutil.Bytes `json:"witness"` - } - var dec ExecutionPayloadEnvelope - if err := json.Unmarshal(input, &dec); err != nil { - return err - } - if dec.ExecutionPayload == nil { - return errors.New("missing required field 'executionPayload' for ExecutionPayloadEnvelope") - } - e.ExecutionPayload = dec.ExecutionPayload - if dec.BlockValue == nil { - return errors.New("missing required field 'blockValue' for ExecutionPayloadEnvelope") - } - e.BlockValue = (*big.Int)(dec.BlockValue) - if dec.BlobsBundle != nil { - e.BlobsBundle = dec.BlobsBundle - } - if dec.Requests != nil { - e.Requests = make([][]byte, len(dec.Requests)) - for k, v := range dec.Requests { - e.Requests[k] = v - } - } - if dec.Override != nil { - e.Override = *dec.Override - } - if dec.Witness != nil { - e.Witness = dec.Witness - } - return nil -} diff --git a/beacon/engine/types.go b/beacon/engine/types.go index e80b6e663325..7f6ee65bb800 100644 --- a/beacon/engine/types.go +++ b/beacon/engine/types.go @@ -101,13 +101,11 @@ type StatelessPayloadStatusV1 struct { ValidationError *string `json:"validationError"` } -//go:generate go run github.com/fjl/gencodec -type ExecutionPayloadEnvelope -field-override executionPayloadEnvelopeMarshaling -out gen_epe.go - type ExecutionPayloadEnvelope struct { ExecutionPayload *ExecutableData `json:"executionPayload" gencodec:"required"` BlockValue *big.Int `json:"blockValue" gencodec:"required"` BlobsBundle *BlobsBundleV1 `json:"blobsBundle"` - Requests [][]byte `json:"executionRequests"` + Requests []hexutil.Bytes `json:"executionRequests"` Override bool `json:"shouldOverrideBuilder"` Witness *hexutil.Bytes `json:"witness"` } @@ -118,12 +116,6 @@ type BlobsBundleV1 struct { Blobs []hexutil.Bytes `json:"blobs"` } -// JSON type overrides for ExecutionPayloadEnvelope. -type executionPayloadEnvelopeMarshaling struct { - BlockValue *hexutil.Big - Requests []hexutil.Bytes -} - type PayloadStatusV1 struct { Status string `json:"status"` Witness *hexutil.Bytes `json:"witness"` @@ -208,7 +200,7 @@ func decodeTransactions(enc [][]byte) ([]*types.Transaction, error) { // and that the blockhash of the constructed block matches the parameters. Nil // Withdrawals value will propagate through the returned block. Empty // Withdrawals value must be passed via non-nil, length 0 value in data. -func ExecutableDataToBlock(data ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests [][]byte) (*types.Block, error) { +func ExecutableDataToBlock(data ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests []hexutil.Bytes) (*types.Block, error) { block, err := ExecutableDataToBlockNoHash(data, versionedHashes, beaconRoot, requests) if err != nil { return nil, err @@ -222,7 +214,7 @@ func ExecutableDataToBlock(data ExecutableData, versionedHashes []common.Hash, b // ExecutableDataToBlockNoHash is analogous to ExecutableDataToBlock, but is used // for stateless execution, so it skips checking if the executable data hashes to // the requested hash (stateless has to *compute* the root hash, it's not given). -func ExecutableDataToBlockNoHash(data ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests [][]byte) (*types.Block, error) { +func ExecutableDataToBlockNoHash(data ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests []hexutil.Bytes) (*types.Block, error) { txs, err := decodeTransactions(data.Transactions) if err != nil { return nil, err @@ -339,9 +331,9 @@ func BlockToExecutableData(block *types.Block, fees *big.Int, sidecars []*types. } // Remove type byte in requests. - var plainRequests [][]byte + var plainRequests []hexutil.Bytes if requests != nil { - plainRequests = make([][]byte, len(requests)) + plainRequests = make([]hexutil.Bytes, len(requests)) for i, reqdata := range requests { plainRequests[i] = reqdata[1:] } diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index 79034fd00a83..4ed47a1ca5d2 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -594,7 +594,7 @@ func (api *ConsensusAPI) NewPayloadV3(params engine.ExecutableData, versionedHas // NewPayloadV4 creates an Eth1 block, inserts it in the chain, and returns the status of the chain. // NewPayloadV4 creates an Eth1 block, inserts it in the chain, and returns the status of the chain. -func (api *ConsensusAPI) NewPayloadV4(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests [][]byte) (engine.PayloadStatusV1, error) { +func (api *ConsensusAPI) NewPayloadV4(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests []hexutil.Bytes) (engine.PayloadStatusV1, error) { if params.Withdrawals == nil { return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil withdrawals post-shanghai")) } @@ -682,7 +682,7 @@ func (api *ConsensusAPI) NewPayloadWithWitnessV3(params engine.ExecutableData, v // NewPayloadWithWitnessV4 is analogous to NewPayloadV4, only it also generates // and returns a stateless witness after running the payload. -func (api *ConsensusAPI) NewPayloadWithWitnessV4(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests [][]byte) (engine.PayloadStatusV1, error) { +func (api *ConsensusAPI) NewPayloadWithWitnessV4(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests []hexutil.Bytes) (engine.PayloadStatusV1, error) { if params.Withdrawals == nil { return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil withdrawals post-shanghai")) } @@ -770,7 +770,7 @@ func (api *ConsensusAPI) ExecuteStatelessPayloadV3(params engine.ExecutableData, // ExecuteStatelessPayloadV4 is analogous to NewPayloadV4, only it operates in // a stateless mode on top of a provided witness instead of the local database. -func (api *ConsensusAPI) ExecuteStatelessPayloadV4(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests [][]byte, opaqueWitness hexutil.Bytes) (engine.StatelessPayloadStatusV1, error) { +func (api *ConsensusAPI) ExecuteStatelessPayloadV4(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests []hexutil.Bytes, opaqueWitness hexutil.Bytes) (engine.StatelessPayloadStatusV1, error) { if params.Withdrawals == nil { return engine.StatelessPayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil withdrawals post-shanghai")) } @@ -797,7 +797,7 @@ func (api *ConsensusAPI) ExecuteStatelessPayloadV4(params engine.ExecutableData, return api.executeStatelessPayload(params, versionedHashes, beaconRoot, requests, opaqueWitness) } -func (api *ConsensusAPI) newPayload(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests [][]byte, witness bool) (engine.PayloadStatusV1, error) { +func (api *ConsensusAPI) newPayload(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests []hexutil.Bytes, witness bool) (engine.PayloadStatusV1, error) { // The locking here is, strictly, not required. Without these locks, this can happen: // // 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 return engine.PayloadStatusV1{Status: engine.VALID, Witness: ow, LatestValidHash: &hash}, nil } -func (api *ConsensusAPI) executeStatelessPayload(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests [][]byte, opaqueWitness hexutil.Bytes) (engine.StatelessPayloadStatusV1, error) { +func (api *ConsensusAPI) executeStatelessPayload(params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, requests []hexutil.Bytes, opaqueWitness hexutil.Bytes) (engine.StatelessPayloadStatusV1, error) { log.Trace("Engine API request received", "method", "ExecuteStatelessPayload", "number", params.Number, "hash", params.BlockHash) block, err := engine.ExecutableDataToBlockNoHash(params, versionedHashes, beaconRoot, requests)