Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
9be82ac9
Unverified
Commit
9be82ac9
authored
Jun 13, 2023
by
mergify[bot]
Committed by
GitHub
Jun 13, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into refcell/array/factory
parents
9bc14682
538f569b
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
20 additions
and
16 deletions
+20
-16
system_test.go
op-e2e/system_test.go
+1
-1
load_config.go
op-node/p2p/cli/load_config.go
+2
-2
config.go
op-node/p2p/config.go
+4
-4
gossip.go
op-node/p2p/gossip.go
+1
-4
host.go
op-node/p2p/host.go
+9
-1
peer_scores.go
op-node/p2p/peer_scores.go
+2
-3
peer_scores_test.go
op-node/p2p/peer_scores_test.go
+1
-1
No files found.
op-e2e/system_test.go
View file @
9be82ac9
...
@@ -816,7 +816,7 @@ func TestSystemDenseTopology(t *testing.T) {
...
@@ -816,7 +816,7 @@ func TestSystemDenseTopology(t *testing.T) {
params
,
err
:=
p2p
.
GetPeerScoreParams
(
"light"
,
2
)
params
,
err
:=
p2p
.
GetPeerScoreParams
(
"light"
,
2
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
node
.
P2P
=
&
p2p
.
Config
{
node
.
P2P
=
&
p2p
.
Config
{
PeerScoring
:
params
,
PeerScoring
:
&
params
,
BanningEnabled
:
false
,
BanningEnabled
:
false
,
}
}
}
}
...
...
op-node/p2p/cli/load_config.go
View file @
9be82ac9
...
@@ -98,7 +98,7 @@ func loadTopicScoringParams(conf *p2p.Config, ctx *cli.Context, blockTime uint64
...
@@ -98,7 +98,7 @@ func loadTopicScoringParams(conf *p2p.Config, ctx *cli.Context, blockTime uint64
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
conf
.
TopicScoring
=
topicScoreParams
conf
.
TopicScoring
=
&
topicScoreParams
}
}
return
nil
return
nil
...
@@ -114,7 +114,7 @@ func loadPeerScoringParams(conf *p2p.Config, ctx *cli.Context, blockTime uint64)
...
@@ -114,7 +114,7 @@ func loadPeerScoringParams(conf *p2p.Config, ctx *cli.Context, blockTime uint64)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
conf
.
PeerScoring
=
peerScoreParams
conf
.
PeerScoring
=
&
peerScoreParams
}
}
return
nil
return
nil
...
...
op-node/p2p/config.go
View file @
9be82ac9
...
@@ -63,8 +63,8 @@ type Config struct {
...
@@ -63,8 +63,8 @@ type Config struct {
AltSync
bool
AltSync
bool
// Pubsub Scoring Parameters
// Pubsub Scoring Parameters
PeerScoring
pubsub
.
PeerScoreParams
PeerScoring
*
pubsub
.
PeerScoreParams
TopicScoring
pubsub
.
TopicScoreParams
TopicScoring
*
pubsub
.
TopicScoreParams
// Whether to ban peers based on their [PeerScoring] score. Should be negative.
// Whether to ban peers based on their [PeerScoring] score. Should be negative.
BanningEnabled
bool
BanningEnabled
bool
...
@@ -135,7 +135,7 @@ func (conf *Config) Disabled() bool {
...
@@ -135,7 +135,7 @@ func (conf *Config) Disabled() bool {
}
}
func
(
conf
*
Config
)
PeerScoringParams
()
*
pubsub
.
PeerScoreParams
{
func
(
conf
*
Config
)
PeerScoringParams
()
*
pubsub
.
PeerScoreParams
{
return
&
conf
.
PeerScoring
return
conf
.
PeerScoring
}
}
func
(
conf
*
Config
)
BanPeers
()
bool
{
func
(
conf
*
Config
)
BanPeers
()
bool
{
...
@@ -151,7 +151,7 @@ func (conf *Config) BanDuration() time.Duration {
...
@@ -151,7 +151,7 @@ func (conf *Config) BanDuration() time.Duration {
}
}
func
(
conf
*
Config
)
TopicScoringParams
()
*
pubsub
.
TopicScoreParams
{
func
(
conf
*
Config
)
TopicScoringParams
()
*
pubsub
.
TopicScoreParams
{
return
&
conf
.
TopicScoring
return
conf
.
TopicScoring
}
}
func
(
conf
*
Config
)
ReqRespSyncEnabled
()
bool
{
func
(
conf
*
Config
)
ReqRespSyncEnabled
()
bool
{
...
...
op-node/p2p/gossip.go
View file @
9be82ac9
...
@@ -443,10 +443,7 @@ func JoinGossip(p2pCtx context.Context, self peer.ID, topicScoreParams *pubsub.T
...
@@ -443,10 +443,7 @@ func JoinGossip(p2pCtx context.Context, self peer.ID, topicScoreParams *pubsub.T
}
}
go
LogTopicEvents
(
p2pCtx
,
log
.
New
(
"topic"
,
"blocks"
),
blocksTopicEvents
)
go
LogTopicEvents
(
p2pCtx
,
log
.
New
(
"topic"
,
"blocks"
),
blocksTopicEvents
)
// A [TimeInMeshQuantum] value of 0 means the topic score is disabled.
if
topicScoreParams
!=
nil
{
// If we passed a topicScoreParams with [TimeInMeshQuantum] set to 0,
// libp2p errors since the params will be rejected.
if
topicScoreParams
!=
nil
&&
topicScoreParams
.
TimeInMeshQuantum
!=
0
{
if
err
=
blocksTopic
.
SetScoreParams
(
topicScoreParams
);
err
!=
nil
{
if
err
=
blocksTopic
.
SetScoreParams
(
topicScoreParams
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to set topic score params: %w"
,
err
)
return
nil
,
fmt
.
Errorf
(
"failed to set topic score params: %w"
,
err
)
}
}
...
...
op-node/p2p/host.go
View file @
9be82ac9
...
@@ -146,7 +146,15 @@ func (conf *Config) Host(log log.Logger, reporter metrics.Reporter, metrics Host
...
@@ -146,7 +146,15 @@ func (conf *Config) Host(log log.Logger, reporter metrics.Reporter, metrics Host
}
}
peerScoreParams
:=
conf
.
PeerScoringParams
()
peerScoreParams
:=
conf
.
PeerScoringParams
()
ps
,
err
:=
store
.
NewExtendedPeerstore
(
context
.
Background
(),
log
,
clock
.
SystemClock
,
basePs
,
conf
.
Store
,
peerScoreParams
.
RetainScore
)
var
scoreRetention
time
.
Duration
if
peerScoreParams
!=
nil
{
// Use the same retention period as gossip will if available
scoreRetention
=
peerScoreParams
.
RetainScore
}
else
{
// Disable score GC if peer scoring is disabled
scoreRetention
=
0
}
ps
,
err
:=
store
.
NewExtendedPeerstore
(
context
.
Background
(),
log
,
clock
.
SystemClock
,
basePs
,
conf
.
Store
,
scoreRetention
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to open extended peerstore: %w"
,
err
)
return
nil
,
fmt
.
Errorf
(
"failed to open extended peerstore: %w"
,
err
)
}
}
...
...
op-node/p2p/peer_scores.go
View file @
9be82ac9
...
@@ -12,14 +12,13 @@ func ConfigurePeerScoring(gossipConf GossipSetupConfigurables, scorer Scorer, lo
...
@@ -12,14 +12,13 @@ func ConfigurePeerScoring(gossipConf GossipSetupConfigurables, scorer Scorer, lo
peerScoreParams
:=
gossipConf
.
PeerScoringParams
()
peerScoreParams
:=
gossipConf
.
PeerScoringParams
()
peerScoreThresholds
:=
NewPeerScoreThresholds
()
peerScoreThresholds
:=
NewPeerScoreThresholds
()
opts
:=
[]
pubsub
.
Option
{}
opts
:=
[]
pubsub
.
Option
{}
// Check the app specific score since libp2p doesn't export it's [validate] function :/
if
peerScoreParams
!=
nil
{
if
peerScoreParams
!=
nil
&&
peerScoreParams
.
AppSpecificScore
!=
nil
{
opts
=
[]
pubsub
.
Option
{
opts
=
[]
pubsub
.
Option
{
pubsub
.
WithPeerScore
(
peerScoreParams
,
&
peerScoreThresholds
),
pubsub
.
WithPeerScore
(
peerScoreParams
,
&
peerScoreThresholds
),
pubsub
.
WithPeerScoreInspect
(
scorer
.
SnapshotHook
(),
peerScoreInspectFrequency
),
pubsub
.
WithPeerScoreInspect
(
scorer
.
SnapshotHook
(),
peerScoreInspectFrequency
),
}
}
}
else
{
}
else
{
log
.
Warn
(
"Proceeding with no peer scoring...
\n
Missing AppSpecificScore in peer scoring params
"
)
log
.
Info
(
"Peer scoring disabled
"
)
}
}
return
opts
return
opts
}
}
op-node/p2p/peer_scores_test.go
View file @
9be82ac9
...
@@ -102,7 +102,7 @@ func newGossipSubs(testSuite *PeerScoresTestSuite, ctx context.Context, hosts []
...
@@ -102,7 +102,7 @@ func newGossipSubs(testSuite *PeerScoresTestSuite, ctx context.Context, hosts []
&
rollup
.
Config
{
L2ChainID
:
big
.
NewInt
(
123
)},
&
rollup
.
Config
{
L2ChainID
:
big
.
NewInt
(
123
)},
extPeerStore
,
testSuite
.
mockMetricer
,
logger
)
extPeerStore
,
testSuite
.
mockMetricer
,
logger
)
opts
=
append
(
opts
,
ConfigurePeerScoring
(
&
Config
{
opts
=
append
(
opts
,
ConfigurePeerScoring
(
&
Config
{
PeerScoring
:
pubsub
.
PeerScoreParams
{
PeerScoring
:
&
pubsub
.
PeerScoreParams
{
AppSpecificScore
:
func
(
p
peer
.
ID
)
float64
{
AppSpecificScore
:
func
(
p
peer
.
ID
)
float64
{
if
p
==
hosts
[
0
]
.
ID
()
{
if
p
==
hosts
[
0
]
.
ID
()
{
return
-
1000
return
-
1000
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment