mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 13:28:01 -05:00
electra payload fix for devnet1 (#14235)
* fixing marshalling and adding more to unit test * updating missed consolidation requests * renaming variables * adding test gen * reverting config change
This commit is contained in:
@@ -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{
|
||||
|
||||
@@ -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),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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++ {
|
||||
|
||||
Reference in New Issue
Block a user