Fix: payload attribute v3 return nil (#12736)

This commit is contained in:
terencechain 2023-08-14 09:46:54 -07:00 committed by Preston Van Loon
parent 96a9a6fc16
commit 83aaf043e4
2 changed files with 13 additions and 0 deletions

View File

@ -83,6 +83,9 @@ func (a *data) PbV3() (*enginev1.PayloadAttributesV3, error) {
if a.version != version.Deneb {
return nil, consensus_types.ErrNotSupported("PbV3", a.version)
}
if a.timeStamp == 0 && len(a.prevRandao) == 0 && len(a.parentBeaconBlockRoot) == 0 {
return nil, nil
}
return &enginev1.PayloadAttributesV3{
Timestamp: a.timeStamp,
PrevRandao: a.prevRandao,

View File

@ -172,6 +172,16 @@ func TestPayloadAttributeGetters(t *testing.T) {
require.ErrorContains(t, "PbV3 is not supported for capella: unsupported getter", err)
},
},
{
name: "Get PbDeneb (nil)",
tc: func(t *testing.T) {
a, err := New(&enginev1.PayloadAttributesV3{})
require.NoError(t, err)
got, err := a.PbV3()
require.NoError(t, err)
require.Equal(t, (*enginev1.PayloadAttributesV3)(nil), got)
},
},
}
for _, test := range tests {