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

Eip 649: Difficulty Bomb Delay and Issuance Reduction #927

Merged
merged 5 commits into from
Aug 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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