Skip to content

Commit

Permalink
enable gnosis chain in go-ethereum
Browse files Browse the repository at this point in the history
Signed-off-by: Guillaume Ballet <[email protected]>
  • Loading branch information
gballet committed Nov 29, 2024
1 parent c64cf28 commit 95b1bca
Show file tree
Hide file tree
Showing 61 changed files with 5,411 additions and 96 deletions.
44 changes: 43 additions & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,16 @@ var (
Usage: "Holesky network: pre-configured proof-of-stake test network",
Category: flags.EthCategory,
}
GnosisChainFlag = &cli.BoolFlag{
Name: "gnosis",
Usage: "Gnosis chain network: pre-configured merged proof-of-authority test network",
Category: flags.EthCategory,
}
ChiadoFlag = &cli.BoolFlag{
Name: "chiado",
Usage: "Chiado network: pre-configured merged proof-of-authority test network",
Category: flags.EthCategory,
}
// Dev mode
DeveloperFlag = &cli.BoolFlag{
Name: "dev",
Expand Down Expand Up @@ -936,6 +946,8 @@ var (
TestnetFlags = []cli.Flag{
SepoliaFlag,
HoleskyFlag,
GnosisChainFlag,
ChiadoFlag,
}
// NetworkFlags is the flag group of all built-in supported networks.
NetworkFlags = append([]cli.Flag{MainnetFlag}, TestnetFlags...)
Expand All @@ -962,6 +974,12 @@ func MakeDataDir(ctx *cli.Context) string {
if ctx.Bool(HoleskyFlag.Name) {
return filepath.Join(path, "holesky")
}
if ctx.Bool(GnosisChainFlag.Name) {
return filepath.Join(path, "gnosis")
}
if ctx.Bool(ChiadoFlag.Name) {
return filepath.Join(path, "chiado")
}
return path
}
Fatalf("Cannot determine default data directory, please set manually (--datadir)")
Expand Down Expand Up @@ -1022,6 +1040,10 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
urls = params.HoleskyBootnodes
case ctx.Bool(SepoliaFlag.Name):
urls = params.SepoliaBootnodes
case ctx.Bool(GnosisChainFlag.Name):
urls = params.GnosisBootnodes
case ctx.Bool(ChiadoFlag.Name):
urls = params.ChiadoBootnodes
}
}
cfg.BootstrapNodes = mustParseBootnodes(urls)
Expand Down Expand Up @@ -1406,6 +1428,10 @@ func SetDataDir(ctx *cli.Context, cfg *node.Config) {
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "sepolia")
case ctx.Bool(HoleskyFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "holesky")
case ctx.Bool(GnosisChainFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "gnosis")
case ctx.Bool(ChiadoFlag.Name) && cfg.DataDir == node.DefaultDataDir():
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "chiado")
}
}

Expand Down Expand Up @@ -1573,7 +1599,7 @@ func CheckExclusive(ctx *cli.Context, args ...interface{}) {
// SetEthConfig applies eth-related command line flags to the config.
func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
// Avoid conflicting network flags
CheckExclusive(ctx, MainnetFlag, DeveloperFlag, SepoliaFlag, HoleskyFlag)
CheckExclusive(ctx, MainnetFlag, DeveloperFlag, SepoliaFlag, HoleskyFlag, ChiadoFlag, GnosisChainFlag)
CheckExclusive(ctx, DeveloperFlag, ExternalSignerFlag) // Can't use both ephemeral unlocked and external signer

// Set configurations from CLI flags
Expand Down Expand Up @@ -1739,6 +1765,18 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
}
cfg.Genesis = core.DefaultSepoliaGenesisBlock()
SetDNSDiscoveryDefaults(cfg, params.SepoliaGenesisHash)
case ctx.Bool(GnosisChainFlag.Name):
if !ctx.IsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 100
}
cfg.Genesis = core.DefaultGnosisGenesisBlock()
SetDNSDiscoveryDefaults(cfg, params.GnosisGenesisHash)
case ctx.Bool(ChiadoFlag.Name):
if !ctx.IsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 10200
}
cfg.Genesis = core.DefaultChiadoGenesisBlock()
SetDNSDiscoveryDefaults(cfg, params.ChiadoGenesisHash)
case ctx.Bool(DeveloperFlag.Name):
if !ctx.IsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 1337
Expand Down Expand Up @@ -2127,6 +2165,10 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
genesis = core.DefaultHoleskyGenesisBlock()
case ctx.Bool(SepoliaFlag.Name):
genesis = core.DefaultSepoliaGenesisBlock()
case ctx.Bool(GnosisChainFlag.Name):
genesis = core.DefaultGnosisGenesisBlock()
case ctx.Bool(ChiadoFlag.Name):
genesis = core.DefaultChiadoGenesisBlock()
case ctx.Bool(DeveloperFlag.Name):
Fatalf("Developer chains are ephemeral")
}
Expand Down
Loading

0 comments on commit 95b1bca

Please sign in to comment.