Refactor and Galilei launch -Callisto testnet-

This commit is contained in:
Yohan Graterol 2018-02-27 22:10:28 -05:00
parent 4602bbc914
commit cdaa207a56
No known key found for this signature in database
GPG key ID: D8C4A70CC26A1F90
5 changed files with 45 additions and 43 deletions

View file

@ -37,13 +37,11 @@ import (
// Ethash proof-of-work protocol constants
// Callisto reward 600 CLO.
var (
callistoBlockReward, _ = new(big.Int).SetString("600000000000000000000", 10) // Block reward in wei for successfully mining a block
//callistoBlockReward, _ = new(big.Int).SetString("600000000000000000000", 10) // 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
maxUncles = 2 // Maximum number of uncles allowed in a single block
allowedFutureBlockTime = 15 * time.Second
treasuryDevFunds *big.Int = big.NewInt(20)
stakeFunds *big.Int = big.NewInt(10)
)
// Various error messages to mark blocks invalid. These should be private to
@ -302,8 +300,8 @@ func (ethash *Ethash) CalcDifficulty(chain consensus.ChainReader, time uint64, p
func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Header) *big.Int {
next := new(big.Int).Add(parent.Number, big1)
switch {
case config.IsCallisto(next):
return calcDifficultyCallisto(time, parent)
//case config.IsCallisto(next):
// return calcDifficultyCallisto(time, parent)
case config.IsByzantium(next):
return calcDifficultyByzantium(time, parent)
case config.IsHomestead(next):
@ -601,26 +599,16 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header
// Select the correct block reward based on chain progression
blockReward := FrontierBlockReward
if config.IsCallisto(header.Number) {
blockReward = callistoBlockReward
}
if config.IsByzantium(header.Number) && !config.IsCallisto(header.Number) {
if config.IsByzantium(header.Number) {
blockReward = ByzantiumBlockReward
}
if config.IsCallisto(header.Number) {
blockReward = config.CallistoMinerReward
}
reward := new(big.Int).Set(blockReward)
// Treasury fee
treasuryReward := new(big.Int)
treasuryReward.Mul(reward, treasuryDevFunds)
treasuryReward.Div(treasuryReward, big.NewInt(100))
// Stake fee
stakeReward := new(big.Int)
stakeReward.Mul(reward, stakeFunds)
stakeReward.Div(stakeReward, big.NewInt(100))
// Accumulate the rewards for the miner and any included uncles
r := new(big.Int)
for _, uncle := range uncles {
@ -635,10 +623,8 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header
}
if config.IsCallisto(header.Number) {
reward.Sub(reward, treasuryReward)
reward.Sub(reward, stakeReward)
state.AddBalance(config.CallistoTreasuryAddress, treasuryReward)
state.AddBalance(config.CallistoStakeAddress, stakeReward)
state.AddBalance(config.CallistoTreasuryAddress, config.CallistoTreasuryReward)
state.AddBalance(config.CallistoStakeAddress, config.CallistoStakeReward)
}
state.AddBalance(header.Coinbase, reward)

View file

@ -349,9 +349,13 @@ func DefaultTestnetGenesisBlock() *Genesis {
func DefaultCallistoTestnetGenesisBlock() *Genesis {
return &Genesis{
Config: params.CallistoTestnetChainConfig,
ExtraData: hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000000073dcf82e65a05dab02da9d899ae472487dfc99bb0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
ExtraData: hexutil.MustDecode("0x0000000000000000000000000000000000000000000000000000000000000000"),
GasLimit: 4700000,
Difficulty: big.NewInt(1),
Difficulty: big.NewInt(524288),
Timestamp: 1519622213,
Nonce: 0,
Coinbase: common.HexToAddress("0xc3F70b10CE5EC4aA47ce44Eb0B7900A883cd45Dd"),
Mixhash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
Alloc: decodePrealloc(callistoTestnetAllocData),
}
}

File diff suppressed because one or more lines are too long

View file

@ -56,5 +56,5 @@ var DiscoveryV5Bootnodes = []string{
// CallistoTestnetBootnodes are the enode URLs of the P2P bootstrap nodes for the
// Callisto tes network.
var CallistoTestnetBootnodes = []string{
"enode://5c0cef5656d2b6c7baee7bb2362b37c96930988622c397885510546cf19f53f4c3c572bca3e0326139502ad28111935e1efcdaa1e6360bbf65c269212802b509@192.168.0.2:30303",
"enode://960fe04f86af9fc61609b79200049333beae15583e343c298b4a676041f0f452329ff3e7bd41651663f82b56f82b3f98fdf85d16f311fa40a00fc900b3db6d7a@159.203.121.76:30303",
}

View file

@ -48,13 +48,13 @@ var (
// CallistoMainnetChainConfig contains the chain parameters to run a node on the Callisto Main network.
CallistoMainnetChainConfig = &ChainConfig{
ChainId: big.NewInt(104729),
HomesteadBlock: big.NewInt(0),
HomesteadBlock: big.NewInt(1),
DAOForkBlock: big.NewInt(0),
DAOForkSupport: false,
EIP150Block: big.NewInt(0),
EIP150Block: big.NewInt(2),
EIP150Hash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
EIP155Block: big.NewInt(3),
EIP158Block: big.NewInt(0),
EIP158Block: big.NewInt(3),
ByzantiumBlock: big.NewInt(4),
CallistoBlock: big.NewInt(1),
}
@ -75,19 +75,27 @@ var (
}
// CallistoTestnetChainConfig contains the chain parameters to run a node on the Callisto test network.
testMinerReward, _ = new(big.Int).SetString("420000000000000000000", 10)
testTreasuryReward, _ = new(big.Int).SetString("120000000000000000000", 10)
testStakeReward, _ = new(big.Int).SetString("60000000000000000000", 10)
CallistoTestnetChainConfig = &ChainConfig{
ChainId: big.NewInt(7919),
HomesteadBlock: big.NewInt(1),
DAOForkBlock: big.NewInt(0),
HomesteadBlock: big.NewInt(0),
DAOForkBlock: nil,
DAOForkSupport: false,
EIP150Block: big.NewInt(2),
EIP150Block: big.NewInt(0),
EIP150Hash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
EIP155Block: big.NewInt(3),
EIP158Block: big.NewInt(3),
ByzantiumBlock: big.NewInt(4),
CallistoBlock: big.NewInt(4),
EIP155Block: big.NewInt(10),
EIP158Block: big.NewInt(10),
ByzantiumBlock: big.NewInt(20),
CallistoBlock: big.NewInt(0),
CallistoMinerReward: testMinerReward,
CallistoTreasuryAddress: common.HexToAddress("0x74682Fc32007aF0b6118F259cBe7bCCC21641600"),
CallistoTreasuryReward: testTreasuryReward,
CallistoStakeAddress: common.HexToAddress("0x3c06f218Ce6dD8E2c535a8925A2eDF81674984D9"),
CallistoStakeReward: testStakeReward,
Ethash: new(EthashConfig),
}
@ -115,16 +123,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), big.NewInt(0), big.NewInt(0), common.Address{}, common.Address{}, 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), big.NewInt(0), big.NewInt(0), big.NewInt(0),common.Address{}, big.NewInt(0), common.Address{}, big.NewInt(0), 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), big.NewInt(0), big.NewInt(0), common.Address{}, common.Address{}, 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), big.NewInt(0), big.NewInt(0), big.NewInt(0),common.Address{}, big.NewInt(0), common.Address{}, big.NewInt(0), 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), big.NewInt(0), big.NewInt(0), common.Address{}, common.Address{}, 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), big.NewInt(0), big.NewInt(0), big.NewInt(0), common.Address{}, big.NewInt(0), common.Address{}, big.NewInt(0), new(EthashConfig), nil}
TestRules = TestChainConfig.Rules(new(big.Int))
)
@ -152,8 +160,11 @@ type ChainConfig struct {
ConstantinopleBlock *big.Int `json:"constantinopleBlock,omitempty"` // Constantinople switch block (nil = no fork, 0 = already activated)
CallistoBlock *big.Int `json:"callistoBlock,omitempty"`
CallistoMinerReward *big.Int `json:"callistoMinerReward,omitempty"`
CallistoTreasuryAddress common.Address `json:"callistoTreasuryAddress,omitempty"`
CallistoTreasuryReward *big.Int `json:"callistoTreasuryReward,omitempty"`
CallistoStakeAddress common.Address `json:"callistoStakeAddress,omitempty"`
CallistoStakeReward *big.Int `json:"callistoStakeReward,omitempty"`
// Various consensus engines
Ethash *EthashConfig `json:"ethash,omitempty"`
Clique *CliqueConfig `json:"clique,omitempty"`
@ -248,8 +259,6 @@ func (c *ChainConfig) GasTable(num *big.Int) GasTable {
return GasTableEIP158
}
switch {
case c.IsCallisto(num):
return GasTableEIP158
case c.IsEIP158(num):
return GasTableEIP158
case c.IsEIP150(num):
@ -299,6 +308,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi
if c.IsEIP158(head) && !configNumEqual(c.ChainId, newcfg.ChainId) {
return newCompatError("EIP158 chain ID", c.EIP158Block, newcfg.EIP158Block)
}
if isForkIncompatible(c.CallistoBlock, newcfg.CallistoBlock, head) {
return newCompatError("Callisto fork block", c.CallistoBlock, newcfg.CallistoBlock)
}
if isForkIncompatible(c.ByzantiumBlock, newcfg.ByzantiumBlock, head) {
return newCompatError("Byzantium fork block", c.ByzantiumBlock, newcfg.ByzantiumBlock)
}