prysm-pulse/fuzz/BUILD.bazel
Preston Van Loon 49a0d3caf0
Refactor dependencies, make Prysm "go gettable" (#6053)
* Fix a few deps to work with go.mod, check in generated files

* Update Gossipsub to 1.1 (#5998)

* update libs

* add new validators

* add new deps

* new set of deps

* tls

* further fix gossip update

* get everything to build

* clean up

* gaz

* fix build

* fix all tests

* add deps to images

* imports

Co-authored-by: rauljordan <raul@prysmaticlabs.com>

* Beacon chain builds with go build

* fix bazel

* fix dep

* lint

* Add github action for testing go

* on PR for any branch

* fix libp2p test failure

* Fix TestProcessBlock_PassesProcessingConditions by updating the proposer index in test

* Revert "Fix TestProcessBlock_PassesProcessingConditions by updating the proposer index in test"

This reverts commit 43676894ab01f03fe90a9b8ee3ecfbc2ec1ec4e4.

* Compute and set proposer index instead of hard code

* Add back go mod/sum, fix deps

* go build ./...

* Temporarily skip two tests

* Fix kafka confluent patch

* Fix kafka confluent patch

* fix kafka build

* fix kafka

* Add info in DEPENDENCIES. Added a stub link for Why Bazel? until https://github.com/prysmaticlabs/documentation/issues/138

* Update fuzz ssz files as well

* Update fuzz ssz files as well

* getting closer

* rollback rules_go and gazelle

* fix gogo protobuf

* install librdkafka-dev as part of github actions

* Update kafka to a recent version where librkafkfa is not required for go modules

* clarify comment

* fix kafka build

* disable go tests

* comment

* Fix geth dependencies for end to end

* rename word

* lint

* fix docker

Co-authored-by: Nishant Das <nishdas93@gmail.com>
Co-authored-by: rauljordan <raul@prysmaticlabs.com>
Co-authored-by: terence tsao <terence@prysmaticlabs.com>
2020-05-31 14:44:34 +08:00

275 lines
8.9 KiB
Python

load("@prysm//tools/go:def.bzl", "go_library")
load("//tools/go:fuzz.bzl", "go_fuzz_test")
load("@com_github_prysmaticlabs_ethereumapis//tools:ssz.bzl", "SSZ_DEPS", "ssz_gen_marshal")
load("@io_bazel_rules_docker//container:container.bzl", "container_image", "container_push")
# gazelle:ignore generated.ssz.go
ssz_gen_marshal(
name = "ssz_generated_files",
srcs = ["inputs.go"],
includes = [
"//proto/beacon/p2p/v1:go_default_library",
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
],
objs = [
"InputBlockHeader",
"InputAttesterSlashingWrapper",
"InputAttestationWrapper",
"InputDepositWrapper",
"InputVoluntaryExitWrapper",
"InputProposerSlashingWrapper",
],
)
container_image(
name = "prysm_fuzzit",
base = "@fuzzit_base//image",
directory = "/beacon_states",
env = {
"BEACONSTATES_PATH": "/beacon_states",
},
files = [
"@sigp_beacon_fuzz_corpora//:current_mainnet_beaconstate",
],
)
container_push(
name = "push_image",
format = "Docker",
image = ":prysm_fuzzit",
registry = "gcr.io",
repository = "prysmaticlabs/prysm-fuzzit",
tag = "v0.11.0",
)
IMPORT_PATH = "github.com/prysmaticlabs/prysm/fuzz"
COMMON_DEPS = [
"//beacon-chain/state:go_default_library",
"//shared/featureconfig:go_default_library",
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
] + SSZ_DEPS
COMMON_SRCS = [
"common.go",
"inputs.go",
":ssz_generated_files",
]
SRCS = COMMON_SRCS + glob(["*_fuzz.go"])
test_suite(
name = "fuzz_tests",
tags = ["manual"],
tests = [
":attestation_fuzz_test_with_libfuzzer",
":attester_slashing_fuzz_test_with_libfuzzer",
":block_fuzz_test_with_libfuzzer",
":block_header_fuzz_test_with_libfuzzer",
":deposit_fuzz_test_with_libfuzzer",
":proposer_slashing_fuzz_test_with_libfuzzer",
":rpc_status_fuzz_test_with_libfuzzer",
":ssz_cache_fuzz_test_with_libfuzzer",
":voluntary_exit_fuzz_test_with_libfuzzer",
],
)
go_fuzz_test(
name = "attestation_fuzz_test",
srcs = [
"attestation_fuzz.go",
] + COMMON_SRCS,
corpus = "@sigp_beacon_fuzz_corpora//:current_mainnet_attestation",
corpus_path = "external/sigp_beacon_fuzz_corpora/0-11-0/mainnet/attestation",
func = "BeaconFuzzAttestation",
importpath = IMPORT_PATH,
deps = [
"//beacon-chain/core/blocks:go_default_library",
"//fuzz/testing:go_default_library",
"//shared/params:go_default_library",
] + COMMON_DEPS,
)
go_fuzz_test(
name = "attester_slashing_fuzz_test",
srcs = [
"attester_slashing_fuzz.go",
] + COMMON_SRCS,
corpus = "@sigp_beacon_fuzz_corpora//:current_mainnet_attester_slashing",
corpus_path = "external/sigp_beacon_fuzz_corpora/0-11-0/mainnet/attester_slashing",
func = "BeaconFuzzAttesterSlashing",
importpath = IMPORT_PATH,
deps = [
"//beacon-chain/core/blocks:go_default_library",
"//fuzz/testing:go_default_library",
"//shared/params:go_default_library",
] + COMMON_DEPS,
)
go_fuzz_test(
name = "block_fuzz_test",
srcs = [
"block_fuzz.go",
] + COMMON_SRCS,
corpus = "@sigp_beacon_fuzz_corpora//:current_mainnet_block_header",
corpus_path = "external/sigp_beacon_fuzz_corpora/0-11-0/mainnet/block_header",
func = "BeaconFuzzBlock",
importpath = IMPORT_PATH,
deps = [
"//beacon-chain/core/blocks:go_default_library",
"//beacon-chain/core/state:go_default_library",
"//fuzz/testing:go_default_library",
"//shared/params:go_default_library",
] + COMMON_DEPS,
)
go_fuzz_test(
name = "block_header_fuzz_test",
srcs = [
"block_header_fuzz.go",
] + COMMON_SRCS,
corpus = "@sigp_beacon_fuzz_corpora//:current_mainnet_block_header",
corpus_path = "external/sigp_beacon_fuzz_corpora/0-11-0/mainnet/block_header",
func = "BeaconFuzzBlockHeader",
importpath = IMPORT_PATH,
deps = [
"//beacon-chain/core/blocks:go_default_library",
"//fuzz/testing:go_default_library",
"//shared/params:go_default_library",
] + COMMON_DEPS,
)
go_fuzz_test(
name = "deposit_fuzz_test",
srcs = [
"deposit_fuzz.go",
] + COMMON_SRCS,
corpus = "deposit_corpus",
corpus_path = "fuzz/deposit_corpus",
func = "BeaconFuzzDeposit",
importpath = IMPORT_PATH,
deps = [
"//beacon-chain/core/blocks:go_default_library",
"//fuzz/testing:go_default_library",
"//shared/params:go_default_library",
] + COMMON_DEPS,
)
go_fuzz_test(
name = "proposer_slashing_fuzz_test",
srcs = [
"proposer_slashing_fuzz.go",
] + COMMON_SRCS,
corpus = "@sigp_beacon_fuzz_corpora//:current_mainnet_proposer_slashing",
corpus_path = "external/sigp_beacon_fuzz_corpora/0-11-0/mainnet/proposer_slashing",
func = "BeaconFuzzProposerSlashing",
importpath = IMPORT_PATH,
deps = [
"//beacon-chain/core/blocks:go_default_library",
"//fuzz/testing:go_default_library",
"//shared/params:go_default_library",
] + COMMON_DEPS,
)
go_fuzz_test(
name = "rpc_status_fuzz_test",
srcs = [
"rpc_status_fuzz.go",
] + COMMON_SRCS,
corpus = "rpc_status_corpus",
corpus_path = "fuzz/rpc_status_corpus",
func = "BeaconFuzzP2PRPCStatus",
importpath = IMPORT_PATH,
deps = [
"//beacon-chain/p2p:go_default_library",
"//beacon-chain/sync:go_default_library",
"//beacon-chain/blockchain/testing:go_default_library",
"//beacon-chain/sync/initial-sync/testing:go_default_library",
"//beacon-chain/cache:go_default_library",
"//proto/beacon/p2p/v1:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_libp2p_go_libp2p//:go_default_library",
"@com_github_libp2p_go_libp2p_core//host:go_default_library",
"@com_github_libp2p_go_libp2p_core//peer:go_default_library",
"@com_github_libp2p_go_libp2p_core//network:go_default_library",
"@com_github_libp2p_go_libp2p_core//mux:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
] + COMMON_DEPS,
)
go_fuzz_test(
name = "ssz_cache_fuzz_test",
srcs = [
"ssz_cache_fuzz.go",
] + COMMON_SRCS,
corpus = "@sigp_beacon_fuzz_corpora//:0_11_0_mainnet_beaconstate",
corpus_path = "external/sigp_beacon_fuzz_corpora/0-11-0/mainnet/beaconstate",
func = "BeaconFuzzSSZCache",
importpath = IMPORT_PATH,
deps = [
"//proto/beacon/p2p/v1:go_default_library",
"//beacon-chain/state/stateutil:go_default_library",
] + COMMON_DEPS,
)
go_fuzz_test(
name = "voluntary_exit_fuzz_test",
srcs = [
"voluntary_exit_fuzz.go",
] + COMMON_SRCS,
corpus = "voluntary_exit_corpus",
corpus_path = "fuzz/voluntary_exit_corpus",
func = "BeaconFuzzVoluntaryExit",
importpath = IMPORT_PATH,
deps = [
"//beacon-chain/core/blocks:go_default_library",
"//fuzz/testing:go_default_library",
"//shared/params:go_default_library",
] + COMMON_DEPS,
)
go_library(
name = "go_default_library",
testonly = 1,
srcs = [
"attestation_fuzz.go",
"attester_slashing_fuzz.go",
"block_fuzz.go",
"block_header_fuzz.go",
"common.go",
"deposit_fuzz.go",
"inputs.go",
"rpc_status_fuzz.go",
"ssz_cache_fuzz.go",
"voluntary_exit_fuzz.go",
":ssz_generated_files", # keep
],
importpath = "github.com/prysmaticlabs/prysm/fuzz",
visibility = ["//visibility:public"],
deps = [
"//beacon-chain/blockchain/testing:go_default_library",
"//beacon-chain/cache:go_default_library",
"//beacon-chain/core/blocks:go_default_library",
"//beacon-chain/core/state:go_default_library",
"//beacon-chain/p2p:go_default_library",
"//beacon-chain/state:go_default_library",
"//beacon-chain/state/stateutil:go_default_library",
"//beacon-chain/sync:go_default_library",
"//beacon-chain/sync/initial-sync/testing:go_default_library",
"//fuzz/testing:go_default_library",
"//proto/beacon/p2p/v1:go_default_library",
"//shared/featureconfig:go_default_library",
"//shared/params:go_default_library",
"@com_github_libp2p_go_libp2p//:go_default_library",
"@com_github_libp2p_go_libp2p_core//host:go_default_library",
"@com_github_libp2p_go_libp2p_core//network:go_default_library",
"@com_github_libp2p_go_libp2p_core//peer:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
] + SSZ_DEPS, # keep
)