mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 17:33:47 +00:00
Init Ethereum Social flags and chain config (#5)
This commit is contained in:
parent
c98385be40
commit
be1c56e244
12 changed files with 105 additions and 6 deletions
|
|
@ -137,6 +137,7 @@ The export-preimages command export hash preimages to an RLP encoded stream`,
|
|||
utils.TestnetFlag,
|
||||
utils.EllaismFlag,
|
||||
utils.ClassicFlag,
|
||||
utils.SocialFlag,
|
||||
utils.RinkebyFlag,
|
||||
},
|
||||
Category: "BLOCKCHAIN COMMANDS",
|
||||
|
|
|
|||
|
|
@ -130,6 +130,8 @@ func remoteConsole(ctx *cli.Context) error {
|
|||
path = filepath.Join(path, "ellaism")
|
||||
} else if ctx.GlobalBool(utils.ClassicFlag.Name) {
|
||||
path = filepath.Join(path, "classic")
|
||||
} else if ctx.GlobalBool(utils.SocialFlag.Name) {
|
||||
path = filepath.Join(path, "social")
|
||||
}
|
||||
}
|
||||
endpoint = fmt.Sprintf("%s/geth.ipc", path)
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ var (
|
|||
utils.TestnetFlag,
|
||||
utils.EllaismFlag,
|
||||
utils.ClassicFlag,
|
||||
utils.SocialFlag,
|
||||
utils.RinkebyFlag,
|
||||
utils.VMEnableDebugFlag,
|
||||
utils.NetworkIdFlag,
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ var AppHelpFlagGroups = []flagGroup{
|
|||
utils.TestnetFlag,
|
||||
utils.EllaismFlag,
|
||||
utils.ClassicFlag,
|
||||
utils.SocialFlag,
|
||||
utils.RinkebyFlag,
|
||||
utils.SyncModeFlag,
|
||||
utils.GCModeFlag,
|
||||
|
|
|
|||
|
|
@ -143,6 +143,10 @@ var (
|
|||
Name: "classic",
|
||||
Usage: "Ethereum Classic network: pre-configured Ethereum Classic mainnet",
|
||||
}
|
||||
SocialFlag = cli.BoolFlag{
|
||||
Name: "social",
|
||||
Usage: "Ethereum Social network: pre-configured Ethereum Social mainnet",
|
||||
}
|
||||
RinkebyFlag = cli.BoolFlag{
|
||||
Name: "rinkeby",
|
||||
Usage: "Rinkeby network: pre-configured proof-of-authority test network",
|
||||
|
|
@ -556,6 +560,9 @@ func MakeDataDir(ctx *cli.Context) string {
|
|||
if ctx.GlobalBool(ClassicFlag.Name) {
|
||||
return filepath.Join(path, "classic")
|
||||
}
|
||||
if ctx.GlobalBool(SocialFlag.Name) {
|
||||
return filepath.Join(path, "social")
|
||||
}
|
||||
if ctx.GlobalBool(RinkebyFlag.Name) {
|
||||
return filepath.Join(path, "rinkeby")
|
||||
}
|
||||
|
|
@ -615,6 +622,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
|
|||
urls = params.EllaismBootnodes
|
||||
case ctx.GlobalBool(ClassicFlag.Name):
|
||||
urls = params.ClassicBootnodes
|
||||
case ctx.GlobalBool(SocialFlag.Name):
|
||||
urls = params.SocialBootnodes
|
||||
case ctx.GlobalBool(RinkebyFlag.Name):
|
||||
urls = params.RinkebyBootnodes
|
||||
case cfg.BootstrapNodes != nil:
|
||||
|
|
@ -905,6 +914,8 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
|
|||
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "ellaism")
|
||||
case ctx.GlobalBool(ClassicFlag.Name):
|
||||
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "classic")
|
||||
case ctx.GlobalBool(SocialFlag.Name):
|
||||
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "social")
|
||||
case ctx.GlobalBool(RinkebyFlag.Name):
|
||||
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "rinkeby")
|
||||
}
|
||||
|
|
@ -1034,7 +1045,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, EllaismFlag, ClassicFlag)
|
||||
checkExclusive(ctx, DeveloperFlag, TestnetFlag, RinkebyFlag, EllaismFlag, ClassicFlag, SocialFlag)
|
||||
checkExclusive(ctx, FastSyncFlag, LightModeFlag, SyncModeFlag)
|
||||
checkExclusive(ctx, LightServFlag, LightModeFlag)
|
||||
checkExclusive(ctx, LightServFlag, SyncModeFlag, "light")
|
||||
|
|
@ -1110,6 +1121,11 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
|
|||
cfg.NetworkId = 1
|
||||
}
|
||||
cfg.Genesis = core.DefaultClassicGenesisBlock()
|
||||
case ctx.GlobalBool(SocialFlag.Name):
|
||||
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
|
||||
cfg.NetworkId = 28
|
||||
}
|
||||
cfg.Genesis = core.DefaultSocialGenesisBlock()
|
||||
case ctx.GlobalBool(RinkebyFlag.Name):
|
||||
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
|
||||
cfg.NetworkId = 4
|
||||
|
|
@ -1239,6 +1255,8 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
|
|||
genesis = core.DefaultEllaismGenesisBlock()
|
||||
case ctx.GlobalBool(ClassicFlag.Name):
|
||||
genesis = core.DefaultClassicGenesisBlock()
|
||||
case ctx.GlobalBool(SocialFlag.Name):
|
||||
genesis = core.DefaultSocialGenesisBlock()
|
||||
case ctx.GlobalBool(RinkebyFlag.Name):
|
||||
genesis = core.DefaultRinkebyGenesisBlock()
|
||||
case ctx.GlobalBool(DeveloperFlag.Name):
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import (
|
|||
var (
|
||||
FrontierBlockReward *big.Int = big.NewInt(5e+18) // Block reward in wei for successfully mining a block
|
||||
ByzantiumBlockReward *big.Int = big.NewInt(3e+18) // Block reward in wei for successfully mining a block upward from Byzantium
|
||||
SocialBlockReward *big.Int = new(big.Int).Mul(big.NewInt(50), big.NewInt(1e+18)) // Block reward in wei for successfully mining a block upward for Ethereum Social
|
||||
maxUncles = 2 // Maximum number of uncles allowed in a single block
|
||||
allowedFutureBlockTime = 15 * time.Second // Max time from current time allowed for blocks, before they're considered future blocks
|
||||
DisinflationRateQuotient = big.NewInt(4) // Disinflation rate quotient for ECIP1017
|
||||
|
|
@ -581,6 +582,9 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header
|
|||
if config.IsByzantium(header.Number) {
|
||||
blockReward = ByzantiumBlockReward
|
||||
}
|
||||
if config.IsSocial(header.Number) {
|
||||
blockReward = SocialBlockReward
|
||||
}
|
||||
if config.HasECIP1017() {
|
||||
// Ensure value 'era' is configured.
|
||||
eraLen := config.ECIP1017EraRounds
|
||||
|
|
|
|||
|
|
@ -216,6 +216,8 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig {
|
|||
return params.TestnetChainConfig
|
||||
case ghash == params.EllaismGenesisHash:
|
||||
return params.EllaismChainConfig
|
||||
case ghash == params.SocialGenesisHash:
|
||||
return params.SocialChainConfig
|
||||
default:
|
||||
return params.AllEthashProtocolChanges
|
||||
}
|
||||
|
|
@ -334,7 +336,7 @@ func DefaultEllaismGenesisBlock() *Genesis {
|
|||
}
|
||||
}
|
||||
|
||||
// ClassicGenesisBlock returns the Ellaism genesis block.
|
||||
// ClassicGenesisBlock returns the Ethereum Classic genesis block.
|
||||
func DefaultClassicGenesisBlock() *Genesis {
|
||||
return &Genesis{
|
||||
Config: params.ClassicChainConfig,
|
||||
|
|
@ -346,6 +348,18 @@ func DefaultClassicGenesisBlock() *Genesis {
|
|||
}
|
||||
}
|
||||
|
||||
// SocialGenesisBlock returns the Ethereum Social genesis block.
|
||||
func DefaultSocialGenesisBlock() *Genesis {
|
||||
return &Genesis{
|
||||
Config: params.SocialChainConfig,
|
||||
Nonce: 66,
|
||||
ExtraData: hexutil.MustDecode("0x3230313820457468657265756d20536f6369616c2050726f6a656374"),
|
||||
GasLimit: 5000,
|
||||
Difficulty: big.NewInt(17179869184),
|
||||
Alloc: decodePrealloc(socialAllocData),
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultTestnetGenesisBlock returns the Ropsten network genesis block.
|
||||
func DefaultTestnetGenesisBlock() *Genesis {
|
||||
return &Genesis{
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -147,6 +147,12 @@ func NewNode(datadir string, config *NodeConfig) (stack *Node, _ error) {
|
|||
config.EthereumNetworkID = 64
|
||||
}
|
||||
}
|
||||
if config.EthereumGenesis == SocialGenesis() {
|
||||
genesis.Config = params.SocialChainConfig
|
||||
if config.EthereumNetworkID == 1 {
|
||||
config.EthereumNetworkID = 28
|
||||
}
|
||||
}
|
||||
}
|
||||
// Register the Ethereum protocol if requested
|
||||
if config.EthereumEnabled {
|
||||
|
|
|
|||
|
|
@ -41,6 +41,15 @@ func EllaismGenesis() string {
|
|||
return string(enc)
|
||||
}
|
||||
|
||||
// SocialGenesis returns the JSON spec to use for the Ethereum Social network.
|
||||
func SocialGenesis() string {
|
||||
enc, err := json.Marshal(core.DefaultSocialGenesisBlock())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return string(enc)
|
||||
}
|
||||
|
||||
// TestnetGenesis returns the JSON spec to use for the Ethereum test network.
|
||||
func TestnetGenesis() string {
|
||||
enc, err := json.Marshal(core.DefaultTestnetGenesisBlock())
|
||||
|
|
|
|||
|
|
@ -57,6 +57,17 @@ var ClassicBootnodes = []string{
|
|||
"enode://f50e675a34f471af2438b921914b5f06499c7438f3146f6b8936f1faeb50b8a91d0d0c24fb05a66f05865cd58c24da3e664d0def806172ddd0d4c5bdbf37747e@144.76.238.49:30306",
|
||||
}
|
||||
|
||||
// SocialBootnodes are the enode URLs of the P2P bootstrap nodes running on
|
||||
// the Ethereum Social network.
|
||||
var SocialBootnodes = []string{
|
||||
"enode://54d0824a268747046b6cabc7ee3afda48edba319f0d175e9e505aa9d425a1872b8b6f9ebf8f3b0a10dc7611a4c44ddec0fc691e5a5cde23e06fc4e4b3ff9dbef@13.125.185.147:30303",
|
||||
"enode://7e150d47637177f675e20d663fc2500987f2149332caf23da522d92363be8a7880ef9150a6183e9031288a441e0457239474967a111eafce17e19a4288076ea9@18.219.40.235:30303",
|
||||
"enode://6244c9d9cd288015d7ff165e90f3bb5649e34467e095a47c6d3c56e8fb8c849b3b4db683ff3c7ae8a654bbdc07ef12ee2fd7d72831ac213723281c1b0cc90599@13.250.220.98:30303",
|
||||
"enode://e39f162b9f4b6ed6f098550f7867c2fb068fc66f362b3db0f45124c43ea18508f5ceef4e0e4de53d301e14a6f1683226aeb931d7401b4e83b5a583153ffdd7fd@52.57.98.157:30303",
|
||||
"enode://54b4a117d66dc3aa93358dec1b31d4f38e72e4381b3e28a65ac6f1aaac3b304ebbe41d32cc864fa69a9a6815c34cf9b8965690dc174a5f72af14547b601b7924@222.239.255.71:30303",
|
||||
"enode://851f14c5cc86cbc0a81acfcbe5dd99ad5c823435357219df736932c5f89ad4318f6973a553857a32d97a71793f5a35c062d46320be282aa0a80b06b9c6b624e4@13.125.232.71:30303",
|
||||
}
|
||||
|
||||
// TestnetBootnodes are the enode URLs of the P2P bootstrap nodes running on the
|
||||
// Ropsten test network.
|
||||
var TestnetBootnodes = []string{
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ var (
|
|||
MainnetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3") // Mainnet genesis hash to enforce below configs on
|
||||
TestnetGenesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d") // Testnet genesis hash to enforce below configs on
|
||||
EllaismGenesisHash = common.HexToHash("0x4d7df65052bb21264d6ad2d6fe2d5578a36be12f71bf8d0559b0c15c4dc539b5") // Ellaism genesis hash to enforce below configs on
|
||||
SocialGenesisHash = common.HexToHash("0xba8314d5c2ebddaf58eb882b364b27cbfa4d3402dacd32b60986754ac25cfe8d") // Ethereum Social genesis hash to enforce below configs on
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -42,6 +43,7 @@ var (
|
|||
EIP158Block: big.NewInt(2675000),
|
||||
ByzantiumBlock: big.NewInt(4370000),
|
||||
DisposalBlock: nil,
|
||||
SocialBlock: nil,
|
||||
ConstantinopleBlock: nil,
|
||||
Ethash: new(EthashConfig),
|
||||
}
|
||||
|
|
@ -58,6 +60,7 @@ var (
|
|||
EIP158Block: nil,
|
||||
ByzantiumBlock: nil,
|
||||
DisposalBlock: big.NewInt(0),
|
||||
SocialBlock: nil,
|
||||
ConstantinopleBlock: nil,
|
||||
ECIP1017EraRounds: big.NewInt(10000000),
|
||||
EIP160Block: big.NewInt(0),
|
||||
|
|
@ -76,12 +79,32 @@ var (
|
|||
EIP158Block: nil,
|
||||
ByzantiumBlock: nil,
|
||||
DisposalBlock: big.NewInt(5900000),
|
||||
SocialBlock: nil,
|
||||
ConstantinopleBlock: nil,
|
||||
ECIP1017EraRounds: big.NewInt(5000000),
|
||||
EIP160Block: big.NewInt(3000000),
|
||||
Ethash: new(EthashConfig),
|
||||
}
|
||||
|
||||
// SocialChainConfig is the chain parameters to run a node on the Ethereum Social main network.
|
||||
SocialChainConfig = &ChainConfig{
|
||||
ChainId: big.NewInt(28),
|
||||
HomesteadBlock: big.NewInt(0),
|
||||
DAOForkBlock: nil,
|
||||
DAOForkSupport: true,
|
||||
EIP150Block: big.NewInt(0),
|
||||
EIP150Hash: common.HexToHash("0xba8314d5c2ebddaf58eb882b364b27cbfa4d3402dacd32b60986754ac25cfe8d"),
|
||||
EIP155Block: big.NewInt(0),
|
||||
EIP158Block: nil,
|
||||
ByzantiumBlock: nil,
|
||||
DisposalBlock: big.NewInt(0),
|
||||
SocialBlock: big.NewInt(0),
|
||||
ConstantinopleBlock: nil,
|
||||
ECIP1017EraRounds: big.NewInt(5000000),
|
||||
EIP160Block: big.NewInt(0),
|
||||
Ethash: new(EthashConfig),
|
||||
}
|
||||
|
||||
// TestnetChainConfig contains the chain parameters to run a node on the Ropsten test network.
|
||||
TestnetChainConfig = &ChainConfig{
|
||||
ChainId: big.NewInt(3),
|
||||
|
|
@ -94,6 +117,7 @@ var (
|
|||
EIP158Block: big.NewInt(10),
|
||||
ByzantiumBlock: big.NewInt(1700000),
|
||||
DisposalBlock: nil,
|
||||
SocialBlock: nil,
|
||||
ConstantinopleBlock: nil,
|
||||
Ethash: new(EthashConfig),
|
||||
}
|
||||
|
|
@ -110,6 +134,7 @@ var (
|
|||
EIP158Block: big.NewInt(3),
|
||||
ByzantiumBlock: big.NewInt(1035301),
|
||||
DisposalBlock: nil,
|
||||
SocialBlock: nil,
|
||||
ConstantinopleBlock: nil,
|
||||
Clique: &CliqueConfig{
|
||||
Period: 15,
|
||||
|
|
@ -122,16 +147,16 @@ var (
|
|||
//
|
||||
// This configuration is intentionally not using keyed fields to force anyone
|
||||
// adding flags to the config to also have to set these fields.
|
||||
AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, nil, new(EthashConfig), nil}
|
||||
AllEthashProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, nil, nil, new(EthashConfig), nil}
|
||||
|
||||
// AllCliqueProtocolChanges contains every protocol change (EIPs) introduced
|
||||
// and accepted by the Ethereum core developers into the Clique consensus.
|
||||
//
|
||||
// This configuration is intentionally not using keyed fields to force anyone
|
||||
// adding flags to the config to also have to set these fields.
|
||||
AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}}
|
||||
AllCliqueProtocolChanges = &ChainConfig{big.NewInt(1337), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, nil, nil, nil, &CliqueConfig{Period: 0, Epoch: 30000}}
|
||||
|
||||
TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, nil, new(EthashConfig), nil}
|
||||
TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, nil, nil, nil, new(EthashConfig), nil}
|
||||
TestRules = TestChainConfig.Rules(new(big.Int))
|
||||
)
|
||||
|
||||
|
|
@ -155,6 +180,7 @@ type ChainConfig struct {
|
|||
EIP155Block *big.Int `json:"eip155Block,omitempty"` // EIP155 HF block
|
||||
EIP158Block *big.Int `json:"eip158Block,omitempty"` // EIP158 HF block
|
||||
DisposalBlock *big.Int `json:"disposalBlock,omitempty"` // Bomb disposal HF block
|
||||
SocialBlock *big.Int `json:"socialBlock,omitempty"` // Ethereum Social Reward block
|
||||
|
||||
ByzantiumBlock *big.Int `json:"byzantiumBlock,omitempty"` // Byzantium switch block (nil = no fork, 0 = already on byzantium)
|
||||
ConstantinopleBlock *big.Int `json:"constantinopleBlock,omitempty"` // Constantinople switch block (nil = no fork, 0 = already activated)
|
||||
|
|
@ -197,7 +223,7 @@ func (c *ChainConfig) String() string {
|
|||
default:
|
||||
engine = "unknown"
|
||||
}
|
||||
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v, Disposal: %v, ECIP1017: %v, EIP160: %v, Constantinople: %v, Engine: %v}",
|
||||
return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v, Disposal: %v, Social: %v, ECIP1017: %v, EIP160: %v, Constantinople: %v, Engine: %v}",
|
||||
c.ChainId,
|
||||
c.HomesteadBlock,
|
||||
c.DAOForkBlock,
|
||||
|
|
@ -207,6 +233,7 @@ func (c *ChainConfig) String() string {
|
|||
c.EIP158Block,
|
||||
c.ByzantiumBlock,
|
||||
c.DisposalBlock,
|
||||
c.SocialBlock,
|
||||
c.ECIP1017EraRounds,
|
||||
c.EIP160Block,
|
||||
c.ConstantinopleBlock,
|
||||
|
|
@ -262,6 +289,10 @@ func (c *ChainConfig) IsBombDisposal(num *big.Int) bool {
|
|||
return isForked(c.DisposalBlock, num)
|
||||
}
|
||||
|
||||
func (c *ChainConfig) IsSocial(num *big.Int) bool {
|
||||
return isForked(c.SocialBlock, num)
|
||||
}
|
||||
|
||||
// GasTable returns the gas table corresponding to the current phase (homestead or homestead reprice).
|
||||
//
|
||||
// The returned GasTable's fields shouldn't, under any circumstances, be changed.
|
||||
|
|
|
|||
Loading…
Reference in a new issue