diff --git a/ethereumj-core/src/main/java/org/ethereum/config/blockchain/ByzantiumConfig.java b/ethereumj-core/src/main/java/org/ethereum/config/blockchain/ByzantiumConfig.java index 5a7a247c38..b90feaf9a5 100644 --- a/ethereumj-core/src/main/java/org/ethereum/config/blockchain/ByzantiumConfig.java +++ b/ethereumj-core/src/main/java/org/ethereum/config/blockchain/ByzantiumConfig.java @@ -2,6 +2,7 @@ import org.ethereum.config.BlockchainConfig; import org.ethereum.config.Constants; +import org.ethereum.config.ConstantsAdapter; import org.ethereum.core.Block; import org.ethereum.core.BlockHeader; import org.ethereum.core.Repository; @@ -29,8 +30,23 @@ */ public class ByzantiumConfig extends Eip160HFConfig { + private final Constants constants; + public ByzantiumConfig(BlockchainConfig parent) { super(parent); + constants = new ConstantsAdapter(parent.getConstants()) { + private final BigInteger BLOCK_REWARD = new BigInteger("3000000000000000000"); + + @Override + public BigInteger getBLOCK_REWARD() { + return BLOCK_REWARD; + } + }; + } + + @Override + public Constants getConstants() { + return constants; } @Override @@ -53,7 +69,7 @@ public BigInteger calcDifficulty(BlockHeader curBlock, BlockHeader parent) { } protected int getExplosion(BlockHeader curBlock, BlockHeader parent) { - int periodCount = (int) (curBlock.getNumber() / getConstants().getEXP_DIFFICULTY_PERIOD()); + int periodCount = (int) (curBlock.getNumber() - 3_000_000 / getConstants().getEXP_DIFFICULTY_PERIOD()); return periodCount - 2; } diff --git a/ethereumj-core/src/main/java/org/ethereum/core/BlockchainImpl.java b/ethereumj-core/src/main/java/org/ethereum/core/BlockchainImpl.java index 7d130d876a..172236ac0a 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/BlockchainImpl.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/BlockchainImpl.java @@ -166,8 +166,6 @@ public class BlockchainImpl implements Blockchain, org.ethereum.facade.Blockchai private byte[] minerCoinbase; private byte[] minerExtraData; - private BigInteger BLOCK_REWARD; - private BigInteger INCLUSION_REWARD; private int UNCLE_LIST_LIMIT; private int UNCLE_GENERATION_LIMIT; @@ -225,8 +223,6 @@ public BlockchainImpl withParentBlockHeaderValidator(ParentBlockHeaderValidator private void initConst(SystemProperties config) { minerCoinbase = config.getMinerCoinbase(); minerExtraData = config.getMineExtraData(); - BLOCK_REWARD = config.getBlockchainConfig().getCommonConstants().getBLOCK_REWARD(); - INCLUSION_REWARD = BLOCK_REWARD.divide(BigInteger.valueOf(32)); UNCLE_LIST_LIMIT = config.getBlockchainConfig().getCommonConstants().getUNCLE_LIST_LIMIT(); UNCLE_GENERATION_LIMIT = config.getBlockchainConfig().getCommonConstants().getUNCLE_GENERATION_LIMIT(); } @@ -939,10 +935,13 @@ private Map addReward(Repository track, Block block, List rewards = new HashMap<>(); + BigInteger blockReward = config.getBlockchainConfig().getConfigForBlock(block.getNumber()).getConstants().getBLOCK_REWARD(); + BigInteger inclusionReward = blockReward.divide(BigInteger.valueOf(32)); + // Add extra rewards based on number of uncles if (block.getUncleList().size() > 0) { for (BlockHeader uncle : block.getUncleList()) { - BigInteger uncleReward = BLOCK_REWARD + BigInteger uncleReward = blockReward .multiply(BigInteger.valueOf(MAGIC_REWARD_OFFSET + uncle.getNumber() - block.getNumber())) .divide(BigInteger.valueOf(MAGIC_REWARD_OFFSET)); @@ -956,7 +955,7 @@ private Map addReward(Repository track, Block block, List