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
78926c36
Unverified
Commit
78926c36
authored
May 04, 2023
by
mergify[bot]
Committed by
GitHub
May 04, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into felipe/log-level
parents
fb6d11aa
2b56105a
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
18 deletions
+34
-18
backend.go
proxyd/backend.go
+8
-0
config.go
proxyd/config.go
+12
-11
consensus_poller.go
proxyd/consensus_poller.go
+10
-7
example.config.toml
proxyd/example.config.toml
+3
-0
proxyd.go
proxyd/proxyd.go
+1
-0
No files found.
proxyd/backend.go
View file @
78926c36
...
...
@@ -132,6 +132,8 @@ type Backend struct {
stripTrailingXFF
bool
proxydIP
string
skipPeerCountCheck
bool
maxDegradedLatencyThreshold
time
.
Duration
maxLatencyThreshold
time
.
Duration
maxErrorRateThreshold
float64
...
...
@@ -207,6 +209,12 @@ func WithProxydIP(ip string) BackendOpt {
}
}
func
WithSkipPeerCountCheck
(
skipPeerCountCheck
bool
)
BackendOpt
{
return
func
(
b
*
Backend
)
{
b
.
skipPeerCountCheck
=
skipPeerCountCheck
}
}
func
WithMaxDegradedLatencyThreshold
(
maxDegradedLatencyThreshold
time
.
Duration
)
BackendOpt
{
return
func
(
b
*
Backend
)
{
b
.
maxDegradedLatencyThreshold
=
maxDegradedLatencyThreshold
...
...
proxyd/config.go
View file @
78926c36
...
...
@@ -92,6 +92,7 @@ type BackendConfig struct {
ClientCertFile
string
`toml:"client_cert_file"`
ClientKeyFile
string
`toml:"client_key_file"`
StripTrailingXFF
bool
`toml:"strip_trailing_xff"`
SkipPeerCountCheck
bool
`toml:"consensus_skip_peer_count"`
}
type
BackendsConfig
map
[
string
]
*
BackendConfig
...
...
proxyd/consensus_poller.go
View file @
78926c36
...
...
@@ -227,11 +227,14 @@ func (cp *ConsensusPoller) UpdateBackend(ctx context.Context, be *Backend) {
return
}
peerCount
,
err
:=
cp
.
getPeerCount
(
ctx
,
be
)
var
peerCount
uint64
if
!
be
.
skipPeerCountCheck
{
peerCount
,
err
=
cp
.
getPeerCount
(
ctx
,
be
)
if
err
!=
nil
{
log
.
Warn
(
"error updating backend"
,
"name"
,
be
.
Name
,
"err"
,
err
)
return
}
}
latestBlockNumber
,
latestBlockHash
,
err
:=
cp
.
fetchBlock
(
ctx
,
be
,
"latest"
)
if
err
!=
nil
{
...
...
@@ -257,7 +260,7 @@ func (cp *ConsensusPoller) UpdateBackendGroupConsensus(ctx context.Context) {
for
_
,
be
:=
range
cp
.
backendGroup
.
Backends
{
peerCount
,
backendLatestBlockNumber
,
backendLatestBlockHash
,
lastUpdate
:=
cp
.
getBackendState
(
be
)
if
peerCount
<
cp
.
minPeerCount
{
if
!
be
.
skipPeerCountCheck
&&
peerCount
<
cp
.
minPeerCount
{
continue
}
if
lastUpdate
.
Add
(
cp
.
maxUpdateThreshold
)
.
Before
(
time
.
Now
())
{
...
...
@@ -306,7 +309,7 @@ func (cp *ConsensusPoller) UpdateBackendGroupConsensus(ctx context.Context) {
bs
:=
cp
.
backendState
[
be
]
notUpdated
:=
bs
.
lastUpdate
.
Add
(
cp
.
maxUpdateThreshold
)
.
Before
(
time
.
Now
())
isBanned
:=
time
.
Now
()
.
Before
(
bs
.
bannedUntil
)
notEnoughPeers
:=
bs
.
peerCount
<
cp
.
minPeerCount
notEnoughPeers
:=
!
be
.
skipPeerCountCheck
&&
bs
.
peerCount
<
cp
.
minPeerCount
if
!
be
.
IsHealthy
()
||
be
.
IsRateLimited
()
||
!
be
.
Online
()
||
notUpdated
||
isBanned
||
notEnoughPeers
{
filteredBackendsNames
=
append
(
filteredBackendsNames
,
be
.
Name
)
continue
...
...
@@ -384,7 +387,7 @@ func (cp *ConsensusPoller) fetchBlock(ctx context.Context, be *Backend, block st
return
}
//
isSyncing Convenient wrapper to check if the backend is syncing from the network
//
getPeerCount Convenient wrapper to retrieve the current peer count from the backend
func
(
cp
*
ConsensusPoller
)
getPeerCount
(
ctx
context
.
Context
,
be
*
Backend
)
(
count
uint64
,
err
error
)
{
var
rpcRes
RPCRes
err
=
be
.
ForwardRPC
(
ctx
,
&
rpcRes
,
"67"
,
"net_peerCount"
)
...
...
proxyd/example.config.toml
View file @
78926c36
...
...
@@ -72,6 +72,9 @@ ca_file = ""
client_cert_file
=
""
# Path to a custom client key file.
client_key_file
=
""
# Allows backends to skip peer count checking, default false
# consensus_skip_peer_count = true
[backends.alchemy]
rpc_url
=
""
...
...
proxyd/proxyd.go
View file @
78926c36
...
...
@@ -157,6 +157,7 @@ func Start(config *Config) (*Server, func(), error) {
opts
=
append
(
opts
,
WithStrippedTrailingXFF
())
}
opts
=
append
(
opts
,
WithProxydIP
(
os
.
Getenv
(
"PROXYD_IP"
)))
opts
=
append
(
opts
,
WithSkipPeerCountCheck
(
cfg
.
SkipPeerCountCheck
))
back
:=
NewBackend
(
name
,
rpcURL
,
wsURL
,
lim
,
rpcRequestSemaphore
,
opts
...
)
backendNames
=
append
(
backendNames
,
name
)
...
...
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