@Test public void testEtherscanIoBlock4490790() throws Exception { ByzantiumConfig byzantiumConfig = new ByzantiumConfig(new TestBlockchainConfig()); String parentHash = "fd9d7467e933ff2975c33ea3045ddf8773c87c4cec4e7da8de1bcc015361b38b"; BlockHeader parent = new BlockHeaderBuilder(parentHash.getBytes(), 4490788, "1,377,255,445,606,146") .withTimestamp(1509827488) .withUncles(Hex.decode("1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347")) .build(); BlockHeader current = new BlockHeaderBuilder(parent.getHash(), 4490789, BigInteger.ZERO) .withTimestamp(1509827494) .build(); BigInteger minimumDifficulty = byzantiumConfig.calcDifficulty(current, parent); BigInteger actualDifficultyOnEtherscan = BlockHeaderBuilder.parse("1,377,927,933,620,791"); assertTrue(actualDifficultyOnEtherscan.compareTo(minimumDifficulty) > -1); }
@Override public BigInteger calcDifficulty(BlockHeader curBlock, BlockHeader parent) { BigInteger pd = parent.getDifficultyBI(); BigInteger quotient = pd.divide(getConstants().getDIFFICULTY_BOUND_DIVISOR()); BigInteger sign = getCalcDifficultyMultiplier(curBlock, parent); BigInteger fromParent = pd.add(quotient.multiply(sign)); BigInteger difficulty = max(getConstants().getMINIMUM_DIFFICULTY(), fromParent); int explosion = getExplosion(curBlock, parent); if (explosion >= 0) { difficulty = max(getConstants().getMINIMUM_DIFFICULTY(), difficulty.add(BigInteger.ONE.shiftLeft(explosion))); } return difficulty; }
ByzantiumConfig extends Eip160HFConfig { @Override public BigInteger calcDifficulty(BlockHeader curBlock, BlockHeader parent) { BigInteger pd = parent.getDifficultyBI(); BigInteger quotient = pd.divide(getConstants().getDIFFICULTY_BOUND_DIVISOR()); BigInteger sign = getCalcDifficultyMultiplier(curBlock, parent); BigInteger fromParent = pd.add(quotient.multiply(sign)); BigInteger difficulty = max(getConstants().getMINIMUM_DIFFICULTY(), fromParent); int explosion = getExplosion(curBlock, parent); if (explosion >= 0) { difficulty = max(getConstants().getMINIMUM_DIFFICULTY(), difficulty.add(BigInteger.ONE.shiftLeft(explosion))); } return difficulty; } }
ByzantiumConfig extends Eip160HFConfig { @Override public BigInteger calcDifficulty(BlockHeader curBlock, BlockHeader parent) { BigInteger pd = parent.getDifficultyBI(); BigInteger quotient = pd.divide(getConstants().getDIFFICULTY_BOUND_DIVISOR()); BigInteger sign = getCalcDifficultyMultiplier(curBlock, parent); BigInteger fromParent = pd.add(quotient.multiply(sign)); BigInteger difficulty = max(getConstants().getMINIMUM_DIFFICULTY(), fromParent); int explosion = getExplosion(curBlock, parent); if (explosion >= 0) { difficulty = max(getConstants().getMINIMUM_DIFFICULTY(), difficulty.add(BigInteger.ONE.shiftLeft(explosion))); } return difficulty; } ByzantiumConfig(BlockchainConfig parent); }
ByzantiumConfig extends Eip160HFConfig { @Override public BigInteger calcDifficulty(BlockHeader curBlock, BlockHeader parent) { BigInteger pd = parent.getDifficultyBI(); BigInteger quotient = pd.divide(getConstants().getDIFFICULTY_BOUND_DIVISOR()); BigInteger sign = getCalcDifficultyMultiplier(curBlock, parent); BigInteger fromParent = pd.add(quotient.multiply(sign)); BigInteger difficulty = max(getConstants().getMINIMUM_DIFFICULTY(), fromParent); int explosion = getExplosion(curBlock, parent); if (explosion >= 0) { difficulty = max(getConstants().getMINIMUM_DIFFICULTY(), difficulty.add(BigInteger.ONE.shiftLeft(explosion))); } return difficulty; } ByzantiumConfig(BlockchainConfig parent); @Override Constants getConstants(); @Override BigInteger calcDifficulty(BlockHeader curBlock, BlockHeader parent); @Override BigInteger getCalcDifficultyMultiplier(BlockHeader curBlock, BlockHeader parent); @Override boolean eip198(); @Override boolean eip206(); @Override boolean eip211(); @Override boolean eip212(); @Override boolean eip213(); @Override boolean eip214(); @Override boolean eip658(); }
ByzantiumConfig extends Eip160HFConfig { @Override public BigInteger calcDifficulty(BlockHeader curBlock, BlockHeader parent) { BigInteger pd = parent.getDifficultyBI(); BigInteger quotient = pd.divide(getConstants().getDIFFICULTY_BOUND_DIVISOR()); BigInteger sign = getCalcDifficultyMultiplier(curBlock, parent); BigInteger fromParent = pd.add(quotient.multiply(sign)); BigInteger difficulty = max(getConstants().getMINIMUM_DIFFICULTY(), fromParent); int explosion = getExplosion(curBlock, parent); if (explosion >= 0) { difficulty = max(getConstants().getMINIMUM_DIFFICULTY(), difficulty.add(BigInteger.ONE.shiftLeft(explosion))); } return difficulty; } ByzantiumConfig(BlockchainConfig parent); @Override Constants getConstants(); @Override BigInteger calcDifficulty(BlockHeader curBlock, BlockHeader parent); @Override BigInteger getCalcDifficultyMultiplier(BlockHeader curBlock, BlockHeader parent); @Override boolean eip198(); @Override boolean eip206(); @Override boolean eip211(); @Override boolean eip212(); @Override boolean eip213(); @Override boolean eip214(); @Override boolean eip658();  }