mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-07 10:12:19 +00:00
35 lines
966 B
Go
35 lines
966 B
Go
|
package fuzz
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||
|
"github.com/prysmaticlabs/go-ssz"
|
||
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/state"
|
||
|
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||
|
prylabs_testing "github.com/prysmaticlabs/prysm/fuzz/testing"
|
||
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||
|
)
|
||
|
|
||
|
// BeaconFuzzBlock using the corpora from sigp/beacon-fuzz.
|
||
|
func BeaconFuzzBlock(b []byte) ([]byte, bool) {
|
||
|
params.UseMainnetConfig()
|
||
|
input := &InputBlockHeader{}
|
||
|
if err := ssz.Unmarshal(b, input); 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 := state.ProcessBlock(context.Background(), st, ðpb.SignedBeaconBlock{Block: input.Block})
|
||
|
if err != nil {
|
||
|
return fail(err)
|
||
|
}
|
||
|
return success(post)
|
||
|
}
|