cmd/*, core, params: add ottoman testnet

This commit is contained in:
mark.lin 2017-10-02 12:05:46 +08:00
parent 159fba764a
commit c7547381b2
7 changed files with 64 additions and 2 deletions

View file

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

View file

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

View file

@ -128,7 +128,7 @@ var (
} }
NetworkIdFlag = cli.Uint64Flag{ NetworkIdFlag = cli.Uint64Flag{
Name: "networkid", 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, 5=Ottoman)",
Value: eth.DefaultConfig.NetworkId, Value: eth.DefaultConfig.NetworkId,
} }
TestnetFlag = cli.BoolFlag{ TestnetFlag = cli.BoolFlag{
@ -143,6 +143,10 @@ var (
Name: "dev", Name: "dev",
Usage: "Ephemeral proof-of-authority network with a pre-funded developer account, mining enabled", Usage: "Ephemeral proof-of-authority network with a pre-funded developer account, mining enabled",
} }
OttomanFlag = cli.BoolFlag{
Name: "ottoman",
Usage: "Ottoman network: pre-configured istanbul bft test network",
}
DeveloperPeriodFlag = cli.IntFlag{ DeveloperPeriodFlag = cli.IntFlag{
Name: "dev.period", Name: "dev.period",
Usage: "Block period to use in developer mode (0 = mine only if transaction pending)", Usage: "Block period to use in developer mode (0 = mine only if transaction pending)",
@ -557,6 +561,9 @@ func MakeDataDir(ctx *cli.Context) string {
if ctx.GlobalBool(RinkebyFlag.Name) { if ctx.GlobalBool(RinkebyFlag.Name) {
return filepath.Join(path, "rinkeby") return filepath.Join(path, "rinkeby")
} }
if ctx.GlobalBool(OttomanFlag.Name) {
return filepath.Join(path, "ottoman")
}
return path return path
} }
Fatalf("Cannot determine default data directory, please set manually (--datadir)") Fatalf("Cannot determine default data directory, please set manually (--datadir)")
@ -611,6 +618,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
urls = params.TestnetBootnodes urls = params.TestnetBootnodes
case ctx.GlobalBool(RinkebyFlag.Name): case ctx.GlobalBool(RinkebyFlag.Name):
urls = params.RinkebyBootnodes urls = params.RinkebyBootnodes
case ctx.GlobalBool(OttomanFlag.Name):
urls = params.OttomanBootnodes
case cfg.BootstrapNodes != nil: case cfg.BootstrapNodes != nil:
return // already set, don't apply defaults. return // already set, don't apply defaults.
} }
@ -897,6 +906,8 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "testnet") cfg.DataDir = filepath.Join(node.DefaultDataDir(), "testnet")
case ctx.GlobalBool(RinkebyFlag.Name): case ctx.GlobalBool(RinkebyFlag.Name):
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "rinkeby") cfg.DataDir = filepath.Join(node.DefaultDataDir(), "rinkeby")
case ctx.GlobalBool(OttomanFlag.Name):
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "ottoman")
} }
if ctx.GlobalIsSet(KeyStoreDirFlag.Name) { if ctx.GlobalIsSet(KeyStoreDirFlag.Name) {
@ -1033,7 +1044,7 @@ func SetShhConfig(ctx *cli.Context, stack *node.Node, cfg *whisper.Config) {
// SetEthConfig applies eth-related command line flags to the config. // SetEthConfig applies eth-related command line flags to the config.
func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) { func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
// Avoid conflicting network flags // Avoid conflicting network flags
checkExclusive(ctx, DeveloperFlag, TestnetFlag, RinkebyFlag) checkExclusive(ctx, DeveloperFlag, TestnetFlag, RinkebyFlag, OttomanFlag)
checkExclusive(ctx, FastSyncFlag, LightModeFlag, SyncModeFlag) checkExclusive(ctx, FastSyncFlag, LightModeFlag, SyncModeFlag)
checkExclusive(ctx, LightServFlag, LightModeFlag) checkExclusive(ctx, LightServFlag, LightModeFlag)
checkExclusive(ctx, LightServFlag, SyncModeFlag, "light") checkExclusive(ctx, LightServFlag, SyncModeFlag, "light")
@ -1128,6 +1139,11 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
if !ctx.GlobalIsSet(GasPriceFlag.Name) { if !ctx.GlobalIsSet(GasPriceFlag.Name) {
cfg.GasPrice = big.NewInt(1) cfg.GasPrice = big.NewInt(1)
} }
case ctx.GlobalBool(OttomanFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 5
}
cfg.Genesis = core.DefaultOttomanGenesisBlock()
} }
// TODO(fjl): move trie cache generations into config // TODO(fjl): move trie cache generations into config
if gen := ctx.GlobalInt(TrieCacheGenFlag.Name); gen > 0 { if gen := ctx.GlobalInt(TrieCacheGenFlag.Name); gen > 0 {
@ -1229,6 +1245,8 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
genesis = core.DefaultRinkebyGenesisBlock() genesis = core.DefaultRinkebyGenesisBlock()
case ctx.GlobalBool(DeveloperFlag.Name): case ctx.GlobalBool(DeveloperFlag.Name):
Fatalf("Developer chains are ephemeral") Fatalf("Developer chains are ephemeral")
case ctx.GlobalBool(OttomanFlag.Name):
genesis = core.DefaultOttomanGenesisBlock()
} }
return genesis return genesis
} }

View file

@ -344,6 +344,19 @@ func DefaultRinkebyGenesisBlock() *Genesis {
} }
} }
// DefaultOttomanGenesisBlock returns the Ottoman network genesis block.
func DefaultOttomanGenesisBlock() *Genesis {
return &Genesis{
Config: params.OttomanChainConfig,
Timestamp: 1496993285,
ExtraData: hexutil.MustDecode("0x0000000000000000000000000000000000000000000000000000000000000000f89af85494475cc98b5521ab2a1335683e7567c8048bfe79ed9407d8299de61faed3686ba4c4e6c3b9083d7e2371944fe035ce99af680d89e2c4d73aca01dbfc1bd2fd94dc421209441a754f79c4a4ecd2b49c935aad0312b8410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0"),
GasLimit: 4700000,
Difficulty: big.NewInt(1),
Mixhash: common.HexToHash("0x63746963616c2062797a616e74696e65206661756c7420746f6c6572616e6365"),
Alloc: decodePrealloc(ottomanAllocData),
}
}
// DeveloperGenesisBlock returns the 'geth --dev' genesis block. Note, this must // DeveloperGenesisBlock returns the 'geth --dev' genesis block. Note, this must
// be seeded with the // be seeded with the
func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis { func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis {

File diff suppressed because one or more lines are too long

View file

@ -47,6 +47,15 @@ var RinkebyBootnodes = []string{
"enode://b6b28890b006743680c52e64e0d16db57f28124885595fa03a562be1d2bf0f3a1da297d56b13da25fb992888fd556d4c1a27b1f39d531bde7de1921c90061cc6@159.89.28.211:30303", // AKASHA "enode://b6b28890b006743680c52e64e0d16db57f28124885595fa03a562be1d2bf0f3a1da297d56b13da25fb992888fd556d4c1a27b1f39d531bde7de1921c90061cc6@159.89.28.211:30303", // AKASHA
} }
// Ottoman are the enode URLs of the P2P bootstrap nodes running on the
// Ottoman test network.
var OttomanBootnodes = []string{
"enode://851ceb576681cf1e0d46ee9f049d6c678f229d806d1b41afe5b6d3c99a43fbbb7271d60e4c43cc5535e125a61db4ea2424823a3ad2c5959e8125f546cd1a7969@13.76.136.158:30303", //SG
"enode://e3b5624752b86b60aa492edd65bdc906f9861a5e9113abd8f908443d1f64395c0e2bdd2e1825154837fd72da9d2e55e4f231411d5ca99ba9c90e14ba2f5612f6@52.163.118.231:30303", //SG
"enode://3a1c96fe1fe9da5d4ea3b1a65bfecb4571101b519595cab6deb2eb029209353cdbc91c8d3751d0c6c00e5440657b678508e99bd9e934d4a0c1ad553fc1cb9155@13.76.140.250:30303", //SG
"enode://aebe74e4ab7db8074d1cb9634dab3fd8c5745f8cc4868da2007ff754721085b189ffaf44b8041219de90b55df3ac515bbd0e1df7fde8d7684df0ecfb12534a73@52.187.45.126:30303", //SG
}
// DiscoveryV5Bootnodes are the enode URLs of the P2P bootstrap nodes for the // DiscoveryV5Bootnodes are the enode URLs of the P2P bootstrap nodes for the
// experimental RLPx v5 topic-discovery network. // experimental RLPx v5 topic-discovery network.
var DiscoveryV5Bootnodes = []string{ var DiscoveryV5Bootnodes = []string{

View file

@ -18,6 +18,7 @@ package params
import ( import (
"fmt" "fmt"
"math"
"math/big" "math/big"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
@ -77,6 +78,24 @@ var (
}, },
} }
// OttomanChainConfig contains the chain parameters to run a node on the Ottoman test network.
OttomanChainConfig = &ChainConfig{
ChainId: big.NewInt(5),
HomesteadBlock: big.NewInt(1),
DAOForkBlock: nil,
DAOForkSupport: true,
EIP150Block: big.NewInt(2),
EIP150Hash: common.HexToHash("0x9b095b36c15eaf13044373aef8ee0bd3a382a5abb92e402afa44b8249c3a90e9"),
EIP155Block: big.NewInt(3),
EIP158Block: big.NewInt(3),
ByzantiumBlock: big.NewInt(math.MaxInt64), // Don't enable yet
Istanbul: &IstanbulConfig{
Epoch: 30000,
ProposerPolicy: 0,
},
}
// AllEthashProtocolChanges contains every protocol change (EIPs) introduced // AllEthashProtocolChanges contains every protocol change (EIPs) introduced
// and accepted by the Ethereum core developers into the Ethash consensus. // and accepted by the Ethereum core developers into the Ethash consensus.
// //