mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 11:32:09 +00:00
41 lines
944 B
Go
41 lines
944 B
Go
|
package fuzz
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||
|
stateutil "github.com/prysmaticlabs/prysm/beacon-chain/core/state"
|
||
|
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||
|
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||
|
"github.com/prysmaticlabs/prysm/shared/featureconfig"
|
||
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||
|
)
|
||
|
|
||
|
func init() {
|
||
|
featureconfig.Init(&featureconfig.Flags{
|
||
|
EnableSSZCache: false,
|
||
|
})
|
||
|
}
|
||
|
|
||
|
// BeaconStateFuzz --
|
||
|
func BeaconStateFuzz(input []byte) {
|
||
|
params.UseMainnetConfig()
|
||
|
st := &pb.BeaconState{}
|
||
|
if err := st.UnmarshalSSZ(input); err != nil {
|
||
|
return
|
||
|
}
|
||
|
s, err := state.InitializeFromProtoUnsafe(st)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
nextEpoch := helpers.SlotToEpoch(s.Slot()) + 1
|
||
|
slot, err := helpers.StartSlot(nextEpoch)
|
||
|
if err != nil {
|
||
|
return
|
||
|
}
|
||
|
if _, err := stateutil.ProcessSlots(context.Background(), s, slot); err != nil {
|
||
|
_ = err
|
||
|
return
|
||
|
}
|
||
|
}
|