diff --git a/ethereumj-core/bintray-publish-version.xml b/ethereumj-core/bintray-publish-version.xml index 64c02dba..10f0af02 100644 --- a/ethereumj-core/bintray-publish-version.xml +++ b/ethereumj-core/bintray-publish-version.xml @@ -26,7 +26,7 @@ - + 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 c34b6896..23d696ed 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/Block.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/Block.java @@ -92,8 +92,8 @@ public class Block { this.header = new BlockHeader(header); // Parse Transactions - RLPList txReceipts = (RLPList) block.get(1); - this.parseTxs(this.header.getTxTrieRoot(), txReceipts); + RLPList txTransactions = (RLPList) block.get(1); + this.parseTxs(this.header.getTxTrieRoot(), txTransactions); // Parse Uncles RLPList uncleBlocks = (RLPList) block.get(2); @@ -272,43 +272,14 @@ public class Block { return toStringBuff.toString(); } - public String toStylishString(){ - if (!parsed) parseRLP(); - - toStringBuff.setLength(0); - toStringBuff.append(" BlockData ["); - toStringBuff.append("hash=" + - ByteUtil.toHexString(this.getHash())).append("
"); - toStringBuff.append(header.toStylishString()); - - for (TransactionReceipt tx : getTxReceiptList()) { - toStringBuff.append("
"); - toStringBuff.append(tx.toStylishString()); - toStringBuff.append("
"); - } - - toStringBuff.append("]"); - return toStringBuff.toString(); - - } - - private void parseTxs(byte[] expectedRoot, RLPList txReceipts) { + private void parseTxs(byte[] expectedRoot, RLPList txTransactions) { this.txsState = new TrieImpl(null); - for (int i = 0; i < txReceipts.size(); i++) { - RLPElement rlpTxReceipt = txReceipts.get(i); - RLPElement txData = ((RLPList)rlpTxReceipt).get(0); - - // YP 4.3.1 - RLPElement pstTxState = ((RLPList)rlpTxReceipt).get(1); - RLPElement cummGas = ((RLPList)rlpTxReceipt).get(2); - - Transaction tx = new Transaction(txData.getRLPData()); - this.transactionsList.add(tx); - TransactionReceipt txReceipt = - new TransactionReceipt(tx, pstTxState.getRLPData(), cummGas.getRLPData()); - this.addTxReceipt(i, txReceipt); + for (int i = 0; i < txTransactions.size(); i++) { + RLPElement transactionRaw = txTransactions.get(i); + this.transactionsList.add(new Transaction(transactionRaw.getRLPData())); + this.txsState.update(RLP.encodeInt(i) , transactionRaw.getRLPData()); } String calculatedRoot = Hex.toHexString(txsState.getRootHash()); @@ -316,23 +287,7 @@ public class Block { logger.error("Added tx receipts don't match the given txsStateRoot"); } - private void addTxReceipt(int counter, TransactionReceipt txReceipt) { - this.txReceiptList.add(txReceipt); - this.txsState.update(RLP.encodeInt(counter), txReceipt.getEncoded()); - - /* Figure out type of tx - * 1. Contract creation - * - perform code - * - create state object - * - add contract body to DB, - * 2. Contract call - * - perform code - * - update state object - * 3. Account to account - - * - update state object - */ - } - + /** * This mechanism enforces a homeostasis in terms of the time between blocks; * a smaller period between the last two blocks results in an increase in the 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 6fc80b14..dab51011 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/BlockHeader.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/BlockHeader.java @@ -5,6 +5,7 @@ import java.math.BigInteger; import static org.ethereum.util.ByteUtil.*; import org.ethereum.crypto.HashUtil; +import org.ethereum.crypto.SHA3Helper; import org.ethereum.manager.WorldManager; import org.ethereum.util.*; import org.spongycastle.util.Arrays; @@ -69,6 +70,7 @@ public class BlockHeader { private byte[] nonce; 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(); @@ -99,6 +101,7 @@ public class BlockHeader { this.extraData = ((RLPItem) rlpHeader.get(13)).getRLPData(); this.nonce = ((RLPItem) rlpHeader.get(14)).getRLPData(); + } public BlockHeader(byte[] parentHash, byte[] unclesHash, byte[] coinbase, @@ -287,17 +290,11 @@ public class BlockHeader { byte[] stateRoot = RLP.encodeElement(this.stateRoot); - if (this.txTrieRoot == null) - this.txTrieRoot = ByteUtil.EMTPY_TRIE_HASH; - - byte[] txTrieRoot = RLP.encodeElement(this.txTrieRoot); - - - if (this.recieptTrieRoot == null) - this.recieptTrieRoot = ByteUtil.EMTPY_TRIE_HASH; - - byte[] recieptTrieRoot = RLP.encodeElement(this.txTrieRoot); + if (txTrieRoot == null) this.txTrieRoot = ByteUtil.EMTPY_TRIE_HASH; + byte[] txTrieRoot = RLP.encodeElement(this.txTrieRoot); + if (recieptTrieRoot == null) this.recieptTrieRoot = ByteUtil.EMTPY_TRIE_HASH; + byte[] recieptTrieRoot = RLP.encodeElement(this.recieptTrieRoot); byte[] logsBloom = RLP.encodeElement(this.logsBloom); byte[] difficulty = RLP.encodeElement(this.difficulty); diff --git a/ethereumj-core/src/main/java/org/ethereum/core/Transaction.java b/ethereumj-core/src/main/java/org/ethereum/core/Transaction.java index 24d9a378..3f95c267 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/Transaction.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/Transaction.java @@ -213,21 +213,6 @@ public class Transaction { "]"; } - public String toStylishString() { - if (!parsed) rlpParse(); - return " TransactionData [" + " hash=" + ByteUtil.toHexString(hash) + "
" + - "-> , nonce=" + ByteUtil.toHexString(nonce) + "
" + - "-> , gasPrice=" + ByteUtil.toHexString(gasPrice) + "
" + - "-> , gas=" + ByteUtil.toHexString(gasLimit) + "
" + - "-> , receiveAddress=" + ByteUtil.toHexString(receiveAddress) + "
" + - "-> , value=" + ByteUtil.toHexString(value) + "
" + - "-> , data=" + ByteUtil.toHexString(data) + "
" + - "-> , signatureV=" + signature.v + "
" + - "-> , signatureR=" + ByteUtil.toHexString(BigIntegers.asUnsignedByteArray(signature.r)) + "
" + - "-> , signatureS=" + ByteUtil.toHexString(BigIntegers.asUnsignedByteArray(signature.s)) + "
" + - " ]"; - } - /** * For signatures you have to keep also * RLP of the transaction without any signature data diff --git a/ethereumj-core/src/main/java/org/ethereum/core/TransactionReceipt.java b/ethereumj-core/src/main/java/org/ethereum/core/TransactionReceipt.java index b1cdbd07..4880312e 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/TransactionReceipt.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/TransactionReceipt.java @@ -8,6 +8,10 @@ import org.spongycastle.util.encoders.Hex; * comprising the transaction, together with the post-transaction state, * and the cumulative gas used in the block containing the transaction receipt * as of immediately after the transaction has happened, + * + * ** not todo: the transaction receipt was removed from the game but don't remove it + * as it will be used in the very near future. + * */ public class TransactionReceipt { @@ -54,13 +58,4 @@ public class TransactionReceipt { ']'; } - - public String toStylishString() { - return " TransactionReceipt[" + - "
" + transaction.toStylishString() + - "
, postTxState=" + Hex.toHexString(postTxState) + - "
, cumulativeGas=" + Hex.toHexString(cumulativeGas) + - ']'; - } - } diff --git a/ethereumj-studio/pom.xml b/ethereumj-studio/pom.xml index b710bb55..8d3922b8 100644 --- a/ethereumj-studio/pom.xml +++ b/ethereumj-studio/pom.xml @@ -4,7 +4,7 @@ org.ethereum ethereumj-studio jar - 0.6.1 + 0.7.8 EthereumJ Studio http://www.ethereumj.org @@ -71,7 +71,7 @@ org.ethereum ethereumj - 0.7.2.20141031.1029 + 0.7.8.20141103.1055