diff --git a/ethereumj-core/src/main/java/org/ethereum/core/Block.java b/ethereumj-core/src/main/java/org/ethereum/core/Block.java index 007685a9..e26c9863 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/Block.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/Block.java @@ -40,7 +40,6 @@ public class Block { private BlockHeader header; /* Transactions */ - private List txReceiptList = new CopyOnWriteArrayList<>() ; private List transactionsList = new CopyOnWriteArrayList<>(); /* Uncles */ @@ -62,11 +61,11 @@ public class Block { } public Block(byte[] parentHash, byte[] unclesHash, byte[] coinbase, byte[] logsBloom, - byte[] difficulty, long number, long minGasPrice, long gasLimit, + byte[] difficulty, long number, long gasLimit, long gasUsed, long timestamp, byte[] extraData, byte[] nonce, List transactionsList, List uncleList) { this.header = new BlockHeader(parentHash, unclesHash, coinbase, logsBloom, - difficulty, number, minGasPrice, gasLimit, gasUsed, + difficulty, number, gasLimit, gasUsed, timestamp, extraData, nonce); this.transactionsList = transactionsList; @@ -192,11 +191,6 @@ public class Block { return this.header.getNumber(); } - public long getMinGasPrice() { - if (!parsed) parseRLP(); - return this.header.getMinGasPrice(); - } - public long getGasLimit() { if (!parsed) parseRLP(); return this.header.getGasLimit(); @@ -227,11 +221,6 @@ public class Block { return transactionsList; } - public List getTxReceiptList() { - if (!parsed) parseRLP(); - return txReceiptList; - } - public List getUncleList() { if (!parsed) parseRLP(); return uncleList; @@ -252,11 +241,6 @@ public class Block { toStringBuff.append("BlockData [ "); toStringBuff.append("hash=" + ByteUtil.toHexString(this.getHash())).append("\n"); toStringBuff.append(header.toString()); - - for (TransactionReceipt txReceipt : getTxReceiptList()) { - toStringBuff.append("\n"); - toStringBuff.append(txReceipt.toString()); - } toStringBuff.append("\nUncles [\n"); for (BlockHeader uncle : getUncleList()){ diff --git a/ethereumj-core/src/main/java/org/ethereum/core/BlockHeader.java b/ethereumj-core/src/main/java/org/ethereum/core/BlockHeader.java index de08971b..7d372ece 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/BlockHeader.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/BlockHeader.java @@ -2,7 +2,6 @@ package org.ethereum.core; import org.ethereum.crypto.HashUtil; import org.ethereum.util.RLP; -import org.ethereum.util.RLPItem; import org.ethereum.util.RLPList; import org.ethereum.util.Utils; @@ -51,10 +50,6 @@ public class BlockHeader { /* A scalar value equal to the number of ancestor blocks. * The genesis block has a number of zero */ private long number; - /* A scalar value equal to the minimum price of gas a transaction - * must have provided in order to be sufficient for inclusion - * by this miner in this block */ - private long minGasPrice; /* A scalar value equal to the current limit of gas expenditure per block */ private long gasLimit; /* A scalar value equal to the total gas used in transactions in this block */ @@ -68,42 +63,41 @@ public class BlockHeader { public BlockHeader(RLPList rlpHeader) { - this.parentHash = ((RLPItem) rlpHeader.get(0)).getRLPData(); - this.unclesHash = ((RLPItem) rlpHeader.get(1)).getRLPData(); - this.coinbase = ((RLPItem) rlpHeader.get(2)).getRLPData(); - this.stateRoot = ((RLPItem) rlpHeader.get(3)).getRLPData(); + this.parentHash = rlpHeader.get(0).getRLPData(); + this.unclesHash = rlpHeader.get(1).getRLPData(); + this.coinbase = rlpHeader.get(2).getRLPData(); + this.stateRoot = rlpHeader.get(3).getRLPData(); - this.txTrieRoot = ((RLPItem) rlpHeader.get(4)).getRLPData(); + this.txTrieRoot = rlpHeader.get(4).getRLPData(); if(this.txTrieRoot == null) this.txTrieRoot = EMPTY_TRIE_HASH; - this.recieptTrieRoot = ((RLPItem) rlpHeader.get(5)).getRLPData(); + this.recieptTrieRoot = rlpHeader.get(5).getRLPData(); if(this.recieptTrieRoot == null) this.recieptTrieRoot = EMPTY_TRIE_HASH; - this.logsBloom = ((RLPItem) rlpHeader.get(6)).getRLPData(); - this.difficulty = ((RLPItem) rlpHeader.get(7)).getRLPData(); + this.logsBloom = rlpHeader.get(6).getRLPData(); + this.difficulty = rlpHeader.get(7).getRLPData(); - byte[] nrBytes = ((RLPItem) rlpHeader.get(8)).getRLPData(); - byte[] gpBytes = ((RLPItem) rlpHeader.get(9)).getRLPData(); - byte[] glBytes = ((RLPItem) rlpHeader.get(10)).getRLPData(); - byte[] guBytes = ((RLPItem) rlpHeader.get(11)).getRLPData(); - byte[] tsBytes = ((RLPItem) rlpHeader.get(12)).getRLPData(); + byte[] nrBytes = rlpHeader.get(8).getRLPData(); + byte[] glBytes = rlpHeader.get(9).getRLPData(); + byte[] guBytes = rlpHeader.get(10).getRLPData(); + byte[] tsBytes = rlpHeader.get(11).getRLPData(); this.number = nrBytes == null ? 0 : (new BigInteger(1, nrBytes)).longValue(); - this.minGasPrice = gpBytes == null ? 0 : (new BigInteger(1, gpBytes)).longValue(); + this.gasLimit = glBytes == null ? 0 : (new BigInteger(1, glBytes)).longValue(); this.gasUsed = guBytes == null ? 0 : (new BigInteger(1, guBytes)).longValue(); this.timestamp = tsBytes == null ? 0 : (new BigInteger(1, tsBytes)).longValue(); - this.extraData = ((RLPItem) rlpHeader.get(13)).getRLPData(); - this.nonce = ((RLPItem) rlpHeader.get(14)).getRLPData(); + this.extraData = rlpHeader.get(12).getRLPData(); + this.nonce = rlpHeader.get(13).getRLPData(); } public BlockHeader(byte[] parentHash, byte[] unclesHash, byte[] coinbase, byte[] logsBloom, byte[] difficulty, long number, - long minGasPrice, long gasLimit, long gasUsed, long timestamp, + long gasLimit, long gasUsed, long timestamp, byte[] extraData, byte[] nonce) { this.parentHash = parentHash; this.unclesHash = unclesHash; @@ -111,7 +105,6 @@ public class BlockHeader { this.logsBloom = logsBloom; this.difficulty = difficulty; this.number = number; - this.minGasPrice = minGasPrice; this.gasLimit = gasLimit; this.gasUsed = gasUsed; this.timestamp = timestamp; @@ -200,12 +193,6 @@ public class BlockHeader { public void setNumber(long number) { this.number = number; } - public long getMinGasPrice() { - return minGasPrice; - } - public void setMinGasPrice(long minGasPrice) { - this.minGasPrice = minGasPrice; - } public long getGasLimit() { return gasLimit; } @@ -256,7 +243,6 @@ public class BlockHeader { byte[] logsBloom = RLP.encodeElement(this.logsBloom); byte[] difficulty = RLP.encodeElement(this.difficulty); byte[] number = RLP.encodeBigInteger(BigInteger.valueOf(this.number)); - byte[] minGasPrice = RLP.encodeBigInteger(BigInteger.valueOf(this.minGasPrice)); byte[] gasLimit = RLP.encodeBigInteger(BigInteger.valueOf(this.gasLimit)); byte[] gasUsed = RLP.encodeBigInteger(BigInteger.valueOf(this.gasUsed)); byte[] timestamp = RLP.encodeBigInteger(BigInteger.valueOf(this.timestamp)); @@ -265,11 +251,11 @@ public class BlockHeader { byte[] nonce = RLP.encodeElement(this.nonce); return RLP.encodeList(parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, recieptTrieRoot, logsBloom, difficulty, number, - minGasPrice, gasLimit, gasUsed, timestamp, extraData, nonce); + gasLimit, gasUsed, timestamp, extraData, nonce); } else { return RLP.encodeList(parentHash, unclesHash, coinbase, stateRoot, txTrieRoot, recieptTrieRoot, logsBloom, difficulty, number, - minGasPrice, gasLimit, gasUsed, timestamp, extraData); + gasLimit, gasUsed, timestamp, extraData); } } @@ -288,7 +274,6 @@ public class BlockHeader { toStringBuff.append(" reciptsTrieHash=" + toHexString(recieptTrieRoot)).append("\n"); toStringBuff.append(" difficulty=" + toHexString(difficulty)).append("\n"); toStringBuff.append(" number=" + number).append("\n"); - toStringBuff.append(" minGasPrice=" + minGasPrice).append("\n"); toStringBuff.append(" gasLimit=" + gasLimit).append("\n"); toStringBuff.append(" gasUsed=" + gasUsed).append("\n"); toStringBuff.append(" timestamp=" + timestamp + " (" + Utils.longToDateTime(timestamp) + ")").append("\n"); @@ -305,7 +290,6 @@ public class BlockHeader { toStringBuff.append(" txTrieHash=" + toHexString(txTrieRoot)).append(""); toStringBuff.append(" difficulty=" + toHexString(difficulty)).append(""); toStringBuff.append(" number=" + number).append(""); - toStringBuff.append(" minGasPrice=" + minGasPrice).append(""); toStringBuff.append(" gasLimit=" + gasLimit).append(""); toStringBuff.append(" gasUsed=" + gasUsed).append(""); toStringBuff.append(" timestamp=" + timestamp).append(""); 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 295f7cb8..702dbd7b 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/BlockchainImpl.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/BlockchainImpl.java @@ -100,12 +100,6 @@ public class BlockchainImpl implements Blockchain { private List altChains = new ArrayList<>(); private List garbage = new ArrayList<>(); - @Override - public long getGasPrice() { - // In case of the genesis block we don't want to rely on the min gas price - return bestBlock.isGenesis() ? bestBlock.getMinGasPrice() : INITIAL_MIN_GAS_PRICE; - } - @Override public byte[] getBestBlockHash() { return getBestBlock().getHash(); @@ -541,6 +535,9 @@ public class BlockchainImpl implements Blockchain { if (CONFIG.playVM()) vm.play(program); + // todo: recepit save logs + // todo: receipt calc and save blooms + program.saveProgramTraceToFile(Hex.toHexString(tx.getHash())); ProgramResult result = program.getResult(); applyProgramResult(result, gasDebit, gasPrice, trackTx, diff --git a/ethereumj-core/src/main/java/org/ethereum/core/Genesis.java b/ethereumj-core/src/main/java/org/ethereum/core/Genesis.java index 6c4046fe..f40d1f5e 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/Genesis.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/Genesis.java @@ -52,7 +52,7 @@ public class Genesis extends Block { public static byte[] DIFFICULTY = BigInteger.valueOf(2).pow(17).toByteArray(); public static long NUMBER = 0; public static long MIN_GAS_PRICE = 0; - public static long GAS_LIMIT = 1000000; + public static long GAS_LIMIT = 0; public static long GAS_USED = 0; public static long TIMESTAMP = 0; public static byte[] EXTRA_DATA = new byte[0]; @@ -62,7 +62,7 @@ public class Genesis extends Block { private Genesis() { super(PARENT_HASH, UNCLES_HASH, COINBASE, LOG_BLOOM, DIFFICULTY, - NUMBER, MIN_GAS_PRICE, GAS_LIMIT, GAS_USED, TIMESTAMP, + NUMBER, GAS_LIMIT, GAS_USED, TIMESTAMP, EXTRA_DATA, NONCE, null, null); Trie state = new TrieImpl(null); diff --git a/ethereumj-core/src/main/java/org/ethereum/facade/Blockchain.java b/ethereumj-core/src/main/java/org/ethereum/facade/Blockchain.java index 480beb76..fbf444fd 100644 --- a/ethereumj-core/src/main/java/org/ethereum/facade/Blockchain.java +++ b/ethereumj-core/src/main/java/org/ethereum/facade/Blockchain.java @@ -19,7 +19,6 @@ public interface Blockchain { public void tryToConnect(Block block); public void storeBlock(Block block); public Block getBlockByNumber(long blockNr); - public long getGasPrice(); public void setBestBlock(Block block); public Block getBestBlock(); public BlockQueue getQueue(); diff --git a/ethereumj-core/src/main/java/org/ethereum/json/JSONHelper.java b/ethereumj-core/src/main/java/org/ethereum/json/JSONHelper.java index 3554891f..aa9b1c4c 100644 --- a/ethereumj-core/src/main/java/org/ethereum/json/JSONHelper.java +++ b/ethereumj-core/src/main/java/org/ethereum/json/JSONHelper.java @@ -73,7 +73,6 @@ public class JSONHelper { blockNode.put("difficulty", new BigInteger(1, block.calcDifficulty()).toString()); blockNode.put("extra_data", "0x"); blockNode.put("gas_used", String.valueOf(gasUsed)); - blockNode.put("min_gas_price", String.valueOf(block.getMinGasPrice())); blockNode.put("nonce", "0x" + Hex.toHexString(block.getNonce())); blockNode.put("number", String.valueOf(block.getNumber())); blockNode.put("prevhash", "0x" + Hex.toHexString(block.getParentHash())); diff --git a/ethereumj-core/src/main/java/org/ethereum/net/eth/EthHandler.java b/ethereumj-core/src/main/java/org/ethereum/net/eth/EthHandler.java index 7749e370..b5ad9a75 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/eth/EthHandler.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/eth/EthHandler.java @@ -42,7 +42,7 @@ import static org.ethereum.net.message.StaticMessages.GET_TRANSACTIONS_MESSAGE; @Scope("prototype") public class EthHandler extends SimpleChannelInboundHandler { - public final static byte VERSION = 43; + public final static byte VERSION = 45; public final static byte NETWORK_ID = 0x0; private final static Logger logger = LoggerFactory.getLogger("net"); diff --git a/ethereumj-core/src/main/java/org/ethereum/net/shh/ShhHandler.java b/ethereumj-core/src/main/java/org/ethereum/net/shh/ShhHandler.java index b43c7c4c..4ad071f3 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/shh/ShhHandler.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/shh/ShhHandler.java @@ -21,7 +21,7 @@ import org.springframework.stereotype.Component; @Scope("prototype") public class ShhHandler extends SimpleChannelInboundHandler { - public final static byte VERSION = 2; + public final static byte VERSION = 1; private MessageQueue msgQueue = null; private boolean active = false; diff --git a/ethereumj-core/src/main/resources/log4j.properties b/ethereumj-core/src/main/resources/log4j.properties index f4b35230..ce4edf2a 100644 --- a/ethereumj-core/src/main/resources/log4j.properties +++ b/ethereumj-core/src/main/resources/log4j.properties @@ -31,12 +31,12 @@ log4j.logger.peerdiscovery = TRACE log4j.logger.peermonitor = TRACE log4j.logger.java.nio = ERROR log4j.logger.io.netty = ERROR -log4j.logger.wire = ERROR +log4j.logger.wire = DEBUG log4j.logger.VM = ERROR log4j.logger.main = ERROR log4j.logger.trie = ERROR log4j.logger.state = INFO -log4j.logger.repository = TRACE +log4j.logger.repository = ERROR log4j.logger.blockchain = DEBUG log4j.logger.txs = ERROR log4j.logger.ui = ERROR diff --git a/ethereumj-core/src/test/java/test/ethereum/core/BlockTest.java b/ethereumj-core/src/test/java/test/ethereum/core/BlockTest.java index d9327bcd..b0b3f249 100644 --- a/ethereumj-core/src/test/java/test/ethereum/core/BlockTest.java +++ b/ethereumj-core/src/test/java/test/ethereum/core/BlockTest.java @@ -6,6 +6,8 @@ import org.ethereum.core.BlockchainImpl; import org.ethereum.core.Genesis; import org.ethereum.facade.Blockchain; import org.ethereum.manager.WorldManager; +import org.ethereum.util.RLP; +import org.ethereum.util.RLPList; import org.junit.After; import org.junit.Ignore; import org.junit.Test; @@ -54,8 +56,8 @@ public class BlockTest { // https://ethereum.etherpad.mozilla.org/12 - private String PoC7_GENESIS_HEX_RLP_ENCODED = "f9012ff9012aa00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0c67c70f5d7d3049337d1dcc0503a249881120019a8e7322774dbfe57b463718ca056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b84000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830200008080830f4240808080a004994f67dc55b09e814ab7ffc8df3686b4afb2bb53e60eae97ef043fe03fb829c0c0"; - private String PoC7_GENESIS_HEX_HASH = "955f36d073ccb026b78ab3424c15cf966a7563aa270413859f78702b9e8e22cb"; + private String PoC7_GENESIS_HEX_RLP_ENCODED = "f9012bf90126a00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0c67c70f5d7d3049337d1dcc0503a249881120019a8e7322774dbfe57b463718ca056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b84000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830200008080808080a004994f67dc55b09e814ab7ffc8df3686b4afb2bb53e60eae97ef043fe03fb829c0c0"; + private String PoC7_GENESIS_HEX_HASH = "4713ad990f439d0b559eb1a3ff0c744dc763df1914ec0aaaf3de3f43ef3c952c"; String block_2 = "f8b5f8b1a0cf4b25b08b39350304fe12a16e4216c01a426f8f3dbf0d392b5b45" + "8ffb6a399da01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a1" @@ -125,6 +127,8 @@ public class BlockTest { ) */ Block genesis = Genesis.getInstance(); + logger.info(genesis.toString()); + logger.info("genesis hash: [{}]", Hex.toHexString(genesis.getHash())); logger.info("genesis rlp: [{}]", Hex.toHexString(genesis.getEncoded())); assertEquals(PoC7_GENESIS_HEX_HASH, Hex.toHexString(genesis.getHash())); diff --git a/ethereumj-core/src/test/java/test/ethereum/core/MinerTest.java b/ethereumj-core/src/test/java/test/ethereum/core/MinerTest.java index 28496e8e..983d6e8e 100644 --- a/ethereumj-core/src/test/java/test/ethereum/core/MinerTest.java +++ b/ethereumj-core/src/test/java/test/ethereum/core/MinerTest.java @@ -105,14 +105,14 @@ public class MinerTest { byte[] stateRoot = Hex.decode("50188ab86bdf164ac90eb2835a04a8930aae5393c3a2ef1166fb95028f9456b8"); Block newBlock = new Block(parentHash, unclesHash, coinbase, null, - difficulty, number, minGasPrice, gasLimit, gasUsed, timestamp, + difficulty, number, gasLimit, gasUsed, timestamp, null, nonce, null, null); // Setting stateRoot manually, because don't have state available. return newBlock; } else{ Block newBlock = new Block(lastBlock.getHash(), lastBlock.getUnclesHash(), lastBlock.getCoinbase(), null, - lastBlock.getDifficulty(), lastBlock.getNumber() + 1, lastBlock.getMinGasPrice(), + lastBlock.getDifficulty(), lastBlock.getNumber() + 1, lastBlock.getGasLimit(), lastBlock.getGasUsed(), lastBlock.getTimestamp(), null, null, null, null); diff --git a/ethereumj-core/src/test/java/test/ethereum/mine/MinerThread.java b/ethereumj-core/src/test/java/test/ethereum/mine/MinerThread.java index 920183a1..2cb5d95c 100644 --- a/ethereumj-core/src/test/java/test/ethereum/mine/MinerThread.java +++ b/ethereumj-core/src/test/java/test/ethereum/mine/MinerThread.java @@ -148,7 +148,7 @@ public class MinerThread implements Runnable { // } Block newBlock = new Block(lastBlock.getHash(), lastBlock.getUnclesHash(), coinbase, lastBlock.getLogBloom(), - difficulty , lastBlock.getNumber() + 1, lastBlock.getMinGasPrice(), + difficulty , lastBlock.getNumber() + 1, lastBlock.getGasLimit(), lastBlock.getGasUsed(), System.currentTimeMillis() / 1000, null, null, null, null);