Skip to content

Commit 0c4366e

Browse files
authored
Merge pull request ethereum#192 from maticnetwork/uttam/mainnet
Add: Bor mainnet network flag
2 parents 440ffaa + 6c7a9e1 commit 0c4366e

File tree

16 files changed

+189
-8
lines changed

16 files changed

+189
-8
lines changed

cmd/devp2p/nodesetcmd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ func ethFilter(args []string) (nodeFilter, error) {
237237
filter = forkid.NewStaticFilter(params.RopstenChainConfig, params.RopstenGenesisHash)
238238
case "mumbai":
239239
filter = forkid.NewStaticFilter(params.MumbaiChainConfig, params.MumbaiGenesisHash)
240+
case "bor-mainnet":
241+
filter = forkid.NewStaticFilter(params.BorMainnetChainConfig, params.BorMainnetGenesisHash)
240242
default:
241243
return nil, fmt.Errorf("unknown network %q", args[0])
242244
}

cmd/geth/chaincmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ It expects the genesis file as argument.`,
6969
utils.RinkebyFlag,
7070
utils.GoerliFlag,
7171
utils.MumbaiFlag,
72+
utils.BorMainnetFlag,
7273
},
7374
Category: "BLOCKCHAIN COMMANDS",
7475
Description: `

cmd/geth/config.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
139139
setDefaultMumbaiGethConfig(ctx, &cfg)
140140
}
141141

142+
if ctx.GlobalIsSet(utils.BorMainnetFlag.Name) {
143+
setDefaultBorMainnetGethConfig(ctx, &cfg)
144+
}
145+
142146
// Apply flags.
143147
utils.SetNodeConfig(ctx, &cfg.Node)
144148
stack, err := node.New(&cfg.Node)
@@ -357,3 +361,26 @@ func setDefaultMumbaiGethConfig(ctx *cli.Context, config *gethConfig) {
357361
config.Metrics.Enabled = true
358362
// --pprof is enabled in 'internal/debug/flags.go'
359363
}
364+
365+
func setDefaultBorMainnetGethConfig(ctx *cli.Context, config *gethConfig) {
366+
config.Node.P2P.ListenAddr = fmt.Sprintf(":%d", 30303)
367+
config.Node.HTTPHost = "0.0.0.0"
368+
config.Node.HTTPVirtualHosts = []string{"*"}
369+
config.Node.HTTPCors = []string{"*"}
370+
config.Node.HTTPPort = 8545
371+
config.Node.IPCPath = utils.MakeDataDir(ctx) + "/bor.ipc"
372+
config.Node.HTTPModules = []string{"eth", "net", "web3", "txpool", "bor"}
373+
config.Eth.SyncMode = downloader.FullSync
374+
config.Eth.NetworkId = 137
375+
config.Eth.Miner.GasCeil = 20000000
376+
//--miner.gastarget is depreceated, No longed used
377+
config.Eth.TxPool.NoLocals = true
378+
config.Eth.TxPool.AccountSlots = 16
379+
config.Eth.TxPool.GlobalSlots = 131072
380+
config.Eth.TxPool.AccountQueue = 64
381+
config.Eth.TxPool.GlobalQueue = 131072
382+
config.Eth.TxPool.Lifetime = 90 * time.Minute
383+
config.Node.P2P.MaxPeers = 200
384+
config.Metrics.Enabled = true
385+
// --pprof is enabled in 'internal/debug/flags.go'
386+
}

cmd/geth/consolecmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func remoteConsole(ctx *cli.Context) error {
134134
path = filepath.Join(path, "rinkeby")
135135
} else if ctx.GlobalBool(utils.GoerliFlag.Name) {
136136
path = filepath.Join(path, "goerli")
137-
} else if ctx.GlobalBool(utils.MumbaiFlag.Name) {
137+
} else if ctx.GlobalBool(utils.MumbaiFlag.Name) || ctx.GlobalBool(utils.BorMainnetFlag.Name) {
138138
homeDir, _ := os.UserHomeDir()
139139
path = filepath.Join(homeDir, "/.bor/data")
140140
}

cmd/geth/dbcmd.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Remove blockchain and state databases`,
7676
utils.RinkebyFlag,
7777
utils.GoerliFlag,
7878
utils.MumbaiFlag,
79+
utils.BorMainnetFlag,
7980
},
8081
Usage: "Inspect the storage size for each type of data in the database",
8182
Description: `This commands iterates the entire database. If the optional 'prefix' and 'start' arguments are provided, then the iteration is limited to the given subset of data.`,
@@ -92,6 +93,7 @@ Remove blockchain and state databases`,
9293
utils.RinkebyFlag,
9394
utils.GoerliFlag,
9495
utils.MumbaiFlag,
96+
utils.BorMainnetFlag,
9597
},
9698
}
9799
dbCompactCmd = cli.Command{
@@ -106,6 +108,7 @@ Remove blockchain and state databases`,
106108
utils.RinkebyFlag,
107109
utils.GoerliFlag,
108110
utils.MumbaiFlag,
111+
utils.BorMainnetFlag,
109112
utils.CacheFlag,
110113
utils.CacheDatabaseFlag,
111114
},
@@ -126,6 +129,7 @@ corruption if it is aborted during execution'!`,
126129
utils.RinkebyFlag,
127130
utils.GoerliFlag,
128131
utils.MumbaiFlag,
132+
utils.BorMainnetFlag,
129133
},
130134
Description: "This command looks up the specified database key from the database.",
131135
}
@@ -142,6 +146,7 @@ corruption if it is aborted during execution'!`,
142146
utils.RinkebyFlag,
143147
utils.GoerliFlag,
144148
utils.MumbaiFlag,
149+
utils.BorMainnetFlag,
145150
},
146151
Description: `This command deletes the specified database key from the database.
147152
WARNING: This is a low-level operation which may cause database corruption!`,
@@ -159,6 +164,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
159164
utils.RinkebyFlag,
160165
utils.GoerliFlag,
161166
utils.MumbaiFlag,
167+
utils.BorMainnetFlag,
162168
},
163169
Description: `This command sets a given database key to the given value.
164170
WARNING: This is a low-level operation which may cause database corruption!`,
@@ -176,6 +182,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
176182
utils.RinkebyFlag,
177183
utils.GoerliFlag,
178184
utils.MumbaiFlag,
185+
utils.BorMainnetFlag,
179186
},
180187
Description: "This command looks up the specified database key from the database.",
181188
}
@@ -192,6 +199,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
192199
utils.RinkebyFlag,
193200
utils.GoerliFlag,
194201
utils.MumbaiFlag,
202+
utils.BorMainnetFlag,
195203
},
196204
Description: "This command displays information about the freezer index.",
197205
}

cmd/geth/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ var (
141141
utils.RinkebyFlag,
142142
utils.GoerliFlag,
143143
utils.MumbaiFlag,
144+
utils.BorMainnetFlag,
144145
utils.VMEnableDebugFlag,
145146
utils.NetworkIdFlag,
146147
utils.EthStatsURLFlag,
@@ -286,14 +287,17 @@ func prepare(ctx *cli.Context) {
286287
case ctx.GlobalIsSet(utils.MumbaiFlag.Name):
287288
log.Info("Starting Bor on Mumbai testnet...")
288289

290+
case ctx.GlobalIsSet(utils.BorMainnetFlag.Name):
291+
log.Info("Starting Bor on Bor mainnet...")
292+
289293
case ctx.GlobalIsSet(utils.DeveloperFlag.Name):
290294
log.Info("Starting Geth in ephemeral dev mode...")
291295

292296
case !ctx.GlobalIsSet(utils.NetworkIdFlag.Name):
293297
log.Info("Starting Geth on Ethereum mainnet...")
294298
}
295299
// If we're a full node on mainnet without --cache specified, bump default cache allowance
296-
if ctx.GlobalString(utils.SyncModeFlag.Name) != "light" && !ctx.GlobalIsSet(utils.CacheFlag.Name) && !ctx.GlobalIsSet(utils.NetworkIdFlag.Name) {
300+
if ctx.GlobalString(utils.SyncModeFlag.Name) != "light" && !ctx.GlobalIsSet(utils.CacheFlag.Name) && !ctx.GlobalIsSet(utils.BorMainnetFlag.Name) && !ctx.GlobalIsSet(utils.NetworkIdFlag.Name) {
297301
// Make sure we're not on any supported preconfigured testnet either
298302
if !ctx.GlobalIsSet(utils.RopstenFlag.Name) && !ctx.GlobalIsSet(utils.RinkebyFlag.Name) && !ctx.GlobalIsSet(utils.GoerliFlag.Name) && !ctx.GlobalIsSet(utils.MumbaiFlag.Name) && !ctx.GlobalIsSet(utils.DeveloperFlag.Name) {
299303
// Nope, we're really on mainnet. Bump that cache up!

cmd/geth/snapshot.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ var (
6464
utils.RinkebyFlag,
6565
utils.GoerliFlag,
6666
utils.MumbaiFlag,
67+
utils.BorMainnetFlag,
6768
utils.CacheTrieJournalFlag,
6869
utils.BloomFilterSizeFlag,
6970
},
@@ -95,6 +96,7 @@ the trie clean cache with default directory will be deleted.
9596
utils.RinkebyFlag,
9697
utils.GoerliFlag,
9798
utils.MumbaiFlag,
99+
utils.BorMainnetFlag,
98100
},
99101
Description: `
100102
geth snapshot verify-state <state-root>
@@ -116,6 +118,7 @@ In other words, this command does the snapshot to trie conversion.
116118
utils.RinkebyFlag,
117119
utils.GoerliFlag,
118120
utils.MumbaiFlag,
121+
utils.BorMainnetFlag,
119122
},
120123
Description: `
121124
geth snapshot traverse-state <state-root>
@@ -139,6 +142,7 @@ It's also usable without snapshot enabled.
139142
utils.RinkebyFlag,
140143
utils.GoerliFlag,
141144
utils.MumbaiFlag,
145+
utils.BorMainnetFlag,
142146
},
143147
Description: `
144148
geth snapshot traverse-rawstate <state-root>
@@ -163,6 +167,7 @@ It's also usable without snapshot enabled.
163167
utils.RinkebyFlag,
164168
utils.GoerliFlag,
165169
utils.MumbaiFlag,
170+
utils.BorMainnetFlag,
166171
utils.ExcludeCodeFlag,
167172
utils.ExcludeStorageFlag,
168173
utils.StartKeyFlag,

cmd/geth/usage.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
4444
utils.MainnetFlag,
4545
utils.GoerliFlag,
4646
utils.MumbaiFlag,
47+
utils.BorMainnetFlag,
4748
utils.RinkebyFlag,
4849
utils.RopstenFlag,
4950
utils.SyncModeFlag,

cmd/utils/flags.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ var (
159159
Name: "mumbai",
160160
Usage: "Mumbai network: pre-configured proof-of-stake test network",
161161
}
162+
BorMainnetFlag = cli.BoolFlag{
163+
Name: "bor-mainnet",
164+
Usage: "Bor mainnet",
165+
}
162166
DeveloperFlag = cli.BoolFlag{
163167
Name: "dev",
164168
Usage: "Ephemeral proof-of-authority network with a pre-funded developer account, mining enabled",
@@ -859,6 +863,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
859863
urls = params.GoerliBootnodes
860864
case ctx.GlobalBool(MumbaiFlag.Name):
861865
urls = params.MumbaiBootnodes
866+
case ctx.GlobalBool(BorMainnetFlag.Name):
867+
urls = params.BorMainnetBootnodes
862868
case cfg.BootstrapNodes != nil:
863869
return // already set, don't apply defaults.
864870
}
@@ -1305,6 +1311,9 @@ func setDataDir(ctx *cli.Context, cfg *node.Config) {
13051311
case ctx.GlobalBool(MumbaiFlag.Name) && cfg.DataDir == node.DefaultDataDir():
13061312
homeDir, _ := os.UserHomeDir()
13071313
cfg.DataDir = filepath.Join(homeDir, "/.bor/data")
1314+
case ctx.GlobalBool(BorMainnetFlag.Name) && cfg.DataDir == node.DefaultDataDir():
1315+
homeDir, _ := os.UserHomeDir()
1316+
cfg.DataDir = filepath.Join(homeDir, "/.bor/data")
13081317
}
13091318
}
13101319

@@ -1490,7 +1499,7 @@ func CheckExclusive(ctx *cli.Context, args ...interface{}) {
14901499
// SetEthConfig applies eth-related command line flags to the config.
14911500
func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
14921501
// Avoid conflicting network flags
1493-
CheckExclusive(ctx, MainnetFlag, DeveloperFlag, RopstenFlag, RinkebyFlag, GoerliFlag, MumbaiFlag)
1502+
CheckExclusive(ctx, MainnetFlag, DeveloperFlag, RopstenFlag, RinkebyFlag, GoerliFlag, MumbaiFlag, BorMainnetFlag)
14941503
CheckExclusive(ctx, LightServeFlag, SyncModeFlag, "light")
14951504
CheckExclusive(ctx, DeveloperFlag, ExternalSignerFlag) // Can't use both ephemeral unlocked and external signer
14961505
if ctx.GlobalString(GCModeFlag.Name) == "archive" && ctx.GlobalUint64(TxLookupLimitFlag.Name) != 0 {
@@ -1653,6 +1662,12 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
16531662
}
16541663
cfg.Genesis = core.DefaultMumbaiGenesisBlock()
16551664
SetDNSDiscoveryDefaults(cfg, params.MumbaiGenesisHash)
1665+
case ctx.GlobalBool(BorMainnetFlag.Name):
1666+
if !ctx.GlobalIsSet(BorMainnetFlag.Name) {
1667+
cfg.NetworkId = 137
1668+
}
1669+
cfg.Genesis = core.DefaultBorMainnetGenesisBlock()
1670+
SetDNSDiscoveryDefaults(cfg, params.BorMainnetGenesisHash)
16561671
case ctx.GlobalBool(DeveloperFlag.Name):
16571672
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
16581673
cfg.NetworkId = 1337
@@ -1875,6 +1890,8 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
18751890
genesis = core.DefaultGoerliGenesisBlock()
18761891
case ctx.GlobalBool(MumbaiFlag.Name):
18771892
genesis = core.DefaultMumbaiGenesisBlock()
1893+
case ctx.GlobalBool(BorMainnetFlag.Name):
1894+
genesis = core.DefaultBorMainnetGenesisBlock()
18781895
case ctx.GlobalBool(DeveloperFlag.Name):
18791896
Fatalf("Developer chains are ephemeral")
18801897
}

core/allocs/bor_mainnet.json

Lines changed: 35 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)