Skip to content

Commit

Permalink
slparser/blkmaker ETH: Because the delay of Ethereum's Constantinople…
Browse files Browse the repository at this point in the history
… hard fork, its fork height was changed to configurable.
  • Loading branch information
SwimmingTiger committed Jan 16, 2019
1 parent 9b4ec85 commit 2d76329
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/blkmaker/BlkMakerMain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -99,6 +100,16 @@ shared_ptr<BlockMakerDefinition> createDefinition(const Setting &setting)
shared_ptr<BlockMakerDefinition> 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)
Expand Down
6 changes: 6 additions & 0 deletions src/blkmaker/blkmaker.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion src/eth/EthConsensus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,18 @@
#include "EthConsensus.h"

#include <algorithm>
#include <glog/logging.h>

// 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
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions src/eth/EthConsensus.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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_
11 changes: 11 additions & 0 deletions src/slparser/ShareLogParserMain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "bitcoin/StatisticsBitcoin.h"
#include "bitcoin/ShareLogParserBitcoin.h"

#include "eth/EthConsensus.h"
#include "eth/StatisticsEth.h"
#include "eth/ShareLogParserEth.h"

Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/slparser/slparser.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 2d76329

Please sign in to comment.