From a3a6b5c8756afc6b6a8196273d30dbc1cae8b4b2 Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Wed, 19 Sep 2018 22:25:24 +0300 Subject: [PATCH 1/3] Refactor mining rewards to readable form in configs --- .../src/main/java/org/ethereum/config/Constants.java | 4 +++- .../java/org/ethereum/config/blockchain/ByzantiumConfig.java | 5 ++--- .../java/org/ethereum/config/blockchain/FrontierConfig.java | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/config/Constants.java b/ethereumj-core/src/main/java/org/ethereum/config/Constants.java index 0379771a22..bc477d8510 100644 --- a/ethereumj-core/src/main/java/org/ethereum/config/Constants.java +++ b/ethereumj-core/src/main/java/org/ethereum/config/Constants.java @@ -17,6 +17,8 @@ */ package org.ethereum.config; +import org.ethereum.util.blockchain.EtherUtil; + import java.math.BigInteger; /** @@ -37,7 +39,7 @@ public class Constants { private static final int BEST_NUMBER_DIFF_LIMIT = 100; - private static final BigInteger BLOCK_REWARD = new BigInteger("1500000000000000000"); + private static final BigInteger BLOCK_REWARD = EtherUtil.convert(1500, EtherUtil.Unit.FINNEY); // 1.5 ETH private static final BigInteger SECP256K1N = new BigInteger("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", 16); 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 5d103c1695..2de35dd954 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 @@ -20,9 +20,8 @@ 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; +import org.ethereum.util.blockchain.EtherUtil; import java.math.BigInteger; @@ -51,7 +50,7 @@ public class ByzantiumConfig extends Eip160HFConfig { public ByzantiumConfig(BlockchainConfig parent) { super(parent); constants = new ConstantsAdapter(super.getConstants()) { - private final BigInteger BLOCK_REWARD = new BigInteger("3000000000000000000"); + private final BigInteger BLOCK_REWARD = EtherUtil.convert(3, EtherUtil.Unit.ETHER); @Override public BigInteger getBLOCK_REWARD() { diff --git a/ethereumj-core/src/main/java/org/ethereum/config/blockchain/FrontierConfig.java b/ethereumj-core/src/main/java/org/ethereum/config/blockchain/FrontierConfig.java index 4e22ddcbe7..0cd05d8eb9 100644 --- a/ethereumj-core/src/main/java/org/ethereum/config/blockchain/FrontierConfig.java +++ b/ethereumj-core/src/main/java/org/ethereum/config/blockchain/FrontierConfig.java @@ -19,6 +19,7 @@ import org.ethereum.config.Constants; import org.ethereum.core.Transaction; +import org.ethereum.util.blockchain.EtherUtil; import java.math.BigInteger; @@ -28,7 +29,7 @@ public class FrontierConfig extends OlympicConfig { public static class FrontierConstants extends Constants { - private static final BigInteger BLOCK_REWARD = new BigInteger("5000000000000000000"); + private static final BigInteger BLOCK_REWARD = EtherUtil.convert(5, EtherUtil.Unit.ETHER); @Override public int getDURATION_LIMIT() { From 6fe97cb30c03e76e60631223dbb52ea044f4bece Mon Sep 17 00:00:00 2001 From: Dmitry Shmatko Date: Wed, 19 Sep 2018 23:21:00 +0300 Subject: [PATCH 2/3] Added EIP-1234 reward change to 2ETH and difficulty explosion delay + tests --- .../blockchain/ConstantinopleConfig.java | 28 +++ .../blockchain/ByzantiumConfigTest.java | 4 - .../blockchain/ConstantinopleConfigTest.java | 196 ++++++++++++++++++ 3 files changed, 224 insertions(+), 4 deletions(-) create mode 100644 ethereumj-core/src/test/java/org/ethereum/config/blockchain/ConstantinopleConfigTest.java diff --git a/ethereumj-core/src/main/java/org/ethereum/config/blockchain/ConstantinopleConfig.java b/ethereumj-core/src/main/java/org/ethereum/config/blockchain/ConstantinopleConfig.java index 84068ecbef..9198ce3cfa 100644 --- a/ethereumj-core/src/main/java/org/ethereum/config/blockchain/ConstantinopleConfig.java +++ b/ethereumj-core/src/main/java/org/ethereum/config/blockchain/ConstantinopleConfig.java @@ -18,10 +18,17 @@ package org.ethereum.config.blockchain; import org.ethereum.config.BlockchainConfig; +import org.ethereum.config.Constants; +import org.ethereum.config.ConstantsAdapter; +import org.ethereum.core.BlockHeader; +import org.ethereum.util.blockchain.EtherUtil; + +import java.math.BigInteger; /** * EIPs included in the Constantinople Hard Fork: *