Skip to content

Commit

Permalink
Merge branch 'main' into revert-validator-wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxMustermann2 authored Nov 20, 2021
2 parents fde5b00 + d5a8969 commit 257d473
Show file tree
Hide file tree
Showing 59 changed files with 935 additions and 257 deletions.
2 changes: 1 addition & 1 deletion accounts/external/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/signer/core"
"github.com/harmony-one/harmony/accounts"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/eth/rpc"
)

// ExternalBackend is a struct for external backend
Expand Down
6 changes: 0 additions & 6 deletions api/service/blockproposal/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package blockproposal
import (
msg_pb "github.com/harmony-one/harmony/api/proto/message"
"github.com/harmony-one/harmony/consensus"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/internal/utils"
)

Expand Down Expand Up @@ -43,8 +42,3 @@ func (s *Service) Stop() error {
utils.Logger().Info().Msg("Role conversion stopped.")
return nil
}

// APIs for the services.
func (s *Service) APIs() []rpc.API {
return nil
}
6 changes: 0 additions & 6 deletions api/service/consensus/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
msg_pb "github.com/harmony-one/harmony/api/proto/message"
"github.com/harmony-one/harmony/consensus"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/internal/utils"
)

Expand Down Expand Up @@ -41,8 +40,3 @@ func (s *Service) Stop() error {
utils.Logger().Info().Msg("Consensus service stopped.")
return s.consensus.Close()
}

// APIs for the services.
func (s *Service) APIs() []rpc.API {
return nil
}
6 changes: 0 additions & 6 deletions api/service/explorer/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/gorilla/mux"
msg_pb "github.com/harmony-one/harmony/api/proto/message"
"github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy"
"github.com/harmony-one/harmony/internal/chain"
nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
Expand Down Expand Up @@ -294,11 +293,6 @@ func (s *Service) SetMessageChan(messageChan chan *msg_pb.Message) {
s.messageChan = messageChan
}

// APIs for the services.
func (s *Service) APIs() []rpc.API {
return nil
}

func defaultDBPath(ip, port string) string {
return path.Join(nodeconfig.GetDefaultConfig().DBDir, "explorer_storage_"+ip+"_"+port)
}
2 changes: 0 additions & 2 deletions api/service/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package service
import (
"fmt"

"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/internal/utils"
"github.com/pkg/errors"
"github.com/rs/zerolog"
Expand Down Expand Up @@ -52,7 +51,6 @@ func (t Type) String() string {
type Service interface {
Start() error
Stop() error
APIs() []rpc.API // the list of RPC descriptors the service provides
}

// Manager stores all services for service manager.
Expand Down
2 changes: 1 addition & 1 deletion api/service/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"testing"

"github.com/harmony-one/harmony/eth/rpc"
"github.com/ethereum/go-ethereum/rpc"
)

func TestManager_StartServices(t *testing.T) {
Expand Down
6 changes: 0 additions & 6 deletions api/service/pprof/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"sync"
"time"

"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/internal/utils"
)

Expand Down Expand Up @@ -127,11 +126,6 @@ func (s *Service) Stop() error {
return nil
}

// APIs return all APIs of the service
func (s *Service) APIs() []rpc.API {
return nil
}

// scheduleProfile schedules the provided profile based on the specified interval (e.g. saves the profile every x seconds)
func scheduleProfile(profile Profile, dir string) {
go func() {
Expand Down
6 changes: 0 additions & 6 deletions api/service/prometheus/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"sync"
"time"

"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/internal/utils"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
Expand Down Expand Up @@ -181,11 +180,6 @@ func (s *Service) Status() error {
return nil
}

// APIs returns the RPC apis of the prometheus service
func (s *Service) APIs() []rpc.API {
return nil
}

func (s *Service) getRegistry() *prometheus.Registry {
s.registryOnce.Do(func() {
if svc.registry == nil {
Expand Down
6 changes: 0 additions & 6 deletions api/service/synchronize/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package synchronize

import (
"github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy/downloader"
"github.com/harmony-one/harmony/p2p"
)
Expand Down Expand Up @@ -30,8 +29,3 @@ func (s *Service) Stop() error {
s.Downloaders.Close()
return nil
}

// APIs return all APIs of the service
func (s *Service) APIs() []rpc.API {
return nil
}
7 changes: 5 additions & 2 deletions cmd/bootnode/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (
"path"

"github.com/ethereum/go-ethereum/log"
"github.com/harmony-one/harmony/internal/utils"
"github.com/harmony-one/harmony/p2p"
net "github.com/libp2p/go-libp2p-core/network"
ma "github.com/multiformats/go-multiaddr"

"github.com/harmony-one/harmony/internal/utils"
"github.com/harmony-one/harmony/p2p"
)

// ConnLogger ..
Expand Down Expand Up @@ -99,6 +100,7 @@ func main() {
versionFlag := flag.Bool("version", false, "Output version info")
verbosity := flag.Int("verbosity", 5, "Logging verbosity: 0=silent, 1=error, 2=warn, 3=info, 4=debug, 5=detail (default: 5)")
logConn := flag.Bool("log_conn", false, "log incoming/outgoing connections")
maxConnPerIP := flag.Int("max_conn_per_ip", 10, "max connections number for same ip")

flag.Parse()

Expand All @@ -124,6 +126,7 @@ func main() {
BLSKey: privKey,
BootNodes: nil, // Boot nodes have no boot nodes :) Will be connected when other nodes joined
DataStoreFile: &dataStorePath,
MaxConnPerIP: *maxConnPerIP,
})
if err != nil {
utils.FatalErrMsg(err, "cannot initialize network")
Expand Down
23 changes: 21 additions & 2 deletions cmd/harmony/config_migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"errors"
"fmt"

goversion "github.com/hashicorp/go-version"
"github.com/pelletier/go-toml"

"github.com/harmony-one/harmony/api/service/legacysync"
harmonyconfig "github.com/harmony-one/harmony/internal/configs/harmony"
nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
goversion "github.com/hashicorp/go-version"
"github.com/pelletier/go-toml"
)

const legacyConfigVersion = "1.0.4"
Expand Down Expand Up @@ -201,4 +202,22 @@ func init() {
confTree.Set("Version", "2.3.0")
return confTree
}

migrations["2.3.0"] = func(confTree *toml.Tree) *toml.Tree {
if confTree.Get("P2P.MaxConnsPerIP") == nil {
confTree.Set("P2P.MaxConnsPerIP", defaultConfig.P2P.MaxConnsPerIP)
}

confTree.Set("Version", "2.4.0")
return confTree
}

migrations["2.4.0"] = func(confTree *toml.Tree) *toml.Tree {
if confTree.Get("WS.AuthPort") == nil {
confTree.Set("WS.AuthPort", defaultConfig.WS.AuthPort)
}

confTree.Set("Version", "2.5.0")
return confTree
}
}
10 changes: 6 additions & 4 deletions cmd/harmony/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
)

const tomlConfigVersion = "2.3.0"
const tomlConfigVersion = "2.5.0"

const (
defNetworkType = nodeconfig.Mainnet
Expand All @@ -28,6 +28,7 @@ var defaultConfig = harmonyconfig.HarmonyConfig{
IP: nodeconfig.DefaultPublicListenIP,
KeyFile: "./.hmykey",
DiscConcurrency: nodeconfig.DefaultP2PConcurrency,
MaxConnsPerIP: nodeconfig.DefaultMaxConnPerIP,
},
HTTP: harmonyconfig.HttpConfig{
Enabled: true,
Expand All @@ -38,9 +39,10 @@ var defaultConfig = harmonyconfig.HarmonyConfig{
RosettaPort: nodeconfig.DefaultRosettaPort,
},
WS: harmonyconfig.WsConfig{
Enabled: true,
IP: "127.0.0.1",
Port: nodeconfig.DefaultWSPort,
Enabled: true,
IP: "127.0.0.1",
Port: nodeconfig.DefaultWSPort,
AuthPort: nodeconfig.DefaultAuthWSPort,
},
RPCOpt: harmonyconfig.RpcOptConfig{
DebugEnabled: false,
Expand Down
23 changes: 22 additions & 1 deletion cmd/harmony/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (

harmonyconfig "github.com/harmony-one/harmony/internal/configs/harmony"

"github.com/spf13/cobra"

"github.com/harmony-one/harmony/api/service/legacysync"
"github.com/harmony-one/harmony/internal/cli"
nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
"github.com/spf13/cobra"
)

var (
Expand Down Expand Up @@ -57,6 +58,7 @@ var (
p2pDHTDataStoreFlag,
p2pDiscoveryConcurrencyFlag,
legacyKeyFileFlag,
maxConnPerIPFlag,
}

httpFlags = []cli.Flag{
Expand All @@ -72,6 +74,7 @@ var (
wsEnabledFlag,
wsIPFlag,
wsPortFlag,
wsAuthPortFlag,
}

rpcOptFlags = []cli.Flag{
Expand Down Expand Up @@ -525,6 +528,11 @@ var (
Usage: "the pubsub's DHT discovery concurrency num (default with raw libp2p dht option)",
DefValue: defaultConfig.P2P.DiscConcurrency,
}
maxConnPerIPFlag = cli.IntFlag{
Name: "p2p.security.max-conn-per-ip",
Usage: "maximum number of connections allowed per node",
DefValue: defaultConfig.P2P.MaxConnsPerIP,
}
)

func applyP2PFlags(cmd *cobra.Command, config *harmonyconfig.HarmonyConfig) {
Expand Down Expand Up @@ -552,6 +560,10 @@ func applyP2PFlags(cmd *cobra.Command, config *harmonyconfig.HarmonyConfig) {
if cli.IsFlagChanged(cmd, p2pDiscoveryConcurrencyFlag) {
config.P2P.DiscConcurrency = cli.GetIntFlagValue(cmd, p2pDiscoveryConcurrencyFlag)
}

if cli.IsFlagChanged(cmd, maxConnPerIPFlag) {
config.P2P.MaxConnsPerIP = cli.GetIntFlagValue(cmd, maxConnPerIPFlag)
}
}

// http flags
Expand Down Expand Up @@ -642,6 +654,11 @@ var (
Usage: "port for websocket endpoint",
DefValue: defaultConfig.WS.Port,
}
wsAuthPortFlag = cli.IntFlag{
Name: "ws.auth-port",
Usage: "port for websocket auth endpoint",
DefValue: defaultConfig.WS.AuthPort,
}
)

func applyWSFlags(cmd *cobra.Command, config *harmonyconfig.HarmonyConfig) {
Expand All @@ -654,6 +671,9 @@ func applyWSFlags(cmd *cobra.Command, config *harmonyconfig.HarmonyConfig) {
if cli.IsFlagChanged(cmd, wsPortFlag) {
config.WS.Port = cli.GetIntFlagValue(cmd, wsPortFlag)
}
if cli.IsFlagChanged(cmd, wsAuthPortFlag) {
config.WS.AuthPort = cli.GetIntFlagValue(cmd, wsAuthPortFlag)
}
}

// rpc opt flags
Expand Down Expand Up @@ -1370,6 +1390,7 @@ func applyLegacyMiscFlags(cmd *cobra.Command, config *harmonyconfig.HarmonyConfi
config.HTTP.AuthPort = nodeconfig.GetRPCAuthHTTPPortFromBase(legacyPort)
config.HTTP.RosettaPort = nodeconfig.GetRosettaHTTPPortFromBase(legacyPort)
config.WS.Port = nodeconfig.GetWSPortFromBase(legacyPort)
config.WS.AuthPort = nodeconfig.GetWSAuthPortFromBase(legacyPort)

legPortStr := strconv.Itoa(legacyPort)
syncPort, _ := strconv.Atoi(legacysync.GetSyncingPort(legPortStr))
Expand Down
Loading

0 comments on commit 257d473

Please sign in to comment.