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

localnet: expose 6060 (pprof) and 9090 (prometheus) on node0 #5805

Merged
merged 5 commits into from
Dec 17, 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
23 changes: 14 additions & 9 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,15 +561,20 @@ func DefaultP2PConfig() *P2PConfig {
MaxNumOutboundPeers: 10,
PersistentPeersMaxDialPeriod: 0 * time.Second,
FlushThrottleTimeout: 100 * time.Millisecond,
MaxPacketMsgPayloadSize: 1024, // 1 kB
SendRate: 5120000, // 5 mB/s
RecvRate: 5120000, // 5 mB/s
PexReactor: true,
SeedMode: false,
AllowDuplicateIP: false,
HandshakeTimeout: 20 * time.Second,
DialTimeout: 3 * time.Second,
TestDialFail: false,
// The MTU (Maximum Transmission Unit) for Ethernet is 1500 bytes.
// The IP header and the TCP header take up 20 bytes each at least (unless
// optional header fields are used) and thus the max for (non-Jumbo frame)
// Ethernet is 1500 - 20 -20 = 1460
// Source: https://stackoverflow.com/a/3074427/820520
MaxPacketMsgPayloadSize: 1400,
SendRate: 5120000, // 5 mB/s
RecvRate: 5120000, // 5 mB/s
PexReactor: true,
SeedMode: false,
AllowDuplicateIP: false,
HandshakeTimeout: 20 * time.Second,
DialTimeout: 3 * time.Second,
TestDialFail: false,
}
}

Expand Down
2 changes: 1 addition & 1 deletion consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -1889,7 +1889,7 @@ func (cs *State) tryAddVote(vote *types.Vote, peerID p2p.ID) (bool, error) {
// 2) not a bad peer? this can also err sometimes with "Unexpected step" OR
// 3) tmkms use with multiple validators connecting to a single tmkms instance
// (https://github.com/tendermint/tendermint/issues/3839).
cs.Logger.Info("Error attempting to add vote", "err", err)
cs.Logger.Error("Error attempting to add vote", "err", err)
return added, ErrAddingVote
}
}
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ services:
image: "tendermint/localnode"
ports:
- "26656-26657:26656-26657"
- "6060:6060"
- "9090:9090"
environment:
- ID=0
- LOG=${LOG:-tendermint.log}
Expand Down
5 changes: 5 additions & 0 deletions docs/networks/docker-compose.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ This file creates a 4-node network using the localnode image.
The nodes of the network expose their P2P and RPC endpoints to the host machine
on ports 26656-26657, 26659-26660, 26661-26662, and 26663-26664 respectively.

The first node (`node0`) exposes two additional ports: 6060 for profiling using
[`pprof`](https://golang.org/pkg/net/http/pprof), and `9090` - for Prometheus
server (if you don't know how to start one check out ["First steps |
Prometheus"](https://prometheus.io/docs/introduction/first_steps/)).

To update the binary, just rebuild it and restart the nodes:

```sh
Expand Down
5 changes: 5 additions & 0 deletions networks/local/localnode/config-template.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
[rpc]
laddr = "tcp://0.0.0.0:26657"
pprof-laddr = ":6060"

[instrumentation]
prometheus = true
prometheus-listen-addr = ":9090"
11 changes: 6 additions & 5 deletions p2p/conn/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import (
)

const (
defaultMaxPacketMsgPayloadSize = 1024
// mirrors MaxPacketMsgPayloadSize from config/config.go
defaultMaxPacketMsgPayloadSize = 1400

numBatchPacketMsgs = 10
minReadBufferSize = 1024
Expand Down Expand Up @@ -352,7 +353,7 @@ func (c *MConnection) Send(chID byte, msgBytes []byte) bool {
return false
}

c.Logger.Debug("Send", "channel", chID, "conn", c, "msgBytes", fmt.Sprintf("%X", msgBytes))
c.Logger.Debug("Send", "channel", chID, "conn", c, "msgBytes", msgBytes)

// Send message to channel.
channel, ok := c.channelsIdx[chID]
Expand All @@ -369,7 +370,7 @@ func (c *MConnection) Send(chID byte, msgBytes []byte) bool {
default:
}
} else {
c.Logger.Debug("Send failed", "channel", chID, "conn", c, "msgBytes", fmt.Sprintf("%X", msgBytes))
c.Logger.Debug("Send failed", "channel", chID, "conn", c, "msgBytes", msgBytes)
}
return success
}
Expand All @@ -381,7 +382,7 @@ func (c *MConnection) TrySend(chID byte, msgBytes []byte) bool {
return false
}

c.Logger.Debug("TrySend", "channel", chID, "conn", c, "msgBytes", fmt.Sprintf("%X", msgBytes))
c.Logger.Debug("TrySend", "channel", chID, "conn", c, "msgBytes", msgBytes)

// Send message to channel.
channel, ok := c.channelsIdx[chID]
Expand Down Expand Up @@ -640,7 +641,7 @@ FOR_LOOP:
break FOR_LOOP
}
if msgBytes != nil {
c.Logger.Debug("Received bytes", "chID", pkt.PacketMsg.ChannelID, "msgBytes", fmt.Sprintf("%X", msgBytes))
c.Logger.Debug("Received bytes", "chID", pkt.PacketMsg.ChannelID, "msgBytes", msgBytes)
// NOTE: This means the reactor.Receive runs in the same thread as the p2p recv routine
c.onReceive(byte(pkt.PacketMsg.ChannelID), msgBytes)
}
Expand Down
2 changes: 1 addition & 1 deletion p2p/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func (sw *Switch) OnStop() {
//
// NOTE: Broadcast uses goroutines, so order of broadcast may not be preserved.
func (sw *Switch) Broadcast(chID byte, msgBytes []byte) chan bool {
sw.Logger.Debug("Broadcast", "channel", chID, "msgBytes", fmt.Sprintf("%X", msgBytes))
sw.Logger.Debug("Broadcast", "channel", chID, "msgBytes", msgBytes)

peers := sw.peers.List()
var wg sync.WaitGroup
Expand Down
2 changes: 1 addition & 1 deletion rpc/jsonrpc/client/ws_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ func (c *WSClient) readRoutine() {
// c.wg.Wait() in c.Stop(). Note we rely on Quit being closed so that it sends unlimited Quit signals to stop
// both readRoutine and writeRoutine

c.Logger.Info("got response", "id", response.ID, "result", fmt.Sprintf("%X", response.Result))
c.Logger.Info("got response", "id", response.ID, "result", response.Result)

select {
case <-c.Quit():
Expand Down