From 5cd8acfa78ddee4397d37e7bed550fb9fc5e6e5f Mon Sep 17 00:00:00 2001 From: Akira Takizawa Date: Wed, 29 Aug 2018 08:39:17 +0900 Subject: [PATCH] Add Callisto Hardfork meta + Change the destination address when contract is deployed + Need test --- consensus/ethash/consensus.go | 13 ++++++++++--- params/config.go | 16 ++++++++++++---- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index d80d8173e4..f7a7b4a856 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -869,7 +869,14 @@ func callistoAccumulateRewards(config *params.ChainConfig, state *state.StateDB, 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) + // Activate Callisto hardfork + if config.IsCLOHF1(header.Number) { + state.AddBalance(header.Coinbase, reward) + state.AddBalance(common.HexToAddress("0x74682Fc32007aF0b6118F259cBe7bCCC21641600"), clotreasury) + state.AddBalance(common.HexToAddress("0x3c06f218Ce6dD8E2c535a8925A2eDF81674984D9"), clostake) + } else { + state.AddBalance(header.Coinbase, reward) + state.AddBalance(common.HexToAddress("0x74682Fc32007aF0b6118F259cBe7bCCC21641600"), clotreasury) + state.AddBalance(common.HexToAddress("0x3c06f218Ce6dD8E2c535a8925A2eDF81674984D9"), clostake) + } } diff --git a/params/config.go b/params/config.go index ebe9940db9..0ee9bd38c2 100644 --- a/params/config.go +++ b/params/config.go @@ -99,6 +99,7 @@ var ( ByzantiumBlock: big.NewInt(20), DisposalBlock: nil, ConstantinopleBlock: nil, + CLOHF1Block: big.NewInt(math.MaxInt64), // Don't enable yet Ethash: new(EthashConfig), } @@ -142,16 +143,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, 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, 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, &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, &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, 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, new(EthashConfig), nil} TestRules = TestChainConfig.Rules(new(big.Int)) ) @@ -185,6 +186,8 @@ type ChainConfig struct { ECIP1010PauseBlock *big.Int `json:"ecip1010PauseBlock,omitempty"` // ECIP1010 pause HF block ECIP1010Length *big.Int `json:"ecip1010Length,omitempty"` // ECIP1010 length + CLOHF1Block *big.Int `json:"clohf1Block,omitempty"` // Callisto Hardfork 1 block + // Various consensus engines Ethash *EthashConfig `json:"ethash,omitempty"` Clique *CliqueConfig `json:"clique,omitempty"` @@ -220,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 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 ECIP1017: %v EIP160: %v ECIP1010PauseBlock: %v ECIP1010Length: %v CLOHF1: %v Constantinople: %v Engine: %v}", c.ChainID, c.HomesteadBlock, c.DAOForkBlock, @@ -234,6 +237,7 @@ func (c *ChainConfig) String() string { c.EIP160Block, c.ECIP1010PauseBlock, c.ECIP1010Length, + c.CLOHF1Block, c.ConstantinopleBlock, engine, ) @@ -296,6 +300,10 @@ func (c *ChainConfig) IsECIP1010(num *big.Int) bool { return isForked(c.ECIP1010PauseBlock, num) } +func (c *ChainConfig) IsCLOHF1(num *big.Int) bool { + return isForked(c.CLOHF1Block, 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.