prysm-pulse/fuzz/block_header_fuzz.go
Shay Zluf 1a27c21d9c
Load chain config from file (#5694)
* load chain config from file

* revert flag name change

* add dependencies to image

* Update shared/cmd/flags.go

Co-authored-by: Victor Farazdagi <simple.square@gmail.com>

* Update beacon-chain/main.go

Co-authored-by: Victor Farazdagi <simple.square@gmail.com>

* added test to load config file

* Merge branch 'yaml_chain_config' of github.com:prysmaticlabs/prysm into yaml_chain_config

# Conflicts:
#	beacon-chain/main.go

* replace hex with yaml format of fixed byte array

* fix test and check if comment

* move to node package

* gaz

* added contract address case

* fix key name issue

* add tests

* gaz

* add 1 byte handling

* change to fatal

* add config printout

* revert main changes

* revert line removal

* fix one byte handling

* fix test and one byte handling

* remove log

* Apply suggestions from code review

* change to debug

* Update beacon-chain/node/node.go

* move helper methods

Co-authored-by: Victor Farazdagi <simple.square@gmail.com>
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
Co-authored-by: terence tsao <terence@prysmaticlabs.com>
2020-05-05 20:58:07 +03:00

32 lines
867 B
Go

package fuzz
import (
"github.com/prysmaticlabs/go-ssz"
"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"
)
// BeaconFuzzBlockHeader using the corpora from sigp/beacon-fuzz.
func BeaconFuzzBlockHeader(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 := blocks.ProcessBlockHeaderNoVerify(st, input.Block)
if err != nil {
return fail(err)
}
return success(post)
}