cmd, core, params: add support for Gangnam

This commit is contained in:
Ikmyeong Na 2018-12-04 17:10:18 +09:00
parent 92639b676a
commit f88acf5924
No known key found for this signature in database
GPG key ID: EC674310ADADE2CA
9 changed files with 63 additions and 2 deletions

View file

@ -136,6 +136,7 @@ The export-preimages command export hash preimages to an RLP encoded stream`,
utils.FakePoWFlag,
utils.TestnetFlag,
utils.RinkebyFlag,
utils.GangnamFlag,
},
Category: "BLOCKCHAIN COMMANDS",
Description: `

View file

@ -126,6 +126,8 @@ func remoteConsole(ctx *cli.Context) error {
path = filepath.Join(path, "testnet")
} else if ctx.GlobalBool(utils.RinkebyFlag.Name) {
path = filepath.Join(path, "rinkeby")
} else if ctx.GlobalBool(utils.GangnamFlag.Name) {
path = filepath.Join(path, "gangnam")
}
}
endpoint = fmt.Sprintf("%s/geth.ipc", path)

View file

@ -120,6 +120,7 @@ var (
utils.DeveloperPeriodFlag,
utils.TestnetFlag,
utils.RinkebyFlag,
utils.GangnamFlag,
utils.VMEnableDebugFlag,
utils.NetworkIdFlag,
utils.RPCCORSDomainFlag,

View file

@ -74,6 +74,7 @@ var AppHelpFlagGroups = []flagGroup{
utils.NetworkIdFlag,
utils.TestnetFlag,
utils.RinkebyFlag,
utils.GangnamFlag,
utils.SyncModeFlag,
utils.GCModeFlag,
utils.EthStatsURLFlag,

View file

@ -129,7 +129,7 @@ var (
}
NetworkIdFlag = cli.Uint64Flag{
Name: "networkid",
Usage: "Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten, 4=Rinkeby)",
Usage: "Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten, 4=Rinkeby, 1204=Gangnam)",
Value: eth.DefaultConfig.NetworkId,
}
TestnetFlag = cli.BoolFlag{
@ -140,6 +140,10 @@ var (
Name: "rinkeby",
Usage: "Rinkeby network: pre-configured proof-of-authority test network",
}
GangnamFlag = cli.BoolFlag{
Name: "gangnam",
Usage: "Gangnam network: pre-configured proof-of-work test network",
}
DeveloperFlag = cli.BoolFlag{
Name: "dev",
Usage: "Ephemeral proof-of-authority network with a pre-funded developer account, mining enabled",
@ -639,6 +643,9 @@ func MakeDataDir(ctx *cli.Context) string {
if ctx.GlobalBool(RinkebyFlag.Name) {
return filepath.Join(path, "rinkeby")
}
if ctx.GlobalBool(GangnamFlag.Name) {
return filepath.Join(path, "gangnam")
}
return path
}
Fatalf("Cannot determine default data directory, please set manually (--datadir)")
@ -693,6 +700,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
urls = params.TestnetBootnodes
case ctx.GlobalBool(RinkebyFlag.Name):
urls = params.RinkebyBootnodes
case ctx.GlobalBool(GangnamFlag.Name):
urls = params.GangnamBootnodes
case cfg.BootstrapNodes != nil:
return // already set, don't apply defaults.
}
@ -720,6 +729,8 @@ func setBootstrapNodesV5(ctx *cli.Context, cfg *p2p.Config) {
}
case ctx.GlobalBool(RinkebyFlag.Name):
urls = params.RinkebyBootnodes
case ctx.GlobalBool(GangnamFlag.Name):
urls = params.GangnamBootnodes
case cfg.BootstrapNodesV5 != nil:
return // already set, don't apply defaults.
}
@ -1001,6 +1012,8 @@ func setDataDir(ctx *cli.Context, cfg *node.Config) {
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "testnet")
case ctx.GlobalBool(RinkebyFlag.Name):
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "rinkeby")
case ctx.GlobalBool(GangnamFlag.Name):
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "gangnam")
}
}
@ -1134,7 +1147,7 @@ func SetShhConfig(ctx *cli.Context, stack *node.Node, cfg *whisper.Config) {
// SetEthConfig applies eth-related command line flags to the config.
func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
// Avoid conflicting network flags
checkExclusive(ctx, DeveloperFlag, TestnetFlag, RinkebyFlag)
checkExclusive(ctx, DeveloperFlag, TestnetFlag, RinkebyFlag, GangnamFlag)
checkExclusive(ctx, LightServFlag, SyncModeFlag, "light")
ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
@ -1230,6 +1243,11 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
cfg.NetworkId = 4
}
cfg.Genesis = core.DefaultRinkebyGenesisBlock()
case ctx.GlobalBool(GangnamFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 1204
}
cfg.Genesis = core.DefaultGangnamGenesisBlock()
case ctx.GlobalBool(DeveloperFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 1337
@ -1370,6 +1388,8 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
genesis = core.DefaultTestnetGenesisBlock()
case ctx.GlobalBool(RinkebyFlag.Name):
genesis = core.DefaultRinkebyGenesisBlock()
case ctx.GlobalBool(GangnamFlag.Name):
genesis = core.DefaultGangnamGenesisBlock()
case ctx.GlobalBool(DeveloperFlag.Name):
Fatalf("Developer chains are ephemeral")
}

View file

@ -333,6 +333,19 @@ func DefaultRinkebyGenesisBlock() *Genesis {
}
}
// DefaultGangnamGenesisBlock returns the Gangnam network genesis block.
func DefaultGangnamGenesisBlock() *Genesis {
return &Genesis{
Config: params.GangnamChainConfig,
Nonce: 66,
Timestamp: 1543910400,
ExtraData: hexutil.MustDecode("0x476f6c64656e20457468657265756d20546573746e657420303031"),
GasLimit: 8000000,
Difficulty: big.NewInt(131072),
Alloc: decodePrealloc(gangnamAllocData),
}
}
// DeveloperGenesisBlock returns the 'geth --dev' genesis block. Note, this must
// be seeded with the
func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis {

File diff suppressed because one or more lines are too long

View file

@ -47,6 +47,12 @@ var RinkebyBootnodes = []string{
"enode://b6b28890b006743680c52e64e0d16db57f28124885595fa03a562be1d2bf0f3a1da297d56b13da25fb992888fd556d4c1a27b1f39d531bde7de1921c90061cc6@159.89.28.211:30303", // AKASHA
}
// GangnamBootnodes are the enode URLs of the P2P bootstrap nodes running on the
// Gangnam test network.
var GangnamBootnodes = []string{
"enode://0db62aeb5a7c7516dc562cbceff318cf1a28a139367c5a3e0fba100948b815e41cbcbc593bfa7ee0c473f644c8845ce676af9e99a2d48e8c31fd306c47573462@115.68.99.108:30403", // Geth Pool
}
// DiscoveryV5Bootnodes are the enode URLs of the P2P bootstrap nodes for the
// experimental RLPx v5 topic-discovery network.
var DiscoveryV5Bootnodes = []string{

View file

@ -28,6 +28,7 @@ var (
MainnetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3")
TestnetGenesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d")
RinkebyGenesisHash = common.HexToHash("0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177")
GangnamGenesisHash = common.HexToHash("0x16e3e67dea810effd94361c03e0d0588701dfd56fd6f4e519ee5525ad4cb9fa0")
)
var (
@ -106,6 +107,21 @@ var (
BloomRoot: common.HexToHash("0xcc401060280c2cc82697ea5ecef8cac61e52063c37533a2e9609332419704d5f"),
}
// GangnamChainConfig contains the chain parameters to run a node on the Gangnam test network.
GangnamChainConfig = &ChainConfig{
ChainID: big.NewInt(1204),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: true,
EIP150Block: big.NewInt(0),
EIP150Hash: common.HexToHash("0x16e3e67dea810effd94361c03e0d0588701dfd56fd6f4e519ee5525ad4cb9fa0"),
EIP155Block: big.NewInt(0),
EIP158Block: big.NewInt(0),
ByzantiumBlock: big.NewInt(0),
ConstantinopleBlock: nil,
Ethash: new(EthashConfig),
}
// AllEthashProtocolChanges contains every protocol change (EIPs) introduced
// and accepted by the Ethereum core developers into the Ethash consensus.
//