Skip to content

Commit

Permalink
Fix: payload attribute v3 return nil (#12736)
Browse files Browse the repository at this point in the history
  • Loading branch information
terencechain authored and kasey committed Aug 24, 2023
1 parent 0328aae commit c6c7cd8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions consensus-types/payload-attribute/getters.go
Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions consensus-types/payload-attribute/getters_test.go
Expand Up @@ -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 {
Expand Down

0 comments on commit c6c7cd8

Please sign in to comment.