mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 21:08:10 -05:00
Fix Operations Length Check For Attestations (#15134)
* fix check for electra * changelog
This commit is contained in:
@@ -415,11 +415,15 @@ func VerifyOperationLengths(_ context.Context, state state.BeaconState, b interf
|
||||
)
|
||||
}
|
||||
|
||||
if uint64(len(body.Attestations())) > params.BeaconConfig().MaxAttestations {
|
||||
maxAttestations := params.BeaconConfig().MaxAttestations
|
||||
if body.Version() >= version.Electra {
|
||||
maxAttestations = params.BeaconConfig().MaxAttestationsElectra
|
||||
}
|
||||
if uint64(len(body.Attestations())) > maxAttestations {
|
||||
return nil, fmt.Errorf(
|
||||
"number of attestations (%d) in block body exceeds allowed threshold of %d",
|
||||
len(body.Attestations()),
|
||||
params.BeaconConfig().MaxAttestations,
|
||||
maxAttestations,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -474,6 +474,24 @@ func TestProcessBlock_OverMaxAttestations(t *testing.T) {
|
||||
assert.ErrorContains(t, want, err)
|
||||
}
|
||||
|
||||
func TestProcessBlock_OverMaxAttestationsElectra(t *testing.T) {
|
||||
b := ðpb.SignedBeaconBlockElectra{
|
||||
Block: ðpb.BeaconBlockElectra{
|
||||
Body: ðpb.BeaconBlockBodyElectra{
|
||||
Attestations: make([]*ethpb.AttestationElectra, params.BeaconConfig().MaxAttestationsElectra+1),
|
||||
},
|
||||
},
|
||||
}
|
||||
want := fmt.Sprintf("number of attestations (%d) in block body exceeds allowed threshold of %d",
|
||||
len(b.Block.Body.Attestations), params.BeaconConfig().MaxAttestationsElectra)
|
||||
s, err := state_native.InitializeFromProtoUnsafeElectra(ðpb.BeaconStateElectra{})
|
||||
require.NoError(t, err)
|
||||
wsb, err := consensusblocks.NewSignedBeaconBlock(b)
|
||||
require.NoError(t, err)
|
||||
_, err = transition.VerifyOperationLengths(context.Background(), s, wsb.Block())
|
||||
assert.ErrorContains(t, want, err)
|
||||
}
|
||||
|
||||
func TestProcessBlock_OverMaxVoluntaryExits(t *testing.T) {
|
||||
maxExits := params.BeaconConfig().MaxVoluntaryExits
|
||||
b := ðpb.SignedBeaconBlock{
|
||||
|
||||
3
changelog/nisdas_fix_operations_check_bug.md
Normal file
3
changelog/nisdas_fix_operations_check_bug.md
Normal file
@@ -0,0 +1,3 @@
|
||||
### Fixed
|
||||
|
||||
- Fixed a bug in checking for attestation lengths in our block.
|
||||
Reference in New Issue
Block a user