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
b857ed65
Unverified
Commit
b857ed65
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 fix-chain-id-log
parents
b748d81f
c2f6c681
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
50 additions
and
16 deletions
+50
-16
registry.go
op-bindings/bindings/registry.go
+30
-0
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-bindings/bindings/registry.go
View file @
b857ed65
...
@@ -2,15 +2,20 @@ package bindings
...
@@ -2,15 +2,20 @@ package bindings
import
(
import
(
"fmt"
"fmt"
"strings"
"github.com/ethereum-optimism/optimism/op-bindings/solc"
"github.com/ethereum-optimism/optimism/op-bindings/solc"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
)
)
// layouts respresents the set of storage layouts. It is populated in an init function.
var
layouts
=
make
(
map
[
string
]
*
solc
.
StorageLayout
)
var
layouts
=
make
(
map
[
string
]
*
solc
.
StorageLayout
)
// deployedBytecodes represents the set of deployed bytecodes. It is populated
// in an init function.
var
deployedBytecodes
=
make
(
map
[
string
]
string
)
var
deployedBytecodes
=
make
(
map
[
string
]
string
)
// GetStorageLayout returns the storage layout of a contract by name.
func
GetStorageLayout
(
name
string
)
(
*
solc
.
StorageLayout
,
error
)
{
func
GetStorageLayout
(
name
string
)
(
*
solc
.
StorageLayout
,
error
)
{
layout
:=
layouts
[
name
]
layout
:=
layouts
[
name
]
if
layout
==
nil
{
if
layout
==
nil
{
...
@@ -19,11 +24,36 @@ func GetStorageLayout(name string) (*solc.StorageLayout, error) {
...
@@ -19,11 +24,36 @@ func GetStorageLayout(name string) (*solc.StorageLayout, error) {
return
layout
,
nil
return
layout
,
nil
}
}
// GetDeployedBytecode returns the deployed bytecode of a contract by name.
func
GetDeployedBytecode
(
name
string
)
([]
byte
,
error
)
{
func
GetDeployedBytecode
(
name
string
)
([]
byte
,
error
)
{
bc
:=
deployedBytecodes
[
name
]
bc
:=
deployedBytecodes
[
name
]
if
bc
==
""
{
if
bc
==
""
{
return
nil
,
fmt
.
Errorf
(
"%s: deployed bytecode not found"
,
name
)
return
nil
,
fmt
.
Errorf
(
"%s: deployed bytecode not found"
,
name
)
}
}
if
!
isHex
(
bc
)
{
return
nil
,
fmt
.
Errorf
(
"%s: invalid deployed bytecode"
,
name
)
}
return
common
.
FromHex
(
bc
),
nil
return
common
.
FromHex
(
bc
),
nil
}
}
// isHexCharacter returns bool of c being a valid hexadecimal.
func
isHexCharacter
(
c
byte
)
bool
{
return
(
'0'
<=
c
&&
c
<=
'9'
)
||
(
'a'
<=
c
&&
c
<=
'f'
)
||
(
'A'
<=
c
&&
c
<=
'F'
)
}
// isHex validates whether each byte is valid hexadecimal string.
func
isHex
(
str
string
)
bool
{
if
len
(
str
)
%
2
!=
0
{
return
false
}
str
=
strings
.
TrimPrefix
(
str
,
"0x"
)
for
_
,
c
:=
range
[]
byte
(
str
)
{
if
!
isHexCharacter
(
c
)
{
return
false
}
}
return
true
}
op-e2e/system_test.go
View file @
b857ed65
...
@@ -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 @
b857ed65
...
@@ -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 @
b857ed65
...
@@ -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 @
b857ed65
...
@@ -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 @
b857ed65
...
@@ -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 @
b857ed65
...
@@ -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 @
b857ed65
...
@@ -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