Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #927 from ethereum/eip-669
Browse files Browse the repository at this point in the history
Eip 649: Difficulty Bomb Delay and Issuance Reduction
  • Loading branch information
mkalinin authored Aug 31, 2017
2 parents 529a546 + 468fde0 commit ae95aa6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -939,10 +935,13 @@ private Map<byte[], BigInteger> addReward(Repository track, Block block, List<Tr

Map<byte[], BigInteger> 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));

Expand All @@ -956,7 +955,7 @@ private Map<byte[], BigInteger> addReward(Repository track, Block block, List<Tr
}
}

BigInteger minerReward = BLOCK_REWARD.add(INCLUSION_REWARD.multiply(BigInteger.valueOf(block.getUncleList().size())));
BigInteger minerReward = blockReward.add(inclusionReward.multiply(BigInteger.valueOf(block.getUncleList().size())));

BigInteger totalFees = BigInteger.ZERO;
for (TransactionExecutionSummary summary : summaries) {
Expand Down

0 comments on commit ae95aa6

Please sign in to comment.