diff --git a/beacon-chain/execution/engine_client_fuzz_test.go b/beacon-chain/execution/engine_client_fuzz_test.go index 9a988f9517..a1210f7615 100644 --- a/beacon-chain/execution/engine_client_fuzz_test.go +++ b/beacon-chain/execution/engine_client_fuzz_test.go @@ -115,28 +115,32 @@ func FuzzExchangeTransitionConfiguration(f *testing.F) { func FuzzExecutionPayload(f *testing.F) { logsBloom := [256]byte{'j', 'u', 'n', 'k'} - execData := &engine.ExecutableData{ - ParentHash: common.Hash([32]byte{0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01}), - FeeRecipient: common.Address([20]byte{0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF}), - StateRoot: common.Hash([32]byte{0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01}), - ReceiptsRoot: common.Hash([32]byte{0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01}), - LogsBloom: logsBloom[:], - Random: common.Hash([32]byte{0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01}), - Number: math.MaxUint64, - GasLimit: math.MaxUint64, - GasUsed: math.MaxUint64, - Timestamp: 100, - ExtraData: nil, - BaseFeePerGas: big.NewInt(math.MaxInt), - BlockHash: common.Hash([32]byte{0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01}), - Transactions: [][]byte{{0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01}, {0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01}, {0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01}, {0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01}}, + execData := &engine.ExecutionPayloadEnvelope{ + ExecutionPayload: &engine.ExecutableData{ + ParentHash: common.Hash([32]byte{0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01}), + FeeRecipient: common.Address([20]byte{0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF}), + StateRoot: common.Hash([32]byte{0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01}), + ReceiptsRoot: common.Hash([32]byte{0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01}), + LogsBloom: logsBloom[:], + Random: common.Hash([32]byte{0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01}), + Number: math.MaxUint64, + GasLimit: math.MaxUint64, + GasUsed: math.MaxUint64, + Timestamp: 100, + ExtraData: nil, + BaseFeePerGas: big.NewInt(math.MaxInt), + BlockHash: common.Hash([32]byte{0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01}), + Transactions: [][]byte{{0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01}, {0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01}, {0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01}, {0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0xFF, 0x01}}, + Withdrawals: []*types.Withdrawal{}, + }, + BlockValue: nil, } output, err := json.Marshal(execData) assert.NoError(f, err) f.Add(output) f.Fuzz(func(t *testing.T, jsonBlob []byte) { - gethResp := &engine.ExecutableData{} - prysmResp := &pb.ExecutionPayload{} + gethResp := &engine.ExecutionPayloadEnvelope{} + prysmResp := &pb.ExecutionPayloadCapellaWithValue{} gethErr := json.Unmarshal(jsonBlob, gethResp) prysmErr := json.Unmarshal(jsonBlob, prysmResp) assert.Equal(t, gethErr != nil, prysmErr != nil, fmt.Sprintf("geth and prysm unmarshaller return inconsistent errors. %v and %v", gethErr, prysmErr)) @@ -147,10 +151,10 @@ func FuzzExecutionPayload(f *testing.F) { gethBlob, gethErr := json.Marshal(gethResp) prysmBlob, prysmErr := json.Marshal(prysmResp) assert.Equal(t, gethErr != nil, prysmErr != nil, "geth and prysm unmarshaller return inconsistent errors") - newGethResp := &engine.ExecutableData{} + newGethResp := &engine.ExecutionPayloadEnvelope{} newGethErr := json.Unmarshal(prysmBlob, newGethResp) assert.NoError(t, newGethErr) - newGethResp2 := &engine.ExecutableData{} + newGethResp2 := &engine.ExecutionPayloadEnvelope{} newGethErr = json.Unmarshal(gethBlob, newGethResp2) assert.NoError(t, newGethErr) diff --git a/proto/engine/v1/json_marshal_unmarshal.go b/proto/engine/v1/json_marshal_unmarshal.go index cd77f12961..ebd08eede5 100644 --- a/proto/engine/v1/json_marshal_unmarshal.go +++ b/proto/engine/v1/json_marshal_unmarshal.go @@ -394,6 +394,9 @@ func (e *ExecutionPayloadCapellaWithValue) UnmarshalJSON(enc []byte) error { if err := json.Unmarshal(enc, &dec); err != nil { return err } + if dec.ExecutionPayload == nil { + return errors.New("missing required field 'executionPayload' for ExecutionPayloadWithValue") + } if dec.ExecutionPayload.ParentHash == nil { return errors.New("missing required field 'parentHash' for ExecutionPayload")