From 781081a7675310220320763b69b45ceaf7cd8a45 Mon Sep 17 00:00:00 2001 From: Alan Orwick Date: Thu, 6 Apr 2023 10:51:38 -0500 Subject: [PATCH] Add Galena network --- cmd/go-quai/chaincmd.go | 1 + cmd/go-quai/main.go | 3 +++ cmd/go-quai/usage.go | 1 + cmd/utils/flags.go | 10 ++++++++++ core/genesis.go | 14 ++++++++++++++ core/genesis_alloc.go | 1 + eth/protocols/eth/handler.go | 2 +- params/bootnodes.go | 10 ++++++++++ params/config.go | 23 +++++++++++++++++++++++ params/protocol_params.go | 1 + 10 files changed, 65 insertions(+), 1 deletion(-) diff --git a/cmd/go-quai/chaincmd.go b/cmd/go-quai/chaincmd.go index 0a14554642..2c97fe9094 100644 --- a/cmd/go-quai/chaincmd.go +++ b/cmd/go-quai/chaincmd.go @@ -67,6 +67,7 @@ It expects the genesis file as argument.`, utils.ColosseumFlag, utils.GardenFlag, utils.OrchardFlag, + utils.GalenaFlag, utils.LocalFlag, }, Category: "BLOCKCHAIN COMMANDS", diff --git a/cmd/go-quai/main.go b/cmd/go-quai/main.go index 5f3d5f2916..8237c96246 100644 --- a/cmd/go-quai/main.go +++ b/cmd/go-quai/main.go @@ -115,6 +115,7 @@ var ( utils.DeveloperPeriodFlag, utils.GardenFlag, utils.OrchardFlag, + utils.GalenaFlag, utils.LocalFlag, utils.VMEnableDebugFlag, utils.NetworkIdFlag, @@ -233,6 +234,8 @@ func prepare(ctx *cli.Context) { netname = utils.OrchardFlag.Name + " testnet" case ctx.GlobalIsSet(utils.LocalFlag.Name): netname = utils.LocalFlag.Name + " testnet" + case ctx.GlobalIsSet(utils.GalenaFlag.Name): + netname = utils.GalenaFlag.Name + " testnet" case ctx.GlobalIsSet(utils.DeveloperFlag.Name): netname = utils.DeveloperFlag.Name + " ephemeral dev network" case !ctx.GlobalIsSet(utils.NetworkIdFlag.Name): diff --git a/cmd/go-quai/usage.go b/cmd/go-quai/usage.go index 713f0af983..c67b7edd42 100644 --- a/cmd/go-quai/usage.go +++ b/cmd/go-quai/usage.go @@ -43,6 +43,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{ utils.ColosseumFlag, utils.GardenFlag, utils.OrchardFlag, + utils.GalenaFlag, utils.LocalFlag, utils.SyncModeFlag, utils.ExitWhenSyncedFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 206fceee1d..63e36938b2 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -142,6 +142,10 @@ var ( Name: "orchard", Usage: "Orchard network: pre-configured proof-of-work test network", } + GalenaFlag = cli.BoolFlag{ + Name: "galena", + Usage: "Galena network: pre-configured proof-of-work test network", + } LocalFlag = cli.BoolFlag{ Name: "local", Usage: "Local network: localhost proof-of-work node, will not attempt to connect to bootnode or any public network", @@ -738,6 +742,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) { urls = params.GardenBootnodes case ctx.GlobalBool(OrchardFlag.Name): urls = params.OrchardBootnodes + case ctx.GlobalBool(GalenaFlag.Name): + urls = params.GalenaBootnodes case ctx.GlobalBool(LocalFlag.Name): urls = []string{} case cfg.BootstrapNodes != nil: @@ -1184,6 +1190,8 @@ func setBlake3pow(ctx *cli.Context, cfg *ethconfig.Config) { cfg.Blake3pow.DurationLimit = params.GardenDurationLimit case ctx.GlobalBool(OrchardFlag.Name): cfg.Blake3pow.DurationLimit = params.OrchardDurationLimit + case ctx.GlobalBool(GalenaFlag.Name): + cfg.Blake3pow.DurationLimit = params.GalenaDurationLimit case ctx.GlobalBool(LocalFlag.Name): cfg.Blake3pow.DurationLimit = params.LocalDurationLimit case ctx.GlobalBool(DeveloperFlag.Name): @@ -1576,6 +1584,8 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis { genesis = core.DefaultGardenGenesisBlock() case ctx.GlobalBool(OrchardFlag.Name): genesis = core.DefaultOrchardGenesisBlock() + case ctx.GlobalBool(GalenaFlag.Name): + genesis = core.DefaultGalenaGenesisBlock() case ctx.GlobalBool(LocalFlag.Name): genesis = core.DefaultLocalGenesisBlock() case ctx.GlobalBool(DeveloperFlag.Name): diff --git a/core/genesis.go b/core/genesis.go index 008cef1238..6323d8b437 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -247,6 +247,8 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig { return params.GardenChainConfig case ghash == params.OrchardGenesisHash: return params.OrchardChainConfig + case ghash == params.GalenaGenesisHash: + return params.GalenaChainConfig case ghash == params.LocalGenesisHash: return params.LocalChainConfig default: @@ -404,6 +406,18 @@ func DefaultOrchardGenesisBlock() *Genesis { } } +// DefaultGalenaGenesisBlock returns the Orchard testnet genesis block. +func DefaultGalenaGenesisBlock() *Genesis { + return &Genesis{ + Config: params.OrchardChainConfig, + Nonce: 68, + ExtraData: hexutil.MustDecode("0x3535353535353535353535353535353535353535353535353535353535353535"), + GasLimit: []uint64{1000000, 1000000, 1000000}, + Difficulty: big.NewInt(8800000000), + Alloc: decodePrealloc(galenaAllocData), + } +} + // DefaultLocalGenesisBlock returns the Local testnet genesis block. func DefaultLocalGenesisBlock() *Genesis { return &Genesis{ diff --git a/core/genesis_alloc.go b/core/genesis_alloc.go index 71da0260b3..95fe8d5cac 100644 --- a/core/genesis_alloc.go +++ b/core/genesis_alloc.go @@ -24,4 +24,5 @@ package core const colosseumAllocData = "\xc0" const gardenAllocData = "\xc0" const orchardAllocData = "\xc0" +const galenaAllocData = "\xc0" const localAllocData = "\xc0" diff --git a/eth/protocols/eth/handler.go b/eth/protocols/eth/handler.go index e7fd8b8fd4..1cc99b3d1e 100644 --- a/eth/protocols/eth/handler.go +++ b/eth/protocols/eth/handler.go @@ -126,7 +126,7 @@ func MakeProtocols(backend Backend, network uint64, dnsdisc enode.Iterator) []p2 // NodeInfo represents a short summary of the `quai` sub-protocol metadata // known about the host peer. type NodeInfo struct { - Network uint64 `json:"network"` // Quai network ID (1=Colosseum, Garden=2, Orchard=3) + Network uint64 `json:"network"` // Quai network ID (1=Colosseum, Garden=2, Orchard=3, Galena=4) Difficulty *big.Int `json:"difficulty"` // Total difficulty of the host's blockchain Genesis common.Hash `json:"genesis"` // SHA3 hash of the host's genesis block Config *params.ChainConfig `json:"config"` // Chain configuration for the fork rules diff --git a/params/bootnodes.go b/params/bootnodes.go index 9959d7729b..31ba98bfdb 100644 --- a/params/bootnodes.go +++ b/params/bootnodes.go @@ -43,6 +43,14 @@ var OrchardBootnodes = []string{ "enode://a63fab2ffb3cd91a3842cb70c7c24018c66d3ba2b5e47b5344d9c8bd8fb034b85f297f07fd97e7f85fca2d2dfd26166677f0aa4d498af8abe5b7c5c251bd60e1@34.22.69.17", // asia-northeast3-a } +// GalenaBootnodes are the enode URLs of the P2P bootstrap nodes running on the +// Galena test network +var GalenaBootnodes = []string{ + "enode://12fa0822887c7c8829c1d30e7aaf430587cc71827f5ab2028ee39acf02c113eb01a4c130258074d3c7868f68280f854036a8a51beb4df96af314f94c7f45966e@34.175.138.4", // europe-southwest1-a + "enode://1dab5f7739dfd6fb037a676607fc86ecc76eff3906abaa8f8662e236eb01937b27db1309c89e0c3af807a64b491f401f52ff75daca49689c99cfe949c359623c@35.199.83.89", // southamerica-east1-b + "enode://402a7cc416700f8717ff35416dfcb3c286921bc4261a9e8cc9948cfac9e3589c8db25fffcf7d6877ec0e7ad93c83e6bde93d4918923dfb9c24c1635a57c5aba2@34.64.122.86", // asia-northeast3-a +} + var V5Bootnodes = []string{} const dnsPrefix = "enrtree://ALE24Z2TEZV2XK46RXVB6IIN5HB5WTI4F4SMAVLYCAQIUPU53RSUU@" @@ -59,6 +67,8 @@ func KnownDNSNetwork(genesis common.Hash, protocol string) string { net = "garden" case OrchardGenesisHash: net = "orchard" + case GalenaGenesisHash: + net = "galena" default: return "" } diff --git a/params/config.go b/params/config.go index 31793271af..872b458d9a 100644 --- a/params/config.go +++ b/params/config.go @@ -29,6 +29,7 @@ var ( GardenGenesisHash = common.HexToHash("0x779f1d7a78675498ba77bc5b47d54fd76033d6e8e89729216ecf365a71c8736c") OrchardGenesisHash = common.HexToHash("0xdc2c8f2c92e18ab8673b8b6291bc02350191f14161c4d881b741d3fb081996f7") LocalGenesisHash = common.HexToHash("0xe0858f853c8965341f99c1baf54aa3404f5e5480226e895c7489dfc77cb69deb") + GalenaGenesisHash = common.HexToHash("0xa5951ca01396546d238c8c900c86bd10894905a04c3f6902142345aabbff7947") ) var ( @@ -95,6 +96,28 @@ var ( GenesisHash: OrchardGenesisHash, } + // GalenaChainConfig contains the chain parameters to run a node on the Orchard test network. + GalenaChainConfig = &ChainConfig{ + ChainID: big.NewInt(17000), + HomesteadBlock: big.NewInt(0), + DAOForkBlock: nil, + DAOForkSupport: true, + EIP150Block: big.NewInt(0), + EIP150Hash: common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + Blake3pow: new(Blake3powConfig), + GenesisHash: GalenaGenesisHash, + } + + // LocalChainConfig contains the chain parameters to run a node on the Local test network. LocalChainConfig = &ChainConfig{ ChainID: big.NewInt(1337), diff --git a/params/protocol_params.go b/params/protocol_params.go index f1b5065cc8..73d3efb39d 100644 --- a/params/protocol_params.go +++ b/params/protocol_params.go @@ -159,6 +159,7 @@ var ( DurationLimit = big.NewInt(10) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. GardenDurationLimit = big.NewInt(3) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. OrchardDurationLimit = big.NewInt(3) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. + GalenaDurationLimit = big.NewInt(3) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. LocalDurationLimit = big.NewInt(2) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. TimeFactor = big.NewInt(7) )