Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: payload attribute v3 return nil #12736

Merged
merged 1 commit into from Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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