mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-03 00:27:38 +00:00
Add pubsub message ID function (#4304)
* add pubsub message ID * thanks linter * Update rules_go, gogo protobuf, comment * Merge branch 'master' into add-msg-fn-id
This commit is contained in:
parent
2c28e4e7a3
commit
65e3f3e007
19
WORKSPACE
19
WORKSPACE
@ -35,9 +35,11 @@ http_archive(
|
||||
|
||||
http_archive(
|
||||
name = "io_bazel_rules_go",
|
||||
sha256 = "886db2f8d620fcb5791c8e2a402a575bc70728e17ec116841d78f3837a09f69e",
|
||||
strip_prefix = "rules_go-9bb1562710f7077cd109b66cd4b45900e6d7ae73",
|
||||
urls = ["https://github.com/bazelbuild/rules_go/archive/9bb1562710f7077cd109b66cd4b45900e6d7ae73.tar.gz"],
|
||||
sha256 = "e88471aea3a3a4f19ec1310a55ba94772d087e9ce46e41ae38ecebe17935de7b",
|
||||
urls = [
|
||||
"https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/v0.20.3/rules_go-v0.20.3.tar.gz",
|
||||
"https://github.com/bazelbuild/rules_go/releases/download/v0.20.3/rules_go-v0.20.3.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
@ -57,14 +59,15 @@ git_repository(
|
||||
# https://github.com/gogo/protobuf/pull/582 is merged.
|
||||
git_repository(
|
||||
name = "com_github_gogo_protobuf",
|
||||
commit = "ba06b47c162d49f2af050fb4c75bcbc86a159d5c", # v1.2.1, as of 2019-03-03
|
||||
# v1.3.0 (latest) as of 2019-10-05
|
||||
commit = "0ca988a254f991240804bf9821f3450d87ccbb1b",
|
||||
patch_args = ["-p1"],
|
||||
patches = [
|
||||
"@io_bazel_rules_go//third_party:com_github_gogo_protobuf-gazelle.patch",
|
||||
"//third_party:com_github_gogo_protobuf-equal.patch",
|
||||
],
|
||||
remote = "https://github.com/gogo/protobuf",
|
||||
shallow_since = "1550471403 +0200",
|
||||
shallow_since = "1567336231 +0200",
|
||||
# gazelle args: -go_prefix github.com/gogo/protobuf -proto legacy
|
||||
)
|
||||
|
||||
@ -742,8 +745,9 @@ go_repository(
|
||||
go_repository(
|
||||
name = "com_github_libp2p_go_libp2p_pubsub",
|
||||
build_file_proto_mode = "disable_global",
|
||||
commit = "9f04364996b415168f0e0d7e9fc82272fbed4005", # v0.1.1
|
||||
importpath = "github.com/libp2p/go-libp2p-pubsub",
|
||||
sum = "h1:tPKbkjAUI0xLGN3KKTKKy9TQEviVfrP++zJgH5Muke4=",
|
||||
version = "v0.2.5",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
@ -834,8 +838,9 @@ go_repository(
|
||||
|
||||
go_repository(
|
||||
name = "com_github_libp2p_go_libp2p_discovery",
|
||||
commit = "d248d63b0af8c023307da18ad7000a12020e06f0", # v0.1.0
|
||||
importpath = "github.com/libp2p/go-libp2p-discovery",
|
||||
sum = "h1:1p3YSOq7VsgaL+xVHPi8XAmtGyas6D2J6rWBEfz/aiY=",
|
||||
version = "v0.2.0",
|
||||
)
|
||||
|
||||
go_repository(
|
||||
|
@ -16,6 +16,7 @@ go_library(
|
||||
"log.go",
|
||||
"monitoring.go",
|
||||
"options.go",
|
||||
"pubsub_message_id.go",
|
||||
"rpc_topic_mappings.go",
|
||||
"sender.go",
|
||||
"service.go",
|
||||
@ -60,6 +61,7 @@ go_library(
|
||||
"@com_github_libp2p_go_libp2p_kad_dht//opts:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p_peerstore//:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p_pubsub//:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p_pubsub//pb:go_default_library",
|
||||
"@com_github_libp2p_go_maddr_filter//:go_default_library",
|
||||
"@com_github_multiformats_go_multiaddr//:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
|
17
beacon-chain/p2p/pubsub_message_id.go
Normal file
17
beacon-chain/p2p/pubsub_message_id.go
Normal file
@ -0,0 +1,17 @@
|
||||
package p2p
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
|
||||
"github.com/libp2p/go-libp2p-pubsub/pb"
|
||||
"github.com/prysmaticlabs/prysm/shared/hashutil"
|
||||
)
|
||||
|
||||
// Content addressable ID function.
|
||||
//
|
||||
// Loosely defined as Base64(sha2(data)) until a formal specification is determined.
|
||||
// Pending: https://github.com/ethereum/eth2.0-specs/issues/1528
|
||||
func msgIDFunction(pmsg *pubsub_pb.Message) string {
|
||||
h := hashutil.FastSum256(pmsg.Data)
|
||||
return base64.URLEncoding.EncodeToString(h[:])
|
||||
}
|
@ -116,6 +116,7 @@ func NewService(cfg *Config) (*Service, error) {
|
||||
psOpts := []pubsub.Option{
|
||||
pubsub.WithMessageSigning(false),
|
||||
pubsub.WithStrictSignatureVerification(false),
|
||||
pubsub.WithMessageIdFn(msgIDFunction),
|
||||
}
|
||||
gs, err := pubsub.NewGossipSub(s.ctx, s.host, psOpts...)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user