mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
Remove getPayloadAttributes from FCU call (#13399)
This commit is contained in:
@@ -94,3 +94,23 @@ func (a *data) PbV3() (*enginev1.PayloadAttributesV3, error) {
|
||||
ParentBeaconBlockRoot: a.parentBeaconBlockRoot,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// IsEmpty returns whether the given payload attribute is empty
|
||||
func (a *data) IsEmpty() bool {
|
||||
if len(a.PrevRandao()) != 0 {
|
||||
return false
|
||||
}
|
||||
if a.Timestamps() != 0 {
|
||||
return false
|
||||
}
|
||||
if len(a.SuggestedFeeRecipient()) != 0 {
|
||||
return false
|
||||
}
|
||||
if a.Version() >= version.Capella && len(a.withdrawals) != 0 {
|
||||
return false
|
||||
}
|
||||
if a.Version() >= version.Deneb && len(a.parentBeaconBlockRoot) != 0 {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -204,3 +204,72 @@ func TestPayloadAttributeGetters(t *testing.T) {
|
||||
t.Run(test.name, test.tc)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsEmpty(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
a Attributer
|
||||
empty bool
|
||||
}{
|
||||
{
|
||||
name: "Empty V1",
|
||||
a: EmptyWithVersion(version.Bellatrix),
|
||||
empty: true,
|
||||
},
|
||||
{
|
||||
name: "Empty V2",
|
||||
a: EmptyWithVersion(version.Capella),
|
||||
empty: true,
|
||||
},
|
||||
{
|
||||
name: "Empty V3",
|
||||
a: EmptyWithVersion(version.Deneb),
|
||||
empty: true,
|
||||
},
|
||||
{
|
||||
name: "non empty prevrandao",
|
||||
a: &data{
|
||||
version: version.Bellatrix,
|
||||
prevRandao: []byte{0x01},
|
||||
},
|
||||
empty: false,
|
||||
},
|
||||
{
|
||||
name: "non zero Timestamps",
|
||||
a: &data{
|
||||
version: version.Bellatrix,
|
||||
timeStamp: 1,
|
||||
},
|
||||
empty: false,
|
||||
},
|
||||
{
|
||||
name: "non empty fee recipient",
|
||||
a: &data{
|
||||
version: version.Bellatrix,
|
||||
suggestedFeeRecipient: []byte{0x01},
|
||||
},
|
||||
empty: false,
|
||||
},
|
||||
{
|
||||
name: "non empty withdrawals",
|
||||
a: &data{
|
||||
version: version.Capella,
|
||||
withdrawals: make([]*enginev1.Withdrawal, 1),
|
||||
},
|
||||
empty: false,
|
||||
},
|
||||
{
|
||||
name: "non empty parent block root",
|
||||
a: &data{
|
||||
version: version.Deneb,
|
||||
parentBeaconBlockRoot: []byte{0x01},
|
||||
},
|
||||
empty: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
require.Equal(t, tt.empty, tt.a.IsEmpty())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,5 @@ type Attributer interface {
|
||||
PbV1() (*enginev1.PayloadAttributes, error)
|
||||
PbV2() (*enginev1.PayloadAttributesV2, error)
|
||||
PbV3() (*enginev1.PayloadAttributesV3, error)
|
||||
IsEmpty() bool
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user