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 8e5350c8..4078b510 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/BlockchainImpl.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/BlockchainImpl.java @@ -216,7 +216,7 @@ public class BlockchainImpl implements Blockchain { this.setLastBlock(block); if (logger.isDebugEnabled()) - logger.debug("block added {}", block.toFlatString()); + logger.debug("block added to the blockChain {}", block.toFlatString()); if (block.getNumber() % 100 == 0) logger.info("*** Last block added [ #{} ]", block.getNumber()); } diff --git a/ethereumj-core/src/main/java/org/ethereum/net/BlockQueue.java b/ethereumj-core/src/main/java/org/ethereum/net/BlockQueue.java index b6e9ccff..4c572f98 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/BlockQueue.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/BlockQueue.java @@ -56,6 +56,8 @@ public class BlockQueue { logger.debug("BlockQueue size: {}", blockReceivedQueue.size()); Block block = blockReceivedQueue.poll(); + + logger.info("Processing block index: {}", block.getNumber()); WorldManager.getInstance().getBlockchain().add(block); } @@ -72,22 +74,38 @@ public class BlockQueue { public void addBlocks(List blockList) { Block lastReceivedBlock = blockList.get(0); - if (lastReceivedBlock.getNumber() != getLastBlock().getNumber() + 1) - return; + if (lastReceivedBlock.getNumber() != getLastBlock().getNumber() + 1){ + logger.error("Block download out of sync"); + return; + } - for (Block block : blockList) { - - if (blockReceivedQueue.size() >= SystemProperties.CONFIG.maxBlocksQueued()) - return; + blockReceivedQueue.addAll(blockList); + lastBlock = blockList.get(blockList.size() - 1); - this.lastBlock = block; - logger.debug("Last block now index: [{}]", lastBlock.getNumber()); - blockReceivedQueue.add(lastBlock); - blockHashQueue.removeLast(); - } - logger.debug("Blocks waiting to be proceed in the queue: [{}]", - blockReceivedQueue.size()); + logger.debug("Blocks waiting to be proceed: queue.size: [{}] lastBlock.number: [{}]" , + blockReceivedQueue.size(), + lastBlock.getNumber()); } + + /** + * adding single block to the queue usually + * a result of a NEW_BLOCK message announce. + * @param block - new block + */ + public void addBlock(Block block){ + + if (block.getNumber() != getLastBlock().getNumber() + 1){ + logger.error("Block download out of sync"); + return; + } + + blockReceivedQueue.add(block); + lastBlock = block; + + logger.debug("Blocks waiting to be proceed: queue.size: [{}] lastBlock.number: [{}]" , + blockReceivedQueue.size(), + lastBlock.getNumber()); + } /** * Returns the last block in the queue. If the queue is empty, @@ -127,22 +145,30 @@ public class BlockQueue { public void addHash(byte[] hash) { blockHashQueue.addLast(hash); } + + public void addNewBlockHash(byte[] hash){ + blockHashQueue.addFirst(hash); + } /** * Return a list of hashes from blocks that still need to be downloaded. * - * @param amount - the number of hashes to return * @return A list of hashes for which blocks need to be retrieved. */ public List getHashes() { List hashes = new ArrayList<>(); - Iterator hashIterator = blockHashQueue.descendingIterator(); - while (hashIterator.hasNext() && hashes.size() <= CONFIG.maxBlocksAsk()) { - hashes.add(hashIterator.next()); + while (!blockHashQueue.isEmpty() && hashes.size() < CONFIG.maxBlocksAsk()) { + hashes.add(blockHashQueue.removeLast()); } return hashes; } + // a bit ugly but really gives + // good result + public void logHashQueueSize(){ + logger.trace("Block hashes list size: [{}]", blockHashQueue.size()); + } + private class BlockByIndexComparator implements Comparator { @Override 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 046871e9..892e9d35 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 @@ -11,7 +11,7 @@ import org.ethereum.net.MessageQueue; import org.ethereum.net.PeerListener; import org.ethereum.net.message.ReasonCode; import org.ethereum.net.p2p.DisconnectMessage; -import org.ethereum.net.p2p.UserMessage; +import org.ethereum.util.ByteUtil; import org.ethereum.util.FastByteComparisons; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,15 +41,17 @@ public class EthHandler extends SimpleChannelInboundHandler { private final static Logger logger = LoggerFactory.getLogger("net"); public static byte version = 0x23; - private int secToAskForBlocks = 1; - private String peerId; private PeerListener peerListener; private static String hashRetrievalLock; private MessageQueue msgQueue = null; + private SyncSatus syncStatus = SyncSatus.INIT; + private Timer getBlocksTimer = new Timer("GetBlocksTimer"); + + // private Timer getTxTimer = new Timer("GetTransactionsTimer"); public EthHandler(MessageQueue msgQueue) { @@ -65,6 +67,7 @@ public class EthHandler extends SimpleChannelInboundHandler { @Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { logger.info("ETH protocol activated"); + sendStatus(); } @Override @@ -76,12 +79,12 @@ public class EthHandler extends SimpleChannelInboundHandler { public void channelRead0(final ChannelHandlerContext ctx, EthMessage msg) throws InterruptedException { if (EthMessageCodes.inRange(msg.getCommand().asByte())) - logger.info("EthHandler invoke: {}", msg.getCommand()); + logger.info("EthHandler invoke: [{}]", msg.getCommand()); switch (msg.getCommand()) { case STATUS: msgQueue.receivedMessage(msg); -// processStatus((StatusMessage)msg, ctx); + processStatus((StatusMessage) msg, ctx); break; case GET_TRANSACTIONS: msgQueue.receivedMessage(msg); @@ -111,6 +114,8 @@ public class EthHandler extends SimpleChannelInboundHandler { msgQueue.receivedMessage(msg); processBlocks((BlocksMessage) msg); break; + case NEW_BLOCK: + procesNewBlock((NewBlockMessage)msg); default: break; } @@ -140,7 +145,7 @@ public class EthHandler extends SimpleChannelInboundHandler { * @param msg is the StatusMessage * @param ctx the ChannelHandlerContext */ - public void processUser(UserMessage msg, ChannelHandlerContext ctx) { + public void processStatus(StatusMessage msg, ChannelHandlerContext ctx) { Blockchain blockchain = WorldManager.getInstance().getBlockchain(); @@ -160,13 +165,13 @@ public class EthHandler extends SimpleChannelInboundHandler { hashRetrievalLock = this.peerId; chainQueue.setHighestTotalDifficulty(peerTotalDifficulty); chainQueue.setBestHash(msg.getBestHash()); + syncStatus = SyncSatus.HASH_RETREIVING; sendGetBlockHashes(); } else startGetBlockTimer(); } } - private void processBlockHashes(BlockHashesMessage blockHashesMessage) { Blockchain blockchain = WorldManager.getInstance().getBlockchain(); @@ -185,8 +190,9 @@ public class EthHandler extends SimpleChannelInboundHandler { byte[] foundHash, latestHash = blockchain.getLatestBlockHash(); while (hashIterator.hasNext()) { foundHash = hashIterator.next(); - if (FastByteComparisons.compareTo(foundHash, 0, 32, latestHash, 0, 32) != 0) + if (FastByteComparisons.compareTo(foundHash, 0, 32, latestHash, 0, 32) != 0){ chainQueue.addHash(foundHash); // store unknown hashes in queue until known hash is found + } else { // if known hash is found, ignore the rest startGetBlockTimer(); // start getting blocks from hash queue @@ -194,30 +200,67 @@ public class EthHandler extends SimpleChannelInboundHandler { } } // no known hash has been reached + chainQueue.logHashQueueSize(); sendGetBlockHashes(); // another getBlockHashes with last received hash. } private void processBlocks(BlocksMessage blocksMessage) { Blockchain blockchain = WorldManager.getInstance().getBlockchain(); List blockList = blocksMessage.getBlocks(); - // If we get one block from a peer we ask less greedy - if (blockList.size() <= 1 && secToAskForBlocks != 10) { - logger.info("Now we ask for blocks every 10 seconds"); - updateGetBlocksTimer(10); - } - // If we get more blocks from a peer we ask more greedy - if (blockList.size() > 2 && secToAskForBlocks != 1) { - logger.info("Now we ask for a chain every 1 seconds"); - updateGetBlocksTimer(1); + // If we got less blocks then we could get, + // it the correct indication that we are in sync we + // the chain from here there will be NEW_BLOCK only + // message expectation + if (blockList.size() < CONFIG.maxBlocksAsk()) { + logger.info(" *** The chain sync process fully complete ***"); + syncStatus = SyncSatus.SYNC_DONE; + stopGetBlocksTimer(); } if (blockList.isEmpty()) return; blockchain.getQueue().addBlocks(blockList); + blockchain.getQueue().logHashQueueSize(); } - private void sendStatus() { - StatusMessage msg = new StatusMessage(); + + /** + * Processing NEW_BLOCK announce message + * @param newBlockMessage - new block message + */ + private void procesNewBlock(NewBlockMessage newBlockMessage){ + + Blockchain blockchain = WorldManager.getInstance().getBlockchain(); + Block newBlock = newBlockMessage.getBlock(); + + // If the hashes still being downloaded ignore the NEW_BLOCKs + // that block hash will be retrieved by the others and letter the block itself + if (syncStatus == SyncSatus.INIT || syncStatus == SyncSatus.HASH_RETREIVING) { + logger.debug("Sync status INIT or HASH_RETREIVING ignore new block.index: [{}]", newBlock.getNumber()); + return; + } + + // If the GET_BLOCKs stage started add hash to the end of the hash list + // then the block will be retrieved in it's turn; + if (syncStatus == SyncSatus.BLOCK_RETREIVING){ + logger.debug("Sync status BLOCK_RETREIVING add to the end of hash list: block.index: [{}]", newBlock.getNumber()); + blockchain.getQueue().addNewBlockHash(newBlockMessage.getBlock().getHash()); + return; + } + + logger.info("New block received: block.index [{}]", newBlockMessage.getBlock().getNumber()); + + blockchain.getQueue().addBlock(newBlockMessage.getBlock()); + blockchain.getQueue().logHashQueueSize(); + } + + private void sendStatus(){ + Blockchain blockChain= WorldManager.getInstance().getBlockchain(); + byte protocolVersion = EthHandler.version, networkId = 0; + BigInteger totalDifficulty = blockChain.getTotalDifficulty(); + byte[] bestHash = blockChain.getLatestBlockHash(); + StatusMessage msg = new StatusMessage(protocolVersion, networkId, + ByteUtil.bigIntegerToBytes(totalDifficulty), bestHash, Blockchain.GENESIS_HASH); msgQueue.sendMessage(msg); } @@ -250,6 +293,10 @@ public class EthHandler extends SimpleChannelInboundHandler { // retrieve list of block hashes from queue List hashes = queue.getHashes(); + if (hashes.isEmpty()) { + stopGetBlocksTimer(); + return; + } GetBlocksMessage msg = new GetBlocksMessage(hashes); msgQueue.sendMessage(msg); @@ -279,23 +326,17 @@ public class EthHandler extends SimpleChannelInboundHandler { } public void startGetBlockTimer() { + syncStatus = SyncSatus.BLOCK_RETREIVING; getBlocksTimer.scheduleAtFixedRate(new TimerTask() { public void run() { + BlockQueue blockQueue = WorldManager.getInstance().getBlockchain().getQueue(); + if (blockQueue.size() > CONFIG.maxBlocksQueued()) { + logger.info("Blocks queue too big temporary postpone blocks request"); + return; + } sendGetBlocks(); } - }, 1000, secToAskForBlocks * 1000); - } - - private void updateGetBlocksTimer(int seconds) { - secToAskForBlocks = seconds; - getBlocksTimer.cancel(); - getBlocksTimer.purge(); - getBlocksTimer = new Timer(); - getBlocksTimer.scheduleAtFixedRate(new TimerTask() { - public void run() { - sendGetBlocks(); - } - }, 3000, secToAskForBlocks * 1000); + }, 1000, 300); } private void stopGetBlocksTimer() { @@ -312,4 +353,12 @@ public class EthHandler extends SimpleChannelInboundHandler { stopGetBlocksTimer(); stopGetTxTimer(); } + + + private enum SyncSatus{ + INIT, + HASH_RETREIVING, + BLOCK_RETREIVING, + SYNC_DONE; + } } \ No newline at end of file diff --git a/ethereumj-core/src/main/java/org/ethereum/net/eth/GetBlockHashesMessage.java b/ethereumj-core/src/main/java/org/ethereum/net/eth/GetBlockHashesMessage.java index d2b01f83..8f61a5b4 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/eth/GetBlockHashesMessage.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/eth/GetBlockHashesMessage.java @@ -40,7 +40,7 @@ public class GetBlockHashesMessage extends EthMessage { } private void parse() { - RLPList paramsList = (RLPList) RLP.decode2(encoded).get(0); + RLPList paramsList = (RLPList) RLP.decode2(encoded).get(1); this.bestHash = paramsList.get(1).getRLPData(); byte[] maxBlocksBytes = paramsList.get(2).getRLPData(); diff --git a/ethereumj-core/src/main/java/org/ethereum/net/eth/NewBlockMessage.java b/ethereumj-core/src/main/java/org/ethereum/net/eth/NewBlockMessage.java index 948230b6..97c8e837 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/eth/NewBlockMessage.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/eth/NewBlockMessage.java @@ -1,16 +1,11 @@ package org.ethereum.net.eth; import org.ethereum.core.Block; -import org.ethereum.net.eth.EthMessage; +import org.ethereum.core.BlockHeader; import org.ethereum.util.RLP; import org.ethereum.util.RLPItem; import org.ethereum.util.RLPList; -import java.util.ArrayList; -import java.util.List; - -import static org.ethereum.net.eth.EthMessageCodes.NEW_BLOCK; - /** * Wrapper around an Ethereum Blocks message on the network */ @@ -26,14 +21,18 @@ public class NewBlockMessage extends EthMessage { private void parse() { RLPList paramsList = (RLPList) RLP.decode2(encoded).get(0); - RLPItem blockItem = ((RLPItem) paramsList.get(0)); - block = new Block(blockItem.getRLPData()); - - difficulty = ((RLPItem) paramsList.get(1)).getRLPData(); + RLPList blockRLP = ((RLPList) paramsList.get(1)); + block = new Block(blockRLP.getRLPData()); + difficulty = paramsList.get(2).getRLPData(); parsed = true; } + public Block getBlock(){ + if (!parsed) parse(); + return block; + } + @Override public byte[] getEncoded() { return encoded; diff --git a/ethereumj-core/src/main/java/org/ethereum/net/eth/StatusMessage.java b/ethereumj-core/src/main/java/org/ethereum/net/eth/StatusMessage.java index 3e373717..e96c413c 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/eth/StatusMessage.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/eth/StatusMessage.java @@ -1,44 +1,120 @@ package org.ethereum.net.eth; -import org.ethereum.net.p2p.PongMessage; +import org.ethereum.util.ByteUtil; import org.ethereum.util.RLP; +import org.ethereum.util.RLPItem; +import org.ethereum.util.RLPList; +import org.spongycastle.util.encoders.Hex; + +import static org.ethereum.net.eth.EthMessageCodes.STATUS; + /** - * Wrapper around an Ethereum Ping message on the network + * Wrapper around an Ethereum Status message on the network * */ public class StatusMessage extends EthMessage { - public StatusMessage() { - encode(); + private byte protocolVersion; + private byte networkId; + + /** Total difficulty of the best chain as found in block header. */ + private byte[] totalDifficulty; + /** The hash of the best (i.e. highest TD) known block. */ + private byte[] bestHash; + /** The hash of the Genesis block */ + private byte[] genesisHash; + + public StatusMessage(byte[] encoded) { + super(encoded); } - public StatusMessage(byte[] payload) { - this.encoded = payload; + public StatusMessage(byte protocolVersion, byte networkId, + byte[] totalDifficulty, byte[] bestHash, byte[] genesisHash) { + this.protocolVersion = protocolVersion; + this.networkId = networkId; + this.totalDifficulty = totalDifficulty; + this.bestHash = bestHash; + this.genesisHash = genesisHash; + this.parsed = true; } + private void parse() { + RLPList paramsList = (RLPList) RLP.decode2(encoded).get(0); - public byte[] getEncoded() { - return this.encoded; - } + this.protocolVersion = ((RLPItem) paramsList.get(1)).getRLPData()[0]; + byte[] networkIdBytes = ((RLPItem) paramsList.get(2)).getRLPData(); + this.networkId = networkIdBytes == null ? 0 : networkIdBytes[0]; + this.totalDifficulty = ((RLPItem) paramsList.get(3)).getRLPData(); + this.bestHash = ((RLPItem) paramsList.get(4)).getRLPData(); + this.genesisHash = ((RLPItem) paramsList.get(5)).getRLPData(); + + parsed = true; + } private void encode() { - this.encoded = RLP.encodeList(new byte[] {EthMessageCodes.STATUS.asByte()} ); + byte[] command = RLP.encodeByte(STATUS.asByte()); + byte[] protocolVersion = RLP.encodeByte(this.protocolVersion); + byte[] networkId = RLP.encodeByte(this.networkId); + byte[] totalDifficulty = RLP.encodeElement(this.totalDifficulty); + byte[] bestHash = RLP.encodeElement(this.bestHash); + byte[] genesisHash = RLP.encodeElement(this.genesisHash); + + this.encoded = RLP.encodeList(command, protocolVersion, networkId, + totalDifficulty, bestHash, genesisHash); } + @Override + public byte[] getEncoded() { + if (encoded == null) encode(); + return encoded; + } - @Override - public Class getAnswerMessage() { - return PongMessage.class; - } + @Override + public Class getAnswerMessage() { + return null; + } + + public byte getProtocolVersion() { + if (!parsed) parse(); + return protocolVersion; + } + + public byte getNetworkId() { + if (!parsed) parse(); + return networkId; + } + + public byte[] getTotalDifficulty() { + if (!parsed) parse(); + return totalDifficulty; + } + + public byte[] getBestHash() { + if (!parsed) parse(); + return bestHash; + } + + public byte[] getGenesisHash() { + if (!parsed) parse(); + return genesisHash; + } @Override public EthMessageCodes getCommand(){ - return EthMessageCodes.STATUS; + return STATUS; } - @Override - public String toString() { - return "[" + getCommand().name() + "]"; - } -} \ No newline at end of file + + @Override + public String toString() { + if (!parsed) parse(); + return "[" + this.getCommand().name() + + " protocolVersion=" + this.protocolVersion + + " networkId=" + this.networkId + + " totalDifficulty=" + ByteUtil.toHexString(this.totalDifficulty) + + " bestHash=" + Hex.toHexString(this.bestHash) + + " genesisHash=" + Hex.toHexString(this.genesisHash) + + "]"; + } +} diff --git a/ethereumj-core/src/main/java/org/ethereum/net/p2p/P2pHandler.java b/ethereumj-core/src/main/java/org/ethereum/net/p2p/P2pHandler.java index 2d1d0476..39ee4df9 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/p2p/P2pHandler.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/p2p/P2pHandler.java @@ -86,14 +86,13 @@ public class P2pHandler extends SimpleChannelInboundHandler { public void channelRead0(final ChannelHandlerContext ctx, P2pMessage msg) throws InterruptedException { if (P2pMessageCodes.inRange(msg.getCommand().asByte())) - logger.info("P2PHandler invoke: {}", msg.getCommand()); + logger.info("P2PHandler invoke: [{}]", msg.getCommand()); switch (msg.getCommand()) { case HELLO: msgQueue.receivedMessage(msg); if (!peerDiscoveryMode) setHandshake((HelloMessage) msg, ctx); - sendUser(); break; case DISCONNECT: msgQueue.receivedMessage(msg); @@ -122,7 +121,7 @@ public class P2pHandler extends SimpleChannelInboundHandler { break; case USER: - processUser((UserMessage)msg, ctx); + processUser((UserMessage) msg); break; default: ctx.fireChannelRead(msg); @@ -131,12 +130,7 @@ public class P2pHandler extends SimpleChannelInboundHandler { } - public void processUser(UserMessage msg, ChannelHandlerContext ctx){ - - ChannelHandler handler = ctx.pipeline().get("eth"); - if (handler != null){ - ((EthHandler)handler).processUser(msg, ctx); - } + public void processUser(UserMessage msg){ } @Override @@ -161,18 +155,7 @@ public class P2pHandler extends SimpleChannelInboundHandler { msgQueue.sendMessage(msg); } - private void sendUser(){ - Blockchain blockChain= WorldManager.getInstance().getBlockchain(); - - byte protocolVersion = EthHandler.version, networkId = 0; - BigInteger totalDifficulty = blockChain.getTotalDifficulty(); - byte[] bestHash = blockChain.getLatestBlockHash(); - UserMessage msg = new UserMessage(protocolVersion, networkId, - ByteUtil.bigIntegerToBytes(totalDifficulty), bestHash, Blockchain.GENESIS_HASH); - msgQueue.sendMessage(msg); - } - private void setHandshake(HelloMessage msg, ChannelHandlerContext ctx) { if (msg.getP2PVersion() != HELLO_MESSAGE.getP2PVersion()) msgQueue.sendMessage(new DisconnectMessage(ReasonCode.INCOMPATIBLE_PROTOCOL)); @@ -203,7 +186,7 @@ public class P2pHandler extends SimpleChannelInboundHandler { public void adaptMessageIds(List capabilities) { - byte offset = 0x10; + byte offset = (byte) (P2pMessageCodes.USER.asByte() + 1); for (String capability : capabilities){ if (capability.equals("eth")){ diff --git a/ethereumj-core/src/main/java/org/ethereum/net/p2p/P2pMessageCodes.java b/ethereumj-core/src/main/java/org/ethereum/net/p2p/P2pMessageCodes.java index d214befa..3b176fc8 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/p2p/P2pMessageCodes.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/p2p/P2pMessageCodes.java @@ -48,7 +48,7 @@ public enum P2pMessageCodes { /** * */ - USER(0x10); + USER(0x0F); private int cmd; 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 4d1e4b58..f41d4ad2 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 @@ -38,7 +38,7 @@ public class ShhHandler extends SimpleChannelInboundHandler { public void channelRead0(final ChannelHandlerContext ctx, ShhMessage msg) throws InterruptedException { if (ShhMessageCodes.inRange(msg.getCommand().asByte())) - logger.info("ShhHandler invoke: {}", msg.getCommand()); + logger.info("ShhHandler invoke: [{}]", msg.getCommand()); switch (msg.getCommand()) { case STATUS: diff --git a/ethereumj-core/src/main/resources/log4j.properties b/ethereumj-core/src/main/resources/log4j.properties index e03e6a9b..c375ec56 100644 --- a/ethereumj-core/src/main/resources/log4j.properties +++ b/ethereumj-core/src/main/resources/log4j.properties @@ -21,22 +21,22 @@ log4j.appender.file.RollingPolicy=org.apache.log4j.rolling.TimeBasedRollingPolic log4j.appender.file.RollingPolicy.FileNamePattern=./logs/ethereum_%d{yyyy-MM-dd}_h%d{HH}.log # filter noisy classes -log4j.logger.block = ERROR -log4j.logger.blockqueue = ERROR -log4j.logger.wallet = ERROR +log4j.logger.block = ERROR +log4j.logger.blockqueue = TRACE +log4j.logger.wallet = ERROR log4j.logger.net = TRACE -log4j.logger.db = ERROR +log4j.logger.db = ERROR log4j.logger.peerdiscovery = ERROR log4j.logger.java.nio = ERROR log4j.logger.io.netty = ERROR -log4j.logger.wire = TRACE -log4j.logger.VM = ERROR -log4j.logger.main = ERROR -log4j.logger.trie = ERROR +log4j.logger.wire = ERROR +log4j.logger.VM = ERROR +log4j.logger.main = ERROR +log4j.logger.trie = ERROR log4j.logger.state = INFO log4j.logger.repository = INFO -log4j.logger.blockchain = INFO +log4j.logger.blockchain = TRACE log4j.logger.txs = ERROR -log4j.logger.ui = ERROR +log4j.logger.ui = ERROR log4j.logger.gas = ERROR diff --git a/ethereumj-core/src/test/java/org/ethereum/net/NewBlockMessageTest.java b/ethereumj-core/src/test/java/org/ethereum/net/NewBlockMessageTest.java new file mode 100644 index 00000000..40ebe1e8 --- /dev/null +++ b/ethereumj-core/src/test/java/org/ethereum/net/NewBlockMessageTest.java @@ -0,0 +1,38 @@ +package org.ethereum.net; + +import org.ethereum.core.Block; +import org.ethereum.net.eth.BlocksMessage; +import org.ethereum.net.eth.NewBlockMessage; +import org.junit.Ignore; +import org.junit.Test; +import org.spongycastle.util.encoders.Hex; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Files; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +public class NewBlockMessageTest { + + /* NEW_BLOCK */ + + @Test + public void test_1() { + + String blocksRaw = "f8c017f8b7f8b3a0d8faffbc4c4213d35db9007de41cece45d95db7fd6c0f129e158baa888c48eefa01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794baedba0480e1b882b606cd302d8c4f5701cabac7a0c7d4565fb7b3d98e54a0dec8b76f8c001a784a5689954ce0aedcc1bbe8d130958083063477825fc88609184e72a0008301e8488084543ffee680a00de0b9d4a0f0c23546d31f1f70db00d25cf6a7af79365b4e058e4a6a3b69527bc0c0850177ddbebe"; + + byte[] payload = Hex.decode(blocksRaw); + + NewBlockMessage newBlockMessage = new NewBlockMessage(payload); + newBlockMessage.toString(); + + + } + +} + diff --git a/ethereumj-studio/pom.xml b/ethereumj-studio/pom.xml index eea812d0..49d342a4 100644 --- a/ethereumj-studio/pom.xml +++ b/ethereumj-studio/pom.xml @@ -71,7 +71,7 @@ org.ethereum ethereumj - 0.6.1.20141014.0918 + 0.7.1 jar diff --git a/ethereumj-studio/src/main/resources/system.properties b/ethereumj-studio/src/main/resources/system.properties index 11747306..c6817e60 100644 --- a/ethereumj-studio/src/main/resources/system.properties +++ b/ethereumj-studio/src/main/resources/system.properties @@ -138,7 +138,7 @@ max.blocks.ask = 100 max.blocks.queued = 300 # project version auto copied during build phase -project.version = 0.6.1 +project.version = 0.7.1 # hello phrase will be included in # the hello message of the peer