Simplify next Fork boilerplate creation. (#14761)

* Simplify next Fork boilerplate creation.

* Update beacon-chain/blockchain/execution_engine.go

Co-authored-by: Radosław Kapka <rkapka@wp.pl>

* Update beacon-chain/blockchain/execution_engine.go

Co-authored-by: Radosław Kapka <rkapka@wp.pl>

* Update beacon-chain/blockchain/execution_engine.go

Co-authored-by: Radosław Kapka <rkapka@wp.pl>

* Update beacon-chain/state/state-native/spec_parameters.go

Co-authored-by: Radosław Kapka <rkapka@wp.pl>

* Update beacon-chain/state/state-native/spec_parameters.go

Co-authored-by: Radosław Kapka <rkapka@wp.pl>

* Update beacon-chain/state/state-native/spec_parameters.go

Co-authored-by: Radosław Kapka <rkapka@wp.pl>

* Update beacon-chain/state/state-native/spec_parameters.go

Co-authored-by: Radosław Kapka <rkapka@wp.pl>

* Fix Radek's comments.

---------

Co-authored-by: Radosław Kapka <rkapka@wp.pl>
This commit is contained in:
Manu NALEPA
2025-01-03 15:39:08 +01:00
committed by GitHub
parent 8cff9356f1
commit 8a439a6f5d
49 changed files with 2542 additions and 2358 deletions

View File

@@ -8,9 +8,6 @@ import (
"github.com/prysmaticlabs/prysm/v5/config/params"
)
type ExecutionPayloadElectra = ExecutionPayloadDeneb
type ExecutionPayloadHeaderElectra = ExecutionPayloadHeaderDeneb
var (
drExample = &DepositRequest{}
drSize = drExample.SizeSSZ()

View File

@@ -5,6 +5,10 @@ import (
enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1"
)
// ----------------------------------------------------------------------------
// Phase 0
// ----------------------------------------------------------------------------
// Copy --
func (sigBlock *SignedBeaconBlock) Copy() *SignedBeaconBlock {
if sigBlock == nil {
@@ -47,443 +51,6 @@ func (body *BeaconBlockBody) Copy() *BeaconBlockBody {
}
}
// Copy --
func (sigBlock *SignedBeaconBlockAltair) Copy() *SignedBeaconBlockAltair {
if sigBlock == nil {
return nil
}
return &SignedBeaconBlockAltair{
Block: sigBlock.Block.Copy(),
Signature: bytesutil.SafeCopyBytes(sigBlock.Signature),
}
}
// Copy --
func (block *BeaconBlockAltair) Copy() *BeaconBlockAltair {
if block == nil {
return nil
}
return &BeaconBlockAltair{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot),
StateRoot: bytesutil.SafeCopyBytes(block.StateRoot),
Body: block.Body.Copy(),
}
}
// Copy --
func (body *BeaconBlockBodyAltair) Copy() *BeaconBlockBodyAltair {
if body == nil {
return nil
}
return &BeaconBlockBodyAltair{
RandaoReveal: bytesutil.SafeCopyBytes(body.RandaoReveal),
Eth1Data: body.Eth1Data.Copy(),
Graffiti: bytesutil.SafeCopyBytes(body.Graffiti),
ProposerSlashings: CopySlice(body.ProposerSlashings),
AttesterSlashings: CopySlice(body.AttesterSlashings),
Attestations: CopySlice(body.Attestations),
Deposits: CopySlice(body.Deposits),
VoluntaryExits: CopySlice(body.VoluntaryExits),
SyncAggregate: body.SyncAggregate.Copy(),
}
}
// Copy --
func (sigBlock *SignedBeaconBlockBellatrix) Copy() *SignedBeaconBlockBellatrix {
if sigBlock == nil {
return nil
}
return &SignedBeaconBlockBellatrix{
Block: sigBlock.Block.Copy(),
Signature: bytesutil.SafeCopyBytes(sigBlock.Signature),
}
}
// Copy --
func (block *BeaconBlockBellatrix) Copy() *BeaconBlockBellatrix {
if block == nil {
return nil
}
return &BeaconBlockBellatrix{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot),
StateRoot: bytesutil.SafeCopyBytes(block.StateRoot),
Body: block.Body.Copy(),
}
}
// Copy --
func (body *BeaconBlockBodyBellatrix) Copy() *BeaconBlockBodyBellatrix {
if body == nil {
return nil
}
return &BeaconBlockBodyBellatrix{
RandaoReveal: bytesutil.SafeCopyBytes(body.RandaoReveal),
Eth1Data: body.Eth1Data.Copy(),
Graffiti: bytesutil.SafeCopyBytes(body.Graffiti),
ProposerSlashings: CopySlice(body.ProposerSlashings),
AttesterSlashings: CopySlice(body.AttesterSlashings),
Attestations: CopySlice(body.Attestations),
Deposits: CopySlice(body.Deposits),
VoluntaryExits: CopySlice(body.VoluntaryExits),
SyncAggregate: body.SyncAggregate.Copy(),
ExecutionPayload: body.ExecutionPayload.Copy(),
}
}
// Copy --
func (sigBlock *SignedBeaconBlockCapella) Copy() *SignedBeaconBlockCapella {
if sigBlock == nil {
return nil
}
return &SignedBeaconBlockCapella{
Block: sigBlock.Block.Copy(),
Signature: bytesutil.SafeCopyBytes(sigBlock.Signature),
}
}
// Copy --
func (block *BeaconBlockCapella) Copy() *BeaconBlockCapella {
if block == nil {
return nil
}
return &BeaconBlockCapella{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot),
StateRoot: bytesutil.SafeCopyBytes(block.StateRoot),
Body: block.Body.Copy(),
}
}
// Copy --
func (body *BeaconBlockBodyCapella) Copy() *BeaconBlockBodyCapella {
if body == nil {
return nil
}
return &BeaconBlockBodyCapella{
RandaoReveal: bytesutil.SafeCopyBytes(body.RandaoReveal),
Eth1Data: body.Eth1Data.Copy(),
Graffiti: bytesutil.SafeCopyBytes(body.Graffiti),
ProposerSlashings: CopySlice(body.ProposerSlashings),
AttesterSlashings: CopySlice(body.AttesterSlashings),
Attestations: CopySlice(body.Attestations),
Deposits: CopySlice(body.Deposits),
VoluntaryExits: CopySlice(body.VoluntaryExits),
SyncAggregate: body.SyncAggregate.Copy(),
ExecutionPayload: body.ExecutionPayload.Copy(),
BlsToExecutionChanges: CopySlice(body.BlsToExecutionChanges),
}
}
// Copy --
func (sigBlock *SignedBlindedBeaconBlockCapella) Copy() *SignedBlindedBeaconBlockCapella {
if sigBlock == nil {
return nil
}
return &SignedBlindedBeaconBlockCapella{
Block: sigBlock.Block.Copy(),
Signature: bytesutil.SafeCopyBytes(sigBlock.Signature),
}
}
// Copy --
func (block *BlindedBeaconBlockCapella) Copy() *BlindedBeaconBlockCapella {
if block == nil {
return nil
}
return &BlindedBeaconBlockCapella{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot),
StateRoot: bytesutil.SafeCopyBytes(block.StateRoot),
Body: block.Body.Copy(),
}
}
// Copy --
func (body *BlindedBeaconBlockBodyCapella) Copy() *BlindedBeaconBlockBodyCapella {
if body == nil {
return nil
}
return &BlindedBeaconBlockBodyCapella{
RandaoReveal: bytesutil.SafeCopyBytes(body.RandaoReveal),
Eth1Data: body.Eth1Data.Copy(),
Graffiti: bytesutil.SafeCopyBytes(body.Graffiti),
ProposerSlashings: CopySlice(body.ProposerSlashings),
AttesterSlashings: CopySlice(body.AttesterSlashings),
Attestations: CopySlice(body.Attestations),
Deposits: CopySlice(body.Deposits),
VoluntaryExits: CopySlice(body.VoluntaryExits),
SyncAggregate: body.SyncAggregate.Copy(),
ExecutionPayloadHeader: body.ExecutionPayloadHeader.Copy(),
BlsToExecutionChanges: CopySlice(body.BlsToExecutionChanges),
}
}
// Copy --
func (sigBlock *SignedBlindedBeaconBlockDeneb) Copy() *SignedBlindedBeaconBlockDeneb {
if sigBlock == nil {
return nil
}
return &SignedBlindedBeaconBlockDeneb{
Message: sigBlock.Message.Copy(),
Signature: bytesutil.SafeCopyBytes(sigBlock.Signature),
}
}
// Copy --
func (block *BlindedBeaconBlockDeneb) Copy() *BlindedBeaconBlockDeneb {
if block == nil {
return nil
}
return &BlindedBeaconBlockDeneb{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot),
StateRoot: bytesutil.SafeCopyBytes(block.StateRoot),
Body: block.Body.Copy(),
}
}
// Copy --
func (body *BlindedBeaconBlockBodyDeneb) Copy() *BlindedBeaconBlockBodyDeneb {
if body == nil {
return nil
}
return &BlindedBeaconBlockBodyDeneb{
RandaoReveal: bytesutil.SafeCopyBytes(body.RandaoReveal),
Eth1Data: body.Eth1Data.Copy(),
Graffiti: bytesutil.SafeCopyBytes(body.Graffiti),
ProposerSlashings: CopySlice(body.ProposerSlashings),
AttesterSlashings: CopySlice(body.AttesterSlashings),
Attestations: CopySlice(body.Attestations),
Deposits: CopySlice(body.Deposits),
VoluntaryExits: CopySlice(body.VoluntaryExits),
SyncAggregate: body.SyncAggregate.Copy(),
ExecutionPayloadHeader: body.ExecutionPayloadHeader.Copy(),
BlsToExecutionChanges: CopySlice(body.BlsToExecutionChanges),
BlobKzgCommitments: CopyBlobKZGs(body.BlobKzgCommitments),
}
}
// Copy --
func (sigBlock *SignedBlindedBeaconBlockElectra) Copy() *SignedBlindedBeaconBlockElectra {
if sigBlock == nil {
return nil
}
return &SignedBlindedBeaconBlockElectra{
Message: sigBlock.Message.Copy(),
Signature: bytesutil.SafeCopyBytes(sigBlock.Signature),
}
}
// Copy --
func (block *BlindedBeaconBlockElectra) Copy() *BlindedBeaconBlockElectra {
if block == nil {
return nil
}
return &BlindedBeaconBlockElectra{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot),
StateRoot: bytesutil.SafeCopyBytes(block.StateRoot),
Body: block.Body.Copy(),
}
}
// Copy --
func (body *BlindedBeaconBlockBodyElectra) Copy() *BlindedBeaconBlockBodyElectra {
if body == nil {
return nil
}
return &BlindedBeaconBlockBodyElectra{
RandaoReveal: bytesutil.SafeCopyBytes(body.RandaoReveal),
Eth1Data: body.Eth1Data.Copy(),
Graffiti: bytesutil.SafeCopyBytes(body.Graffiti),
ProposerSlashings: CopySlice(body.ProposerSlashings),
AttesterSlashings: CopySlice(body.AttesterSlashings),
Attestations: CopySlice(body.Attestations),
Deposits: CopySlice(body.Deposits),
VoluntaryExits: CopySlice(body.VoluntaryExits),
SyncAggregate: body.SyncAggregate.Copy(),
ExecutionPayloadHeader: body.ExecutionPayloadHeader.Copy(),
BlsToExecutionChanges: CopySlice(body.BlsToExecutionChanges),
BlobKzgCommitments: CopyBlobKZGs(body.BlobKzgCommitments),
ExecutionRequests: CopyExecutionRequests(body.ExecutionRequests),
}
}
// Copy --
func (sigBlock *SignedBlindedBeaconBlockBellatrix) Copy() *SignedBlindedBeaconBlockBellatrix {
if sigBlock == nil {
return nil
}
return &SignedBlindedBeaconBlockBellatrix{
Block: sigBlock.Block.Copy(),
Signature: bytesutil.SafeCopyBytes(sigBlock.Signature),
}
}
// Copy --
func (block *BlindedBeaconBlockBellatrix) Copy() *BlindedBeaconBlockBellatrix {
if block == nil {
return nil
}
return &BlindedBeaconBlockBellatrix{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot),
StateRoot: bytesutil.SafeCopyBytes(block.StateRoot),
Body: block.Body.Copy(),
}
}
// Copy --
func (body *BlindedBeaconBlockBodyBellatrix) Copy() *BlindedBeaconBlockBodyBellatrix {
if body == nil {
return nil
}
return &BlindedBeaconBlockBodyBellatrix{
RandaoReveal: bytesutil.SafeCopyBytes(body.RandaoReveal),
Eth1Data: body.Eth1Data.Copy(),
Graffiti: bytesutil.SafeCopyBytes(body.Graffiti),
ProposerSlashings: CopySlice(body.ProposerSlashings),
AttesterSlashings: CopySlice(body.AttesterSlashings),
Attestations: CopySlice(body.Attestations),
Deposits: CopySlice(body.Deposits),
VoluntaryExits: CopySlice(body.VoluntaryExits),
SyncAggregate: body.SyncAggregate.Copy(),
ExecutionPayloadHeader: body.ExecutionPayloadHeader.Copy(),
}
}
// CopyBlobKZGs copies the provided blob kzgs object.
func CopyBlobKZGs(b [][]byte) [][]byte {
return bytesutil.SafeCopy2dBytes(b)
}
// CopyExecutionRequests copies the provided execution requests.
func CopyExecutionRequests(e *enginev1.ExecutionRequests) *enginev1.ExecutionRequests {
if e == nil {
return nil
}
dr := make([]*enginev1.DepositRequest, len(e.Deposits))
for i, d := range e.Deposits {
dr[i] = d.Copy()
}
wr := make([]*enginev1.WithdrawalRequest, len(e.Withdrawals))
for i, w := range e.Withdrawals {
wr[i] = w.Copy()
}
cr := make([]*enginev1.ConsolidationRequest, len(e.Consolidations))
for i, c := range e.Consolidations {
cr[i] = c.Copy()
}
return &enginev1.ExecutionRequests{
Deposits: dr,
Withdrawals: wr,
Consolidations: cr,
}
}
// Copy --
func (sigBlock *SignedBeaconBlockDeneb) Copy() *SignedBeaconBlockDeneb {
if sigBlock == nil {
return nil
}
return &SignedBeaconBlockDeneb{
Block: sigBlock.Block.Copy(),
Signature: bytesutil.SafeCopyBytes(sigBlock.Signature),
}
}
// Copy --
func (block *BeaconBlockDeneb) Copy() *BeaconBlockDeneb {
if block == nil {
return nil
}
return &BeaconBlockDeneb{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot),
StateRoot: bytesutil.SafeCopyBytes(block.StateRoot),
Body: block.Body.Copy(),
}
}
// Copy --
func (body *BeaconBlockBodyDeneb) Copy() *BeaconBlockBodyDeneb {
if body == nil {
return nil
}
return &BeaconBlockBodyDeneb{
RandaoReveal: bytesutil.SafeCopyBytes(body.RandaoReveal),
Eth1Data: body.Eth1Data.Copy(),
Graffiti: bytesutil.SafeCopyBytes(body.Graffiti),
ProposerSlashings: CopySlice(body.ProposerSlashings),
AttesterSlashings: CopySlice(body.AttesterSlashings),
Attestations: CopySlice(body.Attestations),
Deposits: CopySlice(body.Deposits),
VoluntaryExits: CopySlice(body.VoluntaryExits),
SyncAggregate: body.SyncAggregate.Copy(),
ExecutionPayload: body.ExecutionPayload.Copy(),
BlsToExecutionChanges: CopySlice(body.BlsToExecutionChanges),
BlobKzgCommitments: CopyBlobKZGs(body.BlobKzgCommitments),
}
}
// Copy --
func (sigBlock *SignedBeaconBlockElectra) Copy() *SignedBeaconBlockElectra {
if sigBlock == nil {
return nil
}
return &SignedBeaconBlockElectra{
Block: sigBlock.Block.Copy(),
Signature: bytesutil.SafeCopyBytes(sigBlock.Signature),
}
}
// Copy --
func (block *BeaconBlockElectra) Copy() *BeaconBlockElectra {
if block == nil {
return nil
}
return &BeaconBlockElectra{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot),
StateRoot: bytesutil.SafeCopyBytes(block.StateRoot),
Body: block.Body.Copy(),
}
}
// Copy --
func (body *BeaconBlockBodyElectra) Copy() *BeaconBlockBodyElectra {
if body == nil {
return nil
}
return &BeaconBlockBodyElectra{
RandaoReveal: bytesutil.SafeCopyBytes(body.RandaoReveal),
Eth1Data: body.Eth1Data.Copy(),
Graffiti: bytesutil.SafeCopyBytes(body.Graffiti),
ProposerSlashings: CopySlice(body.ProposerSlashings),
AttesterSlashings: CopySlice(body.AttesterSlashings),
Attestations: CopySlice(body.Attestations),
Deposits: CopySlice(body.Deposits),
VoluntaryExits: CopySlice(body.VoluntaryExits),
SyncAggregate: body.SyncAggregate.Copy(),
ExecutionPayload: body.ExecutionPayload.Copy(),
BlsToExecutionChanges: CopySlice(body.BlsToExecutionChanges),
BlobKzgCommitments: CopyBlobKZGs(body.BlobKzgCommitments),
ExecutionRequests: CopyExecutionRequests(body.ExecutionRequests),
}
}
// Copy --
func (data *Eth1Data) Copy() *Eth1Data {
if data == nil {
@@ -581,6 +148,53 @@ func (exit *VoluntaryExit) Copy() *VoluntaryExit {
}
}
// ----------------------------------------------------------------------------
// Altair
// ----------------------------------------------------------------------------
// Copy --
func (sigBlock *SignedBeaconBlockAltair) Copy() *SignedBeaconBlockAltair {
if sigBlock == nil {
return nil
}
return &SignedBeaconBlockAltair{
Block: sigBlock.Block.Copy(),
Signature: bytesutil.SafeCopyBytes(sigBlock.Signature),
}
}
// Copy --
func (block *BeaconBlockAltair) Copy() *BeaconBlockAltair {
if block == nil {
return nil
}
return &BeaconBlockAltair{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot),
StateRoot: bytesutil.SafeCopyBytes(block.StateRoot),
Body: block.Body.Copy(),
}
}
// Copy --
func (body *BeaconBlockBodyAltair) Copy() *BeaconBlockBodyAltair {
if body == nil {
return nil
}
return &BeaconBlockBodyAltair{
RandaoReveal: bytesutil.SafeCopyBytes(body.RandaoReveal),
Eth1Data: body.Eth1Data.Copy(),
Graffiti: bytesutil.SafeCopyBytes(body.Graffiti),
ProposerSlashings: CopySlice(body.ProposerSlashings),
AttesterSlashings: CopySlice(body.AttesterSlashings),
Attestations: CopySlice(body.Attestations),
Deposits: CopySlice(body.Deposits),
VoluntaryExits: CopySlice(body.VoluntaryExits),
SyncAggregate: body.SyncAggregate.Copy(),
}
}
// Copy --
func (a *SyncAggregate) Copy() *SyncAggregate {
if a == nil {
@@ -592,6 +206,203 @@ func (a *SyncAggregate) Copy() *SyncAggregate {
}
}
// Copy --
func (summary *HistoricalSummary) Copy() *HistoricalSummary {
if summary == nil {
return nil
}
return &HistoricalSummary{
BlockSummaryRoot: bytesutil.SafeCopyBytes(summary.BlockSummaryRoot),
StateSummaryRoot: bytesutil.SafeCopyBytes(summary.StateSummaryRoot),
}
}
// ----------------------------------------------------------------------------
// Bellatrix
// ----------------------------------------------------------------------------
// Copy --
func (sigBlock *SignedBeaconBlockBellatrix) Copy() *SignedBeaconBlockBellatrix {
if sigBlock == nil {
return nil
}
return &SignedBeaconBlockBellatrix{
Block: sigBlock.Block.Copy(),
Signature: bytesutil.SafeCopyBytes(sigBlock.Signature),
}
}
// Copy --
func (block *BeaconBlockBellatrix) Copy() *BeaconBlockBellatrix {
if block == nil {
return nil
}
return &BeaconBlockBellatrix{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot),
StateRoot: bytesutil.SafeCopyBytes(block.StateRoot),
Body: block.Body.Copy(),
}
}
// Copy --
func (body *BeaconBlockBodyBellatrix) Copy() *BeaconBlockBodyBellatrix {
if body == nil {
return nil
}
return &BeaconBlockBodyBellatrix{
RandaoReveal: bytesutil.SafeCopyBytes(body.RandaoReveal),
Eth1Data: body.Eth1Data.Copy(),
Graffiti: bytesutil.SafeCopyBytes(body.Graffiti),
ProposerSlashings: CopySlice(body.ProposerSlashings),
AttesterSlashings: CopySlice(body.AttesterSlashings),
Attestations: CopySlice(body.Attestations),
Deposits: CopySlice(body.Deposits),
VoluntaryExits: CopySlice(body.VoluntaryExits),
SyncAggregate: body.SyncAggregate.Copy(),
ExecutionPayload: body.ExecutionPayload.Copy(),
}
}
// Copy --
func (sigBlock *SignedBlindedBeaconBlockBellatrix) Copy() *SignedBlindedBeaconBlockBellatrix {
if sigBlock == nil {
return nil
}
return &SignedBlindedBeaconBlockBellatrix{
Block: sigBlock.Block.Copy(),
Signature: bytesutil.SafeCopyBytes(sigBlock.Signature),
}
}
// Copy --
func (block *BlindedBeaconBlockBellatrix) Copy() *BlindedBeaconBlockBellatrix {
if block == nil {
return nil
}
return &BlindedBeaconBlockBellatrix{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot),
StateRoot: bytesutil.SafeCopyBytes(block.StateRoot),
Body: block.Body.Copy(),
}
}
// Copy --
func (body *BlindedBeaconBlockBodyBellatrix) Copy() *BlindedBeaconBlockBodyBellatrix {
if body == nil {
return nil
}
return &BlindedBeaconBlockBodyBellatrix{
RandaoReveal: bytesutil.SafeCopyBytes(body.RandaoReveal),
Eth1Data: body.Eth1Data.Copy(),
Graffiti: bytesutil.SafeCopyBytes(body.Graffiti),
ProposerSlashings: CopySlice(body.ProposerSlashings),
AttesterSlashings: CopySlice(body.AttesterSlashings),
Attestations: CopySlice(body.Attestations),
Deposits: CopySlice(body.Deposits),
VoluntaryExits: CopySlice(body.VoluntaryExits),
SyncAggregate: body.SyncAggregate.Copy(),
ExecutionPayloadHeader: body.ExecutionPayloadHeader.Copy(),
}
}
// ----------------------------------------------------------------------------
// Capella
// ----------------------------------------------------------------------------
// Copy --
func (sigBlock *SignedBeaconBlockCapella) Copy() *SignedBeaconBlockCapella {
if sigBlock == nil {
return nil
}
return &SignedBeaconBlockCapella{
Block: sigBlock.Block.Copy(),
Signature: bytesutil.SafeCopyBytes(sigBlock.Signature),
}
}
// Copy --
func (block *BeaconBlockCapella) Copy() *BeaconBlockCapella {
if block == nil {
return nil
}
return &BeaconBlockCapella{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot),
StateRoot: bytesutil.SafeCopyBytes(block.StateRoot),
Body: block.Body.Copy(),
}
}
// Copy --
func (body *BeaconBlockBodyCapella) Copy() *BeaconBlockBodyCapella {
if body == nil {
return nil
}
return &BeaconBlockBodyCapella{
RandaoReveal: bytesutil.SafeCopyBytes(body.RandaoReveal),
Eth1Data: body.Eth1Data.Copy(),
Graffiti: bytesutil.SafeCopyBytes(body.Graffiti),
ProposerSlashings: CopySlice(body.ProposerSlashings),
AttesterSlashings: CopySlice(body.AttesterSlashings),
Attestations: CopySlice(body.Attestations),
Deposits: CopySlice(body.Deposits),
VoluntaryExits: CopySlice(body.VoluntaryExits),
SyncAggregate: body.SyncAggregate.Copy(),
ExecutionPayload: body.ExecutionPayload.Copy(),
BlsToExecutionChanges: CopySlice(body.BlsToExecutionChanges),
}
}
// Copy --
func (sigBlock *SignedBlindedBeaconBlockCapella) Copy() *SignedBlindedBeaconBlockCapella {
if sigBlock == nil {
return nil
}
return &SignedBlindedBeaconBlockCapella{
Block: sigBlock.Block.Copy(),
Signature: bytesutil.SafeCopyBytes(sigBlock.Signature),
}
}
// Copy --
func (block *BlindedBeaconBlockCapella) Copy() *BlindedBeaconBlockCapella {
if block == nil {
return nil
}
return &BlindedBeaconBlockCapella{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot),
StateRoot: bytesutil.SafeCopyBytes(block.StateRoot),
Body: block.Body.Copy(),
}
}
// Copy --
func (body *BlindedBeaconBlockBodyCapella) Copy() *BlindedBeaconBlockBodyCapella {
if body == nil {
return nil
}
return &BlindedBeaconBlockBodyCapella{
RandaoReveal: bytesutil.SafeCopyBytes(body.RandaoReveal),
Eth1Data: body.Eth1Data.Copy(),
Graffiti: bytesutil.SafeCopyBytes(body.Graffiti),
ProposerSlashings: CopySlice(body.ProposerSlashings),
AttesterSlashings: CopySlice(body.AttesterSlashings),
Attestations: CopySlice(body.Attestations),
Deposits: CopySlice(body.Deposits),
VoluntaryExits: CopySlice(body.VoluntaryExits),
SyncAggregate: body.SyncAggregate.Copy(),
ExecutionPayloadHeader: body.ExecutionPayloadHeader.Copy(),
BlsToExecutionChanges: CopySlice(body.BlsToExecutionChanges),
}
}
// Copy --
func (change *SignedBLSToExecutionChange) Copy() *SignedBLSToExecutionChange {
if change == nil {
@@ -615,13 +426,226 @@ func (change *BLSToExecutionChange) Copy() *BLSToExecutionChange {
}
}
// ----------------------------------------------------------------------------
// Deneb
// ----------------------------------------------------------------------------
// Copy --
func (summary *HistoricalSummary) Copy() *HistoricalSummary {
if summary == nil {
func (sigBlock *SignedBlindedBeaconBlockDeneb) Copy() *SignedBlindedBeaconBlockDeneb {
if sigBlock == nil {
return nil
}
return &HistoricalSummary{
BlockSummaryRoot: bytesutil.SafeCopyBytes(summary.BlockSummaryRoot),
StateSummaryRoot: bytesutil.SafeCopyBytes(summary.StateSummaryRoot),
return &SignedBlindedBeaconBlockDeneb{
Message: sigBlock.Message.Copy(),
Signature: bytesutil.SafeCopyBytes(sigBlock.Signature),
}
}
// Copy --
func (block *BlindedBeaconBlockDeneb) Copy() *BlindedBeaconBlockDeneb {
if block == nil {
return nil
}
return &BlindedBeaconBlockDeneb{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot),
StateRoot: bytesutil.SafeCopyBytes(block.StateRoot),
Body: block.Body.Copy(),
}
}
// Copy --
func (body *BlindedBeaconBlockBodyDeneb) Copy() *BlindedBeaconBlockBodyDeneb {
if body == nil {
return nil
}
return &BlindedBeaconBlockBodyDeneb{
RandaoReveal: bytesutil.SafeCopyBytes(body.RandaoReveal),
Eth1Data: body.Eth1Data.Copy(),
Graffiti: bytesutil.SafeCopyBytes(body.Graffiti),
ProposerSlashings: CopySlice(body.ProposerSlashings),
AttesterSlashings: CopySlice(body.AttesterSlashings),
Attestations: CopySlice(body.Attestations),
Deposits: CopySlice(body.Deposits),
VoluntaryExits: CopySlice(body.VoluntaryExits),
SyncAggregate: body.SyncAggregate.Copy(),
ExecutionPayloadHeader: body.ExecutionPayloadHeader.Copy(),
BlsToExecutionChanges: CopySlice(body.BlsToExecutionChanges),
BlobKzgCommitments: CopyBlobKZGs(body.BlobKzgCommitments),
}
}
// Copy --
func (sigBlock *SignedBeaconBlockDeneb) Copy() *SignedBeaconBlockDeneb {
if sigBlock == nil {
return nil
}
return &SignedBeaconBlockDeneb{
Block: sigBlock.Block.Copy(),
Signature: bytesutil.SafeCopyBytes(sigBlock.Signature),
}
}
// Copy --
func (block *BeaconBlockDeneb) Copy() *BeaconBlockDeneb {
if block == nil {
return nil
}
return &BeaconBlockDeneb{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot),
StateRoot: bytesutil.SafeCopyBytes(block.StateRoot),
Body: block.Body.Copy(),
}
}
// Copy --
func (body *BeaconBlockBodyDeneb) Copy() *BeaconBlockBodyDeneb {
if body == nil {
return nil
}
return &BeaconBlockBodyDeneb{
RandaoReveal: bytesutil.SafeCopyBytes(body.RandaoReveal),
Eth1Data: body.Eth1Data.Copy(),
Graffiti: bytesutil.SafeCopyBytes(body.Graffiti),
ProposerSlashings: CopySlice(body.ProposerSlashings),
AttesterSlashings: CopySlice(body.AttesterSlashings),
Attestations: CopySlice(body.Attestations),
Deposits: CopySlice(body.Deposits),
VoluntaryExits: CopySlice(body.VoluntaryExits),
SyncAggregate: body.SyncAggregate.Copy(),
ExecutionPayload: body.ExecutionPayload.Copy(),
BlsToExecutionChanges: CopySlice(body.BlsToExecutionChanges),
BlobKzgCommitments: CopyBlobKZGs(body.BlobKzgCommitments),
}
}
// CopyBlobKZGs copies the provided blob kzgs object.
func CopyBlobKZGs(b [][]byte) [][]byte {
return bytesutil.SafeCopy2dBytes(b)
}
// ----------------------------------------------------------------------------
// Electra
// ----------------------------------------------------------------------------
// Copy --
func (sigBlock *SignedBlindedBeaconBlockElectra) Copy() *SignedBlindedBeaconBlockElectra {
if sigBlock == nil {
return nil
}
return &SignedBlindedBeaconBlockElectra{
Message: sigBlock.Message.Copy(),
Signature: bytesutil.SafeCopyBytes(sigBlock.Signature),
}
}
// Copy --
func (block *BlindedBeaconBlockElectra) Copy() *BlindedBeaconBlockElectra {
if block == nil {
return nil
}
return &BlindedBeaconBlockElectra{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot),
StateRoot: bytesutil.SafeCopyBytes(block.StateRoot),
Body: block.Body.Copy(),
}
}
// Copy --
func (body *BlindedBeaconBlockBodyElectra) Copy() *BlindedBeaconBlockBodyElectra {
if body == nil {
return nil
}
return &BlindedBeaconBlockBodyElectra{
RandaoReveal: bytesutil.SafeCopyBytes(body.RandaoReveal),
Eth1Data: body.Eth1Data.Copy(),
Graffiti: bytesutil.SafeCopyBytes(body.Graffiti),
ProposerSlashings: CopySlice(body.ProposerSlashings),
AttesterSlashings: CopySlice(body.AttesterSlashings),
Attestations: CopySlice(body.Attestations),
Deposits: CopySlice(body.Deposits),
VoluntaryExits: CopySlice(body.VoluntaryExits),
SyncAggregate: body.SyncAggregate.Copy(),
ExecutionPayloadHeader: body.ExecutionPayloadHeader.Copy(),
BlsToExecutionChanges: CopySlice(body.BlsToExecutionChanges),
BlobKzgCommitments: CopyBlobKZGs(body.BlobKzgCommitments),
ExecutionRequests: CopyExecutionRequests(body.ExecutionRequests),
}
}
// Copy --
func (sigBlock *SignedBeaconBlockElectra) Copy() *SignedBeaconBlockElectra {
if sigBlock == nil {
return nil
}
return &SignedBeaconBlockElectra{
Block: sigBlock.Block.Copy(),
Signature: bytesutil.SafeCopyBytes(sigBlock.Signature),
}
}
// Copy --
func (block *BeaconBlockElectra) Copy() *BeaconBlockElectra {
if block == nil {
return nil
}
return &BeaconBlockElectra{
Slot: block.Slot,
ProposerIndex: block.ProposerIndex,
ParentRoot: bytesutil.SafeCopyBytes(block.ParentRoot),
StateRoot: bytesutil.SafeCopyBytes(block.StateRoot),
Body: block.Body.Copy(),
}
}
// Copy --
func (body *BeaconBlockBodyElectra) Copy() *BeaconBlockBodyElectra {
if body == nil {
return nil
}
return &BeaconBlockBodyElectra{
RandaoReveal: bytesutil.SafeCopyBytes(body.RandaoReveal),
Eth1Data: body.Eth1Data.Copy(),
Graffiti: bytesutil.SafeCopyBytes(body.Graffiti),
ProposerSlashings: CopySlice(body.ProposerSlashings),
AttesterSlashings: CopySlice(body.AttesterSlashings),
Attestations: CopySlice(body.Attestations),
Deposits: CopySlice(body.Deposits),
VoluntaryExits: CopySlice(body.VoluntaryExits),
SyncAggregate: body.SyncAggregate.Copy(),
ExecutionPayload: body.ExecutionPayload.Copy(),
BlsToExecutionChanges: CopySlice(body.BlsToExecutionChanges),
BlobKzgCommitments: CopyBlobKZGs(body.BlobKzgCommitments),
ExecutionRequests: CopyExecutionRequests(body.ExecutionRequests),
}
}
// CopyExecutionRequests copies the provided execution requests.
func CopyExecutionRequests(e *enginev1.ExecutionRequests) *enginev1.ExecutionRequests {
if e == nil {
return nil
}
dr := make([]*enginev1.DepositRequest, len(e.Deposits))
for i, d := range e.Deposits {
dr[i] = d.Copy()
}
wr := make([]*enginev1.WithdrawalRequest, len(e.Withdrawals))
for i, w := range e.Withdrawals {
wr[i] = w.Copy()
}
cr := make([]*enginev1.ConsolidationRequest, len(e.Consolidations))
for i, c := range e.Consolidations {
cr[i] = c.Copy()
}
return &enginev1.ExecutionRequests{
Deposits: dr,
Withdrawals: wr,
Consolidations: cr,
}
}

View File

@@ -381,6 +381,10 @@ message BeaconStateDeneb {
repeated HistoricalSummary historical_summaries = 11003 [(ethereum.eth.ext.ssz_max) = "16777216"];
}
// ----------------------------------------------------------------------------
// Electra
// ----------------------------------------------------------------------------
message BeaconStateElectra {
// Versioning [1001-2000]
uint64 genesis_time = 1001;
@@ -443,4 +447,4 @@ message BeaconStateElectra {
repeated PendingDeposit pending_deposits = 12007 [(ethereum.eth.ext.ssz_max) = "pending_deposits_limit"];
repeated PendingPartialWithdrawal pending_partial_withdrawals = 12008 [(ethereum.eth.ext.ssz_max) = "pending_partial_withdrawals_limit"];
repeated PendingConsolidation pending_consolidations = 12009 [(ethereum.eth.ext.ssz_max) = "pending_consolidations_limit"];
}
}