Skip to content

Commit f798338

Browse files
committed
Potuz's feedback
1 parent 09ec764 commit f798338

File tree

8 files changed

+70
-14
lines changed

8 files changed

+70
-14
lines changed

consensus-types/blocks/factory.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,6 @@ func BuildSignedBeaconBlockFromExecutionPayload(blk interfaces.ReadOnlySignedBea
641641
},
642642
Signature: sig[:],
643643
}
644-
case version.Gloas:
645-
return nil, errors.Wrap(errUnsupportedBeaconBlock, "gloas blocks are not supported in this function")
646644
default:
647645
return nil, errors.New("Block not of known type")
648646
}

consensus-types/blocks/factory_test.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,12 +571,21 @@ func TestBuildSignedBeaconBlockFromExecutionPayload(t *testing.T) {
571571
require.DeepEqual(t, uint64(123), payload.ExcessBlobGas)
572572
require.DeepEqual(t, uint64(321), payload.BlobGasUsed)
573573
})
574-
t.Run("gloas unsupported", func(t *testing.T) {
575-
blk := &SignedBeaconBlock{
574+
t.Run("gloas execution unsupported", func(t *testing.T) {
575+
base := &SignedBeaconBlock{
576576
version: version.Gloas,
577577
block: &BeaconBlock{version: version.Gloas, body: &BeaconBlockBody{version: version.Gloas}},
578578
}
579-
_, err := BuildSignedBeaconBlockFromExecutionPayload(blk, nil)
580-
require.ErrorIs(t, err, errNonBlindedSignedBeaconBlock)
579+
blinded := &testBlindedSignedBeaconBlock{SignedBeaconBlock: base}
580+
_, err := BuildSignedBeaconBlockFromExecutionPayload(blinded, nil)
581+
require.ErrorContains(t, "Execution is not supported for gloas", err)
581582
})
582583
}
584+
585+
type testBlindedSignedBeaconBlock struct {
586+
*SignedBeaconBlock
587+
}
588+
589+
func (b *testBlindedSignedBeaconBlock) IsBlinded() bool {
590+
return true
591+
}

consensus-types/blocks/getters.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -679,10 +679,10 @@ func (b *SignedBeaconBlock) UnmarshalSSZ(buf []byte) error {
679679
}
680680
case version.Gloas:
681681
pb := &eth.SignedBeaconBlockGloas{}
682-
if err := pb.UnmarshalSSZ(buf); err != nil {
682+
err := pb.UnmarshalSSZ(buf);
683+
if err != nil {
683684
return err
684685
}
685-
var err error
686686
newBlock, err = initSignedBlockFromProtoGloas(pb)
687687
if err != nil {
688688
return err
@@ -1243,7 +1243,7 @@ func (b *BeaconBlockBody) SyncAggregate() (*eth.SyncAggregate, error) {
12431243
// Execution returns the execution payload of the block body.
12441244
func (b *BeaconBlockBody) Execution() (interfaces.ExecutionData, error) {
12451245
switch b.version {
1246-
case version.Phase0, version.Altair:
1246+
case version.Phase0, version.Altair, version.Gloas:
12471247
return nil, consensus_types.ErrNotSupported("Execution", b.version)
12481248
default:
12491249
if b.IsBlinded() {
@@ -1275,7 +1275,7 @@ func (b *BeaconBlockBody) BlobKzgCommitments() ([][]byte, error) {
12751275

12761276
// ExecutionRequests returns the execution requests
12771277
func (b *BeaconBlockBody) ExecutionRequests() (*enginev1.ExecutionRequests, error) {
1278-
if b.version < version.Electra {
1278+
if b.version < version.Electra || b.version >= version.Gloas {
12791279
return nil, consensus_types.ErrNotSupported("ExecutionRequests", b.version)
12801280
}
12811281
return b.executionRequests, nil

consensus-types/blocks/getters_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,32 @@ func Test_BeaconBlockBody_Execution(t *testing.T) {
503503
gas, err = eDenebHeader.ExcessBlobGas()
504504
require.NoError(t, err)
505505
require.DeepEqual(t, gas, uint64(223))
506+
507+
bb = &SignedBeaconBlock{version: version.Gloas, block: &BeaconBlock{version: version.Gloas, body: &BeaconBlockBody{version: version.Gloas}}}
508+
_, err = bb.Block().Body().Execution()
509+
require.ErrorIs(t, err, consensus_types.ErrUnsupportedField)
510+
}
511+
512+
func Test_BeaconBlockBody_ExecutionRequests(t *testing.T) {
513+
t.Run("unsupported before Electra", func(t *testing.T) {
514+
bb := &BeaconBlockBody{version: version.Deneb}
515+
_, err := bb.ExecutionRequests()
516+
require.ErrorIs(t, err, consensus_types.ErrUnsupportedField)
517+
})
518+
519+
t.Run("electra returns requests", func(t *testing.T) {
520+
reqs := &pb.ExecutionRequests{}
521+
bb := &BeaconBlockBody{version: version.Electra, executionRequests: reqs}
522+
result, err := bb.ExecutionRequests()
523+
require.NoError(t, err)
524+
require.Equal(t, reqs, result)
525+
})
526+
527+
t.Run("unsupported for Gloas", func(t *testing.T) {
528+
bb := &BeaconBlockBody{version: version.Gloas}
529+
_, err := bb.ExecutionRequests()
530+
require.ErrorIs(t, err, consensus_types.ErrUnsupportedField)
531+
})
506532
}
507533

508534
func Test_BeaconBlockBody_HashTreeRoot(t *testing.T) {

consensus-types/blocks/proto.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1579,8 +1579,8 @@ func initBlockBodyFromProtoGloas(pb *eth.BeaconBlockBodyGloas) (*BeaconBlockBody
15791579
deposits: pb.Deposits,
15801580
voluntaryExits: pb.VoluntaryExits,
15811581
syncAggregate: pb.SyncAggregate,
1582-
signedExecutionPayloadBid: pb.SignedExecutionPayloadBid,
15831582
blsToExecutionChanges: pb.BlsToExecutionChanges,
1583+
signedExecutionPayloadBid: pb.SignedExecutionPayloadBid,
15841584
payloadAttestations: pb.PayloadAttestations,
15851585
}
15861586
return b, nil

consensus-types/blocks/setters.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func (b *SignedBeaconBlock) SetSyncAggregate(s *eth.SyncAggregate) error {
144144
// SetExecution sets the execution payload of the block body.
145145
// This function is not thread safe, it is only used during block creation.
146146
func (b *SignedBeaconBlock) SetExecution(e interfaces.ExecutionData) error {
147-
if b.version == version.Phase0 || b.version == version.Altair {
147+
if b.version == version.Phase0 || b.version == version.Altair || b.version >= version.Gloas {
148148
return consensus_types.ErrNotSupported("Execution", b.version)
149149
}
150150
if e.IsBlinded() {
@@ -176,7 +176,7 @@ func (b *SignedBeaconBlock) SetBlobKzgCommitments(c [][]byte) error {
176176

177177
// SetExecutionRequests sets the execution requests in the block.
178178
func (b *SignedBeaconBlock) SetExecutionRequests(req *enginev1.ExecutionRequests) error {
179-
if b.version < version.Electra {
179+
if b.version < version.Electra || b.version >= version.Gloas {
180180
return consensus_types.ErrNotSupported("SetExecutionRequests", b.version)
181181
}
182182
b.block.body.executionRequests = req

consensus-types/blocks/setters_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
bitfield "github.com/OffchainLabs/go-bitfield"
77
consensus_types "github.com/OffchainLabs/prysm/v7/consensus-types"
8+
enginev1 "github.com/OffchainLabs/prysm/v7/proto/engine/v1"
89
eth "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1"
910
"github.com/OffchainLabs/prysm/v7/runtime/version"
1011
"github.com/OffchainLabs/prysm/v7/testing/require"
@@ -71,6 +72,28 @@ func TestSignedBeaconBlock_SetSignedExecutionPayloadBid(t *testing.T) {
7172
})
7273
}
7374

75+
func TestSignedBeaconBlock_SetExecution(t *testing.T) {
76+
t.Run("rejects Gloas version", func(t *testing.T) {
77+
sb := newTestSignedBeaconBlock(version.Gloas)
78+
payload := &enginev1.ExecutionPayload{}
79+
wrapped, err := WrappedExecutionPayload(payload)
80+
require.NoError(t, err)
81+
82+
err = sb.SetExecution(wrapped)
83+
require.ErrorIs(t, err, consensus_types.ErrUnsupportedField)
84+
})
85+
}
86+
87+
func TestSignedBeaconBlock_SetExecutionRequests(t *testing.T) {
88+
t.Run("rejects Gloas version", func(t *testing.T) {
89+
sb := newTestSignedBeaconBlock(version.Gloas)
90+
requests := &enginev1.ExecutionRequests{}
91+
92+
err := sb.SetExecutionRequests(requests)
93+
require.ErrorIs(t, err, consensus_types.ErrUnsupportedField)
94+
})
95+
}
96+
7497
func newTestSignedBeaconBlock(ver int) *SignedBeaconBlock {
7598
return &SignedBeaconBlock{
7699
version: ver,

consensus-types/blocks/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ type BeaconBlockBody struct {
5757
blsToExecutionChanges []*eth.SignedBLSToExecutionChange
5858
blobKzgCommitments [][]byte
5959
executionRequests *enginev1.ExecutionRequests
60-
payloadAttestations []*eth.PayloadAttestation
6160
signedExecutionPayloadBid *eth.SignedExecutionPayloadBid
61+
payloadAttestations []*eth.PayloadAttestation
6262
}
6363

6464
var _ interfaces.ReadOnlyBeaconBlockBody = &BeaconBlockBody{}

0 commit comments

Comments
 (0)