Rm changes

This commit is contained in:
terence tsao
2022-12-09 21:38:16 -08:00
parent 590aff40b9
commit 1ae5db79da
5 changed files with 13 additions and 88 deletions

View File

@@ -155,16 +155,6 @@ func (e executionPayload) WithdrawalsRoot() ([]byte, error) {
return nil, ErrUnsupportedGetter
}
// PbV1 --
func (e executionPayload) PbV1() (*enginev1.ExecutionPayload, error) {
return e.p, nil
}
// PbV2 --
func (e 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.
@@ -306,16 +296,6 @@ func (e executionPayloadHeader) WithdrawalsRoot() ([]byte, error) {
return nil, ErrUnsupportedGetter
}
// PbV2 --
func (e executionPayloadHeader) PbV2() (*enginev1.ExecutionPayloadCapella, error) {
return nil, ErrUnsupportedGetter
}
// PbV1 --
func (e 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()
@@ -485,16 +465,6 @@ func (e executionPayloadCapella) WithdrawalsRoot() ([]byte, error) {
return nil, ErrUnsupportedGetter
}
// PbV2 --
func (e executionPayloadCapella) PbV2() (*enginev1.ExecutionPayloadCapella, error) {
return e.p, nil
}
// PbV1 --
func (e 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.
@@ -636,16 +606,6 @@ func (e executionPayloadHeaderCapella) WithdrawalsRoot() ([]byte, error) {
return e.p.WithdrawalsRoot, nil
}
// PbV2 --
func (e executionPayloadHeaderCapella) PbV2() (*enginev1.ExecutionPayloadCapella, error) {
return nil, ErrUnsupportedGetter
}
// PbV1 --
func (e 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()

View File

@@ -23,8 +23,7 @@ var (
// ErrNilObject is returned in a constructor when the underlying object is nil.
ErrNilObject = errors.New("received nil object")
// ErrNilSignedBeaconBlock is returned when a nil signed beacon block is received.
ErrNilSignedBeaconBlock = errors.New("signed beacon block can't be nil")
errNonBlindedSignedBeaconBlock = errors.New("can only build signed beacon block from blinded format")
ErrNilSignedBeaconBlock = errors.New("signed beacon block can't be nil")
)
// NewSignedBeaconBlock creates a signed beacon block from a protobuf signed beacon block.
@@ -178,13 +177,14 @@ func BuildSignedBeaconBlockFromExecutionPayload(
if err := BeaconBlockIsNil(blk); err != nil {
return nil, err
}
if !blk.IsBlinded() {
return nil, errNonBlindedSignedBeaconBlock
}
b := blk.Block()
payloadHeader, err := b.Body().Execution()
if err != nil {
switch {
case errors.Is(err, ErrUnsupportedGetter):
return nil, errors.Wrap(err, "can only build signed beacon block from blinded format")
case err != nil:
return nil, errors.Wrap(err, "could not get execution payload header")
default:
}
var wrappedPayload interfaces.ExecutionData

View File

@@ -332,14 +332,14 @@ func TestBuildSignedBeaconBlockFromExecutionPayload(t *testing.T) {
_, err := BuildSignedBeaconBlockFromExecutionPayload(nil, nil)
require.ErrorIs(t, ErrNilSignedBeaconBlock, err)
})
t.Run("not blinded payload", func(t *testing.T) {
t.Run("unsupported field payload header", func(t *testing.T) {
altairBlock := &eth.SignedBeaconBlockAltair{
Block: &eth.BeaconBlockAltair{
Body: &eth.BeaconBlockBodyAltair{}}}
blk, err := NewSignedBeaconBlock(altairBlock)
require.NoError(t, err)
_, err = BuildSignedBeaconBlockFromExecutionPayload(blk, nil)
require.Equal(t, true, errors.Is(err, errNonBlindedSignedBeaconBlock))
require.Equal(t, true, errors.Is(err, ErrUnsupportedGetter))
})
t.Run("payload header root and payload root mismatch", func(t *testing.T) {
blockHash := bytesutil.Bytes32(1)

View File

@@ -731,41 +731,6 @@ func (b *BeaconBlock) AsSignRequestObject() (validatorpb.SignRequestObject, erro
}
}
func (b *BeaconBlock) Copy() (interfaces.BeaconBlock, error) {
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
@@ -786,11 +751,6 @@ func (b *BeaconBlockBody) Graffiti() [field_params.RootLength]byte {
return b.graffiti
}
// SetGraffiti sets the graffiti in the block.
func (b *BeaconBlockBody) SetGraffiti(g []byte) {
copy(b.graffiti[:], g)
}
// ProposerSlashings returns the proposer slashings in the block.
func (b *BeaconBlockBody) ProposerSlashings() []*eth.ProposerSlashing {
return b.proposerSlashings

View File

@@ -85,6 +85,11 @@ func (b *BeaconBlock) SetStateRoot(root []byte) {
copy(b.stateRoot[:], root)
}
// SetGraffiti sets the graffiti in the block.
func (b *BeaconBlockBody) SetGraffiti(g []byte) {
copy(b.graffiti[:], g)
}
// SetBlinded sets the blinded flag of the beacon block.
// This function is not thread safe, it is only used during block creation.
func (b *BeaconBlock) SetBlinded(blinded bool) {