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

Fixes & bump dependencies for v3 #269

Merged
merged 2 commits into from
Dec 12, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: 1.17.6
go-version: 1.20.7
id: go

- name: Check out code into the Go module directory
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: 1.17.6
go-version: 1.20.7
id: go

- name: Check out code into the Go module directory
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: 1.17.6
go-version: 1.20.7
id: go

- name: Check out code into the Go module directory
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.17.6
go-version: 1.20.7
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.45.2
version: v1.53.2

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: 1.17.6
go-version: 1.20.7
id: go

- name: Check out code
Expand Down
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ build-cmd:
(cd cmd && go build)

clean-test:
go clean -testcache ./...

clean: clean-test
go clean -cache ./...
go clean ./...
go clean -testcache

test: clean-test
go test ./...
Expand Down
8 changes: 4 additions & 4 deletions api/gin/webServer.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ var log = logger.GetOrCreate("api")
type ArgsNewWebServer struct {
Facade shared.FacadeHandler
ApiConfig config.ApiRoutesConfig
AntiFloodConfig config.AntifloodConfig
AntiFloodConfig config.WebAntifloodConfig
}

type webServer struct {
sync.RWMutex
facade shared.FacadeHandler
apiConfig config.ApiRoutesConfig
antiFloodConfig config.AntifloodConfig
antiFloodConfig config.WebAntifloodConfig
httpServer chainShared.HttpServerCloser
groups map[string]shared.GroupHandler
cancelFunc func()
Expand Down Expand Up @@ -116,9 +116,9 @@ func (ws *webServer) StartHttpServer() error {

ws.registerRoutes(engine)

server := &http.Server{Addr: ws.facade.RestApiInterface(), Handler: engine}
serverInstance := &http.Server{Addr: ws.facade.RestApiInterface(), Handler: engine}
log.Debug("creating gin web sever", "interface", ws.facade.RestApiInterface())
ws.httpServer, err = NewHttpServer(server)
ws.httpServer, err = NewHttpServer(serverInstance)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion api/gin/webServer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func createMockArgsNewWebServer() ArgsNewWebServer {
},
APIPackages: make(map[string]config.APIPackageConfig),
},
AntiFloodConfig: config.AntifloodConfig{
AntiFloodConfig: config.WebAntifloodConfig{
Enabled: true,
WebServer: config.WebServerAntifloodConfig{
SimultaneousRequests: 1,
Expand Down
48 changes: 27 additions & 21 deletions cmd/bridge/config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
MaxRetriesOnWasTransferProposed = 3
ProxyCacherExpirationSeconds = 600 # the caching time in seconds

# valid options for ProxyRestAPIEntityType are `observer` and `proxy`. Any other value will trigger an error.
# `observer` is useful when querying an observer, directly and `proxy` is useful when querying a squad's proxy
# valid options for ProxyRestAPIEntityType are "observer" and "proxy". Any other value will trigger an error.
# "observer" is useful when querying an observer, directly and "proxy" is useful when querying a squad's proxy (gateway)
ProxyRestAPIEntityType = "observer"
ProxyFinalityCheck = true
ProxyMaxNoncesDelta = 7 # the number of maximum blocks allowed to be "in front" of what the metachain has notarized
Expand All @@ -48,63 +48,70 @@
Port = "10010"
InitialPeerList = []
ProtocolID = "/erd/relay/1.0.0"
[AntifloodConfig]
[P2P.Transports]
QUICAddress = "" # optional QUIC address. If this transport should be activated, should be in this format: /ip4/0.0.0.0/udp/%d/quic-v1
WebSocketAddress = "" # optional WebSocket address. If this transport should be activated, should be in this format: /ip4/0.0.0.0/tcp/%d/ws
WebTransportAddress = "" # optional WebTransport address. If this transport should be activated, should be in this format: /ip4/0.0.0.0/udp/%d/quic-v1/webtransport
[P2P.Transports.TCP]
ListenAddress = "/ip4/0.0.0.0/tcp/%d" # TCP listen address
PreventPortReuse = false
[P2P.AntifloodConfig]
Enabled = true
NumConcurrentResolverJobs = 50
[Antiflood.FastReacting]
[P2P.AntifloodConfig.FastReacting]
IntervalInSeconds = 1
ReservedPercent = 20.0
[Antiflood.FastReacting.PeerMaxInput]
[P2P.AntifloodConfig.FastReacting.PeerMaxInput]
BaseMessagesPerInterval = 10
TotalSizePerInterval = 1048576 #1MB/s
[Antiflood.FastReacting.PeerMaxInput.IncreaseFactor]
[P2P.AntifloodConfig.FastReacting.PeerMaxInput.IncreaseFactor]
Threshold = 10 #if consensus size will exceed this value, then
Factor = 1.0 #increase the base value with [factor*consensus size]
[Antiflood.FastReacting.BlackList]
[P2P.AntifloodConfig.FastReacting.BlackList]
ThresholdNumMessagesPerInterval = 70
ThresholdSizePerInterval = 2097154 #2MB/s
NumFloodingRounds = 10
PeerBanDurationInSeconds = 300

[Antiflood.SlowReacting]
[P2P.AntifloodConfig.SlowReacting]
IntervalInSeconds = 30
ReservedPercent = 20.0
[Antiflood.SlowReacting.PeerMaxInput]
[P2P.AntifloodConfig.SlowReacting.PeerMaxInput]
BaseMessagesPerInterval = 400
TotalSizePerInterval = 10485760 #10MB/interval
[Antiflood.SlowReacting.PeerMaxInput.IncreaseFactor]
[P2P.AntifloodConfig.SlowReacting.PeerMaxInput.IncreaseFactor]
Threshold = 10 #if consensus size will exceed this value, then
Factor = 0.0 #increase the base value with [factor*consensus size]
[Antiflood.SlowReacting.BlackList]
[P2P.AntifloodConfig.SlowReacting.BlackList]
ThresholdNumMessagesPerInterval = 800
ThresholdSizePerInterval = 20971540 #20MB/interval
NumFloodingRounds = 2
PeerBanDurationInSeconds = 3600

[Antiflood.OutOfSpecs]
[P2P.AntifloodConfig.OutOfSpecs]
IntervalInSeconds = 1
ReservedPercent = 0.0
[Antiflood.OutOfSpecs.PeerMaxInput]
[P2P.AntifloodConfig.OutOfSpecs.PeerMaxInput]
BaseMessagesPerInterval = 140
TotalSizePerInterval = 4194304 #4MB/s
[Antiflood.OutOfSpecs.PeerMaxInput.IncreaseFactor]
[P2P.AntifloodConfig.OutOfSpecs.PeerMaxInput.IncreaseFactor]
Threshold = 0 #if consensus size will exceed this value, then
Factor = 0.0 #increase the base value with [factor*consensus size]
[Antiflood.OutOfSpecs.BlackList]
[P2P.AntifloodConfig.OutOfSpecs.BlackList]
ThresholdNumMessagesPerInterval = 200
ThresholdSizePerInterval = 6291456 #6MB/s
NumFloodingRounds = 2
PeerBanDurationInSeconds = 3600

[Antiflood.PeerMaxOutput]
[P2P.AntifloodConfig.PeerMaxOutput]
BaseMessagesPerInterval = 5
TotalSizePerInterval = 524288 #512KB/s

[Antiflood.Cache]
[P2P.AntifloodConfig.Cache]
Name = "Antiflood"
Capacity = 7000
Type = "LRU"
[Antiflood.Topic]
[P2P.AntifloodConfig.Topic]
DefaultMaxMessagesPerSec = 300 # default number of messages per interval for a topic
MaxMessages = [{ Topic = "EthereumToMultiversX_join", NumMessagesPerSec = 100 },
{ Topic = "EthereumToMultiversX_sign", NumMessagesPerSec = 100 }]
Expand All @@ -114,7 +121,6 @@
Type = "gogo protobuf"
SizeCheckDelta = 10
[Relayer.RoleProvider]
UsePolling = true
PollingIntervalInMillis = 60000 # 1 minute
[Relayer.StatusMetricsStorage]
[Relayer.StatusMetricsStorage.Cache]
Expand All @@ -141,9 +147,9 @@
LogFileLifeSpanInSec = 86400 # 24h
LogFileLifeSpanInMB = 1024 # 1GB

[Antiflood]
[WebAntiflood]
Enabled = true
[Antiflood.WebServer]
[WebAntiflood.WebServer]
# SimultaneousRequests represents the number of concurrent requests accepted by the web server
# this is a global throttler that acts on all http connections regardless of the originating source
SimultaneousRequests = 100
Expand Down
10 changes: 6 additions & 4 deletions cmd/bridge/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ var log = logger.GetOrCreate("main")
// appVersion should be populated at build time using ldflags
// Usage examples:
// linux/mac:
// go build -i -v -ldflags="-X main.appVersion=$(git describe --tags --long --dirty)"
//
// go build -i -v -ldflags="-X main.appVersion=$(git describe --tags --long --dirty)"
//
// windows:
// for /f %i in ('git describe --tags --long --dirty') do set VERS=%i
// go build -i -v -ldflags="-X main.appVersion=%VERS%"
//
// for /f %i in ('git describe --tags --long --dirty') do set VERS=%i
// go build -i -v -ldflags="-X main.appVersion=%VERS%"
var appVersion = chainCommon.UnVersionedAppString

func main() {
Expand Down Expand Up @@ -395,7 +398,6 @@ func buildNetMessenger(cfg config.Config, marshalizer marshal.Marshalizer) (p2p.
p2pPrivKey, _ := p2pKeyGen.GeneratePair()

args := libp2p.ArgsNetworkMessenger{
ListenAddress: chainP2P.ListenAddrWithIp4AndTcp,
Marshalizer: marshalizer,
P2pConfig: p2pCfg,
SyncTimer: &libp2p.LocalSyncTimer{},
Expand Down
8 changes: 5 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package config
import (
"github.com/multiversx/mx-bridge-eth-go/clients/chain"
"github.com/multiversx/mx-chain-go/config"
p2pConfig "github.com/multiversx/mx-chain-go/p2p/config"
)

// Configs is a holder for the relayer configuration parameters
Expand All @@ -20,7 +21,7 @@ type Config struct {
StateMachine map[string]ConfigStateMachine
Relayer ConfigRelayer
Logs LogsConfig
Antiflood AntifloodConfig
WebAntiflood WebAntifloodConfig
BatchValidator BatchValidatorConfig
PeersRatingConfig PeersRatingConfig
}
Expand Down Expand Up @@ -59,6 +60,7 @@ type ConfigP2P struct {
Port string
InitialPeerList []string
ProtocolID string
Transports p2pConfig.P2PTransportConfig
AntifloodConfig config.AntifloodConfig
}

Expand Down Expand Up @@ -95,8 +97,8 @@ type WebServerAntifloodConfig struct {
SameSourceResetIntervalInSec uint32
}

// AntifloodConfig will hold all p2p antiflood parameters
type AntifloodConfig struct {
// WebAntifloodConfig will hold all web antiflood parameters
type WebAntifloodConfig struct {
Enabled bool
WebServer WebServerAntifloodConfig
}
Expand Down
Loading