diff --git a/src/blkmaker/BlkMakerMain.cc b/src/blkmaker/BlkMakerMain.cc index 81606af07..5c34338b2 100644 --- a/src/blkmaker/BlkMakerMain.cc +++ b/src/blkmaker/BlkMakerMain.cc @@ -38,6 +38,7 @@ #include "Utils.h" #include "bitcoin/BlockMakerBitcoin.h" +#include "eth/EthConsensus.h" #include "eth/BlockMakerEth.h" #include "bytom/BlockMakerBytom.h" #include "sia/BlockMakerSia.h" @@ -99,6 +100,16 @@ shared_ptr createDefinition(const Setting &setting) shared_ptr def; readFromSetting(setting, "chain_type", chainType); + + // The hard fork Constantinople of Ethereum mainnet has been delayed. + // So set a default height that won't arrive (9999999). + // The user can change the height in the configuration file + // after the fork height is determined. + if (chainType == "ETH") { + int constantinopleHeight = 9999999; + setting.lookupValue("constantinople_height", constantinopleHeight); + EthConsensus::setHardForkConstantinopleHeight(constantinopleHeight); + } #if defined(CHAIN_TYPE_STR) if (CHAIN_TYPE_STR == chainType) diff --git a/src/blkmaker/blkmaker.cfg b/src/blkmaker/blkmaker.cfg index 0f99f0ec9..5b9cb3585 100644 --- a/src/blkmaker/blkmaker.cfg +++ b/src/blkmaker/blkmaker.cfg @@ -45,6 +45,12 @@ blk_makers = ( ); #solved share topic solved_share_topic = "EthSolvedShare"; + + # The hard fork Constantinople of Ethereum mainnet has been delayed. + # So set a default height that won't arrive (9999999). + # The user can change the height in the configuration file + # after the fork height is determined. + constantinople_height = 9999999; }, { chain_type = "SIA"; //blockchain short name diff --git a/src/eth/EthConsensus.cc b/src/eth/EthConsensus.cc index 84de48ecb..fd4d68293 100644 --- a/src/eth/EthConsensus.cc +++ b/src/eth/EthConsensus.cc @@ -24,7 +24,18 @@ #include "EthConsensus.h" #include +#include +// The hard fork Constantinople of Ethereum mainnet has been delayed. +// So set a default height that won't arrive (9999999). +// The user can change the height in the configuration file +// after the fork height is determined. +int EthConsensus::kHardForkConstantinopleHeight_ = 9999999; + +void EthConsensus::setHardForkConstantinopleHeight(int height) { + kHardForkConstantinopleHeight_ = height; + LOG(INFO) << "Height of Ethereum Constantinople Hard Fork: " << kHardForkConstantinopleHeight_; +} EthConsensus::Chain EthConsensus::getChain(std::string chainStr) { // toupper @@ -95,7 +106,7 @@ int64_t EthConsensus::getStaticBlockRewardClassic(int nHeight) { // static block rewards of Ethereum Main Network int64_t EthConsensus::getStaticBlockRewardFoundation(int nHeight) { // Constantinople fork at block 7080000 on Mainnet. - if (nHeight >= 7080000) { + if (nHeight >= kHardForkConstantinopleHeight_) { return 2e+18; } // Ethereum Main Network has a static block reward (3 Ether) before height 7080000. diff --git a/src/eth/EthConsensus.h b/src/eth/EthConsensus.h index 0bf148047..5f295c7b9 100644 --- a/src/eth/EthConsensus.h +++ b/src/eth/EthConsensus.h @@ -54,6 +54,8 @@ class EthConsensus { // the 0.875 will be returned. static double getUncleBlockRewardRatio(int nHeight, Chain chain); + static void setHardForkConstantinopleHeight(int height); + protected: // static block rewards of Ethereum Classic Main Network static int64_t getStaticBlockRewardClassic(int nHeight); @@ -62,6 +64,12 @@ class EthConsensus { static double getUncleBlockRewardRatioClassic(int nHeight); static double getUncleBlockRewardRatioFoundation(int nHeight); + + // The hard fork Constantinople of Ethereum mainnet has been delayed. + // So set a default height that won't arrive (9999999). + // The user can change the height in the configuration file + // after the fork height is determined. + static int kHardForkConstantinopleHeight_; }; #endif // ETH_CONSENSUS_H_ diff --git a/src/slparser/ShareLogParserMain.cc b/src/slparser/ShareLogParserMain.cc index 4487d41e7..99d60a0c5 100644 --- a/src/slparser/ShareLogParserMain.cc +++ b/src/slparser/ShareLogParserMain.cc @@ -43,6 +43,7 @@ #include "bitcoin/StatisticsBitcoin.h" #include "bitcoin/ShareLogParserBitcoin.h" +#include "eth/EthConsensus.h" #include "eth/StatisticsEth.h" #include "eth/ShareLogParserEth.h" @@ -254,6 +255,16 @@ int main(int argc, char **argv) { // Track duplicate shares within N blocks. int32_t dupShareTrackingHeight = 3; cfg.lookupValue("dup_share_checker.tracking_height_number", dupShareTrackingHeight); + + // The hard fork Constantinople of Ethereum mainnet has been delayed. + // So set a default height that won't arrive (9999999). + // The user can change the height in the configuration file + // after the fork height is determined. + if (chainType == "ETH") { + int constantinopleHeight = 9999999; + cfg.lookupValue("sharelog.constantinople_height", constantinopleHeight); + EthConsensus::setHardForkConstantinopleHeight(constantinopleHeight); + } ////////////////////////////////////////////////////////////////////////////// // dump shares to stdout diff --git a/src/slparser/slparser.cfg b/src/slparser/slparser.cfg index 8beb85084..b8f6ee70b 100644 --- a/src/slparser/slparser.cfg +++ b/src/slparser/slparser.cfg @@ -21,6 +21,12 @@ slparserhttpd = { sharelog = { chain_type = "ETH"; data_dir = "/work/btcpool/data/sharelog"; + + # The hard fork Constantinople of Ethereum mainnet has been delayed. + # So set a default height that won't arrive (9999999). + # The user can change the height in the configuration file + # after the fork height is determined. + constantinople_height = 9999999; }; # Used to detect duplicate share attacks on ETH mining.