prysm-pulse/beacon-chain/p2p
Manu NALEPA 65f71b3a48
P2P: Simplify code (#13719)
* `subscribeStaticWithSubnets`: Fix docstring.

* `buildOptions`: Avoid `options` mutations.

* `dv5Cfg`: Avoid mutation.

* `RefreshENR`: Use default for all but Phase0.

* `udp4`, `udp6`: Create enum.

* `p2p.Config`: `BootstrapNodeAddr`==> `BootstrapNodeAddrs`.

* `p2p.Config`: `Discv5BootStrapAddr` ==> `Discv5BootStrapAddrs`.

* `TestScorers_BadResponses_Score`: Improve.

* `BeaconNode`: Avoid mutation.

* `TestStore_TrustedPeers`: Remove blankline.

* Remove blank identifiers.

* `privKey`: Keep the majority of code with low indentation.

* `P2PPreregistration`: Return error instead of fatal log.

* `parseBootStrapAddrs` => `ParseBootStrapAddrs` (export)

* `p2p.Config`: Remove `BootstrapNodeAddrs`.

* `NewService`: Avoid mutation when possible.

* `Service`: Remove blank identifier.

* `buildOptions`: Avoid `log.Fatalf` (make deepsource happy).

* `registerGRPCGateway`: Use `net.JoinHostPort` (make deepsource happy).

* `registerBuilderService`: Make deepsource happy.

* `scorers`: Add `NoLock` suffix (make deepsource happy).

* `scorerr`: Add some `NoLock`suffixes (making deepsource happy).

* `discovery_test.go`. Remove init.

Rationale:
`rand.Seed` is deprecated: As of Go 1.20 there is no reason to call Seed with a random value. Programs that call Seed with a known value to get a specific sequence of results should use New(NewSource(seed)) to obtain a local random generator.

This makes deepsource happy as well.

* `createListener`: Reduce cyclomatic complexity (make deepsource happy).

* `startDB`: Reduce cyclomatic complexity (make deepsource happy).

* `main`: Log a FATAL on error.

This way, the error message is very readable.
Before this commit, the error message is the less readable
message in the logs.

* `New`: Reduce cyclomatic complexity (make deepsource happy).

* `main`: Avoid `App` mutation, and make deepsource happy.

* Update beacon-chain/node/node.go

Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com>

* `bootnodes` ==> `BootNodes` (Fix PR comment).

* Remove duplicate `configureFastSSZHashingAlgorithm` since already done in `configureBeacon`. (Fix PR comment)

* Add `TestCreateLocalNode`. (PR comment fix.)

* `startModules` ==> `startBaseServices (Fix PR comment).

* `buildOptions` return errors consistently.

* `New`: Change ordering.

---------

Co-authored-by: Sammy Rosso <15244892+saolyn@users.noreply.github.com>
2024-03-15 11:08:19 +00:00
..
encoder Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
peers P2P: Simplify code (#13719) 2024-03-15 11:08:19 +00:00
testing Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
types Remove unused deneb code (#13712) 2024-03-09 00:12:26 +00:00
addr_factory_test.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
addr_factory.go
broadcaster_test.go P2P: Simplify code (#13719) 2024-03-15 11:08:19 +00:00
broadcaster.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
BUILD.bazel Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
config.go P2P: Simplify code (#13719) 2024-03-15 11:08:19 +00:00
connection_gater_test.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
connection_gater.go P2P: Simplify code (#13719) 2024-03-15 11:08:19 +00:00
dial_relay_node_test.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
dial_relay_node.go
discovery_test.go P2P: Simplify code (#13719) 2024-03-15 11:08:19 +00:00
discovery.go P2P: Simplify code (#13719) 2024-03-15 11:08:19 +00:00
doc.go
fork_test.go P2P: Simplify code (#13719) 2024-03-15 11:08:19 +00:00
fork_watcher.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
fork.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
gossip_scoring_params_test.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
gossip_scoring_params.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
gossip_topic_mappings_test.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
gossip_topic_mappings.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
handshake.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
info.go P2P: Simplify code (#13719) 2024-03-15 11:08:19 +00:00
interfaces.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
iterator.go
log.go
message_id_test.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
message_id.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
monitoring.go Improve Gossipsub Rejection Metric (#13236) 2023-11-30 10:16:26 +00:00
options_test.go P2P: Simplify code (#13719) 2024-03-15 11:08:19 +00:00
options.go P2P: Simplify code (#13719) 2024-03-15 11:08:19 +00:00
parameter_test.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
pubsub_filter_test.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
pubsub_filter.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
pubsub_fuzz_test.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
pubsub_test.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
pubsub_tracer.go Improve Gossipsub Rejection Metric (#13236) 2023-11-30 10:16:26 +00:00
pubsub.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
rpc_topic_mappings_test.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
rpc_topic_mappings.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
sender_test.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
sender.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
service_test.go P2P: Simplify code (#13719) 2024-03-15 11:08:19 +00:00
service.go P2P: Simplify code (#13719) 2024-03-15 11:08:19 +00:00
subnets_test.go P2P: Simplify code (#13719) 2024-03-15 11:08:19 +00:00
subnets.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
topics.go Add Blob Gossip (#12413) 2023-08-31 08:41:57 -05:00
utils_test.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00
utils.go P2P: Simplify code (#13719) 2024-03-15 11:08:19 +00:00
watch_peers.go Update to V5 (#13622) 2024-02-15 05:46:47 +00:00