Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Bootnode to v0.11 #5387

Merged
merged 5 commits into from
Apr 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tools/bootnode/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ go_library(
importpath = "github.com/prysmaticlabs/prysm/tools/bootnode",
visibility = ["//visibility:private"],
deps = [
"//proto/beacon/p2p/v1:go_default_library",
"//shared/params:go_default_library",
"//shared/version:go_default_library",
"@com_github_btcsuite_btcd//btcec:go_default_library",
"@com_github_ethereum_go_ethereum//log:go_default_library",
Expand All @@ -24,6 +26,8 @@ go_library(
"@com_github_libp2p_go_libp2p_kad_dht//opts:go_default_library",
"@com_github_multiformats_go_multiaddr//:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@org_uber_go_automaxprocs//:go_default_library",
],
Expand All @@ -41,6 +45,8 @@ go_image(
tags = ["manual"],
visibility = ["//visibility:private"],
deps = [
"//proto/beacon/p2p/v1:go_default_library",
"//shared/params:go_default_library",
"//shared/version:go_default_library",
"@com_github_btcsuite_btcd//btcec:go_default_library",
"@com_github_ethereum_go_ethereum//log:go_default_library",
Expand All @@ -52,11 +58,12 @@ go_image(
"@com_github_ipfs_go_log//:go_default_library",
"@com_github_libp2p_go_libp2p//:go_default_library",
"@com_github_libp2p_go_libp2p_core//crypto:go_default_library",
"@com_github_libp2p_go_libp2p_core//protocol:go_default_library",
"@com_github_libp2p_go_libp2p_kad_dht//:go_default_library",
"@com_github_libp2p_go_libp2p_kad_dht//opts:go_default_library",
"@com_github_multiformats_go_multiaddr//:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@org_uber_go_automaxprocs//:go_default_library",
],
Expand Down
16 changes: 16 additions & 0 deletions tools/bootnode/bootnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ import (
dhtopts "github.com/libp2p/go-libp2p-kad-dht/opts"
ma "github.com/multiformats/go-multiaddr"
"github.com/pkg/errors"
"github.com/prysmaticlabs/go-bitfield"
"github.com/prysmaticlabs/go-ssz"
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
"github.com/prysmaticlabs/prysm/shared/params"
"github.com/prysmaticlabs/prysm/shared/version"
"github.com/sirupsen/logrus"
_ "go.uber.org/automaxprocs"
Expand Down Expand Up @@ -180,13 +184,25 @@ func createLocalNode(privKey *ecdsa.PrivateKey, ipAddr net.IP, port int) (*enode
return nil, errors.Wrap(err, "Could not open node's peer database")
}

forkID := &pb.ENRForkID{
CurrentForkDigest: []byte{0, 0, 0, 0},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it okay to make this hardcoded?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in the context of bootnodes, we have no way to know what the current fork digest is of a chain. Because you need both genesis time + validator root. Therefor we just make it a zeroed out byte array for now. Bootnodes are a special case here, so we just ignore the fact that they have different fork digests for now in the beacon node.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Got it!

NextForkVersion: params.BeaconConfig().NextForkVersion,
NextForkEpoch: params.BeaconConfig().NextForkEpoch,
}
forkEntry, err := ssz.Marshal(forkID)
if err != nil {
return nil, errors.Wrap(err, "Could not marshal fork id")
}

localNode := enode.NewLocalNode(db, privKey)
ipEntry := enr.IP(ipAddr)
udpEntry := enr.UDP(port)
localNode.SetFallbackIP(ipAddr)
localNode.SetFallbackUDP(port)
localNode.Set(ipEntry)
localNode.Set(udpEntry)
localNode.Set(enr.WithEntry("eth2", forkEntry))
localNode.Set(enr.WithEntry("attnets", bitfield.NewBitvector64()))

return localNode, nil
}
Expand Down