Init Callisto flags and chain config

Add CLO mainnet support
This commit is contained in:
Akira Takizawa 2018-04-15 16:10:24 +09:00
parent e7fb746750
commit 3ac1691de6
No known key found for this signature in database
GPG key ID: 4BB42E31C79111B8
11 changed files with 120 additions and 13 deletions

View file

@ -139,6 +139,7 @@ The export-preimages command export hash preimages to an RLP encoded stream`,
utils.EllaismFlag, utils.EllaismFlag,
utils.ClassicFlag, utils.ClassicFlag,
utils.SocialFlag, utils.SocialFlag,
utils.CallistoFlag,
utils.RinkebyFlag, utils.RinkebyFlag,
}, },
Category: "BLOCKCHAIN COMMANDS", Category: "BLOCKCHAIN COMMANDS",

View file

@ -132,6 +132,8 @@ func remoteConsole(ctx *cli.Context) error {
path = filepath.Join(path, "classic") path = filepath.Join(path, "classic")
} else if ctx.GlobalBool(utils.SocialFlag.Name) { } else if ctx.GlobalBool(utils.SocialFlag.Name) {
path = filepath.Join(path, "social") path = filepath.Join(path, "social")
} else if ctx.GlobalBool(utils.CallistoFlag.Name) {
path = filepath.Join(path, "callisto")
} }
} }
endpoint = fmt.Sprintf("%s/geth.ipc", path) endpoint = fmt.Sprintf("%s/geth.ipc", path)

View file

@ -113,6 +113,7 @@ var (
utils.EllaismFlag, utils.EllaismFlag,
utils.ClassicFlag, utils.ClassicFlag,
utils.SocialFlag, utils.SocialFlag,
utils.CallistoFlag,
utils.RinkebyFlag, utils.RinkebyFlag,
utils.VMEnableDebugFlag, utils.VMEnableDebugFlag,
utils.NetworkIdFlag, utils.NetworkIdFlag,

View file

@ -76,6 +76,7 @@ var AppHelpFlagGroups = []flagGroup{
utils.EllaismFlag, utils.EllaismFlag,
utils.ClassicFlag, utils.ClassicFlag,
utils.SocialFlag, utils.SocialFlag,
utils.CallistoFlag,
utils.RinkebyFlag, utils.RinkebyFlag,
utils.SyncModeFlag, utils.SyncModeFlag,
utils.GCModeFlag, utils.GCModeFlag,

View file

@ -149,6 +149,10 @@ var (
Name: "social", Name: "social",
Usage: "Ethereum Social network: pre-configured Ethereum Social mainnet", Usage: "Ethereum Social network: pre-configured Ethereum Social mainnet",
} }
CallistoFlag = cli.BoolFlag{
Name: "callisto",
Usage: "Callisto network: pre-configured Callisto mainnet",
}
RinkebyFlag = cli.BoolFlag{ RinkebyFlag = cli.BoolFlag{
Name: "rinkeby", Name: "rinkeby",
Usage: "Rinkeby network: pre-configured proof-of-authority test network", Usage: "Rinkeby network: pre-configured proof-of-authority test network",
@ -600,6 +604,9 @@ func MakeDataDir(ctx *cli.Context) string {
if ctx.GlobalBool(SocialFlag.Name) { if ctx.GlobalBool(SocialFlag.Name) {
return filepath.Join(path, "social") return filepath.Join(path, "social")
} }
if ctx.GlobalBool(CallistoFlag.Name) {
return filepath.Join(path, "callisto")
}
if ctx.GlobalBool(RinkebyFlag.Name) { if ctx.GlobalBool(RinkebyFlag.Name) {
return filepath.Join(path, "rinkeby") return filepath.Join(path, "rinkeby")
} }
@ -661,6 +668,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
urls = params.ClassicBootnodes urls = params.ClassicBootnodes
case ctx.GlobalBool(SocialFlag.Name): case ctx.GlobalBool(SocialFlag.Name):
urls = params.SocialBootnodes urls = params.SocialBootnodes
case ctx.GlobalBool(CallistoFlag.Name):
urls = params.CallistoBootnodes
case ctx.GlobalBool(RinkebyFlag.Name): case ctx.GlobalBool(RinkebyFlag.Name):
urls = params.RinkebyBootnodes urls = params.RinkebyBootnodes
case cfg.BootstrapNodes != nil: case cfg.BootstrapNodes != nil:
@ -952,6 +961,8 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "classic") cfg.DataDir = filepath.Join(node.DefaultDataDir(), "classic")
case ctx.GlobalBool(SocialFlag.Name): case ctx.GlobalBool(SocialFlag.Name):
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "social") cfg.DataDir = filepath.Join(node.DefaultDataDir(), "social")
case ctx.GlobalBool(CallistoFlag.Name):
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "callisto")
case ctx.GlobalBool(RinkebyFlag.Name): case ctx.GlobalBool(RinkebyFlag.Name):
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "rinkeby") cfg.DataDir = filepath.Join(node.DefaultDataDir(), "rinkeby")
} }
@ -1081,7 +1092,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, EllaismFlag, ClassicFlag, SocialFlag) checkExclusive(ctx, DeveloperFlag, TestnetFlag, RinkebyFlag, EllaismFlag, ClassicFlag, SocialFlag, CallistoFlag)
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")
@ -1169,6 +1180,11 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
cfg.NetworkId = 28 cfg.NetworkId = 28
} }
cfg.Genesis = core.DefaultSocialGenesisBlock() cfg.Genesis = core.DefaultSocialGenesisBlock()
case ctx.GlobalBool(CallistoFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 1
}
cfg.Genesis = core.DefaultCallistoGenesisBlock()
case ctx.GlobalBool(RinkebyFlag.Name): case ctx.GlobalBool(RinkebyFlag.Name):
if !ctx.GlobalIsSet(NetworkIdFlag.Name) { if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
cfg.NetworkId = 4 cfg.NetworkId = 4
@ -1324,6 +1340,8 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
genesis = core.DefaultClassicGenesisBlock() genesis = core.DefaultClassicGenesisBlock()
case ctx.GlobalBool(SocialFlag.Name): case ctx.GlobalBool(SocialFlag.Name):
genesis = core.DefaultSocialGenesisBlock() genesis = core.DefaultSocialGenesisBlock()
case ctx.GlobalBool(CallistoFlag.Name):
genesis = core.DefaultCallistoGenesisBlock()
case ctx.GlobalBool(RinkebyFlag.Name): case ctx.GlobalBool(RinkebyFlag.Name):
genesis = core.DefaultRinkebyGenesisBlock() genesis = core.DefaultRinkebyGenesisBlock()
case ctx.GlobalBool(DeveloperFlag.Name): case ctx.GlobalBool(DeveloperFlag.Name):

View file

@ -39,6 +39,9 @@ var (
FrontierBlockReward *big.Int = big.NewInt(5e+18) // Block reward in wei for successfully mining a block 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 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 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
CLOMinerReward *big.Int = new(big.Int).Mul(big.NewInt(420), big.NewInt(1e+18)) // Block reward in wei for successfully mining a block upward for Callisto Network
CLOTreasuryReward *big.Int = new(big.Int).Mul(big.NewInt(120), big.NewInt(1e+18)) // Block reward in wei for successfully mining a block upward for Callisto Network
CLOStakeReward *big.Int = new(big.Int).Mul(big.NewInt(60), big.NewInt(1e+18)) // Block reward in wei for successfully mining a block upward for Callisto Network
maxUncles = 2 // Maximum number of uncles allowed in a single block 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 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 DisinflationRateQuotient = big.NewInt(4) // Disinflation rate quotient for ECIP1017
@ -667,6 +670,10 @@ func (ethash *Ethash) Prepare(chain consensus.ChainReader, header *types.Header)
// setup accumulateRewards for Ethereum Social // setup accumulateRewards for Ethereum Social
accumulateRewards = socialAccumulateRewards accumulateRewards = socialAccumulateRewards
} }
if chain.GetHeaderByNumber(0).Hash() == params.CallistoGenesisHash {
// setup accumulateRewards for Callisto Network
accumulateRewards = callistoAccumulateRewards
}
parent := chain.GetHeader(header.ParentHash, header.Number.Uint64()-1) parent := chain.GetHeader(header.ParentHash, header.Number.Uint64()-1)
if parent == nil { if parent == nil {
return consensus.ErrUnknownAncestor return consensus.ErrUnknownAncestor
@ -841,3 +848,28 @@ func GetBlockEra(blockNum, eraLength *big.Int) *big.Int {
return new(big.Int).Sub(d, dremainder) return new(big.Int).Sub(d, dremainder)
} }
// callistoAccumulateRewards()
func callistoAccumulateRewards(config *params.ChainConfig, state *state.StateDB, header *types.Header, uncles []*types.Header) {
// Select the correct block reward based on chain progression
blockReward := CLOMinerReward
clotreasury := CLOTreasuryReward
clostake := CLOStakeReward
// Accumulate the rewards for the miner and any included uncles
reward := new(big.Int).Set(blockReward)
r := new(big.Int)
for _, uncle := range uncles {
r.Add(uncle.Number, big8)
r.Sub(r, header.Number)
r.Mul(r, blockReward)
r.Div(r, big8)
state.AddBalance(uncle.Coinbase, r)
r.Div(blockReward, big32)
reward.Add(reward, r)
}
state.AddBalance(header.Coinbase, reward)
state.AddBalance(common.HexToAddress("0x74682Fc32007aF0b6118F259cBe7bCCC21641600"), clotreasury)
state.AddBalance(common.HexToAddress("0x3c06f218Ce6dD8E2c535a8925A2eDF81674984D9"), clostake)
}

View file

@ -217,6 +217,8 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig {
return params.EllaismChainConfig return params.EllaismChainConfig
case ghash == params.SocialGenesisHash: case ghash == params.SocialGenesisHash:
return params.SocialChainConfig return params.SocialChainConfig
case ghash == params.CallistoGenesisHash:
return params.CallistoChainConfig
default: default:
return params.AllEthashProtocolChanges return params.AllEthashProtocolChanges
} }
@ -349,6 +351,21 @@ func DefaultSocialGenesisBlock() *Genesis {
} }
} }
// DefaultCallistoGenesisBlock
func DefaultCallistoGenesisBlock() *Genesis {
return &Genesis{
Config: params.CallistoChainConfig,
ExtraData: hexutil.MustDecode("0x0000000000000000000000000000000000000000000000000000000000000000"),
GasLimit: 10400000,
Difficulty: big.NewInt(524288),
Timestamp: 1519622213,
Nonce: 0,
Coinbase: common.HexToAddress("0xc3F70b10CE5EC4aA47ce44Eb0B7900A883cd45Dd"),
Mixhash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
Alloc: decodePrealloc(callistoAllocData),
}
}
// DefaultTestnetGenesisBlock returns the Ropsten network genesis block. // DefaultTestnetGenesisBlock returns the Ropsten network genesis block.
func DefaultTestnetGenesisBlock() *Genesis { func DefaultTestnetGenesisBlock() *Genesis {
return &Genesis{ return &Genesis{

File diff suppressed because one or more lines are too long

View file

@ -50,6 +50,15 @@ func SocialGenesis() string {
return string(enc) return string(enc)
} }
// CallistoGenesis returns the JSON spec to use for the Callisto network.
func CallistoGenesis() string {
enc, err := json.Marshal(core.DefaultCallistoGenesisBlock())
if err != nil {
panic(err)
}
return string(enc)
}
// TestnetGenesis returns the JSON spec to use for the Ethereum test network. // TestnetGenesis returns the JSON spec to use for the Ethereum test network.
func TestnetGenesis() string { func TestnetGenesis() string {
enc, err := json.Marshal(core.DefaultTestnetGenesisBlock()) enc, err := json.Marshal(core.DefaultTestnetGenesisBlock())

View file

@ -68,6 +68,14 @@ var SocialBootnodes = []string{
"enode://851f14c5cc86cbc0a81acfcbe5dd99ad5c823435357219df736932c5f89ad4318f6973a553857a32d97a71793f5a35c062d46320be282aa0a80b06b9c6b624e4@13.125.232.71:30303", "enode://851f14c5cc86cbc0a81acfcbe5dd99ad5c823435357219df736932c5f89ad4318f6973a553857a32d97a71793f5a35c062d46320be282aa0a80b06b9c6b624e4@13.125.232.71:30303",
} }
// CallistoBootnodes are the enode URLs of the P2P bootstrap nodes running on
// the Callisto network.
var CallistoBootnodes = []string{
"enode://ab0d9fe81f23653c3217303d3a4bc035be908b05f8b12d6f155ab4598d7760cfea1e009e414771279c9ffc3499950283afaabe099a5329c5a6013f57d77de0a6@104.236.96.118:30303",
"enode://9e2d9dc2639e02893aa17c80e6ba8e8803fd3166083b622a841fc852161112720281514436f7605c89041d5efa1738215185c4c4024ff812b0f500c403cc0ab1@206.189.47.198:30303",
"enode://149ba679e8851c3e0d030e0dc0336984b97c83ef649e68ec113dcf266449364cc1ec8ee27950f71b00c2182ef504894fa7bff19f6741978ced67e9e4b6536d2a@206.189.45.31:30303",
}
// TestnetBootnodes are the enode URLs of the P2P bootstrap nodes running on the // TestnetBootnodes are the enode URLs of the P2P bootstrap nodes running on the
// Ropsten test network. // Ropsten test network.
var TestnetBootnodes = []string{ var TestnetBootnodes = []string{

View file

@ -29,6 +29,7 @@ var (
TestnetGenesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d") TestnetGenesisHash = common.HexToHash("0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d")
EllaismGenesisHash = common.HexToHash("0x4d7df65052bb21264d6ad2d6fe2d5578a36be12f71bf8d0559b0c15c4dc539b5") EllaismGenesisHash = common.HexToHash("0x4d7df65052bb21264d6ad2d6fe2d5578a36be12f71bf8d0559b0c15c4dc539b5")
SocialGenesisHash = common.HexToHash("0xba8314d5c2ebddaf58eb882b364b27cbfa4d3402dacd32b60986754ac25cfe8d") SocialGenesisHash = common.HexToHash("0xba8314d5c2ebddaf58eb882b364b27cbfa4d3402dacd32b60986754ac25cfe8d")
CallistoGenesisHash = common.HexToHash("0x82270b80fc90beb005505a9ef95039639968a0e81b2904ad30128c93d713d2c4")
) )
var ( var (
@ -104,6 +105,22 @@ var (
Ethash: new(EthashConfig), Ethash: new(EthashConfig),
} }
// Callisto Mainnet chain parameters
CallistoChainConfig = &ChainConfig{
ChainID: big.NewInt(820),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: false,
EIP150Block: big.NewInt(0),
EIP150Hash: common.HexToHash("0x82270b80fc90beb005505a9ef95039639968a0e81b2904ad30128c93d713d2c4"),
EIP155Block: big.NewInt(10),
EIP158Block: big.NewInt(10),
ByzantiumBlock: big.NewInt(20),
DisposalBlock: nil,
ConstantinopleBlock: nil,
Ethash: new(EthashConfig),
}
// TestnetChainConfig contains the chain parameters to run a node on the Ropsten test network. // TestnetChainConfig contains the chain parameters to run a node on the Ropsten test network.
TestnetChainConfig = &ChainConfig{ TestnetChainConfig = &ChainConfig{
ChainID: big.NewInt(3), ChainID: big.NewInt(3),