Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Commit 3dc6764

Browse files
authored
Merge pull request #268 from 0xProject/release/1.0.3-beta
Release version 1.0.3-beta
2 parents 5288c44 + 7b519b9 commit 3dc6764

File tree

8 files changed

+55
-18
lines changed

8 files changed

+55
-18
lines changed

DEPLOYMENT.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Version](https://img.shields.io/badge/version-1.0.2--beta-orange.svg)](https://github.com/0xProject/0x-mesh/releases)
1+
[![Version](https://img.shields.io/badge/version-1.0.3--beta-orange.svg)](https://github.com/0xProject/0x-mesh/releases)
22

33
# 0x Mesh Deployment Guide
44

DEVELOPMENT.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Version](https://img.shields.io/badge/version-1.0.2--beta-orange.svg)](https://github.com/0xProject/0x-mesh/releases)
1+
[![Version](https://img.shields.io/badge/version-1.0.3--beta-orange.svg)](https://github.com/0xProject/0x-mesh/releases)
22

33
# 0x Mesh Development Guide
44

Gopkg.lock

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Version](https://img.shields.io/badge/version-1.0.2--beta-orange.svg)](https://github.com/0xProject/0x-mesh/releases)
1+
[![Version](https://img.shields.io/badge/version-1.0.3--beta-orange.svg)](https://github.com/0xProject/0x-mesh/releases)
22
[![Chat with us on Discord](https://img.shields.io/badge/chat-Discord-blueViolet.svg)](https://discord.gg/HF7fHwk)
33
[![GoDoc](https://godoc.org/github.com/0xProject/0x-mesh?status.svg)](https://godoc.org/github.com/0xProject/0x-mesh)
44
[![Circle CI](https://img.shields.io/circleci/project/0xProject/0x-mesh/master.svg)](https://circleci.com/gh/0xProject/0x-mesh/tree/master)
@@ -12,7 +12,7 @@
1212

1313
## Versions
1414

15-
You are looking at the documentation for version `1.0.2-beta`. To see the
15+
You are looking at the documentation for version `1.0.3-beta`. To see the
1616
documentation for a different version, visit the
1717
[Releases Page](https://github.com/0xProject/0x-mesh/releases).
1818

USAGE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Version](https://img.shields.io/badge/version-1.0.2--beta-orange.svg)](https://github.com/0xProject/0x-mesh/releases)
1+
[![Version](https://img.shields.io/badge/version-1.0.3--beta-orange.svg)](https://github.com/0xProject/0x-mesh/releases)
22

33
# 0x Mesh Usage Guide
44

cmd/mesh-bootstrap/main.go

+46-11
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,22 @@ import (
99
"context"
1010
"fmt"
1111
"os"
12+
"strings"
1213
"time"
1314

1415
"github.com/0xProject/0x-mesh/keys"
1516
"github.com/0xProject/0x-mesh/loghooks"
1617
"github.com/0xProject/0x-mesh/p2p"
1718
libp2p "github.com/libp2p/go-libp2p"
1819
autonat "github.com/libp2p/go-libp2p-autonat-svc"
20+
relay "github.com/libp2p/go-libp2p-circuit"
1921
connmgr "github.com/libp2p/go-libp2p-connmgr"
2022
p2pcrypto "github.com/libp2p/go-libp2p-crypto"
23+
host "github.com/libp2p/go-libp2p-host"
24+
dht "github.com/libp2p/go-libp2p-kad-dht"
2125
p2pnet "github.com/libp2p/go-libp2p-net"
2226
peer "github.com/libp2p/go-libp2p-peer"
27+
routing "github.com/libp2p/go-libp2p-routing"
2328
ma "github.com/multiformats/go-multiaddr"
2429
"github.com/plaid/go-envvar/envvar"
2530
log "github.com/sirupsen/logrus"
@@ -43,10 +48,12 @@ const (
4348
// Config contains configuration options for a Node.
4449
type Config struct {
4550
// Verbosity is the logging verbosity: 0=panic, 1=fatal, 2=error, 3=warn, 4=info, 5=debug 6=trace
46-
Verbosity int `envvar:"VERBOSITY" default:"6"`
47-
// P2PListenPort is the port on which to listen for new connections. It can be
48-
// set to 0 to make the OS automatically choose any available port.
49-
P2PListenPort int `envvar:"P2P_LISTEN_PORT" default:"0"`
51+
Verbosity int `envvar:"VERBOSITY" default:"5"`
52+
// P2PListenPort is the port on which to listen for new connections.
53+
P2PListenPort int `envvar:"P2P_LISTEN_PORT"`
54+
// PublicIPAddrs is a comma separated list of public IPv4 addresses at which
55+
// the bootstrap node is accessible.
56+
PublicIPAddrs string `envvar:"PUBLIC_IP_ADDRS"`
5057
// PrivateKey path is the path to a private key file which will be used for
5158
// signing messages and generating a peer ID.
5259
PrivateKeyPath string `envvar:"PRIVATE_KEY_PATH" default:"0x_mesh/keys/privkey"`
@@ -73,6 +80,29 @@ func main() {
7380
log.WithField("error", err).Fatal("could not initialize private key")
7481
}
7582

83+
// We need to declare the newDHT function ahead of time so we can use it in
84+
// the libp2p.Routing option.
85+
var kadDHT *dht.IpfsDHT
86+
newDHT := func(h host.Host) (routing.PeerRouting, error) {
87+
var err error
88+
kadDHT, err = p2p.NewDHT(ctx, h)
89+
if err != nil {
90+
log.WithField("error", err).Fatal("could not create DHT")
91+
}
92+
return kadDHT, err
93+
}
94+
// Parse advertiseAddresses from Public IPs
95+
ipAddrs := strings.Split(config.PublicIPAddrs, ",")
96+
advertiseAddrs := make([]ma.Multiaddr, len(ipAddrs))
97+
for i, ipAddr := range ipAddrs {
98+
maddrString := fmt.Sprintf("/ip4/%s/tcp/%d", ipAddr, config.P2PListenPort)
99+
ma, err := ma.NewMultiaddr(maddrString)
100+
if err != nil {
101+
log.Fatal(err)
102+
}
103+
advertiseAddrs[i] = ma
104+
}
105+
76106
// Set up the transport and the host.
77107
// Note: 0.0.0.0 will use all available addresses.
78108
hostAddr, err := ma.NewMultiaddr(fmt.Sprintf("/ip4/0.0.0.0/tcp/%d", config.P2PListenPort))
@@ -84,6 +114,10 @@ func main() {
84114
libp2p.ListenAddrs(hostAddr),
85115
libp2p.Identity(privKey),
86116
libp2p.ConnectionManager(connManager),
117+
libp2p.EnableRelay(relay.OptHop),
118+
libp2p.EnableAutoRelay(),
119+
libp2p.Routing(newDHT),
120+
libp2p.AddrsFactory(newAddrsFactory(advertiseAddrs)),
87121
}
88122
basicHost, err := libp2p.New(ctx, opts...)
89123
if err != nil {
@@ -101,12 +135,6 @@ func main() {
101135
log.WithField("error", err).Fatal("could not enable AutoNAT service")
102136
}
103137

104-
// Set up DHT for peer discovery.
105-
kadDHT, err := p2p.NewDHT(ctx, basicHost)
106-
if err != nil {
107-
log.WithField("error", err).Fatal("could not create DHT")
108-
}
109-
110138
// Initialize the DHT and then connect to the other bootstrap nodes.
111139
if err := kadDHT.Bootstrap(ctx); err != nil {
112140
log.WithField("error", err).Fatal("could not bootstrap DHT")
@@ -130,7 +158,8 @@ func main() {
130158
}
131159

132160
log.WithFields(map[string]interface{}{
133-
"addrs": basicHost.Addrs(),
161+
"addrs": basicHost.Addrs(),
162+
"config": config,
134163
}).Info("started bootstrap node")
135164

136165
// Sleep until stopped
@@ -183,3 +212,9 @@ func (n *notifee) OpenedStream(network p2pnet.Network, stream p2pnet.Stream) {}
183212

184213
// ClosedStream is called when a stream closed
185214
func (n *notifee) ClosedStream(network p2pnet.Network, stream p2pnet.Stream) {}
215+
216+
func newAddrsFactory(advertiseAddrs []ma.Multiaddr) func([]ma.Multiaddr) []ma.Multiaddr {
217+
return func([]ma.Multiaddr) []ma.Multiaddr {
218+
return advertiseAddrs
219+
}
220+
}

core/core.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func New(config Config) (*App, error) {
107107
log.SetLevel(log.Level(config.Verbosity))
108108
log.WithFields(map[string]interface{}{
109109
"config": config,
110-
"version": "1.0.2-beta",
110+
"version": "1.0.3-beta",
111111
}).Info("Initializing new core.App")
112112

113113
if config.EthereumRPCMaxContentLength < maxOrderSizeInBytes {

examples/beta_telemetry_node/docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: '3'
22

33
services:
44
mesh:
5-
image: 0xorg/mesh:1.0.2-beta
5+
image: 0xorg/mesh:1.0.3-beta
66
restart: always
77
logging:
88
driver: fluentd

0 commit comments

Comments
 (0)