Merge pull request #81 from nicksavers/master

Fix for consensus block 1501
This commit is contained in:
romanman 2014-08-17 13:10:10 +03:00
commit 85872e88b5
3 changed files with 29 additions and 33 deletions

View File

@ -171,7 +171,7 @@ public class Blockchain {
stateLogger.debug("apply block: [ {} ] tx: [ {} ] ", block.getNumber(), i); stateLogger.debug("apply block: [ {} ] tx: [ {} ] ", block.getNumber(), i);
totalGasUsed += applyTransaction(block, txr.getTransaction()); totalGasUsed += applyTransaction(block, txr.getTransaction());
if(!Arrays.equals(this.repository.getWorldState().getRootHash(), txr.getPostTxState())) if(!Arrays.equals(this.repository.getWorldState().getRootHash(), txr.getPostTxState()))
logger.warn("STATE CONFLICT {}..: {}", Hex.toHexString(txr.getTransaction().getHash()).substring(0, 8), logger.warn("TX: STATE CONFLICT {}..: {}", Hex.toHexString(txr.getTransaction().getHash()).substring(0, 8),
Hex.toHexString(this.repository.getWorldState().getRootHash())); Hex.toHexString(this.repository.getWorldState().getRootHash()));
if(block.getNumber() >= CONFIG.traceStartBlock()) if(block.getNumber() >= CONFIG.traceStartBlock())
repository.dumpState(block, totalGasUsed, i++, txr.getTransaction().getHash()); repository.dumpState(block, totalGasUsed, i++, txr.getTransaction().getHash());
@ -197,8 +197,7 @@ public class Blockchain {
String blockStateRootHash = Hex.toHexString(block.getStateRoot()); String blockStateRootHash = Hex.toHexString(block.getStateRoot());
String worldStateRootHash = Hex.toHexString(WorldManager.getInstance().getRepository().getWorldState().getRootHash()); String worldStateRootHash = Hex.toHexString(WorldManager.getInstance().getRepository().getWorldState().getRootHash());
if(!blockStateRootHash.equals(worldStateRootHash)){ if(!blockStateRootHash.equals(worldStateRootHash)){
logger.error("ERROR: STATE CONFLICT! block: {} worldstate {} mismatch", block.getNumber(), worldStateRootHash); logger.warn("BLOCK: STATE CONFLICT! block: {} worldstate {} mismatch", block.getNumber(), worldStateRootHash);
// Last conflict on block 1501 -> worldstate 27920c6c7acd42c8a7ac8a835d4c0e0a45590deb094d6b72a8493fac5d7a3654
repository.close(); repository.close();
System.exit(-1); // Don't add block System.exit(-1); // Don't add block
} }
@ -309,7 +308,7 @@ public class Blockchain {
} }
// 4. THE SIMPLE VALUE/BALANCE CHANGE // 3. THE SIMPLE VALUE/BALANCE CHANGE
if (tx.getValue() != null) { if (tx.getValue() != null) {
BigInteger senderBalance = senderAccount.getBalance(); BigInteger senderBalance = senderAccount.getBalance();
@ -329,7 +328,7 @@ public class Blockchain {
} }
} }
// 3. START TRACKING FOR REVERT CHANGES OPTION !!! // 4. START TRACKING FOR REVERT CHANGES OPTION !!!
Repository trackRepository = repository.getTrack(); Repository trackRepository = repository.getTrack();
trackRepository.startTracking(); trackRepository.startTracking();
long gasUsed = 0; long gasUsed = 0;

View File

@ -84,11 +84,8 @@ public class Cache {
} }
this.isDirty = false; this.isDirty = false;
// If the nodes grows beyond the 200 entries we simple empty it // TODO come up with a way to clean up this.nodes
// FIXME come up with something better // from memory without breaking consensus
if (this.nodes.size() > 200) {
this.nodes = new HashMap<>();
}
} }
public void undo() { public void undo() {

View File

@ -99,7 +99,7 @@ coinbase.secret = monkey
# posible values [true/false] # posible values [true/false]
dump.full = false dump.full = false
dump.dir = dmp dump.dir = dmp
dump.block = 1501 dump.block = -1
# clean the dump dir each start # clean the dump dir each start
dump.clean.on.restart = true dump.clean.on.restart = true