diff --git a/.bazelrc b/.bazelrc index e270301e3..19501018f 100644 --- a/.bazelrc +++ b/.bazelrc @@ -38,6 +38,41 @@ build:release --compilation_mode=opt # LLVM compiler for building C/C++ dependencies. build:llvm --crosstool_top=@llvm_toolchain//:toolchain build:llvm --define compiler=llvm +build:llvm --copt -fno-sanitize=vptr,function +build:llvm --linkopt -fno-sanitize=vptr,function + +build:asan --copt -fsanitize=address,undefined +build:asan --copt -fno-omit-frame-pointer +build:asan --linkopt -fsanitize=address,undefined +build:asan --copt -fno-sanitize=vptr,function +build:asan --linkopt -fno-sanitize=vptr,function +build:asan --copt -DADDRESS_SANITIZER=1 +build:asan --copt -D__SANITIZE_ADDRESS__ +build:asan --linkopt -ldl + +build:llvm-asan --config=llvm +build:llvm-asan --config=asan +build:llvm-asan --linkopt -fuse-ld=ld.lld + +build:fuzz --define=gotags=libfuzzer +build:fuzz --config=llvm-asan +build:fuzz --copt=-fsanitize=fuzzer-no-link +build:fuzz --linkopt=-fsanitize=fuzzer +build:fuzz --copt=-fno-omit-frame-pointer +build:fuzz --define=FUZZING_ENGINE=libfuzzer +build:fuzz --copt=-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION +build:fuzz --linkopt -Wl,--no-as-needed +build:fuzz --define=gc_goopts=-d=libfuzzer +build:fuzz --run_under=//tools:fuzz_wrapper +build:fuzz --compilation_mode=opt + +test:fuzz --local_test_jobs="HOST_CPUS*.5" + +test:fuzzit --config=fuzz +test:fuzzit --test_env=FUZZIT_API_KEY +test:fuzzit --test_env=PRYSM_BUILD_IMAGE=gcr.io/prysmaticlabs/prysm-fuzzit:v0.11.0 +test:fuzzit --test_timeout=1200 +test:fuzzit --run_under=//tools:fuzzit_wrapper # Build binary with cgo symbolizer for debugging / profiling. build:cgo_symbolizer --config=llvm diff --git a/.buildkite-bazelrc b/.buildkite-bazelrc index 694c6ad21..bc25cc803 100644 --- a/.buildkite-bazelrc +++ b/.buildkite-bazelrc @@ -49,3 +49,11 @@ test --define kafka_enabled=true build --bes_backend=grpcs://builds.prylabs.net:1985 build --bes_results_url=https://builds.prylabs.net/invocation/ + +# Disable flaky test detection for fuzzing. +test:fuzz --flaky_test_attempts=1 + +# Expose test environment variables in CI +test:fuzzit --test_env=GITHUB_REF +test:fuzzit --test_env=GITHUB_SHA +test:fuzzit --test_env=DOCKER_HOST diff --git a/BUILD.bazel b/BUILD.bazel index 35e033f59..b02d61e9a 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -4,6 +4,7 @@ load("@com_github_atlassian_bazel_tools//goimports:def.bzl", "goimports") load("@io_kubernetes_build//defs:run_in_workspace.bzl", "workspace_binary") load("@io_bazel_rules_go//go:def.bzl", "nogo") load("@graknlabs_bazel_distribution//common:rules.bzl", "assemble_targz", "assemble_versioned") +load("@bazel_skylib//rules:common_settings.bzl", "string_setting") prefix = "github.com/prysmaticlabs/prysm" @@ -12,6 +13,7 @@ exports_files([ ]) # gazelle:prefix github.com/prysmaticlabs/prysm +# gazelle:map_kind go_library go_library @prysm//tools/go:def.bzl gazelle( name = "gazelle", prefix = prefix, @@ -120,3 +122,12 @@ toolchain( toolchain = "@rules_foreign_cc//tools/build_defs/native_tools:built_cmake", toolchain_type = "@rules_foreign_cc//tools/build_defs:cmake_toolchain", ) + +string_setting( + name = "gotags", + build_setting_default = "", + values = [ + "", + "libfuzzer", + ], +) diff --git a/README.md b/README.md index 51ee99ec0..217320d2f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Prysm: An Ethereum 2.0 Client Written in Go [![Build status](https://badge.buildkite.com/b555891daf3614bae4284dcf365b2340cefc0089839526f096.svg?branch=master)](https://buildkite.com/prysmatic-labs/prysm) +[![fuzzit](https://app.fuzzit.dev/badge?org_id=prysmaticlabs-gh)](https://app.fuzzit.dev/orgs/prysmaticlabs-gh/dashboard) [![ETH2.0_Spec_Version 0.11.1](https://img.shields.io/badge/ETH2.0%20Spec%20Version-v0.11.1-blue.svg)](https://github.com/ethereum/eth2.0-specs/tree/v0.11.1) [![Discord](https://user-images.githubusercontent.com/7288322/34471967-1df7808a-efbb-11e7-9088-ed0b04151291.png)](https://discord.gg/KSA7rPr) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/prysmaticlabs/geth-sharding?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) diff --git a/WORKSPACE b/WORKSPACE index 1c11b2580..07a92f81c 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -43,6 +43,8 @@ load("@prysm//tools/cross-toolchain:rbe_toolchains_config.bzl", "rbe_toolchains_ rbe_toolchains_config() +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + http_archive( name = "bazel_skylib", sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44", @@ -88,6 +90,13 @@ http_archive( ], ) +http_archive( + name = "fuzzit_linux", + build_file_content = "exports_files([\"fuzzit\"])", + sha256 = "9ca76ac1c22d9360936006efddf992977ebf8e4788ded8e5f9d511285c9ac774", + urls = ["https://github.com/fuzzitdev/fuzzit/releases/download/v2.4.76/fuzzit_Linux_x86_64.zip"], +) + git_repository( name = "graknlabs_bazel_distribution", commit = "962f3a7e56942430c0ec120c24f9e9f2a9c2ce1a", @@ -129,6 +138,13 @@ container_pull( repository = "frolvlad/alpine-glibc", ) +container_pull( + name = "fuzzit_base", + digest = "sha256:24a39a4360b07b8f0121eb55674a2e757ab09f0baff5569332fefd227ee4338f", + registry = "gcr.io", + repository = "fuzzit-public/stretch-llvm8", +) + load("@prysm//third_party/herumi:herumi.bzl", "bls_dependencies") bls_dependencies() @@ -139,7 +155,8 @@ go_rules_dependencies() go_register_toolchains(nogo = "@//:nogo") -load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository") +load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") +load("@prysm//tools/go:def.bzl", "go_repository") gazelle_dependencies() @@ -266,9 +283,9 @@ all_content = """filegroup(name = "all", srcs = glob(["**"]), visibility = ["//v http_archive( name = "rules_foreign_cc", - sha256 = "450563dc2938f38566a59596bb30a3e905fbbcc35b3fff5a1791b122bc140465", - strip_prefix = "rules_foreign_cc-456425521973736ef346d93d3d6ba07d807047df", - url = "https://github.com/bazelbuild/rules_foreign_cc/archive/456425521973736ef346d93d3d6ba07d807047df.zip", + sha256 = "b85ce66a3410f7370d1a9a61dfe3a29c7532b7637caeb2877d8d0dfd41d77abb", + strip_prefix = "rules_foreign_cc-3515b20a2417c4dd51c8a4a8cac1f6ecf3c6d934", + url = "https://github.com/bazelbuild/rules_foreign_cc/archive/3515b20a2417c4dd51c8a4a8cac1f6ecf3c6d934.zip", ) load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies") @@ -285,6 +302,16 @@ http_archive( urls = ["https://github.com/edenhill/librdkafka/archive/v1.2.1.tar.gz"], ) +http_archive( + name = "sigp_beacon_fuzz_corpora", + build_file = "//third_party:beacon-fuzz/corpora.BUILD", + sha256 = "42993d0901a316afda45b4ba6d53c7c21f30c551dcec290a4ca131c24453d1ef", + strip_prefix = "beacon-fuzz-corpora-bac24ad78d45cc3664c0172241feac969c1ac29b", + urls = [ + "https://github.com/sigp/beacon-fuzz-corpora/archive/bac24ad78d45cc3664c0172241feac969c1ac29b.tar.gz", + ], +) + # External dependencies go_repository( @@ -1607,6 +1634,34 @@ go_repository( name = "com_github_ferranbt_fastssz", commit = "06015a5d84f9e4eefe2c21377ca678fa8f1a1b09", importpath = "github.com/ferranbt/fastssz", + nofuzz = True, +) + +http_archive( + name = "sszgen", # Hack because we don't want to build this binary with libfuzzer, but need it to build. + build_file_content = """ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_binary") + +go_library( + name = "go_default_library", + srcs = [ + "sszgen/main.go", + "sszgen/marshal.go", + "sszgen/size.go", + "sszgen/unmarshal.go", + ], + importpath = "github.com/ferranbt/fastssz/sszgen", + visibility = ["//visibility:private"], +) + +go_binary( + name = "sszgen", + embed = [":go_default_library"], + visibility = ["//visibility:public"], +) + """, + strip_prefix = "fastssz-06015a5d84f9e4eefe2c21377ca678fa8f1a1b09", + urls = ["https://github.com/ferranbt/fastssz/archive/06015a5d84f9e4eefe2c21377ca678fa8f1a1b09.tar.gz"], ) go_repository( diff --git a/beacon-chain/BUILD.bazel b/beacon-chain/BUILD.bazel index d877862fd..5c84e06e2 100644 --- a/beacon-chain/BUILD.bazel +++ b/beacon-chain/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_test") load("@io_bazel_rules_docker//go:image.bzl", "go_image") load("@io_bazel_rules_docker//container:container.bzl", "container_bundle") load("//tools:go_image.bzl", "go_image_alpine", "go_image_debug") diff --git a/beacon-chain/archiver/BUILD.bazel b/beacon-chain/archiver/BUILD.bazel index 993e8dec4..dae5a00eb 100644 --- a/beacon-chain/archiver/BUILD.bazel +++ b/beacon-chain/archiver/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/blockchain/BUILD.bazel b/beacon-chain/blockchain/BUILD.bazel index 7a22d39a4..411b374d0 100644 --- a/beacon-chain/blockchain/BUILD.bazel +++ b/beacon-chain/blockchain/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/blockchain/testing/BUILD.bazel b/beacon-chain/blockchain/testing/BUILD.bazel index 1e5eb575c..4411c96aa 100644 --- a/beacon-chain/blockchain/testing/BUILD.bazel +++ b/beacon-chain/blockchain/testing/BUILD.bazel @@ -1,11 +1,14 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", testonly = True, srcs = ["mock.go"], importpath = "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing", - visibility = ["//beacon-chain:__subpackages__"], + visibility = [ + "//beacon-chain:__subpackages__", + "//fuzz:__pkg__", + ], deps = [ "//beacon-chain/core/epoch/precompute:go_default_library", "//beacon-chain/core/feed/block:go_default_library", diff --git a/beacon-chain/cache/BUILD.bazel b/beacon-chain/cache/BUILD.bazel index 383f8e610..2e9693e21 100644 --- a/beacon-chain/cache/BUILD.bazel +++ b/beacon-chain/cache/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", @@ -17,6 +18,7 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/beacon-chain/cache", visibility = [ "//beacon-chain:__subpackages__", + "//fuzz:__pkg__", "//tools:__subpackages__", ], deps = [ diff --git a/beacon-chain/cache/depositcache/BUILD.bazel b/beacon-chain/cache/depositcache/BUILD.bazel index 3cc619e35..df2dbb19c 100644 --- a/beacon-chain/cache/depositcache/BUILD.bazel +++ b/beacon-chain/cache/depositcache/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/core/blocks/BUILD.bazel b/beacon-chain/core/blocks/BUILD.bazel index 66a0c9c24..be02e73eb 100644 --- a/beacon-chain/core/blocks/BUILD.bazel +++ b/beacon-chain/core/blocks/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", @@ -9,6 +10,7 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks", visibility = [ "//beacon-chain:__subpackages__", + "//fuzz:__pkg__", "//shared/testutil:__pkg__", ], deps = [ diff --git a/beacon-chain/core/blocks/spectest/BUILD.bazel b/beacon-chain/core/blocks/spectest/BUILD.bazel index aef6bc9c1..690b37cc1 100644 --- a/beacon-chain/core/blocks/spectest/BUILD.bazel +++ b/beacon-chain/core/blocks/spectest/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/core/blocks/spectest/block_header_test.go b/beacon-chain/core/blocks/spectest/block_header_test.go index f8a910127..889bd8da6 100644 --- a/beacon-chain/core/blocks/spectest/block_header_test.go +++ b/beacon-chain/core/blocks/spectest/block_header_test.go @@ -11,7 +11,7 @@ import ( ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1" "github.com/prysmaticlabs/go-ssz" "github.com/prysmaticlabs/prysm/beacon-chain/core/blocks" - beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state" + stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/shared/params/spectest" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -43,7 +43,7 @@ func runBlockHeaderTest(t *testing.T, config string) { if err := ssz.Unmarshal(preBeaconStateFile, preBeaconStateBase); err != nil { t.Fatalf("Failed to unmarshal: %v", err) } - preBeaconState, err := beaconstate.InitializeFromProto(preBeaconStateBase) + preBeaconState, err := stateTrie.InitializeFromProto(preBeaconStateBase) if err != nil { t.Fatal(err) } diff --git a/beacon-chain/core/blocks/spectest/block_processing_test.go b/beacon-chain/core/blocks/spectest/block_processing_test.go index 86b818da2..75e55a54b 100644 --- a/beacon-chain/core/blocks/spectest/block_processing_test.go +++ b/beacon-chain/core/blocks/spectest/block_processing_test.go @@ -16,7 +16,7 @@ import ( "github.com/prysmaticlabs/go-ssz" "github.com/prysmaticlabs/prysm/beacon-chain/core/helpers" "github.com/prysmaticlabs/prysm/beacon-chain/core/state" - beaconstate "github.com/prysmaticlabs/prysm/beacon-chain/state" + stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state" pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" "github.com/prysmaticlabs/prysm/shared/params/spectest" "github.com/prysmaticlabs/prysm/shared/testutil" @@ -44,7 +44,7 @@ func runBlockProcessingTest(t *testing.T, config string) { if err := ssz.Unmarshal(preBeaconStateFile, beaconStateBase); err != nil { t.Fatalf("Failed to unmarshal: %v", err) } - beaconState, err := beaconstate.InitializeFromProto(beaconStateBase) + beaconState, err := stateTrie.InitializeFromProto(beaconStateBase) if err != nil { t.Fatal(err) } diff --git a/beacon-chain/core/epoch/BUILD.bazel b/beacon-chain/core/epoch/BUILD.bazel index 4197e7afb..54133b9a7 100644 --- a/beacon-chain/core/epoch/BUILD.bazel +++ b/beacon-chain/core/epoch/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/core/epoch/precompute/BUILD.bazel b/beacon-chain/core/epoch/precompute/BUILD.bazel index 6d7bf1ed9..d617f1bbd 100644 --- a/beacon-chain/core/epoch/precompute/BUILD.bazel +++ b/beacon-chain/core/epoch/precompute/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/core/feed/BUILD.bazel b/beacon-chain/core/feed/BUILD.bazel index 880ea902b..ca84ccfb9 100644 --- a/beacon-chain/core/feed/BUILD.bazel +++ b/beacon-chain/core/feed/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/beacon-chain/core/feed/block/BUILD.bazel b/beacon-chain/core/feed/block/BUILD.bazel index c13063239..cd96c3280 100644 --- a/beacon-chain/core/feed/block/BUILD.bazel +++ b/beacon-chain/core/feed/block/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/beacon-chain/core/feed/operation/BUILD.bazel b/beacon-chain/core/feed/operation/BUILD.bazel index aed4971ea..46bd10363 100644 --- a/beacon-chain/core/feed/operation/BUILD.bazel +++ b/beacon-chain/core/feed/operation/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/beacon-chain/core/feed/state/BUILD.bazel b/beacon-chain/core/feed/state/BUILD.bazel index d694c9a69..0519e59ae 100644 --- a/beacon-chain/core/feed/state/BUILD.bazel +++ b/beacon-chain/core/feed/state/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/beacon-chain/core/helpers/BUILD.bazel b/beacon-chain/core/helpers/BUILD.bazel index 47c9c396d..b283bc451 100644 --- a/beacon-chain/core/helpers/BUILD.bazel +++ b/beacon-chain/core/helpers/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/core/helpers/spectest/BUILD.bazel b/beacon-chain/core/helpers/spectest/BUILD.bazel index a907fa053..d6f6087e5 100644 --- a/beacon-chain/core/helpers/spectest/BUILD.bazel +++ b/beacon-chain/core/helpers/spectest/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/core/state/BUILD.bazel b/beacon-chain/core/state/BUILD.bazel index 22d18db1a..c57765ab8 100644 --- a/beacon-chain/core/state/BUILD.bazel +++ b/beacon-chain/core/state/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") # gazelle:exclude testdata @@ -13,6 +14,7 @@ go_library( visibility = [ "//beacon-chain:__subpackages__", "//endtoend:__pkg__", + "//fuzz:__pkg__", "//shared/interop:__pkg__", "//shared/testutil:__pkg__", "//tools/benchmark-files-gen:__pkg__", diff --git a/beacon-chain/core/state/interop/BUILD.bazel b/beacon-chain/core/state/interop/BUILD.bazel index a7f9afb65..0469b36c0 100644 --- a/beacon-chain/core/state/interop/BUILD.bazel +++ b/beacon-chain/core/state/interop/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/beacon-chain/core/state/stateutils/BUILD.bazel b/beacon-chain/core/state/stateutils/BUILD.bazel index 7f967274d..af2837f6a 100644 --- a/beacon-chain/core/state/stateutils/BUILD.bazel +++ b/beacon-chain/core/state/stateutils/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/core/state/transition.go b/beacon-chain/core/state/transition.go index 5afff49d6..9fd324892 100644 --- a/beacon-chain/core/state/transition.go +++ b/beacon-chain/core/state/transition.go @@ -425,7 +425,7 @@ func ProcessBlockNoVerifyAttSigs( return nil, errors.Wrap(err, "could not process eth1 data") } - state, err = processOperationsNoVerify(ctx, state, signed.Block.Body) + state, err = ProcessOperationsNoVerify(ctx, state, signed.Block.Body) if err != nil { traceutil.AnnotateError(span, err) return nil, errors.Wrap(err, "could not process block operation") @@ -491,7 +491,7 @@ func ProcessOperations( return state, nil } -// processOperationsNoVerify processes the operations in the beacon block and updates beacon state +// ProcessOperationsNoVerify processes the operations in the beacon block and updates beacon state // with the operations in block. It does not verify attestation signatures or voluntary exit signatures. // // WARNING: This method does not verify attestation signatures or voluntary exit signatures. @@ -516,7 +516,7 @@ func ProcessOperations( // for operations, function in all_operations: // for operation in operations: // function(state, operation) -func processOperationsNoVerify( +func ProcessOperationsNoVerify( ctx context.Context, state *stateTrie.BeaconState, body *ethpb.BeaconBlockBody) (*stateTrie.BeaconState, error) { @@ -685,7 +685,7 @@ func ProcessBlockForStateRoot( return nil, errors.Wrap(err, "could not process eth1 data") } - state, err = processOperationsNoVerify(ctx, state, signed.Block.Body) + state, err = ProcessOperationsNoVerify(ctx, state, signed.Block.Body) if err != nil { traceutil.AnnotateError(span, err) return nil, errors.Wrap(err, "could not process block operation") diff --git a/beacon-chain/core/state/transition_fuzz_test.go b/beacon-chain/core/state/transition_fuzz_test.go index e7caae82f..c36ba5da5 100644 --- a/beacon-chain/core/state/transition_fuzz_test.go +++ b/beacon-chain/core/state/transition_fuzz_test.go @@ -162,7 +162,7 @@ func TestFuzzprocessOperationsNoVerify_1000(t *testing.T) { for i := 0; i < 1000; i++ { fuzzer.Fuzz(state) fuzzer.Fuzz(bb) - s, err := processOperationsNoVerify(ctx, state, bb) + s, err := ProcessOperationsNoVerify(ctx, state, bb) if err != nil && s != nil { t.Fatalf("state should be nil on err. found: %v on error: %v for block body: %v", s, err, bb) } diff --git a/beacon-chain/core/validators/BUILD.bazel b/beacon-chain/core/validators/BUILD.bazel index 4eebee5a7..f6add7c6e 100644 --- a/beacon-chain/core/validators/BUILD.bazel +++ b/beacon-chain/core/validators/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/db/filters/BUILD.bazel b/beacon-chain/db/filters/BUILD.bazel index d638212d9..79455ef86 100644 --- a/beacon-chain/db/filters/BUILD.bazel +++ b/beacon-chain/db/filters/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/db/iface/BUILD.bazel b/beacon-chain/db/iface/BUILD.bazel index 0c144e9b9..eacad0d55 100644 --- a/beacon-chain/db/iface/BUILD.bazel +++ b/beacon-chain/db/iface/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/beacon-chain/db/kafka/BUILD.bazel b/beacon-chain/db/kafka/BUILD.bazel index 00fd619f7..df653098c 100644 --- a/beacon-chain/db/kafka/BUILD.bazel +++ b/beacon-chain/db/kafka/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/beacon-chain/db/kv/BUILD.bazel b/beacon-chain/db/kv/BUILD.bazel index f7bdff520..018c3bf64 100644 --- a/beacon-chain/db/kv/BUILD.bazel +++ b/beacon-chain/db/kv/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/db/testing/BUILD.bazel b/beacon-chain/db/testing/BUILD.bazel index 3df156edb..c5d90826b 100644 --- a/beacon-chain/db/testing/BUILD.bazel +++ b/beacon-chain/db/testing/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/beacon-chain/flags/BUILD.bazel b/beacon-chain/flags/BUILD.bazel index 0444b0587..cbafe3ab9 100644 --- a/beacon-chain/flags/BUILD.bazel +++ b/beacon-chain/flags/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/beacon-chain/forkchoice/BUILD.bazel b/beacon-chain/forkchoice/BUILD.bazel index 015a3ae93..e48470ef9 100644 --- a/beacon-chain/forkchoice/BUILD.bazel +++ b/beacon-chain/forkchoice/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/beacon-chain/forkchoice/protoarray/BUILD.bazel b/beacon-chain/forkchoice/protoarray/BUILD.bazel index 9edf83c09..e6cf46379 100644 --- a/beacon-chain/forkchoice/protoarray/BUILD.bazel +++ b/beacon-chain/forkchoice/protoarray/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/gateway/server/BUILD.bazel b/beacon-chain/gateway/server/BUILD.bazel index ff444240e..70d288b73 100644 --- a/beacon-chain/gateway/server/BUILD.bazel +++ b/beacon-chain/gateway/server/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary") load("@io_bazel_rules_docker//go:image.bzl", "go_image") load("@io_bazel_rules_docker//container:container.bzl", "container_bundle") load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push") diff --git a/beacon-chain/interop-cold-start/BUILD.bazel b/beacon-chain/interop-cold-start/BUILD.bazel index e9f78c350..c87956f9e 100644 --- a/beacon-chain/interop-cold-start/BUILD.bazel +++ b/beacon-chain/interop-cold-start/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/beacon-chain/node/BUILD.bazel b/beacon-chain/node/BUILD.bazel index ee8ce766c..cc46273f3 100644 --- a/beacon-chain/node/BUILD.bazel +++ b/beacon-chain/node/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/operations/attestations/BUILD.bazel b/beacon-chain/operations/attestations/BUILD.bazel index 4abc1eb8d..e8779c510 100644 --- a/beacon-chain/operations/attestations/BUILD.bazel +++ b/beacon-chain/operations/attestations/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/operations/attestations/kv/BUILD.bazel b/beacon-chain/operations/attestations/kv/BUILD.bazel index be98776d7..6e82e3252 100644 --- a/beacon-chain/operations/attestations/kv/BUILD.bazel +++ b/beacon-chain/operations/attestations/kv/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/operations/slashings/BUILD.bazel b/beacon-chain/operations/slashings/BUILD.bazel index ebb185cd9..9b03d685f 100644 --- a/beacon-chain/operations/slashings/BUILD.bazel +++ b/beacon-chain/operations/slashings/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/operations/voluntaryexits/BUILD.bazel b/beacon-chain/operations/voluntaryexits/BUILD.bazel index 1c91e7f19..5addcadc1 100644 --- a/beacon-chain/operations/voluntaryexits/BUILD.bazel +++ b/beacon-chain/operations/voluntaryexits/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/p2p/BUILD.bazel b/beacon-chain/p2p/BUILD.bazel index 38889315f..d6ffc5cab 100644 --- a/beacon-chain/p2p/BUILD.bazel +++ b/beacon-chain/p2p/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", @@ -28,6 +29,7 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/beacon-chain/p2p", visibility = [ "//beacon-chain:__subpackages__", + "//fuzz:__pkg__", "//tools:__subpackages__", ], deps = [ diff --git a/beacon-chain/p2p/connmgr/BUILD.bazel b/beacon-chain/p2p/connmgr/BUILD.bazel index c3a3a3a45..28933adbb 100644 --- a/beacon-chain/p2p/connmgr/BUILD.bazel +++ b/beacon-chain/p2p/connmgr/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/p2p/encoder/BUILD.bazel b/beacon-chain/p2p/encoder/BUILD.bazel index cd6f5a5ff..18aecdf19 100644 --- a/beacon-chain/p2p/encoder/BUILD.bazel +++ b/beacon-chain/p2p/encoder/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/p2p/peers/BUILD.bazel b/beacon-chain/p2p/peers/BUILD.bazel index e48ca45f9..05783d135 100644 --- a/beacon-chain/p2p/peers/BUILD.bazel +++ b/beacon-chain/p2p/peers/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/p2p/service.go b/beacon-chain/p2p/service.go index b2d3f8941..ed82ade4b 100644 --- a/beacon-chain/p2p/service.go +++ b/beacon-chain/p2p/service.go @@ -364,6 +364,11 @@ func (s *Service) Disconnect(pid peer.ID) error { return s.host.Network().ClosePeer(pid) } +// Connect to a specific peer. +func (s *Service) Connect(pi peer.AddrInfo) error { + return s.host.Connect(s.ctx, pi) +} + // Peers returns the peer status interface. func (s *Service) Peers() *peers.Status { return s.peers diff --git a/beacon-chain/p2p/testing/BUILD.bazel b/beacon-chain/p2p/testing/BUILD.bazel index 41dc9a944..2e768f4cf 100644 --- a/beacon-chain/p2p/testing/BUILD.bazel +++ b/beacon-chain/p2p/testing/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/beacon-chain/powchain/BUILD.bazel b/beacon-chain/powchain/BUILD.bazel index 387ea6b5c..983302e32 100644 --- a/beacon-chain/powchain/BUILD.bazel +++ b/beacon-chain/powchain/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/powchain/testing/BUILD.bazel b/beacon-chain/powchain/testing/BUILD.bazel index 787f7ba84..97331781d 100644 --- a/beacon-chain/powchain/testing/BUILD.bazel +++ b/beacon-chain/powchain/testing/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/beacon-chain/rpc/BUILD.bazel b/beacon-chain/rpc/BUILD.bazel index 36f472013..738d5d3be 100644 --- a/beacon-chain/rpc/BUILD.bazel +++ b/beacon-chain/rpc/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/rpc/beacon/BUILD.bazel b/beacon-chain/rpc/beacon/BUILD.bazel index 089c441ca..833564547 100644 --- a/beacon-chain/rpc/beacon/BUILD.bazel +++ b/beacon-chain/rpc/beacon/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/rpc/node/BUILD.bazel b/beacon-chain/rpc/node/BUILD.bazel index e9f9fb67f..9b8ca5d33 100644 --- a/beacon-chain/rpc/node/BUILD.bazel +++ b/beacon-chain/rpc/node/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/rpc/testing/BUILD.bazel b/beacon-chain/rpc/testing/BUILD.bazel index c2744700a..b9600f853 100644 --- a/beacon-chain/rpc/testing/BUILD.bazel +++ b/beacon-chain/rpc/testing/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/beacon-chain/rpc/validator/BUILD.bazel b/beacon-chain/rpc/validator/BUILD.bazel index abf6268c3..d779cad94 100644 --- a/beacon-chain/rpc/validator/BUILD.bazel +++ b/beacon-chain/rpc/validator/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/state/BUILD.bazel b/beacon-chain/state/BUILD.bazel index 5fa378a05..778a72ab7 100644 --- a/beacon-chain/state/BUILD.bazel +++ b/beacon-chain/state/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", @@ -13,6 +14,7 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/beacon-chain/state", visibility = [ "//beacon-chain:__subpackages__", + "//fuzz:__pkg__", "//shared/benchutil:__pkg__", "//shared/testutil:__pkg__", "//tools/benchmark-files-gen:__pkg__", diff --git a/beacon-chain/state/stategen/BUILD.bazel b/beacon-chain/state/stategen/BUILD.bazel index cfa612ce0..1b815737b 100644 --- a/beacon-chain/state/stategen/BUILD.bazel +++ b/beacon-chain/state/stategen/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/state/stateutil/BUILD.bazel b/beacon-chain/state/stateutil/BUILD.bazel index b24118150..07aa9bda2 100644 --- a/beacon-chain/state/stateutil/BUILD.bazel +++ b/beacon-chain/state/stateutil/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", @@ -16,6 +17,7 @@ go_library( importpath = "github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil", visibility = [ "//beacon-chain:__subpackages__", + "//fuzz:__pkg__", "//proto/testing:__subpackages__", "//shared/testutil:__subpackages__", "//slasher:__subpackages__", diff --git a/beacon-chain/sync/BUILD.bazel b/beacon-chain/sync/BUILD.bazel index 8aa029754..b58773c5f 100644 --- a/beacon-chain/sync/BUILD.bazel +++ b/beacon-chain/sync/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", @@ -33,7 +34,10 @@ go_library( "validate_voluntary_exit.go", ], importpath = "github.com/prysmaticlabs/prysm/beacon-chain/sync", - visibility = ["//beacon-chain:__subpackages__"], + visibility = [ + "//beacon-chain:__subpackages__", + "//fuzz:__pkg__", + ], deps = [ "//beacon-chain/blockchain:go_default_library", "//beacon-chain/cache:go_default_library", diff --git a/beacon-chain/sync/initial-sync-old/BUILD.bazel b/beacon-chain/sync/initial-sync-old/BUILD.bazel index 2fe4c9c51..e8661b34e 100644 --- a/beacon-chain/sync/initial-sync-old/BUILD.bazel +++ b/beacon-chain/sync/initial-sync-old/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/sync/initial-sync/BUILD.bazel b/beacon-chain/sync/initial-sync/BUILD.bazel index 7dc5d15ea..64a416060 100644 --- a/beacon-chain/sync/initial-sync/BUILD.bazel +++ b/beacon-chain/sync/initial-sync/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/beacon-chain/sync/initial-sync/testing/BUILD.bazel b/beacon-chain/sync/initial-sync/testing/BUILD.bazel index b3243170d..735e73c5c 100644 --- a/beacon-chain/sync/initial-sync/testing/BUILD.bazel +++ b/beacon-chain/sync/initial-sync/testing/BUILD.bazel @@ -1,9 +1,12 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", testonly = True, srcs = ["mock.go"], importpath = "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing", - visibility = ["//beacon-chain:__subpackages__"], + visibility = [ + "//beacon-chain:__subpackages__", + "//fuzz:__pkg__", + ], ) diff --git a/contracts/deposit-contract/BUILD.bazel b/contracts/deposit-contract/BUILD.bazel index c1b45fecd..5a0ab7e0d 100644 --- a/contracts/deposit-contract/BUILD.bazel +++ b/contracts/deposit-contract/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/endtoend/components/BUILD.bazel b/endtoend/components/BUILD.bazel index 213b08318..7ac902bba 100644 --- a/endtoend/components/BUILD.bazel +++ b/endtoend/components/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/endtoend/evaluators/BUILD.bazel b/endtoend/evaluators/BUILD.bazel index c5fa5ccaf..486056b54 100644 --- a/endtoend/evaluators/BUILD.bazel +++ b/endtoend/evaluators/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/endtoend/helpers/BUILD.bazel b/endtoend/helpers/BUILD.bazel index 16ad4851d..885290a18 100644 --- a/endtoend/helpers/BUILD.bazel +++ b/endtoend/helpers/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/endtoend/params/BUILD.bazel b/endtoend/params/BUILD.bazel index 0039113de..65ac5ef74 100644 --- a/endtoend/params/BUILD.bazel +++ b/endtoend/params/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/endtoend/types/BUILD.bazel b/endtoend/types/BUILD.bazel index 96a30839f..cdc7577df 100644 --- a/endtoend/types/BUILD.bazel +++ b/endtoend/types/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/fuzz/BUILD.bazel b/fuzz/BUILD.bazel new file mode 100644 index 000000000..f8c0a2898 --- /dev/null +++ b/fuzz/BUILD.bazel @@ -0,0 +1,272 @@ +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") + +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 +) diff --git a/fuzz/README.md b/fuzz/README.md new file mode 100644 index 000000000..de321aae5 --- /dev/null +++ b/fuzz/README.md @@ -0,0 +1,102 @@ +# Prysm Fuzz Testing + +[![fuzzit](https://app.fuzzit.dev/badge?org_id=prysmaticlabs-gh)](https://app.fuzzit.dev/orgs/prysmaticlabs-gh/dashboard) + +## Adding a fuzz test + +Fuzz testing attempts to find crash level bugs within the tested code paths, but could also be used +as a sanity check certain logic. + +### 1) Determining an ideal target + +A fuzz test inputs pseudo-random data to a given method and attempts to find input data that tests +as many code branches as possible. When choosing a target to test, consider that the method under +test should be as stateless as possible. While stateful methods (i.e. methods that use a cache), +can be tested, they are often hard to reproduce in a regression test. Consider disabling any caches +or persistence layers if possible. + +### 2) Writing a fuzz test + +First, you need to determine in your input data. The current test suite uses SSZ encoded bytes to +deserialize to input objects. + +_Example: Block header input data_ + +```go +type InputBlockHeader struct { + StateID uint16 + Block *ethpb.BeaconBlock +} +``` + +You'll also want to add that struct to `//fuzz:ssz_generated_files` to generate the custom fast SSZ +methods for serialization to improve test performance. + +Your fuzz test must accept a single argument of type `[]byte`. The return types are ignored by +libfuzzer, but might be useful for other applications such as +[beacon-fuzz](https://github.com/sigp/beacon-fuzz). Be sure to name your test file with the +`_fuzz.go` suffix for consistency. + +```go +func MyExampleFuzz(b []byte) { + input := &MyFuzzInputData{} + if err := ssz.Unmarshal(b, input); err != nil { + return // Input bytes doesn't serialize to input object. + } + + result, err := somePackage.MethodUnderTest(input) + if err != nil { + // Input was invalid for processing, but the method didn't panic so that's OK. + return + } + // Optional: sanity check the resulting data. + if result < 0 { + panic("MethodUnderTest should never return a negative number") // Fail! + } +} +``` + +### 3) Add your fuzz target to fuzz/BUILD.bazel + +Since we are using some custom rules to generate the fuzz test instrumentation and appropriate +libfuzz testing suite, we cannot rely on gazelle to generate these targets for us. + +```starlark +go_fuzz_test( + name = "example_fuzz_test", + srcs = [ + "example_fuzz.go", + ] + COMMON_SRCS, # common and input type files. + corpus = "example_corpus", + corpus_path = "fuzz/example_corpus", # Path from root of project + func = "MyExampleFuzz", + importpath = IMPORT_PATH, + deps = [ + # Deps used in your fuzz test. + ] + COMMON_DEPS, +) +``` + +Be sure to add your target to the test suite at `//fuzz:fuzz_tests`. + +### 4) Run your fuzz test + +To run your fuzz test you must manually target it with bazel test and run with the config flag +`--config=fuzz`. + +``` +bazel test //fuzz:example_fuzz_test --config=fuzz +``` + +## Running fuzzit regression tests + +To run fuzzit regression tests, you can run the fuzz test suite with the 1--config=fuzzit` +configuration flag. Note: This requires docker installed on your machine. See +[fuzzitdev/fuzzit#58](https://github.com/fuzzitdev/fuzzit/issues/58). + +``` +bazel test //fuzz:fuzz_tests --config=fuzzit +``` + +If the same command above is run with the FUZZIT_API_KEY environment variable set, then the fuzzit +test targets will be uploaded and restarted at https://app.fuzzit.dev. diff --git a/fuzz/attestation_fuzz.go b/fuzz/attestation_fuzz.go new file mode 100644 index 000000000..d70bb3f4f --- /dev/null +++ b/fuzz/attestation_fuzz.go @@ -0,0 +1,34 @@ +package fuzz + +import ( + "context" + + "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" +) + +// BeaconFuzzAttestation implements libfuzzer and beacon fuzz interface. +func BeaconFuzzAttestation(b []byte) ([]byte, bool) { + params.UseMainnetConfig() + input := &InputAttestationWrapper{} + 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.ProcessAttestationNoVerify(context.Background(), st, input.Attestation) + if err != nil { + return fail(err) + } + + return success(post) +} diff --git a/fuzz/attester_slashing_fuzz.go b/fuzz/attester_slashing_fuzz.go new file mode 100644 index 000000000..fc7f1ec79 --- /dev/null +++ b/fuzz/attester_slashing_fuzz.go @@ -0,0 +1,33 @@ +package fuzz + +import ( + "context" + + 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" +) + +// BeaconFuzzAttesterSlashing implements libfuzzer and beacon fuzz interface. +func BeaconFuzzAttesterSlashing(b []byte) ([]byte, bool) { + params.UseMainnetConfig() + input := &InputAttesterSlashingWrapper{} + 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.ProcessAttesterSlashings(context.Background(), st, ðpb.BeaconBlockBody{AttesterSlashings: []*ethpb.AttesterSlashing{input.AttesterSlashing}}) + if err != nil { + return fail(err) + } + return success(post) +} diff --git a/fuzz/block_fuzz.go b/fuzz/block_fuzz.go new file mode 100644 index 000000000..89f1cace4 --- /dev/null +++ b/fuzz/block_fuzz.go @@ -0,0 +1,36 @@ + +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) +} + diff --git a/fuzz/block_header_fuzz.go b/fuzz/block_header_fuzz.go new file mode 100644 index 000000000..fd418ee33 --- /dev/null +++ b/fuzz/block_header_fuzz.go @@ -0,0 +1,31 @@ +package fuzz + +import ( + "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" + "github.com/prysmaticlabs/go-ssz" +) + +// 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) +} diff --git a/fuzz/common.go b/fuzz/common.go new file mode 100644 index 000000000..a678428d0 --- /dev/null +++ b/fuzz/common.go @@ -0,0 +1,41 @@ +package fuzz + +import ( + "os" + "strings" + + "github.com/prysmaticlabs/go-ssz" + stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state" + "github.com/prysmaticlabs/prysm/shared/featureconfig" +) + +func init() { + featureconfig.Init(&featureconfig.Flags{ + SkipBLSVerify: true, + }) +} + +func fail(err error) ([]byte, bool) { + shouldPanic := false + if val, ok := os.LookupEnv("PANIC_ON_ERROR"); ok { + shouldPanic = strings.ToLower(val) == "true" + } + if shouldPanic { + panic(err) + } + return nil, false +} + +func success(post *stateTrie.BeaconState) ([]byte, bool) { + if val, ok := os.LookupEnv("RETURN_SSZ_POST_STATE"); ok { + if strings.ToLower(val) != "true" { + return nil, true + } + } + + result, err := ssz.Marshal(post.InnerStateUnsafe()) + if err != nil { + panic(err) + } + return result, true +} \ No newline at end of file diff --git a/fuzz/deposit_corpus/.gitkeep b/fuzz/deposit_corpus/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/fuzz/deposit_fuzz.go b/fuzz/deposit_fuzz.go new file mode 100644 index 000000000..0a1e55f82 --- /dev/null +++ b/fuzz/deposit_fuzz.go @@ -0,0 +1,31 @@ +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" +) + +// BeaconFuzzDeposit implements libfuzzer and beacon fuzz interface. +func BeaconFuzzDeposit(b []byte) ([]byte, bool) { + params.UseMainnetConfig() + input := &InputDepositWrapper{} + 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.ProcessDeposit(st, input.Deposit) + if err != nil { + return fail(err) + } + return success(post) +} diff --git a/fuzz/inputs.go b/fuzz/inputs.go new file mode 100644 index 000000000..835a9c0e9 --- /dev/null +++ b/fuzz/inputs.go @@ -0,0 +1,41 @@ +package fuzz + +import ( + ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1" +) + +// InputBlockHeader for fuzz testing beacon block headers. +type InputBlockHeader struct { + StateID uint16 + Block *ethpb.BeaconBlock +} + +// InputAttesterSlashingWrapper for fuzz testing attester slashing. +type InputAttesterSlashingWrapper struct { + StateID uint16 + AttesterSlashing *ethpb.AttesterSlashing +} + +// InputAttestationWrapper for fuzz testing attestations. +type InputAttestationWrapper struct { + StateID uint16 + Attestation *ethpb.Attestation +} + +// InputDepositWrapper for fuzz testing deposits. +type InputDepositWrapper struct { + StateID uint16 + Deposit *ethpb.Deposit +} + +// InputVoluntaryExitWrapper for fuzz testing voluntary exits. +type InputVoluntaryExitWrapper struct { + StateID uint16 + VoluntaryExit *ethpb.VoluntaryExit +} + +// InputProposerSlashingWrapper for fuzz testing proposer slashings. +type InputProposerSlashingWrapper struct { + StateID uint16 + ProposerSlashing *ethpb.ProposerSlashing +} diff --git a/fuzz/proposer_slashing_fuzz.go b/fuzz/proposer_slashing_fuzz.go new file mode 100644 index 000000000..df9fa3708 --- /dev/null +++ b/fuzz/proposer_slashing_fuzz.go @@ -0,0 +1,35 @@ +// +build libfuzzer + +package fuzz + +import ( + "context" + + 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" +) + +// BeaconFuzzDeposit implements libfuzzer and beacon fuzz interface. +func BeaconFuzzProposerSlashing(b []byte) ([]byte, bool) { + params.UseMainnetConfig() + input := &InputProposerSlashingWrapper{} + 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.ProcessProposerSlashings(context.Background(), st, ðpb.BeaconBlockBody{ProposerSlashings: []*ethpb.ProposerSlashing{input.ProposerSlashing}}) + if err != nil { + return fail(err) + } + return success(post) +} diff --git a/fuzz/rpc_status_corpus/.gitkeep b/fuzz/rpc_status_corpus/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/fuzz/rpc_status_fuzz.go b/fuzz/rpc_status_fuzz.go new file mode 100644 index 000000000..e717cf92a --- /dev/null +++ b/fuzz/rpc_status_fuzz.go @@ -0,0 +1,88 @@ +package fuzz + +import ( + "context" + "strings" + + "github.com/libp2p/go-libp2p" + "github.com/libp2p/go-libp2p-core/host" + "github.com/libp2p/go-libp2p-core/network" + "github.com/libp2p/go-libp2p-core/peer" + "github.com/pkg/errors" + ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1" + mock "github.com/prysmaticlabs/prysm/beacon-chain/blockchain/testing" + "github.com/prysmaticlabs/prysm/beacon-chain/cache" + "github.com/prysmaticlabs/prysm/beacon-chain/p2p" + "github.com/prysmaticlabs/prysm/beacon-chain/sync" + mockSync "github.com/prysmaticlabs/prysm/beacon-chain/sync/initial-sync/testing" + pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + "github.com/sirupsen/logrus" +) + +var p *p2p.Service +var s network.Stream +var h host.Host + +func init() { + logrus.SetLevel(logrus.PanicLevel) + + var err error + p, err = p2p.NewService(&p2p.Config{ + NoDiscovery: true, + Encoding: "ssz", + }) + if err != nil { + panic(errors.Wrap(err, "could not create new p2p service")) + } + + h, err = libp2p.New(context.Background()) + if err != nil { + panic(errors.Wrap(err, "could not create new libp2p host")) + } + + info := peer.AddrInfo{ + ID: h.ID(), + Addrs: h.Addrs(), + } + if err := p.Connect(info); err != nil { + panic(errors.Wrap(err, "could not connect to peer")) + } + sync.NewRegularSync(&sync.Config{ + P2P: p, + DB: nil, + AttPool: nil, + ExitPool: nil, + SlashingPool: nil, + Chain: &mock.ChainService{ + Root: []byte("root"), + FinalizedCheckPoint: ðpb.Checkpoint{Epoch: 4}, + Fork: &pb.Fork{CurrentVersion: []byte("foo")}, + }, + StateNotifier: (&mock.ChainService{}).StateNotifier(), + AttestationNotifier: (&mock.ChainService{}).OperationNotifier(), + InitialSync: &mockSync.Sync{IsSyncing: false}, + StateSummaryCache: cache.NewStateSummaryCache(), + BlockNotifier: nil, + }) +} + +// BeaconFuzzP2PRPCStatus implements libfuzzer and beacon fuzz interface. +func BeaconFuzzP2PRPCStatus(b []byte) { + s, err := h.NewStream(context.Background(), p.PeerID(), "/eth2/beacon_chain/req/status/1/ssz") + if err != nil { + // libp2p ¯\_(ツ)_/¯ + if strings.Contains(err.Error(), "stream reset") || strings.Contains(err.Error(), "connection reset by peer") || strings.Contains(err.Error(), "max dial attempts exceeded") { + return + } + panic(errors.Wrap(err, "failed to open stream")) + } + if s == nil { + panic("nil stream") + } + defer func() { + err := s.Close() + _ = err + }() + _, err = s.Write(b) + _ = err +} diff --git a/fuzz/ssz_cache_fuzz.go b/fuzz/ssz_cache_fuzz.go new file mode 100644 index 000000000..23a6087f5 --- /dev/null +++ b/fuzz/ssz_cache_fuzz.go @@ -0,0 +1,36 @@ +package fuzz + +import ( + "github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil" + pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + "github.com/prysmaticlabs/prysm/shared/featureconfig" +) + +// BeaconFuzzSSZCache for testing critical paths along the ssz cache for beacon state HTR. +func BeaconFuzzSSZCache(input []byte) { + s := &pb.BeaconState{} + if err := s.UnmarshalSSZ(input); err != nil { + return + } + + fc := featureconfig.Get() + fc.EnableSSZCache = true + featureconfig.Init(fc) + + a, err := stateutil.HashTreeRootState(s) + if err != nil { + return + } + + fc.EnableSSZCache = false + featureconfig.Init(fc) + + b, err := stateutil.HashTreeRootState(s) + if err != nil { + return + } + + if a != b { + panic("Cached and non cached hash tree root hashers produced different results") + } +} diff --git a/fuzz/testing/BUILD.bazel b/fuzz/testing/BUILD.bazel new file mode 100644 index 000000000..555426bee --- /dev/null +++ b/fuzz/testing/BUILD.bazel @@ -0,0 +1,25 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + testonly = 1, + srcs = ["beacon_fuzz_states.go"], + data = [ + "@sigp_beacon_fuzz_corpora//:current_mainnet_beaconstate", + ], + importpath = "github.com/prysmaticlabs/prysm/fuzz/testing", + visibility = [ + "//fuzz:__pkg__", + ], + deps = [ + "//proto/beacon/p2p/v1:go_default_library", + "//shared/testutil:go_default_library", + ], +) + +go_test( + name = "go_default_test", + srcs = ["beacon_fuzz_states_test.go"], + embed = [":go_default_library"], +) diff --git a/fuzz/testing/beacon_fuzz_states.go b/fuzz/testing/beacon_fuzz_states.go new file mode 100644 index 000000000..201aa84a8 --- /dev/null +++ b/fuzz/testing/beacon_fuzz_states.go @@ -0,0 +1,38 @@ +package testing + +import ( + "fmt" + pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1" + "github.com/prysmaticlabs/prysm/shared/testutil" + "os" + "strconv" +) + +const fileBase = "0-11-0/mainnet/beaconstate" +const fileBaseENV = "BEACONSTATES_PATH" + +// GetBeaconFuzzState returns a beacon state by ID using the beacon-fuzz corpora. +func GetBeaconFuzzState(ID uint16) (*pb.BeaconState, error) { + base := fileBase + // Using an environment variable allows a host image to specify the path when only the binary + // executable was uploaded (without the runfiles). i.e. fuzzit's platform. + if p, ok := os.LookupEnv(fileBaseENV); ok { + base = p + } + ok, err := testutil.BazelDirectoryNonEmpty(base) + if err != nil { + panic(err) + } + if !ok { + panic(fmt.Sprintf("Beacon states directory (%s) does not exist or has no files.", base)) + } + b, err := testutil.BazelFileBytes(base, strconv.Itoa(int(ID))) + if err != nil { + return nil, err + } + st := &pb.BeaconState{} + if err := st.UnmarshalSSZ(b); err != nil { + return nil, err + } + return st, nil +} diff --git a/fuzz/testing/beacon_fuzz_states_test.go b/fuzz/testing/beacon_fuzz_states_test.go new file mode 100644 index 000000000..827276009 --- /dev/null +++ b/fuzz/testing/beacon_fuzz_states_test.go @@ -0,0 +1,11 @@ +package testing + +import ( + "testing" +) + +func TestGetBeaconFuzzState(t *testing.T) { + if _, err := GetBeaconFuzzState(1); err != nil { + t.Fatal(err) + } +} diff --git a/fuzz/voluntary_exit_corpus/.gitkeep b/fuzz/voluntary_exit_corpus/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/fuzz/voluntary_exit_fuzz.go b/fuzz/voluntary_exit_fuzz.go new file mode 100644 index 000000000..d1f35f7e7 --- /dev/null +++ b/fuzz/voluntary_exit_fuzz.go @@ -0,0 +1,31 @@ +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) +} diff --git a/proto/cluster/BUILD.bazel b/proto/cluster/BUILD.bazel index 3ff92a391..19ee03585 100644 --- a/proto/cluster/BUILD.bazel +++ b/proto/cluster/BUILD.bazel @@ -1,5 +1,5 @@ +load("@prysm//tools/go:def.bzl", "go_library") load("@rules_proto//proto:defs.bzl", "proto_library") -load("@io_bazel_rules_go//go:def.bzl", "go_library") load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") proto_library( diff --git a/proto/testing/BUILD.bazel b/proto/testing/BUILD.bazel index 7637efa80..a909e7567 100644 --- a/proto/testing/BUILD.bazel +++ b/proto/testing/BUILD.bazel @@ -51,6 +51,7 @@ go_test( "//shared/bytesutil:go_default_library", "//shared/params/spectest:go_default_library", "//shared/testutil:go_default_library", + "@com_github_ferranbt_fastssz//:go_default_library", "@com_github_ghodss_yaml//:go_default_library", "@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library", "@com_github_prysmaticlabs_go_ssz//:go_default_library", @@ -81,6 +82,7 @@ go_test( "//shared/bytesutil:go_default_library", "//shared/params/spectest:go_default_library", "//shared/testutil:go_default_library", + "@com_github_ferranbt_fastssz//:go_default_library", "@com_github_ghodss_yaml//:go_default_library", "@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library", "@com_github_prysmaticlabs_go_ssz//:go_default_library", @@ -106,6 +108,7 @@ go_test( "//shared/bytesutil:go_default_library", "//shared/params/spectest:go_default_library", "//shared/testutil:go_default_library", + "@com_github_ferranbt_fastssz//:go_default_library", "@com_github_ghodss_yaml//:go_default_library", "@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library", "@com_github_prysmaticlabs_go_ssz//:go_default_library", diff --git a/proto/testing/ssz_static_test.go b/proto/testing/ssz_static_test.go index 7f51077dc..1a4af9da5 100644 --- a/proto/testing/ssz_static_test.go +++ b/proto/testing/ssz_static_test.go @@ -7,6 +7,7 @@ import ( "path" "testing" + fssz "github.com/ferranbt/fastssz" ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1" "github.com/prysmaticlabs/go-ssz" "github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil" @@ -162,6 +163,11 @@ func UnmarshalledSSZ(t *testing.T, serializedBytes []byte, folderName string) (i default: return nil, errors.New("type not found") } - err := ssz.Unmarshal(serializedBytes, obj) + var err error + if o, ok := obj.(fssz.Unmarshaler); ok { + err = o.UnmarshalSSZ(serializedBytes) + } else { + err = ssz.Unmarshal(serializedBytes, obj) + } return obj, err } diff --git a/shared/BUILD.bazel b/shared/BUILD.bazel index b19f47224..743a415d3 100644 --- a/shared/BUILD.bazel +++ b/shared/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/attestationutil/BUILD.bazel b/shared/attestationutil/BUILD.bazel index fc3c4ff4a..e4d1e1259 100644 --- a/shared/attestationutil/BUILD.bazel +++ b/shared/attestationutil/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/benchutil/BUILD.bazel b/shared/benchutil/BUILD.bazel index fbc720ef6..06b3923fa 100644 --- a/shared/benchutil/BUILD.bazel +++ b/shared/benchutil/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/bls/BUILD.bazel b/shared/bls/BUILD.bazel index 86f3695ed..f4f8f6192 100644 --- a/shared/bls/BUILD.bazel +++ b/shared/bls/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") # gazelle:resolve go github.com/herumi/bls-eth-go-binary/bls @herumi_bls_eth_go_binary//:go_default_library diff --git a/shared/bls/spectest/BUILD.bazel b/shared/bls/spectest/BUILD.bazel index a92fe6477..3aedfc24f 100644 --- a/shared/bls/spectest/BUILD.bazel +++ b/shared/bls/spectest/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/bytesutil/BUILD.bazel b/shared/bytesutil/BUILD.bazel index f986067e3..49b03f220 100644 --- a/shared/bytesutil/BUILD.bazel +++ b/shared/bytesutil/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/cmd/BUILD.bazel b/shared/cmd/BUILD.bazel index d7823be16..ac59ef2de 100644 --- a/shared/cmd/BUILD.bazel +++ b/shared/cmd/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/event/BUILD.bazel b/shared/event/BUILD.bazel index a9e8708b1..ef64fa95a 100644 --- a/shared/event/BUILD.bazel +++ b/shared/event/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/featureconfig/BUILD.bazel b/shared/featureconfig/BUILD.bazel index 19157affe..090eeeb70 100644 --- a/shared/featureconfig/BUILD.bazel +++ b/shared/featureconfig/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/hashutil/BUILD.bazel b/shared/hashutil/BUILD.bazel index 3f87936df..b97e01396 100644 --- a/shared/hashutil/BUILD.bazel +++ b/shared/hashutil/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/interop/BUILD.bazel b/shared/interop/BUILD.bazel index 2947fbcec..905f61b69 100644 --- a/shared/interop/BUILD.bazel +++ b/shared/interop/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/iputils/BUILD.bazel b/shared/iputils/BUILD.bazel index a8a83423a..ae45d10c6 100644 --- a/shared/iputils/BUILD.bazel +++ b/shared/iputils/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/keystore/BUILD.bazel b/shared/keystore/BUILD.bazel index 42ec165cc..2b850ec18 100644 --- a/shared/keystore/BUILD.bazel +++ b/shared/keystore/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/logutil/BUILD.bazel b/shared/logutil/BUILD.bazel index d50c56066..a72fc11a3 100644 --- a/shared/logutil/BUILD.bazel +++ b/shared/logutil/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/shared/mathutil/BUILD.bazel b/shared/mathutil/BUILD.bazel index dacc90b46..d6921b1b4 100644 --- a/shared/mathutil/BUILD.bazel +++ b/shared/mathutil/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/mclockutil/BUILD.bazel b/shared/mclockutil/BUILD.bazel index 9a0f4add9..6e01102bc 100644 --- a/shared/mclockutil/BUILD.bazel +++ b/shared/mclockutil/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/shared/memorypool/BUILD.bazel b/shared/memorypool/BUILD.bazel index 777e326a7..3a8cba998 100644 --- a/shared/memorypool/BUILD.bazel +++ b/shared/memorypool/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/messagehandler/BUILD.bazel b/shared/messagehandler/BUILD.bazel index 789a174a8..8bd1fa2e4 100644 --- a/shared/messagehandler/BUILD.bazel +++ b/shared/messagehandler/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/mock/BUILD.bazel b/shared/mock/BUILD.bazel index 731bcb6f8..8e929be5e 100644 --- a/shared/mock/BUILD.bazel +++ b/shared/mock/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") package(default_testonly = True) diff --git a/shared/mputil/BUILD.bazel b/shared/mputil/BUILD.bazel index 8a55f91f7..fa7a8cc57 100644 --- a/shared/mputil/BUILD.bazel +++ b/shared/mputil/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/p2putils/BUILD.bazel b/shared/p2putils/BUILD.bazel index fdbd77141..c7548f730 100644 --- a/shared/p2putils/BUILD.bazel +++ b/shared/p2putils/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/shared/pagination/BUILD.bazel b/shared/pagination/BUILD.bazel index 8e5661f8c..ca17d09be 100644 --- a/shared/pagination/BUILD.bazel +++ b/shared/pagination/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/params/BUILD.bazel b/shared/params/BUILD.bazel index e796ac865..e5b8daa81 100644 --- a/shared/params/BUILD.bazel +++ b/shared/params/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/params/spectest/BUILD.bazel b/shared/params/spectest/BUILD.bazel index 70ea03f4e..55ffe411c 100644 --- a/shared/params/spectest/BUILD.bazel +++ b/shared/params/spectest/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/prometheus/BUILD.bazel b/shared/prometheus/BUILD.bazel index cf95d2ba8..b7fd6d527 100644 --- a/shared/prometheus/BUILD.bazel +++ b/shared/prometheus/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/roughtime/BUILD.bazel b/shared/roughtime/BUILD.bazel index a429b8bf9..0d8d0716a 100644 --- a/shared/roughtime/BUILD.bazel +++ b/shared/roughtime/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/shared/runutil/BUILD.bazel b/shared/runutil/BUILD.bazel index 18aefd513..738808e59 100644 --- a/shared/runutil/BUILD.bazel +++ b/shared/runutil/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/sliceutil/BUILD.bazel b/shared/sliceutil/BUILD.bazel index 87be09275..35a3836c3 100644 --- a/shared/sliceutil/BUILD.bazel +++ b/shared/sliceutil/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/slotutil/BUILD.bazel b/shared/slotutil/BUILD.bazel index 4a6a05fd7..50ca59601 100644 --- a/shared/slotutil/BUILD.bazel +++ b/shared/slotutil/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/slotutil/testing/BUILD.bazel b/shared/slotutil/testing/BUILD.bazel index c999b83fc..2aa6af582 100644 --- a/shared/slotutil/testing/BUILD.bazel +++ b/shared/slotutil/testing/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/testutil/BUILD.bazel b/shared/testutil/BUILD.bazel index cca45f10b..7933e35a4 100644 --- a/shared/testutil/BUILD.bazel +++ b/shared/testutil/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/testutil/spectest.go b/shared/testutil/spectest.go index 6bc5bb56a..8312e1580 100644 --- a/shared/testutil/spectest.go +++ b/shared/testutil/spectest.go @@ -56,6 +56,20 @@ func TestFolders(t *testing.T, config string, folderPath string) ([]os.FileInfo, return testFolders, testsFolderPath } + +// BazelDirectoryNonEmpty returns true if directory exists and is not empty. +func BazelDirectoryNonEmpty(filePath string) (bool, error) { + p, err := bazel.Runfile(filePath) + if err != nil { + return false, err + } + fs, err := ioutil.ReadDir(p) + if err != nil { + return false, err + } + return len(fs) > 0, nil +} + // BazelFileBytes returns the byte array of the bazel file path given. func BazelFileBytes(filePaths ...string) ([]byte, error) { filepath, err := bazel.Runfile(path.Join(filePaths...)) diff --git a/shared/traceutil/BUILD.bazel b/shared/traceutil/BUILD.bazel index 867aa6207..fcafb3e0b 100644 --- a/shared/traceutil/BUILD.bazel +++ b/shared/traceutil/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/shared/tracing/BUILD.bazel b/shared/tracing/BUILD.bazel index a85a2b40d..a2a65f992 100644 --- a/shared/tracing/BUILD.bazel +++ b/shared/tracing/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/shared/trieutil/BUILD.bazel b/shared/trieutil/BUILD.bazel index fc65a8d94..047e6531c 100644 --- a/shared/trieutil/BUILD.bazel +++ b/shared/trieutil/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/shared/version/BUILD.bazel b/shared/version/BUILD.bazel index 2b4acdc9e..c9ad5a32b 100644 --- a/shared/version/BUILD.bazel +++ b/shared/version/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/slasher/BUILD.bazel b/slasher/BUILD.bazel index c72727f82..7931fe500 100644 --- a/slasher/BUILD.bazel +++ b/slasher/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_test") load("@io_bazel_rules_docker//go:image.bzl", "go_image") load("@io_bazel_rules_docker//container:container.bzl", "container_bundle") load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push") diff --git a/slasher/beaconclient/BUILD.bazel b/slasher/beaconclient/BUILD.bazel index 6759712b4..67e1aa8c7 100644 --- a/slasher/beaconclient/BUILD.bazel +++ b/slasher/beaconclient/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/slasher/cache/BUILD.bazel b/slasher/cache/BUILD.bazel index 690579281..e58c77ada 100644 --- a/slasher/cache/BUILD.bazel +++ b/slasher/cache/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/slasher/db/BUILD.bazel b/slasher/db/BUILD.bazel index 88296c775..e1b09ca2f 100644 --- a/slasher/db/BUILD.bazel +++ b/slasher/db/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/slasher/db/iface/BUILD.bazel b/slasher/db/iface/BUILD.bazel index b62428be8..8f692cfea 100644 --- a/slasher/db/iface/BUILD.bazel +++ b/slasher/db/iface/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/slasher/db/kv/BUILD.bazel b/slasher/db/kv/BUILD.bazel index 85013031a..09c7ccd8d 100644 --- a/slasher/db/kv/BUILD.bazel +++ b/slasher/db/kv/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/slasher/db/testing/BUILD.bazel b/slasher/db/testing/BUILD.bazel index 76c6de3fa..82a913869 100644 --- a/slasher/db/testing/BUILD.bazel +++ b/slasher/db/testing/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/slasher/db/types/BUILD.bazel b/slasher/db/types/BUILD.bazel index abb8cba80..4571b1e42 100644 --- a/slasher/db/types/BUILD.bazel +++ b/slasher/db/types/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/slasher/detection/BUILD.bazel b/slasher/detection/BUILD.bazel index 1e1392985..e1941a259 100644 --- a/slasher/detection/BUILD.bazel +++ b/slasher/detection/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/slasher/detection/attestations/BUILD.bazel b/slasher/detection/attestations/BUILD.bazel index bb1f60bf4..7e3a60d3c 100644 --- a/slasher/detection/attestations/BUILD.bazel +++ b/slasher/detection/attestations/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/slasher/detection/attestations/iface/BUILD.bazel b/slasher/detection/attestations/iface/BUILD.bazel index 283662168..ff4cea7b6 100644 --- a/slasher/detection/attestations/iface/BUILD.bazel +++ b/slasher/detection/attestations/iface/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/slasher/detection/attestations/types/BUILD.bazel b/slasher/detection/attestations/types/BUILD.bazel index 7f3cbd3bb..b6dfd523d 100644 --- a/slasher/detection/attestations/types/BUILD.bazel +++ b/slasher/detection/attestations/types/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/slasher/detection/proposals/BUILD.bazel b/slasher/detection/proposals/BUILD.bazel index 1f4e5239f..7be8fb730 100644 --- a/slasher/detection/proposals/BUILD.bazel +++ b/slasher/detection/proposals/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/slasher/detection/proposals/iface/BUILD.bazel b/slasher/detection/proposals/iface/BUILD.bazel index 04f759f5e..6d6d706fa 100644 --- a/slasher/detection/proposals/iface/BUILD.bazel +++ b/slasher/detection/proposals/iface/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/slasher/detection/testing/BUILD.bazel b/slasher/detection/testing/BUILD.bazel index 73aacd54e..9fac2862a 100644 --- a/slasher/detection/testing/BUILD.bazel +++ b/slasher/detection/testing/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/slasher/flags/BUILD.bazel b/slasher/flags/BUILD.bazel index d775759a7..ac2ec8d67 100644 --- a/slasher/flags/BUILD.bazel +++ b/slasher/flags/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/slasher/node/BUILD.bazel b/slasher/node/BUILD.bazel index f6bbc486e..b565d6075 100644 --- a/slasher/node/BUILD.bazel +++ b/slasher/node/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/slasher/rpc/BUILD.bazel b/slasher/rpc/BUILD.bazel index 7c17a4ada..df86d2454 100644 --- a/slasher/rpc/BUILD.bazel +++ b/slasher/rpc/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/test/fuzz/BUILD.bazel b/test/fuzz/BUILD.bazel new file mode 100644 index 000000000..e69de29bb diff --git a/test/fuzz/main.cc b/test/fuzz/main.cc new file mode 100644 index 000000000..e69de29bb diff --git a/third_party/beacon-fuzz/corpora.BUILD b/third_party/beacon-fuzz/corpora.BUILD new file mode 100644 index 000000000..4d59c4b68 --- /dev/null +++ b/third_party/beacon-fuzz/corpora.BUILD @@ -0,0 +1,60 @@ +package(default_visibility = ["//visibility:public"]) + +filegroup( + name = "all", + srcs = glob(["**"]), +) + +# See: https://github.com/sigp/beacon-fuzz-corpora + +current_version = "0_11_0" + +alias( + name = "current_mainnet_attestation", + actual = ":" + current_version + "_mainnet_attestation", +) + +alias( + name = "current_mainnet_attester_slashing", + actual = ":" + current_version + "_mainnet_attester_slashing", +) + +alias( + name = "current_mainnet_block_header", + actual = ":" + current_version + "_mainnet_block_header", +) + +alias( + name = "current_mainnet_beaconstate", + actual = ":" + current_version + "_mainnet_beaconstate", +) + +alias( + name = "current_mainnet_proposer_slashing", + actual = ":" + current_version + "_mainnet_proposer_slashing", +) + +filegroup( + name = "0_11_0_mainnet_attestation", + srcs = glob(["0-11-0/mainnet/attestation/*"]), +) + +filegroup( + name = "0_11_0_mainnet_attester_slashing", + srcs = glob(["0-11-0/mainnet/attester_slashing/*"]), +) + +filegroup( + name = "0_11_0_mainnet_block_header", + srcs = glob(["0-11-0/mainnet/block_header/*"]), +) + +filegroup( + name = "0_11_0_mainnet_beaconstate", + srcs = glob(["0-11-0/mainnet/beaconstate/*"]), +) + +filegroup( + name = "0_11_0_mainnet_proposer_slashing", + srcs = glob(["0-11-0/mainnet/proposer_slashing/*"]), +) diff --git a/third_party/com_github_prysmaticlabs_ethereumapis-tags.patch b/third_party/com_github_prysmaticlabs_ethereumapis-tags.patch new file mode 100644 index 000000000..e69de29bb diff --git a/third_party/herumi/bls_eth_go_binary.BUILD b/third_party/herumi/bls_eth_go_binary.BUILD index 62ad0b2c8..d7762b459 100644 --- a/third_party/herumi/bls_eth_go_binary.BUILD +++ b/third_party/herumi/bls_eth_go_binary.BUILD @@ -83,6 +83,7 @@ cc_library( ], "//conditions:default": [], }), + visibility = ["//visibility:public"], ) cc_library( @@ -141,11 +142,15 @@ go_library( ":llvm_compiler_enabled": [":lib"], "//conditions:default": [":precompiled"], }), - copts = OPTS, cgo = True, + copts = OPTS, visibility = [ # Additional access will require security approval. "@prysm//shared/bls:__pkg__", "@com_github_wealdtech_go_eth2_types_v2//:__pkg__", ], + clinkopts = select({ + "@io_bazel_rules_go//go/platform:linux": ["-Wl,--unresolved-symbols=ignore-all"], + "//conditions:default": [], + }), ) diff --git a/tools/BUILD.bazel b/tools/BUILD.bazel index 533c8c6c1..9d06478ca 100644 --- a/tools/BUILD.bazel +++ b/tools/BUILD.bazel @@ -11,6 +11,17 @@ alias( visibility = ["//visibility:public"], ) +sh_binary( + name = "fuzzit_wrapper", + srcs = ["fuzzit_wrapper.sh"], + data = ["@fuzzit_linux//:fuzzit"], +) + +sh_binary( + name = "fuzz_wrapper", + srcs = ["fuzz_wrapper.sh"], +) + ################################################################################ ## Docker images as non-root user ## ################################################################################ diff --git a/tools/analyzers/errcheck/BUILD.bazel b/tools/analyzers/errcheck/BUILD.bazel index 0a35f5841..0d8402334 100644 --- a/tools/analyzers/errcheck/BUILD.bazel +++ b/tools/analyzers/errcheck/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test", "go_tool_library") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test", "go_tool_library") go_library( name = "go_default_library", diff --git a/tools/analyzers/featureconfig/BUILD.bazel b/tools/analyzers/featureconfig/BUILD.bazel index 7d265bc9a..73ca9c9e3 100644 --- a/tools/analyzers/featureconfig/BUILD.bazel +++ b/tools/analyzers/featureconfig/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_tool_library") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_tool_library") go_library( name = "go_default_library", diff --git a/tools/analyzers/maligned/BUILD.bazel b/tools/analyzers/maligned/BUILD.bazel index 576a893ab..2080fe7a7 100644 --- a/tools/analyzers/maligned/BUILD.bazel +++ b/tools/analyzers/maligned/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_tool_library") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_tool_library") go_tool_library( name = "go_tool_library", diff --git a/tools/analyzers/roughtime/BUILD.bazel b/tools/analyzers/roughtime/BUILD.bazel index 5c5f67402..bde313f67 100644 --- a/tools/analyzers/roughtime/BUILD.bazel +++ b/tools/analyzers/roughtime/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_tool_library") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_tool_library") go_library( name = "go_default_library", diff --git a/tools/beacon-fuzz/BUILD.bazel b/tools/beacon-fuzz/BUILD.bazel new file mode 100644 index 000000000..5e111f318 --- /dev/null +++ b/tools/beacon-fuzz/BUILD.bazel @@ -0,0 +1,16 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") + +# gazelle:ignore Prevent this tool from using @prysm//tools/go:def.bzl go_library. + +go_library( + name = "go_default_library", + srcs = ["main.go"], + importpath = "github.com/prysmaticlabs/prysm/tools/beacon-fuzz", + visibility = ["//visibility:private"], +) + +go_binary( + name = "beacon-fuzz", + embed = [":go_default_library"], + visibility = ["//visibility:public"], +) diff --git a/tools/beacon-fuzz/main.go b/tools/beacon-fuzz/main.go new file mode 100644 index 000000000..c3e9b823f --- /dev/null +++ b/tools/beacon-fuzz/main.go @@ -0,0 +1,86 @@ +package main + +import ( + "bytes" + "flag" + "fmt" + "io/ioutil" + "os" + "path/filepath" + "strconv" + "text/template" +) + +var ( + output = flag.String("output", "", "Output filepath for generated states file.") +) + +const tpl = `// Code generated by //tools/beacon-fuzz:beacon-fuzz. DO NOT EDIT. +package {{.Package}} + +// generateStates is a map of generated states from ssz. +var generatedStates = map[uint16]string{ + {{.MapStr}} +} +` + +// This program generates a map of ID(uint16) -> hex encoded strings of SSZ binary data. This tool +// exists to facilitate running beacon-fuzz targets within the constraints of fuzzit. I.e. fuzz +// only loads the corpus to the file system without the beacon states. An alternative approach would +// be to create a docker image where the state files are available or changing the corpus seed data +// to contain the beacon state itself. +func main() { + flag.Parse() + if *output == "" { + panic("Missing output. Usage: beacon-fuzz --output=out.go path/to/state/0 path/to/state/1 ...") + } + statePaths := os.Args[2:] + + if len(statePaths) > 15 { + statePaths = statePaths[:15] + } + + m := make(map[int][]byte, len(statePaths)) + for _, p := range statePaths { + ID, err := strconv.Atoi(filepath.Base(p)) + if err != nil { + panic(fmt.Sprintf("%s does not end in an integer for the filename.", p)) + } + b, err := ioutil.ReadFile(p) + if err != nil { + panic(err) + } + m[ID] = b + } + + res := execTmpl(tpl, input{Package: "testing", MapStr: sszBytesToMapStr(m)}) + if err := ioutil.WriteFile(*output, res.Bytes(), 0644); err != nil { + panic(err) + } +} + +func sszBytesToMapStr(ss map[int][]byte) string { + dst := "" + for i, s := range ss { + dst += fmt.Sprintf("%d: \"%x\",", i, s) + } + return dst +} + +type input struct { + Package string + States map[int][]byte + MapStr string +} + +func execTmpl(tpl string, input interface{}) *bytes.Buffer { + tmpl, err := template.New("template").Parse(tpl) + if err != nil { + panic(err) + } + buf := new(bytes.Buffer) + if err = tmpl.Execute(buf, input); err != nil { + panic(err) + } + return buf +} diff --git a/tools/benchmark-files-gen/BUILD.bazel b/tools/benchmark-files-gen/BUILD.bazel index 8d525b607..fead45298 100644 --- a/tools/benchmark-files-gen/BUILD.bazel +++ b/tools/benchmark-files-gen/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary") go_library( name = "go_default_library", diff --git a/tools/blocktree/BUILD.bazel b/tools/blocktree/BUILD.bazel index a774a743a..67675a21b 100644 --- a/tools/blocktree/BUILD.bazel +++ b/tools/blocktree/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary") go_library( name = "go_default_library", diff --git a/tools/bootnode-query/BUILD.bazel b/tools/bootnode-query/BUILD.bazel index 99de092ee..b879303c2 100644 --- a/tools/bootnode-query/BUILD.bazel +++ b/tools/bootnode-query/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary") go_library( name = "go_default_library", diff --git a/tools/bootnode/BUILD.bazel b/tools/bootnode/BUILD.bazel index ed5f2a39f..1bade08c9 100644 --- a/tools/bootnode/BUILD.bazel +++ b/tools/bootnode/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_test") load("@io_bazel_rules_docker//go:image.bzl", "go_image") load("@io_bazel_rules_docker//container:container.bzl", "container_bundle") load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push") diff --git a/tools/cluster-pk-manager/client/BUILD.bazel b/tools/cluster-pk-manager/client/BUILD.bazel index d710bdcbc..a2e2f02c9 100644 --- a/tools/cluster-pk-manager/client/BUILD.bazel +++ b/tools/cluster-pk-manager/client/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary") load("@io_bazel_rules_docker//go:image.bzl", "go_image") load("@io_bazel_rules_docker//container:container.bzl", "container_bundle") load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push") diff --git a/tools/cluster-pk-manager/server/BUILD.bazel b/tools/cluster-pk-manager/server/BUILD.bazel index ea4c8841e..f29fb9c2c 100644 --- a/tools/cluster-pk-manager/server/BUILD.bazel +++ b/tools/cluster-pk-manager/server/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_test") load("@io_bazel_rules_docker//go:image.bzl", "go_image") load("@io_bazel_rules_docker//container:container.bzl", "container_bundle") load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push") diff --git a/tools/contract-addr/BUILD.bazel b/tools/contract-addr/BUILD.bazel index a925c3c41..47f015094 100644 --- a/tools/contract-addr/BUILD.bazel +++ b/tools/contract-addr/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary") load("@io_bazel_rules_docker//go:image.bzl", "go_image") load("@io_bazel_rules_docker//container:container.bzl", "container_bundle") load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push") diff --git a/tools/deployContract/BUILD.bazel b/tools/deployContract/BUILD.bazel index 226eb361f..645e589f4 100644 --- a/tools/deployContract/BUILD.bazel +++ b/tools/deployContract/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary") go_library( name = "go_default_library", diff --git a/tools/drainContracts/BUILD.bazel b/tools/drainContracts/BUILD.bazel index 230d4487b..a753f3794 100644 --- a/tools/drainContracts/BUILD.bazel +++ b/tools/drainContracts/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary") go_library( name = "go_default_library", diff --git a/tools/enr-calculator/BUILD.bazel b/tools/enr-calculator/BUILD.bazel index ede08bd3a..cf7f6cf97 100644 --- a/tools/enr-calculator/BUILD.bazel +++ b/tools/enr-calculator/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary") load("@io_bazel_rules_docker//go:image.bzl", "go_image") load("@io_bazel_rules_docker//container:container.bzl", "container_bundle") load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push") diff --git a/tools/eth1exporter/BUILD.bazel b/tools/eth1exporter/BUILD.bazel index c049fa5bf..d130afb40 100644 --- a/tools/eth1exporter/BUILD.bazel +++ b/tools/eth1exporter/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary") load("@io_bazel_rules_docker//go:image.bzl", "go_image") load("@io_bazel_rules_docker//container:container.bzl", "container_bundle") load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push") diff --git a/tools/extractor/BUILD.bazel b/tools/extractor/BUILD.bazel index ecefdbfa2..da8657f10 100644 --- a/tools/extractor/BUILD.bazel +++ b/tools/extractor/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary") go_library( name = "go_default_library", diff --git a/tools/forkchecker/BUILD.bazel b/tools/forkchecker/BUILD.bazel index 733e6204d..31001f9e7 100644 --- a/tools/forkchecker/BUILD.bazel +++ b/tools/forkchecker/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary") go_library( name = "go_default_library", diff --git a/tools/fuzz_wrapper.sh b/tools/fuzz_wrapper.sh new file mode 100755 index 000000000..99698dae6 --- /dev/null +++ b/tools/fuzz_wrapper.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +# A wrapper for libfuzz tests that sets test undeclared outputs directory as the first corpus +# which libfuzz will write to and the artifact prefix to write any crashes. + +$1 $TEST_UNDECLARED_OUTPUTS_DIR ${@:2} -artifact_prefix=$TEST_UNDECLARED_OUTPUTS_DIR/ diff --git a/tools/fuzzit_wrapper.sh b/tools/fuzzit_wrapper.sh new file mode 100755 index 000000000..2e6a213f4 --- /dev/null +++ b/tools/fuzzit_wrapper.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -e + +# run fuzzing regression or upload to Fuzzit for long running fuzzing job depending on whether FUZZIT_API_KEY is set + +FUZZIT="${TEST_SRCDIR}/fuzzit_linux/fuzzit" + +FUZZER_BINARY=$1 +FUZZIT_TARGET_NAME="$(basename $1 | sed -e s/_fuzz_test_with_libfuzzer$// -e s/_/-/g)" + +if [[ ! -z "${FUZZIT_API_KEY}" ]]; then + "${FUZZIT}" create target --skip-if-exists --public-corpus prysmaticlabs-gh/"${FUZZIT_TARGET_NAME}" + + # Run fuzzing first so this is not affected by local-regression timeout + "${FUZZIT}" create job --skip-if-not-exists --host "${PRYSM_BUILD_IMAGE}" --type fuzzing prysmaticlabs-gh/"${FUZZIT_TARGET_NAME}" "${FUZZER_BINARY}" +fi + +"${FUZZIT}" create job --skip-if-not-exists --host "${PRYSM_BUILD_IMAGE}" --type local-regression prysmaticlabs-gh/"${FUZZIT_TARGET_NAME}" "${FUZZER_BINARY}" diff --git a/tools/genesis-state-gen/BUILD.bazel b/tools/genesis-state-gen/BUILD.bazel index bd31c6339..c3748f8d1 100644 --- a/tools/genesis-state-gen/BUILD.bazel +++ b/tools/genesis-state-gen/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary") go_library( name = "go_default_library", diff --git a/tools/go/BUILD.bazel b/tools/go/BUILD.bazel new file mode 100644 index 000000000..7a5a5bd6d --- /dev/null +++ b/tools/go/BUILD.bazel @@ -0,0 +1,6 @@ +config_setting( + name = "libfuzz_enabled", + define_values = { + "FUZZING_ENGINE": "libfuzzer", + }, +) diff --git a/tools/go/def.bzl b/tools/go/def.bzl new file mode 100644 index 000000000..617669e8b --- /dev/null +++ b/tools/go/def.bzl @@ -0,0 +1,35 @@ +load("@io_bazel_rules_go//go:def.bzl", _go_library = "go_library") +load("@bazel_gazelle//:deps.bzl", _go_repository = "go_repository") + +def go_library(name, **kwargs): + gc_goopts = [] + + if "gc_goopts" in kwargs: + go_goopts = kwargs["gc_goopts"] + + gc_goopts += select({ + "@prysm//tools/go:libfuzz_enabled": ["-d=libfuzzer"], + "//conditions:default": [], + }) + + kwargs["gc_goopts"] = gc_goopts + _go_library(name = name, **kwargs) + +# A wrapper around go_repository to add gazelle directives. +def go_repository(**kwargs): + # Some third party go tools may be used by the fuzzing pipeline to generate code. This causes + # an issue when running with --config=fuzz and is not necessary since the dependency is not + # part of the final binary. + if "nofuzz" in kwargs: + kwargs.pop("nofuzz", None) + return _go_repository(**kwargs) + + directives = [] + if "build_directives" in kwargs: + directives = kwargs["build_directives"] + + directives += [ + "gazelle:map_kind go_library go_library @prysm//tools/go:def.bzl", + ] + kwargs["build_directives"] = directives + _go_repository(**kwargs) diff --git a/tools/go/fuzz.bzl b/tools/go/fuzz.bzl new file mode 100644 index 000000000..44e6f8091 --- /dev/null +++ b/tools/go/fuzz.bzl @@ -0,0 +1,140 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_context", "go_rule") +load( + "@io_bazel_rules_go//go/private:providers.bzl", + "GoLibrary", + "INFERRED_PATH", +) +load( + "@io_bazel_rules_go//go/private:mode.bzl", + "LINKMODE_C_ARCHIVE", +) +load( + "@io_bazel_rules_go//go:def.bzl", + "go_binary", + "go_library", +) + +main_tpl = """ +// Generated file. DO NOT EDIT. + +package main +import ( + "unsafe" + target "%s" +) +// #include +import "C" +//export LLVMFuzzerTestOneInput +func LLVMFuzzerTestOneInput(data *C.char, size C.size_t) C.int { + s := make([]byte, size) + copy(s, (*[1 << 30]byte)(unsafe.Pointer(data))[:size:size]) + target.%s(s) + return 0 +} +func main() { +} +""" + +def _gen_fuzz_main_impl(ctx): + if ctx.var.get("gotags") != "libfuzzer": + fail("gotags must be set to libfuzzer. Use --config=fuzz or --config=fuzzit.") + if ctx.var.get("gc_goopts") != "-d=libfuzzer": + fail("gc_goopts must be set to -d=libfuzzer. Use --config=fuzz or --config=fuzzit.") + + pkg = ctx.attr.target_pkg + func = ctx.attr.func + + output_file_name = ctx.label.name + "_main.fuzz.go" + output_file = ctx.actions.declare_file(output_file_name) + ctx.actions.write(output_file, main_tpl % (pkg, func)) + return [DefaultInfo(files = depset([output_file]))] + +gen_fuzz_main = rule( + implementation = _gen_fuzz_main_impl, + attrs = { + "target_pkg": attr.string(mandatory = True), + "func": attr.string(mandatory = True), + }, +) + +def go_fuzz_test( + name, + corpus, + corpus_path, + importpath, + func = "Fuzz", + repository = "", + input_size = 0, + size = "medium", + tags = [], + **kwargs): + go_library( + name = name + "_lib_with_fuzzer", + tags = ["manual"] + tags, + visibility = ["//visibility:private"], + testonly = 1, + importpath = importpath, + gc_goopts = ["-d=libfuzzer"], + **kwargs + ) + gen_fuzz_main( + name = name + "_libfuzz_main", + target_pkg = importpath, + func = func, + tags = ["manual"] + tags, + testonly = 1, + visibility = ["//visibility:private"], + ) + go_binary( + name = name + "_binary", + srcs = [name + "_libfuzz_main"], + deps = [name + "_lib_with_fuzzer"], + linkmode = LINKMODE_C_ARCHIVE, + cgo = True, + tags = ["manual"] + tags, + visibility = ["//visibility:private"], + gc_goopts = ["-d=libfuzzer"], + testonly = 1, + ) + native.genrule( + name = name, + outs = [name + ".a"], + srcs = [":" + name + "_binary"], + cmd = "cp $< $@", + visibility = kwargs.get("visibility"), + tags = ["manual"] + tags, + testonly = 1, + ) + + if not (corpus.startswith("//") or corpus.startswith(":") or corpus.startswith("@")): + corpus_name = name + "_corpus" + corpus = native.glob([corpus + "/**"]) + native.filegroup( + name = corpus_name, + srcs = corpus, + ) + else: + corpus_name = corpus + + additional_args = [] + if input_size > 0: + additional_args += ["-max_len=%s" % input_size] + + native.cc_test( + name = name + "_with_libfuzzer", + linkopts = ["-fsanitize=fuzzer,address"], + copts = ["-fsantize=fuzzer,address"], + linkstatic = 1, + testonly = 1, + srcs = [":" + name], + deps = ["@herumi_bls_eth_go_binary//:lib"], + tags = ["manual", "fuzzer"] + tags, + args = [ + corpus_path, + "-print_final_stats=1", + "-use_value_profile=1", + "-max_total_time=3540", # One minute early of 3600. + ] + additional_args, + data = [corpus_name], + timeout = "eternal", + ) diff --git a/tools/interop/convert-keys/BUILD.bazel b/tools/interop/convert-keys/BUILD.bazel index 14543e54d..c424ec81e 100644 --- a/tools/interop/convert-keys/BUILD.bazel +++ b/tools/interop/convert-keys/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary") go_library( name = "go_default_library", diff --git a/tools/interop/export-genesis/BUILD.bazel b/tools/interop/export-genesis/BUILD.bazel index 1c02a2086..58b817561 100644 --- a/tools/interop/export-genesis/BUILD.bazel +++ b/tools/interop/export-genesis/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary") go_library( name = "go_default_library", diff --git a/tools/pcli/BUILD.bazel b/tools/pcli/BUILD.bazel index 702103f31..d6e5e0cf1 100644 --- a/tools/pcli/BUILD.bazel +++ b/tools/pcli/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary") load("@io_bazel_rules_docker//go:image.bzl", "go_image") load("@io_bazel_rules_docker//container:container.bzl", "container_bundle") load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push") diff --git a/tools/relaynode/BUILD.bazel b/tools/relaynode/BUILD.bazel index ba9f33069..e800d0354 100644 --- a/tools/relaynode/BUILD.bazel +++ b/tools/relaynode/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary") load("@io_bazel_rules_docker//go:image.bzl", "go_image") load("@io_bazel_rules_docker//container:container.bzl", "container_bundle") load("@io_bazel_rules_docker//contrib:push-all.bzl", "docker_push") diff --git a/tools/sendDepositTx/BUILD.bazel b/tools/sendDepositTx/BUILD.bazel index 74a9773b4..db404da08 100644 --- a/tools/sendDepositTx/BUILD.bazel +++ b/tools/sendDepositTx/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_test") go_library( name = "go_default_library", diff --git a/tools/ssz.bzl b/tools/ssz.bzl new file mode 100644 index 000000000..e69de29bb diff --git a/tools/unencrypted-keys-gen/BUILD.bazel b/tools/unencrypted-keys-gen/BUILD.bazel index 06ea7db87..7be4b1a49 100644 --- a/tools/unencrypted-keys-gen/BUILD.bazel +++ b/tools/unencrypted-keys-gen/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_test") go_library( name = "go_default_library", diff --git a/tools/update-genesis-time/BUILD.bazel b/tools/update-genesis-time/BUILD.bazel index 9d6b3ac52..e9fd92b72 100644 --- a/tools/update-genesis-time/BUILD.bazel +++ b/tools/update-genesis-time/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary") go_library( name = "go_default_library", diff --git a/validator/BUILD.bazel b/validator/BUILD.bazel index 88cda1bbd..6a92da0ee 100644 --- a/validator/BUILD.bazel +++ b/validator/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_test") load("@io_bazel_rules_docker//go:image.bzl", "go_image") load("@io_bazel_rules_docker//container:container.bzl", "container_bundle") load("//tools:go_image.bzl", "go_image_alpine", "go_image_debug") diff --git a/validator/accounts/BUILD.bazel b/validator/accounts/BUILD.bazel index 266eacc20..cc2102aa2 100644 --- a/validator/accounts/BUILD.bazel +++ b/validator/accounts/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/validator/client/BUILD.bazel b/validator/client/BUILD.bazel index 903e3a4f6..5a53afed0 100644 --- a/validator/client/BUILD.bazel +++ b/validator/client/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/validator/db/BUILD.bazel b/validator/db/BUILD.bazel index b9fc03bc3..d2c982288 100644 --- a/validator/db/BUILD.bazel +++ b/validator/db/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/validator/db/iface/BUILD.bazel b/validator/db/iface/BUILD.bazel index d999fb9ac..99470f4e7 100644 --- a/validator/db/iface/BUILD.bazel +++ b/validator/db/iface/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/validator/flags/BUILD.bazel b/validator/flags/BUILD.bazel index 6e79b94f3..cf33a31a6 100644 --- a/validator/flags/BUILD.bazel +++ b/validator/flags/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/validator/internal/BUILD.bazel b/validator/internal/BUILD.bazel index 52ab303ee..293ac4881 100644 --- a/validator/internal/BUILD.bazel +++ b/validator/internal/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@prysm//tools/go:def.bzl", "go_library") go_library( name = "go_default_library", diff --git a/validator/keymanager/BUILD.bazel b/validator/keymanager/BUILD.bazel index 4540021ec..f3fd965af 100644 --- a/validator/keymanager/BUILD.bazel +++ b/validator/keymanager/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_library( name = "go_default_library", diff --git a/validator/node/BUILD.bazel b/validator/node/BUILD.bazel index 4551639f5..eff1fffa7 100644 --- a/validator/node/BUILD.bazel +++ b/validator/node/BUILD.bazel @@ -1,4 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@prysm//tools/go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_test") go_test( name = "go_default_test",