fix: pbv2 condition (#12812)

This commit is contained in:
terencechain 2023-08-25 15:54:27 -07:00 committed by Preston Van Loon
parent cd340cb0c8
commit b335eba625
2 changed files with 17 additions and 1 deletions

View File

@ -61,7 +61,7 @@ func (a *data) PbV2() (*enginev1.PayloadAttributesV2, error) {
if a == nil {
return nil, errNilPayloadAttribute
}
if a.version < version.Capella {
if a.version != version.Capella {
return nil, consensus_types.ErrNotSupported("PbV2", a.version)
}
if a.timeStamp == 0 && len(a.prevRandao) == 0 {

View File

@ -182,6 +182,22 @@ func TestPayloadAttributeGetters(t *testing.T) {
require.Equal(t, (*enginev1.PayloadAttributesV3)(nil), got)
},
},
{
name: "Get PbDeneb on pbv2 will fail",
tc: func(t *testing.T) {
p := &enginev1.PayloadAttributesV3{
Timestamp: 1,
PrevRandao: []byte{1, 2, 3},
SuggestedFeeRecipient: []byte{4, 5, 6},
Withdrawals: []*enginev1.Withdrawal{{Index: 1}, {Index: 2}, {Index: 3}},
ParentBeaconBlockRoot: []byte{'a'},
}
a, err := New(p)
require.NoError(t, err)
_, err = a.PbV2()
require.ErrorContains(t, "PbV2 is not supported for deneb", err)
},
},
}
for _, test := range tests {