diff --git a/beacon-chain/execution/engine_client_test.go b/beacon-chain/execution/engine_client_test.go index 2977249c0a7b..2e3e29b1defb 100644 --- a/beacon-chain/execution/engine_client_test.go +++ b/beacon-chain/execution/engine_client_test.go @@ -374,6 +374,17 @@ func TestClient_HTTP(t *testing.T) { require.DeepEqual(t, proofs, resp.BlobsBundle.Proofs) blobs := [][]byte{bytesutil.PadTo([]byte("a"), fieldparams.BlobLength), bytesutil.PadTo([]byte("b"), fieldparams.BlobLength)} require.DeepEqual(t, blobs, resp.BlobsBundle.Blobs) + ede, ok := resp.ExecutionData.(interfaces.ExecutionDataElectra) + require.Equal(t, true, ok) + require.NotNil(t, ede.WithdrawalRequests()) + wrequestsNotOverMax := len(ede.WithdrawalRequests()) <= int(params.BeaconConfig().MaxWithdrawalRequestsPerPayload) + require.Equal(t, true, wrequestsNotOverMax) + require.NotNil(t, ede.DepositRequests()) + drequestsNotOverMax := len(ede.DepositRequests()) <= int(params.BeaconConfig().MaxDepositRequestsPerPayload) + require.Equal(t, true, drequestsNotOverMax) + require.NotNil(t, ede.ConsolidationRequests()) + consolidationsNotOverMax := len(ede.ConsolidationRequests()) <= int(params.BeaconConfig().MaxConsolidationsRequestsPerPayload) + require.Equal(t, true, consolidationsNotOverMax) }) t.Run(ForkchoiceUpdatedMethod+" VALID status", func(t *testing.T) { forkChoiceState := &pb.ForkchoiceState{ @@ -1633,24 +1644,25 @@ func fixturesStruct() *payloadFixtures { executionPayloadWithValueFixtureElectra := &pb.GetPayloadV4ResponseJson{ ShouldOverrideBuilder: true, ExecutionPayload: &pb.ExecutionPayloadElectraJSON{ - ParentHash: &common.Hash{'a'}, - FeeRecipient: &common.Address{'b'}, - StateRoot: &common.Hash{'c'}, - ReceiptsRoot: &common.Hash{'d'}, - LogsBloom: &hexutil.Bytes{'e'}, - PrevRandao: &common.Hash{'f'}, - BaseFeePerGas: "0x123", - BlockHash: &common.Hash{'g'}, - Transactions: []hexutil.Bytes{{'h'}}, - Withdrawals: []*pb.Withdrawal{}, - BlockNumber: &hexUint, - GasLimit: &hexUint, - GasUsed: &hexUint, - Timestamp: &hexUint, - BlobGasUsed: &bgu, - ExcessBlobGas: &ebg, - DepositRequests: depositRequests, - WithdrawalRequests: withdrawalRequests, + ParentHash: &common.Hash{'a'}, + FeeRecipient: &common.Address{'b'}, + StateRoot: &common.Hash{'c'}, + ReceiptsRoot: &common.Hash{'d'}, + LogsBloom: &hexutil.Bytes{'e'}, + PrevRandao: &common.Hash{'f'}, + BaseFeePerGas: "0x123", + BlockHash: &common.Hash{'g'}, + Transactions: []hexutil.Bytes{{'h'}}, + Withdrawals: []*pb.Withdrawal{}, + BlockNumber: &hexUint, + GasLimit: &hexUint, + GasUsed: &hexUint, + Timestamp: &hexUint, + BlobGasUsed: &bgu, + ExcessBlobGas: &ebg, + DepositRequests: depositRequests, + WithdrawalRequests: withdrawalRequests, + ConsolidationRequests: consolidationRequests, }, BlockValue: "0x11fffffffff", BlobsBundle: &pb.BlobBundleJSON{ diff --git a/proto/engine/v1/json_marshal_unmarshal.go b/proto/engine/v1/json_marshal_unmarshal.go index 8e489154f4d6..3a7de3a5efe4 100644 --- a/proto/engine/v1/json_marshal_unmarshal.go +++ b/proto/engine/v1/json_marshal_unmarshal.go @@ -992,25 +992,26 @@ func (e *ExecutionPayloadElectra) MarshalJSON() ([]byte, error) { excessBlobGas := hexutil.Uint64(e.ExcessBlobGas) return json.Marshal(ExecutionPayloadElectraJSON{ - ParentHash: &pHash, - FeeRecipient: &recipient, - StateRoot: &sRoot, - ReceiptsRoot: &recRoot, - LogsBloom: &logsBloom, - PrevRandao: &prevRan, - BlockNumber: &blockNum, - GasLimit: &gasLimit, - GasUsed: &gasUsed, - Timestamp: &timeStamp, - ExtraData: e.ExtraData, - BaseFeePerGas: baseFeeHex, - BlockHash: &bHash, - Transactions: transactions, - Withdrawals: withdrawals, - BlobGasUsed: &blobGasUsed, - ExcessBlobGas: &excessBlobGas, - WithdrawalRequests: ProtoWithdrawalRequestsToJson(e.WithdrawalRequests), - DepositRequests: ProtoDepositRequestsToJson(e.DepositRequests), + ParentHash: &pHash, + FeeRecipient: &recipient, + StateRoot: &sRoot, + ReceiptsRoot: &recRoot, + LogsBloom: &logsBloom, + PrevRandao: &prevRan, + BlockNumber: &blockNum, + GasLimit: &gasLimit, + GasUsed: &gasUsed, + Timestamp: &timeStamp, + ExtraData: e.ExtraData, + BaseFeePerGas: baseFeeHex, + BlockHash: &bHash, + Transactions: transactions, + Withdrawals: withdrawals, + BlobGasUsed: &blobGasUsed, + ExcessBlobGas: &excessBlobGas, + WithdrawalRequests: ProtoWithdrawalRequestsToJson(e.WithdrawalRequests), + DepositRequests: ProtoDepositRequestsToJson(e.DepositRequests), + ConsolidationRequests: ProtoConsolidationRequestsToJson(e.ConsolidationRequests), }) } diff --git a/proto/prysm/v1alpha1/cloners.go b/proto/prysm/v1alpha1/cloners.go index 8e51844d7127..1727c0ab0af0 100644 --- a/proto/prysm/v1alpha1/cloners.go +++ b/proto/prysm/v1alpha1/cloners.go @@ -1002,25 +1002,26 @@ func CopyExecutionPayloadElectra(payload *enginev1.ExecutionPayloadElectra) *eng return nil } return &enginev1.ExecutionPayloadElectra{ - ParentHash: bytesutil.SafeCopyBytes(payload.ParentHash), - FeeRecipient: bytesutil.SafeCopyBytes(payload.FeeRecipient), - StateRoot: bytesutil.SafeCopyBytes(payload.StateRoot), - ReceiptsRoot: bytesutil.SafeCopyBytes(payload.ReceiptsRoot), - LogsBloom: bytesutil.SafeCopyBytes(payload.LogsBloom), - PrevRandao: bytesutil.SafeCopyBytes(payload.PrevRandao), - BlockNumber: payload.BlockNumber, - GasLimit: payload.GasLimit, - GasUsed: payload.GasUsed, - Timestamp: payload.Timestamp, - ExtraData: bytesutil.SafeCopyBytes(payload.ExtraData), - BaseFeePerGas: bytesutil.SafeCopyBytes(payload.BaseFeePerGas), - BlockHash: bytesutil.SafeCopyBytes(payload.BlockHash), - Transactions: bytesutil.SafeCopy2dBytes(payload.Transactions), - Withdrawals: CopyWithdrawalSlice(payload.Withdrawals), - BlobGasUsed: payload.BlobGasUsed, - ExcessBlobGas: payload.ExcessBlobGas, - DepositRequests: CopyDepositRequests(payload.DepositRequests), - WithdrawalRequests: CopyWithdrawalRequests(payload.WithdrawalRequests), + ParentHash: bytesutil.SafeCopyBytes(payload.ParentHash), + FeeRecipient: bytesutil.SafeCopyBytes(payload.FeeRecipient), + StateRoot: bytesutil.SafeCopyBytes(payload.StateRoot), + ReceiptsRoot: bytesutil.SafeCopyBytes(payload.ReceiptsRoot), + LogsBloom: bytesutil.SafeCopyBytes(payload.LogsBloom), + PrevRandao: bytesutil.SafeCopyBytes(payload.PrevRandao), + BlockNumber: payload.BlockNumber, + GasLimit: payload.GasLimit, + GasUsed: payload.GasUsed, + Timestamp: payload.Timestamp, + ExtraData: bytesutil.SafeCopyBytes(payload.ExtraData), + BaseFeePerGas: bytesutil.SafeCopyBytes(payload.BaseFeePerGas), + BlockHash: bytesutil.SafeCopyBytes(payload.BlockHash), + Transactions: bytesutil.SafeCopy2dBytes(payload.Transactions), + Withdrawals: CopyWithdrawalSlice(payload.Withdrawals), + BlobGasUsed: payload.BlobGasUsed, + ExcessBlobGas: payload.ExcessBlobGas, + DepositRequests: CopyDepositRequests(payload.DepositRequests), + WithdrawalRequests: CopyWithdrawalRequests(payload.WithdrawalRequests), + ConsolidationRequests: CopyConsolidationRequests(payload.ConsolidationRequests), } } @@ -1058,6 +1059,22 @@ func CopyWithdrawalRequests(wr []*enginev1.WithdrawalRequest) []*enginev1.Withdr return newWr } +func CopyConsolidationRequests(cr []*enginev1.ConsolidationRequest) []*enginev1.ConsolidationRequest { + if cr == nil { + return nil + } + newCr := make([]*enginev1.ConsolidationRequest, len(cr)) + for i, w := range cr { + newCr[i] = &enginev1.ConsolidationRequest{ + SourceAddress: bytesutil.SafeCopyBytes(w.SourceAddress), + SourcePubkey: bytesutil.SafeCopyBytes(w.SourcePubkey), + TargetPubkey: bytesutil.SafeCopyBytes(w.TargetPubkey), + } + } + + return newCr +} + func CopyExecutionPayloadHeaderElectra(payload *enginev1.ExecutionPayloadHeaderElectra) *enginev1.ExecutionPayloadHeaderElectra { if payload == nil { return nil diff --git a/proto/prysm/v1alpha1/cloners_test.go b/proto/prysm/v1alpha1/cloners_test.go index e408599cf50d..5383970c9dec 100644 --- a/proto/prysm/v1alpha1/cloners_test.go +++ b/proto/prysm/v1alpha1/cloners_test.go @@ -1465,25 +1465,26 @@ func genBeaconBlockBodyElectra() *v1alpha1.BeaconBlockBodyElectra { func genExecutionPayloadElectra() *enginev1.ExecutionPayloadElectra { return &enginev1.ExecutionPayloadElectra{ - ParentHash: bytes(32), - FeeRecipient: bytes(20), - StateRoot: bytes(32), - ReceiptsRoot: bytes(32), - LogsBloom: bytes(256), - PrevRandao: bytes(32), - BlockNumber: 1, - GasLimit: 2, - GasUsed: 3, - Timestamp: 4, - ExtraData: bytes(32), - BaseFeePerGas: bytes(32), - BlockHash: bytes(32), - Transactions: [][]byte{{'a'}, {'b'}, {'c'}}, - Withdrawals: genWithdrawals(10), - BlobGasUsed: 5, - ExcessBlobGas: 6, - DepositRequests: genDepositRequests(10), - WithdrawalRequests: genWithdrawalRequests(10), + ParentHash: bytes(32), + FeeRecipient: bytes(20), + StateRoot: bytes(32), + ReceiptsRoot: bytes(32), + LogsBloom: bytes(256), + PrevRandao: bytes(32), + BlockNumber: 1, + GasLimit: 2, + GasUsed: 3, + Timestamp: 4, + ExtraData: bytes(32), + BaseFeePerGas: bytes(32), + BlockHash: bytes(32), + Transactions: [][]byte{{'a'}, {'b'}, {'c'}}, + Withdrawals: genWithdrawals(10), + BlobGasUsed: 5, + ExcessBlobGas: 6, + DepositRequests: genDepositRequests(10), + WithdrawalRequests: genWithdrawalRequests(10), + ConsolidationRequests: genConsolidationRequests(10), } } @@ -1521,6 +1522,22 @@ func genWithdrawalRequest() *enginev1.WithdrawalRequest { } } +func genConsolidationRequests(num int) []*enginev1.ConsolidationRequest { + crs := make([]*enginev1.ConsolidationRequest, num) + for i := 0; i < num; i++ { + crs[i] = genConsolidationRequest() + } + return crs +} + +func genConsolidationRequest() *enginev1.ConsolidationRequest { + return &enginev1.ConsolidationRequest{ + SourceAddress: bytes(20), + SourcePubkey: bytes(48), + TargetPubkey: bytes(48), + } +} + func genPendingPartialWithdrawals(num int) []*v1alpha1.PendingPartialWithdrawal { ppws := make([]*v1alpha1.PendingPartialWithdrawal, num) for i := 0; i < num; i++ {