-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add block setters for consensus type #11751
Changes from 6 commits
590aff4
1ae5db7
1f916bd
716d16d
f7142a6
54a6808
060597e
4d5158b
b28299c
3c58728
731d77f
bfe37f6
19efb97
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,6 +155,16 @@ func (e executionPayload) WithdrawalsRoot() ([]byte, error) { | |
return nil, ErrUnsupportedGetter | ||
} | ||
|
||
// PbV1 -- | ||
func (e executionPayload) PbV1() (*enginev1.ExecutionPayload, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really want to name things |
||
return e.p, nil | ||
} | ||
|
||
// PbV2 -- | ||
func (executionPayload) PbV2() (*enginev1.ExecutionPayloadCapella, error) { | ||
return nil, ErrUnsupportedGetter | ||
} | ||
|
||
// executionPayloadHeader is a convenience wrapper around a blinded beacon block body's execution header data structure | ||
// This wrapper allows us to conform to a common interface so that beacon | ||
// blocks for future forks can also be applied across Prysm without issues. | ||
|
@@ -296,6 +306,16 @@ func (e executionPayloadHeader) WithdrawalsRoot() ([]byte, error) { | |
return nil, ErrUnsupportedGetter | ||
} | ||
|
||
// PbV2 -- | ||
func (executionPayloadHeader) PbV2() (*enginev1.ExecutionPayloadCapella, error) { | ||
return nil, ErrUnsupportedGetter | ||
} | ||
|
||
// PbV1 -- | ||
func (executionPayloadHeader) PbV1() (*enginev1.ExecutionPayload, error) { | ||
return nil, ErrUnsupportedGetter | ||
} | ||
|
||
// PayloadToHeader converts `payload` into execution payload header format. | ||
func PayloadToHeader(payload interfaces.ExecutionData) (*enginev1.ExecutionPayloadHeader, error) { | ||
txs, err := payload.Transactions() | ||
|
@@ -465,6 +485,16 @@ func (e executionPayloadCapella) WithdrawalsRoot() ([]byte, error) { | |
return nil, ErrUnsupportedGetter | ||
} | ||
|
||
// PbV2 -- | ||
func (e executionPayloadCapella) PbV2() (*enginev1.ExecutionPayloadCapella, error) { | ||
return e.p, nil | ||
} | ||
|
||
// PbV1 -- | ||
func (executionPayloadCapella) PbV1() (*enginev1.ExecutionPayload, error) { | ||
return nil, ErrUnsupportedGetter | ||
} | ||
|
||
// executionPayloadHeaderCapella is a convenience wrapper around a blinded beacon block body's execution header data structure | ||
// This wrapper allows us to conform to a common interface so that beacon | ||
// blocks for future forks can also be applied across Prysm without issues. | ||
|
@@ -606,6 +636,16 @@ func (e executionPayloadHeaderCapella) WithdrawalsRoot() ([]byte, error) { | |
return e.p.WithdrawalsRoot, nil | ||
} | ||
|
||
// PbV2 -- | ||
func (executionPayloadHeaderCapella) PbV2() (*enginev1.ExecutionPayloadCapella, error) { | ||
return nil, ErrUnsupportedGetter | ||
} | ||
|
||
// PbV1 -- | ||
func (executionPayloadHeaderCapella) PbV1() (*enginev1.ExecutionPayload, error) { | ||
return nil, ErrUnsupportedGetter | ||
} | ||
|
||
// PayloadToHeaderCapella converts `payload` into execution payload header format. | ||
func PayloadToHeaderCapella(payload interfaces.ExecutionData) (*enginev1.ExecutionPayloadHeaderCapella, error) { | ||
txs, err := payload.Transactions() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -731,6 +731,41 @@ func (b *BeaconBlock) AsSignRequestObject() (validatorpb.SignRequestObject, erro | |
} | ||
} | ||
|
||
func (b *BeaconBlock) Copy() (interfaces.BeaconBlock, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not tested |
||
if b == nil { | ||
return nil, nil | ||
} | ||
|
||
pb, err := b.Proto() | ||
if err != nil { | ||
return nil, err | ||
} | ||
switch b.version { | ||
case version.Phase0: | ||
cp := eth.CopyBeaconBlock(pb.(*eth.BeaconBlock)) | ||
return initBlockFromProtoPhase0(cp) | ||
case version.Altair: | ||
cp := eth.CopyBeaconBlockAltair(pb.(*eth.BeaconBlockAltair)) | ||
return initBlockFromProtoAltair(cp) | ||
case version.Bellatrix: | ||
if b.IsBlinded() { | ||
cp := eth.CopyBlindedBeaconBlockBellatrix(pb.(*eth.BlindedBeaconBlockBellatrix)) | ||
return initBlindedBlockFromProtoBellatrix(cp) | ||
} | ||
cp := eth.CopyBeaconBlockBellatrix(pb.(*eth.BeaconBlockBellatrix)) | ||
return initBlockFromProtoBellatrix(cp) | ||
case version.Capella: | ||
if b.IsBlinded() { | ||
cp := eth.CopyBlindedBeaconBlockCapella(pb.(*eth.BlindedBeaconBlockCapella)) | ||
return initBlindedBlockFromProtoCapella(cp) | ||
} | ||
cp := eth.CopyBeaconBlockCapella(pb.(*eth.BeaconBlockCapella)) | ||
return initBlockFromProtoCapella(cp) | ||
default: | ||
return nil, errIncorrectBlockVersion | ||
} | ||
} | ||
|
||
// IsNil checks if the block body is nil. | ||
func (b *BeaconBlockBody) IsNil() bool { | ||
return b == nil | ||
|
@@ -751,6 +786,11 @@ func (b *BeaconBlockBody) Graffiti() [field_params.RootLength]byte { | |
return b.graffiti | ||
} | ||
|
||
// SetGraffiti sets the graffiti in the block. | ||
func (b *BeaconBlockBody) SetGraffiti(g []byte) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this isnt a getter |
||
copy(b.graffiti[:], g) | ||
} | ||
|
||
// ProposerSlashings returns the proposer slashings in the block. | ||
func (b *BeaconBlockBody) ProposerSlashings() []*eth.ProposerSlashing { | ||
return b.proposerSlashings | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these PbVx from the different targets are not tested.