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

Support Nacos #1

Open
wants to merge 2 commits into
base: leo/xl-adaptation
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ var (
utils.RollupComputePendingBlock,
utils.RollupHaltOnIncompatibleProtocolVersionFlag,
utils.RollupSuperchainUpgradesFlag,
utils.NacosURLsFlag,
utils.NacosNamespaceIdFlag,
utils.NacosApplicationNameFlag,
utils.NacosExternalListenAddrFlag,
configFileFlag,
utils.LogDebugFlag,
utils.LogBacktraceAtFlag,
Expand Down
1 change: 1 addition & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1719,6 +1719,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
setMiner(ctx, &cfg.Miner)
setRequiredBlocks(ctx, cfg)
setLes(ctx, cfg)
setXLayerNacos(ctx, &cfg.Nacos)

// Cap the cache allowance and tune the garbage collector
mem, err := gopsutil.VirtualMemory()
Expand Down
48 changes: 48 additions & 0 deletions cmd/utils/flags_xlayer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package utils

import (
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/urfave/cli/v2"
)

var (
// X Layer nacos
NacosURLsFlag = &cli.StringFlag{
Name: "nacos.urls",
Usage: "Nacos urls.",
Value: "",
}
NacosNamespaceIdFlag = &cli.StringFlag{
Name: "nacos.namespace-id",
Usage: "Nacos namespace Id.",
Value: "",
}
NacosApplicationNameFlag = &cli.StringFlag{
Name: "nacos.application-name",
Usage: "Nacos application name",
Value: "",
}
NacosExternalListenAddrFlag = &cli.StringFlag{
Name: "nacos.external-listen-addr",
Usage: "Nacos external listen addr.",
Value: "",
}
)

func setXLayerNacos(ctx *cli.Context, cfg *ethconfig.NacosConfig) {
if ctx.IsSet(NacosURLsFlag.Name) {
cfg.URLs = ctx.String(NacosURLsFlag.Name)
}

if ctx.IsSet(NacosNamespaceIdFlag.Name) {
cfg.NamespaceId = ctx.String(NacosNamespaceIdFlag.Name)
}

if ctx.IsSet(NacosApplicationNameFlag.Name) {
cfg.ApplicationName = ctx.String(NacosApplicationNameFlag.Name)
}

if ctx.IsSet(NacosExternalListenAddrFlag.Name) {
cfg.ExternalListenAddr = ctx.String(NacosExternalListenAddrFlag.Name)
}
}
7 changes: 7 additions & 0 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import (
"github.com/ethereum/go-ethereum/internal/shutdowncheck"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/miner"
"github.com/ethereum/go-ethereum/nacos"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/dnsdisc"
Expand Down Expand Up @@ -328,6 +329,12 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
eth.historicalRPCService = client
}

// X Layer
cfg := eth.config
if len(cfg.Nacos.URLs) > 0 {
nacos.StartNacosClient(cfg.Nacos.URLs, cfg.Nacos.NamespaceId, cfg.Nacos.ApplicationName, cfg.Nacos.ExternalListenAddr)
}

// Start the RPC service
eth.netRPCService = ethapi.NewNetAPI(eth.p2pServer, networkID)

Expand Down
3 changes: 3 additions & 0 deletions eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ type Config struct {
RollupDisableTxPoolGossip bool
RollupDisableTxPoolAdmission bool
RollupHaltOnIncompatibleProtocolVersion string

// X Layer
Nacos NacosConfig
}

// CreateConsensusEngine creates a consensus engine for the given chain config.
Expand Down
9 changes: 9 additions & 0 deletions eth/ethconfig/config_xlayer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package ethconfig

// NacosConfig is the config for Nacos
type NacosConfig struct {
URLs string
NamespaceId string
ApplicationName string
ExternalListenAddr string
}
15 changes: 14 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ require (
github.com/julienschmidt/httprouter v1.3.0
github.com/karalabe/usb v0.0.2
github.com/kylelemons/godebug v1.1.0
github.com/ledgerwatch/log/v3 v3.9.0
github.com/mattn/go-colorable v0.1.13
github.com/mattn/go-isatty v0.0.17
github.com/mattn/go-isatty v0.0.19
github.com/nacos-group/nacos-sdk-go v1.1.4
github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416
github.com/olekukonko/tablewriter v0.0.5
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7
Expand Down Expand Up @@ -82,6 +84,7 @@ require (
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
github.com/DataDog/zstd v1.4.5 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/aliyun/alibaba-cloud-sdk-go v1.61.18 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.13 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.43 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.37 // indirect
Expand All @@ -93,6 +96,7 @@ require (
github.com/aws/smithy-go v1.15.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/errors v1.8.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f // indirect
Expand All @@ -105,8 +109,10 @@ require (
github.com/deepmap/oapi-codegen v1.6.0 // indirect
github.com/dlclark/regexp2 v1.7.0 // indirect
github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61 // indirect
github.com/go-errors/errors v1.0.1 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
Expand All @@ -116,6 +122,7 @@ require (
github.com/hashicorp/go-retryablehttp v0.7.4 // indirect
github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kilic/bls12-381 v0.1.0 // indirect
github.com/klauspost/compress v1.15.15 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
Expand All @@ -127,6 +134,8 @@ require (
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/mitchellh/pointerstructure v1.2.0 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/naoina/go-stringutil v0.1.0 // indirect
github.com/opentracing/opentracing-go v1.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
Expand All @@ -142,9 +151,13 @@ require (
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
go.uber.org/atomic v1.6.0 // indirect
go.uber.org/multierr v1.5.0 // indirect
go.uber.org/zap v1.15.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.18.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/ini.v1 v1.42.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)
Expand Down
Loading