From 237d538f52e53b94760d5003e1b9b90e26d322da Mon Sep 17 00:00:00 2001 From: nicksavers Date: Wed, 6 Aug 2014 01:08:04 +0200 Subject: [PATCH] Add logging for Program and VM --- .../src/main/java/org/ethereum/db/ContractDetails.java | 4 ++-- .../src/main/java/org/ethereum/json/JSONHelper.java | 4 ++-- .../src/main/java/org/ethereum/trie/TrieFacade.java | 2 -- ethereumj-core/src/main/java/org/ethereum/vm/Program.java | 5 +++-- .../src/main/java/org/ethereum/vm/ProgramInvokeFactory.java | 2 +- ethereumj-core/src/main/java/org/ethereum/vm/VM.java | 4 ++++ ethereumj-core/src/main/resources/system.properties | 6 +++--- 7 files changed, 15 insertions(+), 12 deletions(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/db/ContractDetails.java b/ethereumj-core/src/main/java/org/ethereum/db/ContractDetails.java index 31334881..d7c9d1dd 100644 --- a/ethereumj-core/src/main/java/org/ethereum/db/ContractDetails.java +++ b/ethereumj-core/src/main/java/org/ethereum/db/ContractDetails.java @@ -42,7 +42,7 @@ public class ContractDetails { public void put(DataWord key, DataWord value) { - if (value.equals(DataWord.ZERO)){ + if (value.equals(DataWord.ZERO)) { storageTrie.delete(key.getData()); int index = storageKeys.indexOf(key); @@ -50,7 +50,7 @@ public class ContractDetails { storageKeys.remove(index); storageValues.remove(index); } - } else{ + } else { storageTrie.update(key.getData(), RLP.encodeElement(value.getNoLeadZeroesData())); int index = storageKeys.indexOf(key); 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 bb4be525..e6cd6114 100644 --- a/ethereumj-core/src/main/java/org/ethereum/json/JSONHelper.java +++ b/ethereumj-core/src/main/java/org/ethereum/json/JSONHelper.java @@ -39,8 +39,8 @@ public class JSONHelper { JSONArray orderFields = new JSONArray(); orderFields.add("address: " + Hex.toHexString(address)); - orderFields.add(" nonce: " + (nonce == null ? "00" : Hex.toHexString(nonce))); - orderFields.add(" balance: " + (balance == null ? "00" : Hex.toHexString(balance).toString())); + orderFields.add(" nonce: " + (nonce == null ? "00" : new BigInteger(1, nonce).toString())); + orderFields.add(" balance: " + (balance == null ? "00" : new BigInteger(1, balance).toString())); orderFields.add(" stateRoot: " + (stateRoot == null ? "" : Hex.toHexString(stateRoot))); orderFields.add(" codeHash: " + (codeHash == null ? "" : Hex.toHexString(codeHash))); orderFields.add(" code: " + (code == null ? "" : Hex.toHexString(code))); diff --git a/ethereumj-core/src/main/java/org/ethereum/trie/TrieFacade.java b/ethereumj-core/src/main/java/org/ethereum/trie/TrieFacade.java index 4f4cc6dd..ef6b51eb 100644 --- a/ethereumj-core/src/main/java/org/ethereum/trie/TrieFacade.java +++ b/ethereumj-core/src/main/java/org/ethereum/trie/TrieFacade.java @@ -11,6 +11,4 @@ public interface TrieFacade { public void update(byte[] key, byte[] value); public byte[] get(byte[] key); public void delete(byte[] key); - - public void sync(); } diff --git a/ethereumj-core/src/main/java/org/ethereum/vm/Program.java b/ethereumj-core/src/main/java/org/ethereum/vm/Program.java index e6e901a9..ec10d613 100644 --- a/ethereumj-core/src/main/java/org/ethereum/vm/Program.java +++ b/ethereumj-core/src/main/java/org/ethereum/vm/Program.java @@ -221,8 +221,9 @@ public class Program { DataWord balance = getBalance(this.getOwnerAddress()); // 1) pass full endowment to the obtainer if (logger.isInfoEnabled()) - logger.info("Transfer to: [ {} ] heritage: [ {} ]", Hex.toHexString(obtainer.getLast20Bytes()) - , balance.longValue()); + logger.info("Transfer to: [ {} ] heritage: [ {} ]", + Hex.toHexString(obtainer.getLast20Bytes()), + balance.longValue()); this.result.getRepository().addBalance(obtainer.getLast20Bytes(), balance.value()); this.result.getRepository().addBalance(this.getOwnerAddress().getLast20Bytes(), balance.value().negate()); diff --git a/ethereumj-core/src/main/java/org/ethereum/vm/ProgramInvokeFactory.java b/ethereumj-core/src/main/java/org/ethereum/vm/ProgramInvokeFactory.java index 37772475..3c9cb79d 100644 --- a/ethereumj-core/src/main/java/org/ethereum/vm/ProgramInvokeFactory.java +++ b/ethereumj-core/src/main/java/org/ethereum/vm/ProgramInvokeFactory.java @@ -171,7 +171,7 @@ public class ProgramInvokeFactory { Hex.toHexString(coinbase.getLast20Bytes()), timestamp.longValue(), number.longValue(), - difficulty.longValue(), + Hex.toHexString(difficulty.getNoLeadZeroesData()), gasLimit.longValue()); } diff --git a/ethereumj-core/src/main/java/org/ethereum/vm/VM.java b/ethereumj-core/src/main/java/org/ethereum/vm/VM.java index db7e3d1a..77d3c6cc 100644 --- a/ethereumj-core/src/main/java/org/ethereum/vm/VM.java +++ b/ethereumj-core/src/main/java/org/ethereum/vm/VM.java @@ -744,6 +744,10 @@ public class VM { case SUICIDE:{ DataWord address = program.stackPop(); program.suicide(address); + + if (logger.isInfoEnabled()) + hint = "address: " + Hex.toHexString(program.getOwnerAddress().getLast20Bytes()); + program.stop(); } break; default:{ diff --git a/ethereumj-core/src/main/resources/system.properties b/ethereumj-core/src/main/resources/system.properties index 262f1f1b..663a84e3 100644 --- a/ethereumj-core/src/main/resources/system.properties +++ b/ethereumj-core/src/main/resources/system.properties @@ -81,7 +81,7 @@ samples.dir = samples # the existing database will be # destroyed and all the data will be # downloaded from peers again -database.reset = false +database.reset = true # place to save physical storage files database.dir = database @@ -96,7 +96,7 @@ coinbase.secret = monkey # in JSON form to [dump.dir] # if [dump.full] = true # posible values [true/false] -dump.full = false +dump.full = true dump.dir = dmp # clean the dump dir each start @@ -105,7 +105,7 @@ dump.clean.on.restart = true # make changes to tracing options # starting from certain block # -1 don't make any tracing changes -trace.startblock = -1 +trace.startblock = 1500 # invoke vm program on # message received,