mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
Disable some static analysis checks for coverage builds (#6105)
* Disable some static analysis checks for coverage builds * Merge branch 'master' into fix-coverage-builds * disable lostcancel for third_party code * Merge branch 'fix-coverage-builds' of github.com:prysmaticlabs/prysm into fix-coverage-builds * Merge refs/heads/master into fix-coverage-builds * A few lostcancel fixes * Merge branch 'fix-coverage-builds' of github.com:prysmaticlabs/prysm into fix-coverage-builds * Merge refs/heads/master into fix-coverage-builds
This commit is contained in:
parent
4e96cbeae7
commit
d2337d0ec1
3
.bazelrc
3
.bazelrc
@ -5,6 +5,9 @@ test --test_verbose_timeout_warnings
|
|||||||
test --build_tests_only
|
test --build_tests_only
|
||||||
test --test_output=errors
|
test --test_output=errors
|
||||||
|
|
||||||
|
# Clearly indicate that coverage is enabled to disable certain nogo checks.
|
||||||
|
coverage --define=coverage_enabled=1
|
||||||
|
|
||||||
# Fix for rules_docker. See: https://github.com/bazelbuild/rules_docker/issues/842
|
# Fix for rules_docker. See: https://github.com/bazelbuild/rules_docker/issues/842
|
||||||
build --host_force_python=PY2
|
build --host_force_python=PY2
|
||||||
test --host_force_python=PY2
|
test --host_force_python=PY2
|
||||||
|
17
BUILD.bazel
17
BUILD.bazel
@ -88,15 +88,12 @@ nogo(
|
|||||||
"@org_golang_x_tools//go/analysis/passes/pkgfact:go_tool_library",
|
"@org_golang_x_tools//go/analysis/passes/pkgfact:go_tool_library",
|
||||||
"@org_golang_x_tools//go/analysis/passes/nilness:go_tool_library",
|
"@org_golang_x_tools//go/analysis/passes/nilness:go_tool_library",
|
||||||
"@org_golang_x_tools//go/analysis/passes/nilfunc:go_tool_library",
|
"@org_golang_x_tools//go/analysis/passes/nilfunc:go_tool_library",
|
||||||
# lost cancel ignore doesn't seem to work when running with coverage
|
|
||||||
#"@org_golang_x_tools//go/analysis/passes/lostcancel:go_tool_library",
|
|
||||||
"@org_golang_x_tools//go/analysis/passes/loopclosure:go_tool_library",
|
"@org_golang_x_tools//go/analysis/passes/loopclosure:go_tool_library",
|
||||||
"@org_golang_x_tools//go/analysis/passes/httpresponse:go_tool_library",
|
"@org_golang_x_tools//go/analysis/passes/httpresponse:go_tool_library",
|
||||||
"@org_golang_x_tools//go/analysis/passes/findcall:go_tool_library",
|
"@org_golang_x_tools//go/analysis/passes/findcall:go_tool_library",
|
||||||
"@org_golang_x_tools//go/analysis/passes/deepequalerrors:go_tool_library",
|
"@org_golang_x_tools//go/analysis/passes/deepequalerrors:go_tool_library",
|
||||||
"@org_golang_x_tools//go/analysis/passes/ctrlflow:go_tool_library",
|
"@org_golang_x_tools//go/analysis/passes/ctrlflow:go_tool_library",
|
||||||
"@org_golang_x_tools//go/analysis/passes/copylock:go_tool_library",
|
"@org_golang_x_tools//go/analysis/passes/copylock:go_tool_library",
|
||||||
"@org_golang_x_tools//go/analysis/passes/composite:go_tool_library",
|
|
||||||
# "@org_golang_x_tools//go/analysis/passes/cgocall:go_tool_library",
|
# "@org_golang_x_tools//go/analysis/passes/cgocall:go_tool_library",
|
||||||
"@org_golang_x_tools//go/analysis/passes/buildtag:go_tool_library",
|
"@org_golang_x_tools//go/analysis/passes/buildtag:go_tool_library",
|
||||||
"@org_golang_x_tools//go/analysis/passes/buildssa:go_tool_library",
|
"@org_golang_x_tools//go/analysis/passes/buildssa:go_tool_library",
|
||||||
@ -110,7 +107,19 @@ nogo(
|
|||||||
"//tools/analyzers/roughtime:go_tool_library",
|
"//tools/analyzers/roughtime:go_tool_library",
|
||||||
"//tools/analyzers/errcheck:go_tool_library",
|
"//tools/analyzers/errcheck:go_tool_library",
|
||||||
"//tools/analyzers/featureconfig:go_tool_library",
|
"//tools/analyzers/featureconfig:go_tool_library",
|
||||||
],
|
] + select({
|
||||||
|
# nogo checks that fail with coverage enabled.
|
||||||
|
":coverage_enabled": [],
|
||||||
|
"//conditions:default": [
|
||||||
|
"@org_golang_x_tools//go/analysis/passes/lostcancel:go_tool_library",
|
||||||
|
"@org_golang_x_tools//go/analysis/passes/composite:go_tool_library",
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
|
config_setting(
|
||||||
|
name = "coverage_enabled",
|
||||||
|
values = {"define": "coverage_enabled=1"},
|
||||||
)
|
)
|
||||||
|
|
||||||
common_files = {
|
common_files = {
|
||||||
|
@ -94,6 +94,7 @@ type Service struct {
|
|||||||
func NewService(cfg *Config) (*Service, error) {
|
func NewService(cfg *Config) (*Service, error) {
|
||||||
var err error
|
var err error
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
_ = cancel // govet fix for lost cancel. Cancel is handled in service.Stop().
|
||||||
cache, err := ristretto.NewCache(&ristretto.Config{
|
cache, err := ristretto.NewCache(&ristretto.Config{
|
||||||
NumCounters: 1000,
|
NumCounters: 1000,
|
||||||
MaxCost: 1000,
|
MaxCost: 1000,
|
||||||
|
@ -172,6 +172,7 @@ func NewService(ctx context.Context, config *Web3ServiceConfig) (*Service, error
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
ctx, cancel := context.WithCancel(ctx)
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
|
_ = cancel // govet fix for lost cancel. Cancel is handled in service.Stop()
|
||||||
depositTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth))
|
depositTrie, err := trieutil.NewTrie(int(params.BeaconConfig().DepositContractTreeDepth))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cancel()
|
cancel()
|
||||||
|
@ -436,7 +436,8 @@ func TestBlocksFetcherHandleRequest(t *testing.T) {
|
|||||||
p2p: p2p,
|
p2p: p2p,
|
||||||
})
|
})
|
||||||
|
|
||||||
requestCtx, _ := context.WithTimeout(context.Background(), 2*time.Second)
|
requestCtx, reqCancel := context.WithTimeout(context.Background(), 2*time.Second)
|
||||||
|
defer reqCancel()
|
||||||
go func() {
|
go func() {
|
||||||
response := fetcher.handleRequest(requestCtx, 1 /* start */, blockBatchLimit /* count */)
|
response := fetcher.handleRequest(requestCtx, 1 /* start */, blockBatchLimit /* count */)
|
||||||
select {
|
select {
|
||||||
@ -529,7 +530,8 @@ func TestBlocksFetcherRequestBeaconBlocksByRangeRequest(t *testing.T) {
|
|||||||
|
|
||||||
// Test request fail over (error).
|
// Test request fail over (error).
|
||||||
err = fetcher.p2p.Disconnect(peers[1])
|
err = fetcher.p2p.Disconnect(peers[1])
|
||||||
ctx, _ = context.WithTimeout(context.Background(), time.Second*1)
|
ctx, cancel = context.WithTimeout(context.Background(), time.Second*1)
|
||||||
|
defer cancel()
|
||||||
blocks, err = fetcher.requestBeaconBlocksByRange(ctx, peers[1], root, 1, 1, blockBatchLimit)
|
blocks, err = fetcher.requestBeaconBlocksByRange(ctx, peers[1], root, 1, 1, blockBatchLimit)
|
||||||
testutil.AssertLogsContain(t, hook, "Request failed, trying to forward request to another peer")
|
testutil.AssertLogsContain(t, hook, "Request failed, trying to forward request to another peer")
|
||||||
if err == nil || err.Error() != "context deadline exceeded" {
|
if err == nil || err.Error() != "context deadline exceeded" {
|
||||||
|
@ -114,7 +114,8 @@ func (r *Service) subscribeWithBase(base proto.Message, topic string, validator
|
|||||||
// Pipeline decodes the incoming subscription data, runs the validation, and handles the
|
// Pipeline decodes the incoming subscription data, runs the validation, and handles the
|
||||||
// message.
|
// message.
|
||||||
pipeline := func(msg *pubsub.Message) {
|
pipeline := func(msg *pubsub.Message) {
|
||||||
ctx, _ := context.WithTimeout(context.Background(), pubsubMessageTimeout)
|
ctx, cancel := context.WithTimeout(context.Background(), pubsubMessageTimeout)
|
||||||
|
defer cancel()
|
||||||
ctx, span := trace.StartSpan(ctx, "sync.pubsub")
|
ctx, span := trace.StartSpan(ctx, "sync.pubsub")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
@ -169,7 +170,8 @@ func (r *Service) subscribeWithBase(base proto.Message, topic string, validator
|
|||||||
func wrapAndReportValidation(topic string, v pubsub.ValidatorEx) (string, pubsub.ValidatorEx) {
|
func wrapAndReportValidation(topic string, v pubsub.ValidatorEx) (string, pubsub.ValidatorEx) {
|
||||||
return topic, func(ctx context.Context, pid peer.ID, msg *pubsub.Message) pubsub.ValidationResult {
|
return topic, func(ctx context.Context, pid peer.ID, msg *pubsub.Message) pubsub.ValidationResult {
|
||||||
defer messagehandler.HandlePanic(ctx, msg)
|
defer messagehandler.HandlePanic(ctx, msg)
|
||||||
ctx, _ = context.WithTimeout(ctx, pubsubMessageTimeout)
|
ctx, cancel := context.WithTimeout(ctx, pubsubMessageTimeout)
|
||||||
|
defer cancel()
|
||||||
messageReceivedCounter.WithLabelValues(topic).Inc()
|
messageReceivedCounter.WithLabelValues(topic).Inc()
|
||||||
b := v(ctx, pid, msg)
|
b := v(ctx, pid, msg)
|
||||||
if b == pubsub.ValidationReject {
|
if b == pubsub.ValidationReject {
|
||||||
|
@ -134,7 +134,8 @@ func TestValidateAttesterSlashing_ContextTimeout(t *testing.T) {
|
|||||||
slashing, state := setupValidAttesterSlashing(t)
|
slashing, state := setupValidAttesterSlashing(t)
|
||||||
slashing.Attestation_1.Data.Target.Epoch = 100000000
|
slashing.Attestation_1.Data.Target.Epoch = 100000000
|
||||||
|
|
||||||
ctx, _ := context.WithTimeout(context.Background(), 100*time.Millisecond)
|
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
c, err := lru.New(10)
|
c, err := lru.New(10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -170,7 +170,8 @@ func TestValidateProposerSlashing_ContextTimeout(t *testing.T) {
|
|||||||
slashing, state := setupValidProposerSlashing(t)
|
slashing, state := setupValidProposerSlashing(t)
|
||||||
slashing.Header_1.Header.Slot = 100000000
|
slashing.Header_1.Header.Slot = 100000000
|
||||||
|
|
||||||
ctx, _ := context.WithTimeout(context.Background(), 100*time.Millisecond)
|
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
c, err := lru.New(10)
|
c, err := lru.New(10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -13,7 +13,8 @@
|
|||||||
},
|
},
|
||||||
"lostcancel": {
|
"lostcancel": {
|
||||||
"exclude_files": {
|
"exclude_files": {
|
||||||
"validator/client/runner.go": "No need to cancel right when goroutines begin"
|
"validator/client/runner.go": "No need to cancel right when goroutines begin",
|
||||||
|
"external/.*": "Third party code"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nilness": {
|
"nilness": {
|
||||||
@ -41,12 +42,12 @@
|
|||||||
"composites": {
|
"composites": {
|
||||||
"exclude_files": {
|
"exclude_files": {
|
||||||
"external/.*": "Third party code"
|
"external/.*": "Third party code"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cgocall": {
|
"cgocall": {
|
||||||
"exclude_files": {
|
"exclude_files": {
|
||||||
"external/.*": "Third party code"
|
"external/.*": "Third party code"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"assign": {
|
"assign": {
|
||||||
"exclude_files": {
|
"exclude_files": {
|
||||||
|
@ -75,6 +75,7 @@ type Config struct {
|
|||||||
// NewBeaconClientService instantiation.
|
// NewBeaconClientService instantiation.
|
||||||
func NewBeaconClientService(ctx context.Context, cfg *Config) (*Service, error) {
|
func NewBeaconClientService(ctx context.Context, cfg *Config) (*Service, error) {
|
||||||
ctx, cancel := context.WithCancel(ctx)
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
|
_ = cancel // govet fix for lost cancel. Cancel is handled in service.Stop()
|
||||||
publicKeyCache, err := cache.NewPublicKeyCache(0, nil)
|
publicKeyCache, err := cache.NewPublicKeyCache(0, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "could not create new cache")
|
return nil, errors.Wrap(err, "could not create new cache")
|
||||||
|
Loading…
Reference in New Issue
Block a user