Skip to content

Commit

Permalink
Merge pull request ethereum#14 from kimmyeonghun/add-ethersocial
Browse files Browse the repository at this point in the history
Support Ethersocial network
  • Loading branch information
sorpaas authored Oct 23, 2018
2 parents a79cdd7 + 12888f8 commit f0efabf
Show file tree
Hide file tree
Showing 12 changed files with 108 additions and 15 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ For a full list of networks supported by multi-geth, take a look at the command-
--classic Ethereum Classic network: pre-configured Ethereum Classic mainnet
--social Ethereum Social network: pre-configured Ethereum Social mainnet
--mix MIX network: pre-configured MIX mainnet
--ethersocial Ethersocial network: pre-configured Ethersocial mainnet
--rinkeby Rinkeby network: pre-configured proof-of-authority test network
```

Expand Down
1 change: 1 addition & 0 deletions cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ The export-preimages command export hash preimages to an RLP encoded stream`,
utils.EllaismFlag,
utils.ClassicFlag,
utils.SocialFlag,
utils.EthersocialFlag,
utils.RinkebyFlag,
},
Category: "BLOCKCHAIN COMMANDS",
Expand Down
2 changes: 2 additions & 0 deletions cmd/geth/consolecmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ func remoteConsole(ctx *cli.Context) error {
path = filepath.Join(path, "social")
} else if ctx.GlobalBool(utils.MixFlag.Name) {
path = filepath.Join(path, "mix")
} else if ctx.GlobalBool(utils.EthersocialFlag.Name) {
path = filepath.Join(path, "ethersocial")
}
}
endpoint = fmt.Sprintf("%s/geth.ipc", path)
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ var (
utils.ClassicFlag,
utils.SocialFlag,
utils.MixFlag,
utils.EthersocialFlag,
utils.RinkebyFlag,
utils.VMEnableDebugFlag,
utils.NetworkIdFlag,
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ var AppHelpFlagGroups = []flagGroup{
utils.ClassicFlag,
utils.SocialFlag,
utils.MixFlag,
utils.EthersocialFlag,
utils.RinkebyFlag,
utils.SyncModeFlag,
utils.GCModeFlag,
Expand Down
20 changes: 19 additions & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ var (
Name: "mix",
Usage: "MIX network: pre-configured MIX mainnet",
}
EthersocialFlag = cli.BoolFlag{
Name: "ethersocial",
Usage: "Ethersocial network: pre-configured Ethersocial mainnet",
}
RinkebyFlag = cli.BoolFlag{
Name: "rinkeby",
Usage: "Rinkeby network: pre-configured proof-of-authority test network",
Expand Down Expand Up @@ -659,6 +663,9 @@ func MakeDataDir(ctx *cli.Context) string {
if ctx.GlobalBool(MixFlag.Name) {
return filepath.Join(path, "mix")
}
if ctx.GlobalBool(EthersocialFlag.Name) {
return filepath.Join(path, "ethersocial")
}
if ctx.GlobalBool(RinkebyFlag.Name) {
return filepath.Join(path, "rinkeby")
}
Expand Down Expand Up @@ -722,6 +729,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
urls = params.SocialBootnodes
case ctx.GlobalBool(MixFlag.Name):
urls = params.MixBootnodes
case ctx.GlobalBool(EthersocialFlag.Name):
urls = params.EthersocialBootnodes
case ctx.GlobalBool(RinkebyFlag.Name):
urls = params.RinkebyBootnodes
case cfg.BootstrapNodes != nil:
Expand Down Expand Up @@ -1024,6 +1033,8 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "social")
case ctx.GlobalBool(MixFlag.Name):
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "mix")
case ctx.GlobalBool(EthersocialFlag.Name):
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "ethersocial")
case ctx.GlobalBool(RinkebyFlag.Name):
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "rinkeby")
}
Expand Down Expand Up @@ -1169,7 +1180,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, SocialFlag, MixFlag)
checkExclusive(ctx, DeveloperFlag, TestnetFlag, RinkebyFlag, EllaismFlag, ClassicFlag, SocialFlag, MixFlag, EthersocialFlag)
checkExclusive(ctx, LightServFlag, SyncModeFlag, "light")

if ctx.GlobalIsSet(EllaismFlag.Name) {
Expand Down Expand Up @@ -1279,6 +1290,11 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
cfg.NetworkId = 28
}
cfg.Genesis = core.DefaultSocialGenesisBlock()
case ctx.GlobalBool(EthersocialFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 1
}
cfg.Genesis = core.DefaultEthersocialGenesisBlock()
case ctx.GlobalBool(RinkebyFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 4
Expand Down Expand Up @@ -1435,6 +1451,8 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
genesis = core.DefaultSocialGenesisBlock()
case ctx.GlobalBool(MixFlag.Name):
genesis = core.DefaultMixGenesisBlock()
case ctx.GlobalBool(EthersocialFlag.Name):
genesis = core.DefaultEthersocialGenesisBlock()
case ctx.GlobalBool(RinkebyFlag.Name):
genesis = core.DefaultRinkebyGenesisBlock()
case ctx.GlobalBool(DeveloperFlag.Name):
Expand Down
4 changes: 4 additions & 0 deletions consensus/ethash/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var (
ByzantiumBlockReward = big.NewInt(3e+18) // Block reward in wei for successfully mining a block upward from Byzantium
ConstantinopleBlockReward = big.NewInt(2e+18) // Block reward in wei for successfully mining a block upward from Constantinople
SocialBlockReward = new(big.Int).Mul(big.NewInt(50), big.NewInt(1e+18)) // Block reward in wei for successfully mining a block upward for Ethereum Social
EthersocialBlockReward = big.NewInt(5e+18) // Block reward in wei for successfully mining a block upward for Ethersocial Network
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
Expand Down Expand Up @@ -774,6 +775,9 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header
if config.IsSocial(header.Number) {
blockReward = SocialBlockReward
}
if config.IsEthersocial(header.Number) {
blockReward = EthersocialBlockReward
}
if config.HasECIP1017() {
// Ensure value 'era' is configured.
eraLen := config.ECIP1017EraRounds
Expand Down
14 changes: 14 additions & 0 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig {
return params.SocialChainConfig
case ghash == params.MixGenesisHash:
return params.MixChainConfig
case ghash == params.EthersocialGenesisHash:
return params.EthersocialChainConfig
default:
return params.AllEthashProtocolChanges
}
Expand Down Expand Up @@ -363,6 +365,18 @@ func DefaultMixGenesisBlock() *Genesis {
}
}

// EthersocialGenesisBlock returns the Ethersocial main net genesis block.
func DefaultEthersocialGenesisBlock() *Genesis {
return &Genesis{
Config: params.EthersocialChainConfig,
Nonce: 66,
ExtraData: hexutil.MustDecode("0x"),
GasLimit: 3141592,
Difficulty: big.NewInt(131072),
Alloc: decodePrealloc(ethersocialAllocData),
}
}

// DefaultTestnetGenesisBlock returns the Ropsten network genesis block.
func DefaultTestnetGenesisBlock() *Genesis {
return &Genesis{
Expand Down
1 change: 1 addition & 0 deletions core/genesis_alloc.go

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions mobile/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ func MixGenesis() string {
return string(enc)
}

// EthersocialGenesis returns the JSON spec to use for the Ethersocial network.
func EthersocialGenesis() string {
enc, err := json.Marshal(core.DefaultEthersocialGenesisBlock())
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())
Expand Down
10 changes: 10 additions & 0 deletions params/bootnodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ var MixBootnodes = []string{
"enode://799d0a8836e17ef7fcc58b3d5ced5bb1fe474b31a09851f938d381f4556fa8954ca308f6a178d22ed56769a8b878ac8f9cc62c889f9cafab45a3bd4f6024bb29@172.104.68.7:30313",
}

// EthersocialBootnodes are the enode URLs of the P2P bootstrap nodes running on
// the Ethersocial network.
var EthersocialBootnodes = []string{
"enode://6dcb79d9a9f978521a7edf53a50484f0595e14aa08575f0e71099a009ce2dbf40ef9b2dada99e3c78782f1300c1f6726c3d5acefa02730e1c8fe3c1a5301d8d8@52.231.75.3:50501",
"enode://e1d30788711266f699bf95f0392120ec620086d4eeabfd7e92e65a996ecd116cb9331ee3623aab88f498fb28bc302ac827cd3dc71f2db3c134e726eb23944af6@23.100.101.195:50501",
"enode://f2c298eee215cefa930b5280e665a38b2706be3120c302b9fcb48dc7d3ceba3a3e7bac354dccbbcbc3bfd177882b0d5498f36833dfcd5674225adb19dd04ec3a@52.231.74.146:50505",
"enode://7769cf0bdb7edd8dd95e590b46f950b9bd9625d681ec6123b31d3be58f1f1e0531d9811ccd9c1ad5d52a73999c6da2131943ca02666e238b1f265a1cc64dcae7@52.231.35.75:50505",
"enode://52e5e84d44bbda7e24a92826e60dfeb20a5d840c3c0be646b21940d7648f49a91bff2b7c47d37894b962eb183d8c7f71f693efb8534ee170ccd902addd487970@52.226.16.248:50505",
}

// TestnetBootnodes are the enode URLs of the P2P bootstrap nodes running on the
// Ropsten test network.
var TestnetBootnodes = []string{
Expand Down
59 changes: 45 additions & 14 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ import (

// Genesis hashes to enforce below configs on.
var (
MainnetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3")
TestnetGenesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d")
EllaismGenesisHash = common.HexToHash("0x4d7df65052bb21264d6ad2d6fe2d5578a36be12f71bf8d0559b0c15c4dc539b5")
SocialGenesisHash = common.HexToHash("0xba8314d5c2ebddaf58eb882b364b27cbfa4d3402dacd32b60986754ac25cfe8d")
MixGenesisHash = common.HexToHash("0x4fa57903dad05875ddf78030c16b5da886f7d81714cf66946a4c02566dbb2af5")
RinkebyGenesisHash = common.HexToHash("0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177")
MainnetGenesisHash = common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3")
TestnetGenesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d")
EllaismGenesisHash = common.HexToHash("0x4d7df65052bb21264d6ad2d6fe2d5578a36be12f71bf8d0559b0c15c4dc539b5")
SocialGenesisHash = common.HexToHash("0xba8314d5c2ebddaf58eb882b364b27cbfa4d3402dacd32b60986754ac25cfe8d")
MixGenesisHash = common.HexToHash("0x4fa57903dad05875ddf78030c16b5da886f7d81714cf66946a4c02566dbb2af5")
EthersocialGenesisHash = common.HexToHash("0x310dd3c4ae84dd89f1b46cfdd5e26c8f904dfddddc73f323b468127272e20e9f")
RinkebyGenesisHash = common.HexToHash("0x6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177")
)

var (
Expand All @@ -47,6 +48,7 @@ var (
ByzantiumBlock: big.NewInt(4370000),
DisposalBlock: nil,
SocialBlock: nil,
EthersocialBlock: nil,
ConstantinopleBlock: nil,
Ethash: new(EthashConfig),
}
Expand All @@ -64,6 +66,7 @@ var (
ByzantiumBlock: nil,
DisposalBlock: big.NewInt(0),
SocialBlock: nil,
EthersocialBlock: nil,
ConstantinopleBlock: nil,
ECIP1017EraRounds: big.NewInt(10000000),
EIP160Block: big.NewInt(0),
Expand All @@ -83,6 +86,7 @@ var (
ByzantiumBlock: nil,
DisposalBlock: big.NewInt(5900000),
SocialBlock: nil,
EthersocialBlock: nil,
ConstantinopleBlock: nil,
ECIP1017EraRounds: big.NewInt(5000000),
EIP160Block: big.NewInt(3000000),
Expand All @@ -104,6 +108,7 @@ var (
ByzantiumBlock: nil,
DisposalBlock: big.NewInt(0),
SocialBlock: big.NewInt(0),
EthersocialBlock: nil,
ConstantinopleBlock: nil,
ECIP1017EraRounds: big.NewInt(5000000),
EIP160Block: big.NewInt(0),
Expand Down Expand Up @@ -132,8 +137,26 @@ var (
ByzantiumBlock: nil,
DisposalBlock: nil,
SocialBlock: nil,
EthersocialBlock: nil,
ConstantinopleBlock: nil,
EIP160Block: big.NewInt(0),
}

// EthersocialChainConfig is the chain parameters to run a node on the Ethersocial main network.
EthersocialChainConfig = &ChainConfig{
ChainID: big.NewInt(31102),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: big.NewInt(0),
DAOForkSupport: false,
EIP150Block: big.NewInt(0),
EIP150Hash: common.HexToHash("0x310dd3c4ae84dd89f1b46cfdd5e26c8f904dfddddc73f323b468127272e20e9f"),
EIP155Block: big.NewInt(845000),
EIP158Block: big.NewInt(845000),
ByzantiumBlock: big.NewInt(600000),
DisposalBlock: nil,
SocialBlock: nil,
EthersocialBlock: big.NewInt(0),
ConstantinopleBlock: nil,
Ethash: new(EthashConfig),
}

Expand All @@ -150,6 +173,7 @@ var (
ByzantiumBlock: big.NewInt(1700000),
DisposalBlock: nil,
SocialBlock: nil,
EthersocialBlock: nil,
ConstantinopleBlock: big.NewInt(4230000),
Ethash: new(EthashConfig),
}
Expand All @@ -176,6 +200,7 @@ var (
ByzantiumBlock: big.NewInt(1035301),
DisposalBlock: nil,
SocialBlock: nil,
EthersocialBlock: nil,
ConstantinopleBlock: nil,
Clique: &CliqueConfig{
Period: 15,
Expand All @@ -197,16 +222,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, 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, 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, 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, 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, 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, nil, nil, nil, nil, new(EthashConfig), nil}
TestRules = TestChainConfig.Rules(new(big.Int))
)

Expand Down Expand Up @@ -239,10 +264,11 @@ type ChainConfig struct {
EIP150Block *big.Int `json:"eip150Block,omitempty"` // EIP150 HF block (nil = no fork)
EIP150Hash common.Hash `json:"eip150Hash,omitempty"` // EIP150 HF hash (needed for header only clients as only gas pricing changed)

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
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
EthersocialBlock *big.Int `json:"ethersocialBlock,omitempty"` // Ethersocial 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)
Expand Down Expand Up @@ -289,7 +315,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 Social: %v ECIP1017: %v EIP160: %v ECIP1010PauseBlock: %v ECIP1010Length: %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 Ethersocial: %v ECIP1017: %v EIP160: %v ECIP1010PauseBlock: %v ECIP1010Length: %v Constantinople: %v Engine: %v}",
c.ChainID,
c.HomesteadBlock,
c.DAOForkBlock,
Expand All @@ -300,6 +326,7 @@ func (c *ChainConfig) String() string {
c.ByzantiumBlock,
c.DisposalBlock,
c.SocialBlock,
c.EthersocialBlock,
c.ECIP1017EraRounds,
c.EIP160Block,
c.ECIP1010PauseBlock,
Expand Down Expand Up @@ -366,6 +393,10 @@ func (c *ChainConfig) IsSocial(num *big.Int) bool {
return isForked(c.SocialBlock, num)
}

func (c *ChainConfig) IsEthersocial(num *big.Int) bool {
return isForked(c.EthersocialBlock, num)
}

func (c *ChainConfig) IsECIP1010(num *big.Int) bool {
return isForked(c.ECIP1010PauseBlock, num)
}
Expand Down

0 comments on commit f0efabf

Please sign in to comment.