mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 21:38:05 -05:00
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
// +build libfuzzer
|
|
|
|
package fuzz
|
|
|
|
import (
|
|
"context"
|
|
|
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
|
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
|
prylabs_testing "github.com/prysmaticlabs/prysm/fuzz/testing"
|
|
"github.com/prysmaticlabs/prysm/shared/params"
|
|
)
|
|
|
|
// BeaconFuzzDeposit implements libfuzzer and beacon fuzz interface.
|
|
func BeaconFuzzProposerSlashing(b []byte) ([]byte, bool) {
|
|
params.UseMainnetConfig()
|
|
input := &InputProposerSlashingWrapper{}
|
|
if err := input.UnmarshalSSZ(b); err != nil {
|
|
return fail(err)
|
|
}
|
|
s, err := prylabs_testing.GetBeaconFuzzState(input.StateID)
|
|
if err != nil || s == nil {
|
|
return nil, false
|
|
}
|
|
st, err := stateTrie.InitializeFromProto(s)
|
|
if err != nil {
|
|
return fail(err)
|
|
}
|
|
block := ðpb.SignedBeaconBlock{
|
|
Block: ðpb.BeaconBlock{
|
|
Body: ðpb.BeaconBlockBody{ProposerSlashings: []*ethpb.ProposerSlashing{input.ProposerSlashing}},
|
|
},
|
|
}
|
|
post, err := blocks.ProcessProposerSlashings(context.Background(), st, block)
|
|
if err != nil {
|
|
return fail(err)
|
|
}
|
|
return success(post)
|
|
}
|