-
Notifications
You must be signed in to change notification settings - Fork 479
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
p2p: test scenarios support #5962
Merged
algorandskiy
merged 48 commits into
algorand:feature/p2p
from
algorandskiy:pavel/p2p-scenarios
Jun 12, 2024
Merged
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
356dd08
add p2p dnsadddr support to netdeploy
algorandskiy b86c22f
add a minimal p2p cluster test scenario
algorandskiy 3110bf7
Add logging
algorandskiy c01e430
fixes: peerID string, network data dir vs genesis dir
algorandskiy 7de8e80
fix tests
algorandskiy 4f13174
Make scenarion1s rounds smaller
algorandskiy 06d52dd
add scenario1s-p2p
algorandskiy 3255688
rename hw-p2p to hw-tiny-p2p
algorandskiy 43f91c1
add hw-small-p2p
algorandskiy e2d6d88
enable metrics on all hello-world-small-p2p nodes
algorandskiy 0b1198a
heapwatch scripts fix - metric and empty {}
algorandskiy d842a15
emable runtime mertics in hello-world-small-p2p
algorandskiy 018bbd7
add more block data plots
algorandskiy 8545d6c
fix prometheus metrics collection
algorandskiy 9d0d4bc
extend logging
algorandskiy 98e9d4f
more logging
algorandskiy 99e5804
make libp2p logger to log into node.log
algorandskiy a8bbffe
fix linter
algorandskiy cae5145
fix scenario1s-p2p Makefile
algorandskiy 4d4222e
log p2p htto host id
algorandskiy 56844bd
implement gossipSubPeer.RoutingAddr
algorandskiy 017d5b7
make gossipSubPeer hashable
algorandskiy 132ab28
set pubsub number workers to 20
algorandskiy 5a4879d
heapwatch scripts for p2p topology visualization
algorandskiy 10dc270
add network-related graph stats
algorandskiy 12aac6e
support topology vizualization for wsnet
algorandskiy 3e965fe
use StrictNoSign on gossibsub messages
algorandskiy fe0d4bb
wip: try yamux high prio fork
algorandskiy 952b398
copy libp2p muxer to use forked yamux
algorandskiy 8f6e578
heapwatch metrics viz: fix ip to names resolution
algorandskiy 0cf4dc4
metric_viz: store html
algorandskiy f0ed6e5
metric_viz: nodes filtering
algorandskiy 739f10f
metric_viz fixes
algorandskiy 06a0282
metrics_viz: support metrics with tags
algorandskiy ea3d65c
fix opensensus metrics names
algorandskiy 73b9519
metrics_viz refactoring, add metrics_aggs
algorandskiy 9c3d134
topology scripts: support missing local addr
algorandskiy 2666244
use connection direction for conn counting instead of stream direction
algorandskiy 1358067
agreement node.log aggregator
algorandskiy 6f2d5fc
Add connection timestamp to topology parser
algorandskiy c0d2e78
add DNSSecurityFlags=dnssecTXT flag to config
algorandskiy e794266
fix outgoing conn counting
algorandskiy d05aa9c
add exp backoff to mesh thread
algorandskiy b27c949
post rebase fixes
algorandskiy cb06762
linter fixes
algorandskiy 5942217
round time in agreement log
algorandskiy 78a35fe
Revert "copy libp2p muxer to use forked yamux"
algorandskiy e59fd47
Revert "wip: try yamux high prio fork"
algorandskiy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -268,6 +268,7 @@ const ( | |
dnssecSRV = 1 << iota | ||
dnssecRelayAddr | ||
dnssecTelemetryAddr | ||
dnssecTXT | ||
) | ||
|
||
const ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
// Copyright (C) 2019-2024 Algorand, Inc. | ||
// This file is part of go-algorand | ||
// | ||
// go-algorand is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as | ||
// published by the Free Software Foundation, either version 3 of the | ||
// License, or (at your option) any later version. | ||
// | ||
// go-algorand is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with go-algorand. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
// This package implement a zap.Core in order to wrap lip2p logger into algod's logger. | ||
|
||
package p2p | ||
|
||
import ( | ||
"runtime" | ||
|
||
p2plogging "github.com/ipfs/go-log/v2" | ||
"github.com/sirupsen/logrus" | ||
"go.uber.org/zap/zapcore" | ||
|
||
"github.com/algorand/go-algorand/logging" | ||
) | ||
|
||
// var levelsMap = map[logging.Level]zapcore.Level{ | ||
// logging.Debug: zapcore.DebugLevel, | ||
// logging.Info: zapcore.InfoLevel, | ||
// logging.Warn: zapcore.WarnLevel, | ||
// logging.Error: zapcore.ErrorLevel, | ||
// logging.Fatal: zapcore.FatalLevel, | ||
// logging.Panic: zapcore.PanicLevel, | ||
// } | ||
|
||
var levelsMap = map[zapcore.Level]logging.Level{ | ||
zapcore.DebugLevel: logging.Debug, | ||
zapcore.InfoLevel: logging.Info, | ||
zapcore.WarnLevel: logging.Warn, | ||
zapcore.ErrorLevel: logging.Error, | ||
zapcore.FatalLevel: logging.Fatal, | ||
zapcore.PanicLevel: logging.Panic, | ||
} | ||
|
||
// loggingCore implements zapcore.Core | ||
type loggingCore struct { | ||
log logging.Logger | ||
level logging.Level | ||
fields []zapcore.Field | ||
zapcore.Core | ||
} | ||
|
||
// EnableP2PLogging enables libp2p logging into the provided logger with the provided level. | ||
func EnableP2PLogging(log logging.Logger, l logging.Level) { | ||
core := loggingCore{ | ||
log: log, | ||
level: l, | ||
} | ||
for p2pLevel, logLevel := range levelsMap { | ||
if logLevel == l { | ||
p2plogging.SetAllLoggers(p2plogging.LogLevel(p2pLevel)) | ||
break | ||
} | ||
} | ||
p2plogging.SetPrimaryCore(&core) | ||
} | ||
|
||
func (c *loggingCore) Enabled(l zapcore.Level) bool { | ||
return c.log.IsLevelEnabled(c.level) | ||
} | ||
|
||
func (c *loggingCore) With(fields []zapcore.Field) zapcore.Core { | ||
return &loggingCore{ | ||
log: c.log, | ||
level: c.level, | ||
fields: append(c.fields, fields...), | ||
} | ||
} | ||
|
||
func (c *loggingCore) Check(e zapcore.Entry, ce *zapcore.CheckedEntry) *zapcore.CheckedEntry { | ||
if c.Enabled(e.Level) { | ||
return ce.AddCore(e, c) | ||
} | ||
return ce | ||
} | ||
|
||
func (c *loggingCore) Write(e zapcore.Entry, fields []zapcore.Field) error { | ||
allFields := append(c.fields, fields...) | ||
loggingFields := make(logging.Fields, len(allFields)) | ||
|
||
for _, f := range allFields { | ||
if len(f.String) > 0 { | ||
loggingFields[f.Key] = f.String | ||
} else if f.Interface != nil { | ||
loggingFields[f.Key] = f.Interface | ||
} else { | ||
loggingFields[f.Key] = f.Integer | ||
} | ||
} | ||
event := c.log.WithFields(loggingFields).With("libp2p", e.LoggerName) | ||
event = event.WithFields(logrus.Fields{ | ||
"file": e.Caller.File, | ||
"line": e.Caller.Line, | ||
}) | ||
if function := runtime.FuncForPC(e.Caller.PC); function != nil { | ||
event = event.With("function", function.Name()) | ||
} | ||
event.Entry().Log(logrus.Level(levelsMap[e.Level]), e.Message) | ||
return nil | ||
} | ||
|
||
func (c *loggingCore) Sync() error { | ||
return nil | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it is OK to ignore the field type because they all boil down to one of these three types?