Skip to content

Commit

Permalink
Add Galena network
Browse files Browse the repository at this point in the history
  • Loading branch information
alanorwick committed Apr 11, 2023
1 parent 7f010d3 commit 781081a
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/go-quai/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ It expects the genesis file as argument.`,
utils.ColosseumFlag,
utils.GardenFlag,
utils.OrchardFlag,
utils.GalenaFlag,
utils.LocalFlag,
},
Category: "BLOCKCHAIN COMMANDS",
Expand Down
3 changes: 3 additions & 0 deletions cmd/go-quai/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ var (
utils.DeveloperPeriodFlag,
utils.GardenFlag,
utils.OrchardFlag,
utils.GalenaFlag,
utils.LocalFlag,
utils.VMEnableDebugFlag,
utils.NetworkIdFlag,
Expand Down Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions cmd/go-quai/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
utils.ColosseumFlag,
utils.GardenFlag,
utils.OrchardFlag,
utils.GalenaFlag,
utils.LocalFlag,
utils.SyncModeFlag,
utils.ExitWhenSyncedFlag,
Expand Down
10 changes: 10 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
14 changes: 14 additions & 0 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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{
Expand Down
1 change: 1 addition & 0 deletions core/genesis_alloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ package core
const colosseumAllocData = "\xc0"
const gardenAllocData = "\xc0"
const orchardAllocData = "\xc0"
const galenaAllocData = "\xc0"
const localAllocData = "\xc0"
2 changes: 1 addition & 1 deletion eth/protocols/eth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions params/bootnodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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@"
Expand All @@ -59,6 +67,8 @@ func KnownDNSNetwork(genesis common.Hash, protocol string) string {
net = "garden"
case OrchardGenesisHash:
net = "orchard"
case GalenaGenesisHash:
net = "galena"
default:
return ""
}
Expand Down
23 changes: 23 additions & 0 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var (
GardenGenesisHash = common.HexToHash("0x779f1d7a78675498ba77bc5b47d54fd76033d6e8e89729216ecf365a71c8736c")
OrchardGenesisHash = common.HexToHash("0xdc2c8f2c92e18ab8673b8b6291bc02350191f14161c4d881b741d3fb081996f7")
LocalGenesisHash = common.HexToHash("0xe0858f853c8965341f99c1baf54aa3404f5e5480226e895c7489dfc77cb69deb")
GalenaGenesisHash = common.HexToHash("0xa5951ca01396546d238c8c900c86bd10894905a04c3f6902142345aabbff7947")
)

var (
Expand Down Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions params/protocol_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)

0 comments on commit 781081a

Please sign in to comment.