mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
creating execution payload copy and fuzz tests (#14246)
* creating execution payload copy and fuzz tests * fixing build * removing unused code
This commit is contained in:
@@ -5,8 +5,6 @@ import (
|
|||||||
|
|
||||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
|
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
|
||||||
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
"github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces"
|
||||||
enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1"
|
|
||||||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
|
||||||
"github.com/prysmaticlabs/prysm/v5/runtime/version"
|
"github.com/prysmaticlabs/prysm/v5/runtime/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -21,34 +19,14 @@ func (b *BeaconState) LatestExecutionPayloadHeader() (interfaces.ExecutionData,
|
|||||||
|
|
||||||
switch b.version {
|
switch b.version {
|
||||||
case version.Bellatrix:
|
case version.Bellatrix:
|
||||||
return blocks.WrappedExecutionPayloadHeader(b.latestExecutionPayloadHeaderVal())
|
return blocks.WrappedExecutionPayloadHeader(b.latestExecutionPayloadHeader.Copy())
|
||||||
case version.Capella:
|
case version.Capella:
|
||||||
return blocks.WrappedExecutionPayloadHeaderCapella(b.latestExecutionPayloadHeaderCapellaVal())
|
return blocks.WrappedExecutionPayloadHeaderCapella(b.latestExecutionPayloadHeaderCapella.Copy())
|
||||||
case version.Deneb:
|
case version.Deneb:
|
||||||
return blocks.WrappedExecutionPayloadHeaderDeneb(b.latestExecutionPayloadHeaderDenebVal())
|
return blocks.WrappedExecutionPayloadHeaderDeneb(b.latestExecutionPayloadHeaderDeneb.Copy())
|
||||||
case version.Electra:
|
case version.Electra:
|
||||||
return blocks.WrappedExecutionPayloadHeaderElectra(b.latestExecutionPayloadHeaderElectraVal())
|
return blocks.WrappedExecutionPayloadHeaderElectra(b.latestExecutionPayloadHeaderElectra.Copy())
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unsupported version (%s) for latest execution payload header", version.String(b.version))
|
return nil, fmt.Errorf("unsupported version (%s) for latest execution payload header", version.String(b.version))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// latestExecutionPayloadHeaderVal of the beacon state.
|
|
||||||
// This assumes that a lock is already held on BeaconState.
|
|
||||||
func (b *BeaconState) latestExecutionPayloadHeaderVal() *enginev1.ExecutionPayloadHeader {
|
|
||||||
return ethpb.CopyExecutionPayloadHeader(b.latestExecutionPayloadHeader)
|
|
||||||
}
|
|
||||||
|
|
||||||
// latestExecutionPayloadHeaderCapellaVal of the beacon state.
|
|
||||||
// This assumes that a lock is already held on BeaconState.
|
|
||||||
func (b *BeaconState) latestExecutionPayloadHeaderCapellaVal() *enginev1.ExecutionPayloadHeaderCapella {
|
|
||||||
return ethpb.CopyExecutionPayloadHeaderCapella(b.latestExecutionPayloadHeaderCapella)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *BeaconState) latestExecutionPayloadHeaderDenebVal() *enginev1.ExecutionPayloadHeaderDeneb {
|
|
||||||
return ethpb.CopyExecutionPayloadHeaderDeneb(b.latestExecutionPayloadHeaderDeneb)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *BeaconState) latestExecutionPayloadHeaderElectraVal() *enginev1.ExecutionPayloadHeaderElectra {
|
|
||||||
return ethpb.CopyExecutionPayloadHeaderElectra(b.latestExecutionPayloadHeaderElectra)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ func (b *BeaconState) ToProto() interface{} {
|
|||||||
InactivityScores: inactivityScores,
|
InactivityScores: inactivityScores,
|
||||||
CurrentSyncCommittee: b.currentSyncCommitteeVal(),
|
CurrentSyncCommittee: b.currentSyncCommitteeVal(),
|
||||||
NextSyncCommittee: b.nextSyncCommitteeVal(),
|
NextSyncCommittee: b.nextSyncCommitteeVal(),
|
||||||
LatestExecutionPayloadHeader: b.latestExecutionPayloadHeaderVal(),
|
LatestExecutionPayloadHeader: b.latestExecutionPayloadHeader.Copy(),
|
||||||
}
|
}
|
||||||
case version.Capella:
|
case version.Capella:
|
||||||
return ðpb.BeaconStateCapella{
|
return ðpb.BeaconStateCapella{
|
||||||
@@ -342,7 +342,7 @@ func (b *BeaconState) ToProto() interface{} {
|
|||||||
InactivityScores: inactivityScores,
|
InactivityScores: inactivityScores,
|
||||||
CurrentSyncCommittee: b.currentSyncCommitteeVal(),
|
CurrentSyncCommittee: b.currentSyncCommitteeVal(),
|
||||||
NextSyncCommittee: b.nextSyncCommitteeVal(),
|
NextSyncCommittee: b.nextSyncCommitteeVal(),
|
||||||
LatestExecutionPayloadHeader: b.latestExecutionPayloadHeaderCapellaVal(),
|
LatestExecutionPayloadHeader: b.latestExecutionPayloadHeaderCapella.Copy(),
|
||||||
NextWithdrawalIndex: b.nextWithdrawalIndex,
|
NextWithdrawalIndex: b.nextWithdrawalIndex,
|
||||||
NextWithdrawalValidatorIndex: b.nextWithdrawalValidatorIndex,
|
NextWithdrawalValidatorIndex: b.nextWithdrawalValidatorIndex,
|
||||||
HistoricalSummaries: b.historicalSummariesVal(),
|
HistoricalSummaries: b.historicalSummariesVal(),
|
||||||
@@ -373,7 +373,7 @@ func (b *BeaconState) ToProto() interface{} {
|
|||||||
InactivityScores: b.inactivityScoresVal(),
|
InactivityScores: b.inactivityScoresVal(),
|
||||||
CurrentSyncCommittee: b.currentSyncCommitteeVal(),
|
CurrentSyncCommittee: b.currentSyncCommitteeVal(),
|
||||||
NextSyncCommittee: b.nextSyncCommitteeVal(),
|
NextSyncCommittee: b.nextSyncCommitteeVal(),
|
||||||
LatestExecutionPayloadHeader: b.latestExecutionPayloadHeaderDenebVal(),
|
LatestExecutionPayloadHeader: b.latestExecutionPayloadHeaderDeneb.Copy(),
|
||||||
NextWithdrawalIndex: b.nextWithdrawalIndex,
|
NextWithdrawalIndex: b.nextWithdrawalIndex,
|
||||||
NextWithdrawalValidatorIndex: b.nextWithdrawalValidatorIndex,
|
NextWithdrawalValidatorIndex: b.nextWithdrawalValidatorIndex,
|
||||||
HistoricalSummaries: b.historicalSummariesVal(),
|
HistoricalSummaries: b.historicalSummariesVal(),
|
||||||
@@ -404,7 +404,7 @@ func (b *BeaconState) ToProto() interface{} {
|
|||||||
InactivityScores: b.inactivityScoresVal(),
|
InactivityScores: b.inactivityScoresVal(),
|
||||||
CurrentSyncCommittee: b.currentSyncCommitteeVal(),
|
CurrentSyncCommittee: b.currentSyncCommitteeVal(),
|
||||||
NextSyncCommittee: b.nextSyncCommitteeVal(),
|
NextSyncCommittee: b.nextSyncCommitteeVal(),
|
||||||
LatestExecutionPayloadHeader: b.latestExecutionPayloadHeaderElectraVal(),
|
LatestExecutionPayloadHeader: b.latestExecutionPayloadHeaderElectra.Copy(),
|
||||||
NextWithdrawalIndex: b.nextWithdrawalIndex,
|
NextWithdrawalIndex: b.nextWithdrawalIndex,
|
||||||
NextWithdrawalValidatorIndex: b.nextWithdrawalValidatorIndex,
|
NextWithdrawalValidatorIndex: b.nextWithdrawalValidatorIndex,
|
||||||
HistoricalSummaries: b.historicalSummariesVal(),
|
HistoricalSummaries: b.historicalSummariesVal(),
|
||||||
|
|||||||
@@ -907,10 +907,10 @@ func (b *BeaconState) Copy() state.BeaconState {
|
|||||||
finalizedCheckpoint: b.finalizedCheckpointVal(),
|
finalizedCheckpoint: b.finalizedCheckpointVal(),
|
||||||
currentSyncCommittee: b.currentSyncCommitteeVal(),
|
currentSyncCommittee: b.currentSyncCommitteeVal(),
|
||||||
nextSyncCommittee: b.nextSyncCommitteeVal(),
|
nextSyncCommittee: b.nextSyncCommitteeVal(),
|
||||||
latestExecutionPayloadHeader: b.latestExecutionPayloadHeaderVal(),
|
latestExecutionPayloadHeader: b.latestExecutionPayloadHeader.Copy(),
|
||||||
latestExecutionPayloadHeaderCapella: b.latestExecutionPayloadHeaderCapellaVal(),
|
latestExecutionPayloadHeaderCapella: b.latestExecutionPayloadHeaderCapella.Copy(),
|
||||||
latestExecutionPayloadHeaderDeneb: b.latestExecutionPayloadHeaderDenebVal(),
|
latestExecutionPayloadHeaderDeneb: b.latestExecutionPayloadHeaderDeneb.Copy(),
|
||||||
latestExecutionPayloadHeaderElectra: b.latestExecutionPayloadHeaderElectraVal(),
|
latestExecutionPayloadHeaderElectra: b.latestExecutionPayloadHeaderElectra.Copy(),
|
||||||
|
|
||||||
id: types.Enumerator.Inc(),
|
id: types.Enumerator.Inc(),
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ func copySlice[T any, C copier[T]](original []C) []T {
|
|||||||
return newSlice
|
return newSlice
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy --
|
||||||
func (w *Withdrawal) Copy() *Withdrawal {
|
func (w *Withdrawal) Copy() *Withdrawal {
|
||||||
if w == nil {
|
if w == nil {
|
||||||
return nil
|
return nil
|
||||||
@@ -28,6 +29,7 @@ func (w *Withdrawal) Copy() *Withdrawal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy --
|
||||||
func (d *DepositRequest) Copy() *DepositRequest {
|
func (d *DepositRequest) Copy() *DepositRequest {
|
||||||
if d == nil {
|
if d == nil {
|
||||||
return nil
|
return nil
|
||||||
@@ -41,6 +43,7 @@ func (d *DepositRequest) Copy() *DepositRequest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy --
|
||||||
func (wr *WithdrawalRequest) Copy() *WithdrawalRequest {
|
func (wr *WithdrawalRequest) Copy() *WithdrawalRequest {
|
||||||
if wr == nil {
|
if wr == nil {
|
||||||
return nil
|
return nil
|
||||||
@@ -52,6 +55,7 @@ func (wr *WithdrawalRequest) Copy() *WithdrawalRequest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy --
|
||||||
func (cr *ConsolidationRequest) Copy() *ConsolidationRequest {
|
func (cr *ConsolidationRequest) Copy() *ConsolidationRequest {
|
||||||
if cr == nil {
|
if cr == nil {
|
||||||
return nil
|
return nil
|
||||||
@@ -63,6 +67,7 @@ func (cr *ConsolidationRequest) Copy() *ConsolidationRequest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy -- Electra
|
||||||
func (payload *ExecutionPayloadElectra) Copy() *ExecutionPayloadElectra {
|
func (payload *ExecutionPayloadElectra) Copy() *ExecutionPayloadElectra {
|
||||||
if payload == nil {
|
if payload == nil {
|
||||||
return nil
|
return nil
|
||||||
@@ -90,3 +95,181 @@ func (payload *ExecutionPayloadElectra) Copy() *ExecutionPayloadElectra {
|
|||||||
ConsolidationRequests: copySlice(payload.ConsolidationRequests),
|
ConsolidationRequests: copySlice(payload.ConsolidationRequests),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy -- Deneb
|
||||||
|
func (payload *ExecutionPayloadDeneb) Copy() *ExecutionPayloadDeneb {
|
||||||
|
if payload == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &ExecutionPayloadDeneb{
|
||||||
|
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: copySlice(payload.Withdrawals),
|
||||||
|
BlobGasUsed: payload.BlobGasUsed,
|
||||||
|
ExcessBlobGas: payload.ExcessBlobGas,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy -- Capella
|
||||||
|
func (payload *ExecutionPayloadCapella) Copy() *ExecutionPayloadCapella {
|
||||||
|
if payload == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return &ExecutionPayloadCapella{
|
||||||
|
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: copySlice(payload.Withdrawals),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy -- Bellatrix
|
||||||
|
func (payload *ExecutionPayload) Copy() *ExecutionPayload {
|
||||||
|
if payload == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return &ExecutionPayload{
|
||||||
|
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),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy -- Electra
|
||||||
|
func (payload *ExecutionPayloadHeaderElectra) Copy() *ExecutionPayloadHeaderElectra {
|
||||||
|
if payload == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return &ExecutionPayloadHeaderElectra{
|
||||||
|
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),
|
||||||
|
TransactionsRoot: bytesutil.SafeCopyBytes(payload.TransactionsRoot),
|
||||||
|
WithdrawalsRoot: bytesutil.SafeCopyBytes(payload.WithdrawalsRoot),
|
||||||
|
BlobGasUsed: payload.BlobGasUsed,
|
||||||
|
ExcessBlobGas: payload.ExcessBlobGas,
|
||||||
|
DepositRequestsRoot: bytesutil.SafeCopyBytes(payload.DepositRequestsRoot),
|
||||||
|
WithdrawalRequestsRoot: bytesutil.SafeCopyBytes(payload.WithdrawalRequestsRoot),
|
||||||
|
ConsolidationRequestsRoot: bytesutil.SafeCopyBytes(payload.ConsolidationRequestsRoot),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy -- Deneb
|
||||||
|
func (payload *ExecutionPayloadHeaderDeneb) Copy() *ExecutionPayloadHeaderDeneb {
|
||||||
|
if payload == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &ExecutionPayloadHeaderDeneb{
|
||||||
|
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),
|
||||||
|
TransactionsRoot: bytesutil.SafeCopyBytes(payload.TransactionsRoot),
|
||||||
|
WithdrawalsRoot: bytesutil.SafeCopyBytes(payload.WithdrawalsRoot),
|
||||||
|
BlobGasUsed: payload.BlobGasUsed,
|
||||||
|
ExcessBlobGas: payload.ExcessBlobGas,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy -- Capella
|
||||||
|
func (payload *ExecutionPayloadHeaderCapella) Copy() *ExecutionPayloadHeaderCapella {
|
||||||
|
if payload == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &ExecutionPayloadHeaderCapella{
|
||||||
|
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),
|
||||||
|
TransactionsRoot: bytesutil.SafeCopyBytes(payload.TransactionsRoot),
|
||||||
|
WithdrawalsRoot: bytesutil.SafeCopyBytes(payload.WithdrawalsRoot),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy -- Bellatrix
|
||||||
|
func (payload *ExecutionPayloadHeader) Copy() *ExecutionPayloadHeader {
|
||||||
|
if payload == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &ExecutionPayloadHeader{
|
||||||
|
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),
|
||||||
|
TransactionsRoot: bytesutil.SafeCopyBytes(payload.TransactionsRoot),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,6 +11,16 @@ import (
|
|||||||
|
|
||||||
func TestCopyExecutionPayload_Fuzz(t *testing.T) {
|
func TestCopyExecutionPayload_Fuzz(t *testing.T) {
|
||||||
fuzzCopies(t, &enginev1.ExecutionPayloadElectra{})
|
fuzzCopies(t, &enginev1.ExecutionPayloadElectra{})
|
||||||
|
fuzzCopies(t, &enginev1.ExecutionPayloadDeneb{})
|
||||||
|
fuzzCopies(t, &enginev1.ExecutionPayloadCapella{})
|
||||||
|
fuzzCopies(t, &enginev1.ExecutionPayload{})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCopyExecutionPayloadHeader_Fuzz(t *testing.T) {
|
||||||
|
fuzzCopies(t, &enginev1.ExecutionPayloadHeaderElectra{})
|
||||||
|
fuzzCopies(t, &enginev1.ExecutionPayloadHeaderDeneb{})
|
||||||
|
fuzzCopies(t, &enginev1.ExecutionPayloadHeaderCapella{})
|
||||||
|
fuzzCopies(t, &enginev1.ExecutionPayloadHeader{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func fuzzCopies[T any, C enginev1.Copier[T]](t *testing.T, obj C) {
|
func fuzzCopies[T any, C enginev1.Copier[T]](t *testing.T, obj C) {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package eth
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
|
||||||
enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// CopyETH1Data copies the provided eth1data object.
|
// CopyETH1Data copies the provided eth1data object.
|
||||||
@@ -474,7 +473,7 @@ func CopyBeaconBlockBodyBellatrix(body *BeaconBlockBodyBellatrix) *BeaconBlockBo
|
|||||||
Deposits: CopyDeposits(body.Deposits),
|
Deposits: CopyDeposits(body.Deposits),
|
||||||
VoluntaryExits: CopySignedVoluntaryExits(body.VoluntaryExits),
|
VoluntaryExits: CopySignedVoluntaryExits(body.VoluntaryExits),
|
||||||
SyncAggregate: CopySyncAggregate(body.SyncAggregate),
|
SyncAggregate: CopySyncAggregate(body.SyncAggregate),
|
||||||
ExecutionPayload: CopyExecutionPayload(body.ExecutionPayload),
|
ExecutionPayload: body.ExecutionPayload.Copy(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -518,7 +517,7 @@ func CopyBeaconBlockBodyCapella(body *BeaconBlockBodyCapella) *BeaconBlockBodyCa
|
|||||||
Deposits: CopyDeposits(body.Deposits),
|
Deposits: CopyDeposits(body.Deposits),
|
||||||
VoluntaryExits: CopySignedVoluntaryExits(body.VoluntaryExits),
|
VoluntaryExits: CopySignedVoluntaryExits(body.VoluntaryExits),
|
||||||
SyncAggregate: CopySyncAggregate(body.SyncAggregate),
|
SyncAggregate: CopySyncAggregate(body.SyncAggregate),
|
||||||
ExecutionPayload: CopyExecutionPayloadCapella(body.ExecutionPayload),
|
ExecutionPayload: body.ExecutionPayload.Copy(),
|
||||||
BlsToExecutionChanges: CopyBLSToExecutionChanges(body.BlsToExecutionChanges),
|
BlsToExecutionChanges: CopyBLSToExecutionChanges(body.BlsToExecutionChanges),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -563,7 +562,7 @@ func CopyBlindedBeaconBlockBodyCapella(body *BlindedBeaconBlockBodyCapella) *Bli
|
|||||||
Deposits: CopyDeposits(body.Deposits),
|
Deposits: CopyDeposits(body.Deposits),
|
||||||
VoluntaryExits: CopySignedVoluntaryExits(body.VoluntaryExits),
|
VoluntaryExits: CopySignedVoluntaryExits(body.VoluntaryExits),
|
||||||
SyncAggregate: CopySyncAggregate(body.SyncAggregate),
|
SyncAggregate: CopySyncAggregate(body.SyncAggregate),
|
||||||
ExecutionPayloadHeader: CopyExecutionPayloadHeaderCapella(body.ExecutionPayloadHeader),
|
ExecutionPayloadHeader: body.ExecutionPayloadHeader.Copy(),
|
||||||
BlsToExecutionChanges: CopyBLSToExecutionChanges(body.BlsToExecutionChanges),
|
BlsToExecutionChanges: CopyBLSToExecutionChanges(body.BlsToExecutionChanges),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -608,7 +607,7 @@ func CopyBlindedBeaconBlockBodyDeneb(body *BlindedBeaconBlockBodyDeneb) *Blinded
|
|||||||
Deposits: CopyDeposits(body.Deposits),
|
Deposits: CopyDeposits(body.Deposits),
|
||||||
VoluntaryExits: CopySignedVoluntaryExits(body.VoluntaryExits),
|
VoluntaryExits: CopySignedVoluntaryExits(body.VoluntaryExits),
|
||||||
SyncAggregate: CopySyncAggregate(body.SyncAggregate),
|
SyncAggregate: CopySyncAggregate(body.SyncAggregate),
|
||||||
ExecutionPayloadHeader: CopyExecutionPayloadHeaderDeneb(body.ExecutionPayloadHeader),
|
ExecutionPayloadHeader: body.ExecutionPayloadHeader.Copy(),
|
||||||
BlsToExecutionChanges: CopyBLSToExecutionChanges(body.BlsToExecutionChanges),
|
BlsToExecutionChanges: CopyBLSToExecutionChanges(body.BlsToExecutionChanges),
|
||||||
BlobKzgCommitments: CopyBlobKZGs(body.BlobKzgCommitments),
|
BlobKzgCommitments: CopyBlobKZGs(body.BlobKzgCommitments),
|
||||||
}
|
}
|
||||||
@@ -654,108 +653,12 @@ func CopyBlindedBeaconBlockBodyElectra(body *BlindedBeaconBlockBodyElectra) *Bli
|
|||||||
Deposits: CopyDeposits(body.Deposits),
|
Deposits: CopyDeposits(body.Deposits),
|
||||||
VoluntaryExits: CopySignedVoluntaryExits(body.VoluntaryExits),
|
VoluntaryExits: CopySignedVoluntaryExits(body.VoluntaryExits),
|
||||||
SyncAggregate: CopySyncAggregate(body.SyncAggregate),
|
SyncAggregate: CopySyncAggregate(body.SyncAggregate),
|
||||||
ExecutionPayloadHeader: CopyExecutionPayloadHeaderElectra(body.ExecutionPayloadHeader),
|
ExecutionPayloadHeader: body.ExecutionPayloadHeader.Copy(),
|
||||||
BlsToExecutionChanges: CopyBLSToExecutionChanges(body.BlsToExecutionChanges),
|
BlsToExecutionChanges: CopyBLSToExecutionChanges(body.BlsToExecutionChanges),
|
||||||
BlobKzgCommitments: CopyBlobKZGs(body.BlobKzgCommitments),
|
BlobKzgCommitments: CopyBlobKZGs(body.BlobKzgCommitments),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CopyExecutionPayload copies the provided execution payload.
|
|
||||||
func CopyExecutionPayload(payload *enginev1.ExecutionPayload) *enginev1.ExecutionPayload {
|
|
||||||
if payload == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return &enginev1.ExecutionPayload{
|
|
||||||
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),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// CopyExecutionPayloadCapella copies the provided execution payload.
|
|
||||||
func CopyExecutionPayloadCapella(payload *enginev1.ExecutionPayloadCapella) *enginev1.ExecutionPayloadCapella {
|
|
||||||
if payload == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return &enginev1.ExecutionPayloadCapella{
|
|
||||||
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: copySlice(payload.Withdrawals),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// CopyExecutionPayloadHeader copies the provided execution payload object.
|
|
||||||
func CopyExecutionPayloadHeader(payload *enginev1.ExecutionPayloadHeader) *enginev1.ExecutionPayloadHeader {
|
|
||||||
if payload == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return &enginev1.ExecutionPayloadHeader{
|
|
||||||
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),
|
|
||||||
TransactionsRoot: bytesutil.SafeCopyBytes(payload.TransactionsRoot),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// CopyExecutionPayloadHeaderCapella copies the provided execution payload object.
|
|
||||||
func CopyExecutionPayloadHeaderCapella(payload *enginev1.ExecutionPayloadHeaderCapella) *enginev1.ExecutionPayloadHeaderCapella {
|
|
||||||
if payload == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return &enginev1.ExecutionPayloadHeaderCapella{
|
|
||||||
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),
|
|
||||||
TransactionsRoot: bytesutil.SafeCopyBytes(payload.TransactionsRoot),
|
|
||||||
WithdrawalsRoot: bytesutil.SafeCopyBytes(payload.WithdrawalsRoot),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// CopySignedBlindedBeaconBlockBellatrix copies the provided SignedBlindedBeaconBlockBellatrix.
|
// CopySignedBlindedBeaconBlockBellatrix copies the provided SignedBlindedBeaconBlockBellatrix.
|
||||||
func CopySignedBlindedBeaconBlockBellatrix(sigBlock *SignedBlindedBeaconBlockBellatrix) *SignedBlindedBeaconBlockBellatrix {
|
func CopySignedBlindedBeaconBlockBellatrix(sigBlock *SignedBlindedBeaconBlockBellatrix) *SignedBlindedBeaconBlockBellatrix {
|
||||||
if sigBlock == nil {
|
if sigBlock == nil {
|
||||||
@@ -796,7 +699,7 @@ func CopyBlindedBeaconBlockBodyBellatrix(body *BlindedBeaconBlockBodyBellatrix)
|
|||||||
Deposits: CopyDeposits(body.Deposits),
|
Deposits: CopyDeposits(body.Deposits),
|
||||||
VoluntaryExits: CopySignedVoluntaryExits(body.VoluntaryExits),
|
VoluntaryExits: CopySignedVoluntaryExits(body.VoluntaryExits),
|
||||||
SyncAggregate: CopySyncAggregate(body.SyncAggregate),
|
SyncAggregate: CopySyncAggregate(body.SyncAggregate),
|
||||||
ExecutionPayloadHeader: CopyExecutionPayloadHeader(body.ExecutionPayloadHeader),
|
ExecutionPayloadHeader: body.ExecutionPayloadHeader.Copy(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -865,64 +768,12 @@ func CopyBeaconBlockBodyDeneb(body *BeaconBlockBodyDeneb) *BeaconBlockBodyDeneb
|
|||||||
Deposits: CopyDeposits(body.Deposits),
|
Deposits: CopyDeposits(body.Deposits),
|
||||||
VoluntaryExits: CopySignedVoluntaryExits(body.VoluntaryExits),
|
VoluntaryExits: CopySignedVoluntaryExits(body.VoluntaryExits),
|
||||||
SyncAggregate: CopySyncAggregate(body.SyncAggregate),
|
SyncAggregate: CopySyncAggregate(body.SyncAggregate),
|
||||||
ExecutionPayload: CopyExecutionPayloadDeneb(body.ExecutionPayload),
|
ExecutionPayload: body.ExecutionPayload.Copy(),
|
||||||
BlsToExecutionChanges: CopyBLSToExecutionChanges(body.BlsToExecutionChanges),
|
BlsToExecutionChanges: CopyBLSToExecutionChanges(body.BlsToExecutionChanges),
|
||||||
BlobKzgCommitments: CopyBlobKZGs(body.BlobKzgCommitments),
|
BlobKzgCommitments: CopyBlobKZGs(body.BlobKzgCommitments),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CopyExecutionPayloadHeaderDeneb copies the provided execution payload object.
|
|
||||||
func CopyExecutionPayloadHeaderDeneb(payload *enginev1.ExecutionPayloadHeaderDeneb) *enginev1.ExecutionPayloadHeaderDeneb {
|
|
||||||
if payload == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return &enginev1.ExecutionPayloadHeaderDeneb{
|
|
||||||
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),
|
|
||||||
TransactionsRoot: bytesutil.SafeCopyBytes(payload.TransactionsRoot),
|
|
||||||
WithdrawalsRoot: bytesutil.SafeCopyBytes(payload.WithdrawalsRoot),
|
|
||||||
BlobGasUsed: payload.BlobGasUsed,
|
|
||||||
ExcessBlobGas: payload.ExcessBlobGas,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// CopyExecutionPayloadDeneb copies the provided execution payload.
|
|
||||||
func CopyExecutionPayloadDeneb(payload *enginev1.ExecutionPayloadDeneb) *enginev1.ExecutionPayloadDeneb {
|
|
||||||
if payload == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return &enginev1.ExecutionPayloadDeneb{
|
|
||||||
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: copySlice(payload.Withdrawals),
|
|
||||||
BlobGasUsed: payload.BlobGasUsed,
|
|
||||||
ExcessBlobGas: payload.ExcessBlobGas,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// CopySignedBeaconBlockElectra copies the provided SignedBeaconBlockElectra.
|
// CopySignedBeaconBlockElectra copies the provided SignedBeaconBlockElectra.
|
||||||
func CopySignedBeaconBlockElectra(sigBlock *SignedBeaconBlockElectra) *SignedBeaconBlockElectra {
|
func CopySignedBeaconBlockElectra(sigBlock *SignedBeaconBlockElectra) *SignedBeaconBlockElectra {
|
||||||
if sigBlock == nil {
|
if sigBlock == nil {
|
||||||
@@ -969,34 +820,6 @@ func CopyBeaconBlockBodyElectra(body *BeaconBlockBodyElectra) *BeaconBlockBodyEl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func CopyExecutionPayloadHeaderElectra(payload *enginev1.ExecutionPayloadHeaderElectra) *enginev1.ExecutionPayloadHeaderElectra {
|
|
||||||
if payload == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return &enginev1.ExecutionPayloadHeaderElectra{
|
|
||||||
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),
|
|
||||||
TransactionsRoot: bytesutil.SafeCopyBytes(payload.TransactionsRoot),
|
|
||||||
WithdrawalsRoot: bytesutil.SafeCopyBytes(payload.WithdrawalsRoot),
|
|
||||||
BlobGasUsed: payload.BlobGasUsed,
|
|
||||||
ExcessBlobGas: payload.ExcessBlobGas,
|
|
||||||
DepositRequestsRoot: bytesutil.SafeCopyBytes(payload.DepositRequestsRoot),
|
|
||||||
WithdrawalRequestsRoot: bytesutil.SafeCopyBytes(payload.WithdrawalRequestsRoot),
|
|
||||||
ConsolidationRequestsRoot: bytesutil.SafeCopyBytes(payload.ConsolidationRequestsRoot),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// CopyHistoricalSummaries copies the historical summaries.
|
// CopyHistoricalSummaries copies the historical summaries.
|
||||||
func CopyHistoricalSummaries(summaries []*HistoricalSummary) []*HistoricalSummary {
|
func CopyHistoricalSummaries(summaries []*HistoricalSummary) []*HistoricalSummary {
|
||||||
if summaries == nil {
|
if summaries == nil {
|
||||||
@@ -1055,16 +878,3 @@ func CopyPendingBalanceDeposits(pbd []*PendingBalanceDeposit) []*PendingBalanceD
|
|||||||
}
|
}
|
||||||
return newPbd
|
return newPbd
|
||||||
}
|
}
|
||||||
|
|
||||||
type cloneable[T any] interface {
|
|
||||||
Copy() T
|
|
||||||
}
|
|
||||||
|
|
||||||
func copySlice[T any, C cloneable[T]](original []C) []T {
|
|
||||||
// Create a new slice with the same length as the original
|
|
||||||
newSlice := make([]T, len(original))
|
|
||||||
for i := 0; i < len(newSlice); i++ {
|
|
||||||
newSlice[i] = original[i].Copy()
|
|
||||||
}
|
|
||||||
return newSlice
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -309,36 +309,6 @@ func TestCopyPendingAttestationSlice(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCopyPayloadHeader(t *testing.T) {
|
|
||||||
p := genPayloadHeader()
|
|
||||||
|
|
||||||
got := v1alpha1.CopyExecutionPayloadHeader(p)
|
|
||||||
if !reflect.DeepEqual(got, p) {
|
|
||||||
t.Errorf("CopyExecutionPayloadHeader() = %v, want %v", got, p)
|
|
||||||
}
|
|
||||||
assert.NotEmpty(t, got, "Copied execution payload header has empty fields")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCopyPayloadHeaderCapella(t *testing.T) {
|
|
||||||
p := genPayloadHeaderCapella()
|
|
||||||
|
|
||||||
got := v1alpha1.CopyExecutionPayloadHeaderCapella(p)
|
|
||||||
if !reflect.DeepEqual(got, p) {
|
|
||||||
t.Errorf("TestCopyPayloadHeaderCapella() = %v, want %v", got, p)
|
|
||||||
}
|
|
||||||
assert.NotEmpty(t, got, "Copied execution payload header has empty fields")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCopyPayloadHeaderDeneb(t *testing.T) {
|
|
||||||
p := genPayloadHeaderDeneb()
|
|
||||||
|
|
||||||
got := v1alpha1.CopyExecutionPayloadHeaderDeneb(p)
|
|
||||||
if !reflect.DeepEqual(got, p) {
|
|
||||||
t.Errorf("TestCopyPayloadHeaderDeneb() = %v, want %v", got, p)
|
|
||||||
}
|
|
||||||
assert.NotEmpty(t, got, "Copied execution payload header has empty fields")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCopySignedBeaconBlockBellatrix(t *testing.T) {
|
func TestCopySignedBeaconBlockBellatrix(t *testing.T) {
|
||||||
sbb := genSignedBeaconBlockBellatrix()
|
sbb := genSignedBeaconBlockBellatrix()
|
||||||
|
|
||||||
@@ -638,15 +608,6 @@ func TestCopyBeaconBlockBodyElectra(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCopyExecutionPayloadHeaderElectra(t *testing.T) {
|
|
||||||
p := genExecutionPayloadHeaderElectra()
|
|
||||||
|
|
||||||
got := v1alpha1.CopyExecutionPayloadHeaderElectra(p)
|
|
||||||
if !reflect.DeepEqual(got, p) {
|
|
||||||
t.Errorf("TestCopyExecutionPayloadHeaderElectra() = %v, want %v", got, p)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCopyPendingPartialWithdrawals(t *testing.T) {
|
func TestCopyPendingPartialWithdrawals(t *testing.T) {
|
||||||
ppws := genPendingPartialWithdrawals(10)
|
ppws := genPendingPartialWithdrawals(10)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user