mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
32 lines
999 B
Go
32 lines
999 B
Go
|
package fuzz
|
||
|
|
||
|
import (
|
||
|
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"
|
||
|
)
|
||
|
|
||
|
// BeaconFuzzVoluntaryExit implements libfuzzer and beacon fuzz interface.
|
||
|
func BeaconFuzzVoluntaryExit(b []byte) ([]byte, bool) {
|
||
|
params.UseMainnetConfig()
|
||
|
input := &InputVoluntaryExitWrapper{}
|
||
|
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)
|
||
|
}
|
||
|
post, err := blocks.ProcessVoluntaryExitsNoVerify(st, ðpb.BeaconBlockBody{VoluntaryExits: []*ethpb.SignedVoluntaryExit{{Exit: input.VoluntaryExit}}})
|
||
|
if err != nil {
|
||
|
return fail(err)
|
||
|
}
|
||
|
return success(post)
|
||
|
}
|