From add64b08d7d2a9122013b672e4438ab7f3fef0c8 Mon Sep 17 00:00:00 2001 From: Alexandra Date: Tue, 27 Mar 2018 15:50:15 -0400 Subject: [PATCH] removing the use of JournalPruneDataSource until tested with pruning enabled --- .../aion/zero/impl/db/AionRepositoryImpl.java | 21 +++++++++++-------- .../zero/impl/BlockchainDataRecoveryTest.java | 8 +++---- .../org/aion/mcf/db/AbstractRepository.java | 8 ++++--- .../src/org/aion/mcf/db/DetailsDataStore.java | 14 ++++++------- 4 files changed, 28 insertions(+), 23 deletions(-) diff --git a/modAionImpl/src/org/aion/zero/impl/db/AionRepositoryImpl.java b/modAionImpl/src/org/aion/zero/impl/db/AionRepositoryImpl.java index bed88211a9..e73edaba2f 100644 --- a/modAionImpl/src/org/aion/zero/impl/db/AionRepositoryImpl.java +++ b/modAionImpl/src/org/aion/zero/impl/db/AionRepositoryImpl.java @@ -19,7 +19,7 @@ * * Contributors: * Aion foundation. - * + * ******************************************************************************/ package org.aion.zero.impl.db; @@ -125,7 +125,7 @@ public TransactionStore getTransacti } private Trie createStateTrie() { - return new SecureTrie(stateDSPrune).withPruningEnabled(pruneBlockCount >= 0); + return new SecureTrie(stateDatabase).withPruningEnabled(pruneBlockCount >= 0); } @Override @@ -444,14 +444,17 @@ public synchronized void commitBlock(A0BlockHeader blockHeader) { worldState.sync(); detailsDS.syncLargeStorage(); - if (pruneBlockCount >= 0) { + // temporarily removed since never used + /* if (pruneBlockCount >= 0) { stateDSPrune.storeBlockChanges(blockHeader); detailsDS.getStorageDSPrune().storeBlockChanges(blockHeader); pruneBlocks(blockHeader); - } + } */ } - private void pruneBlocks(A0BlockHeader curBlock) { + // TODO-AR: reenable state pruning + // temporarily removed since never used + /* private void pruneBlocks(A0BlockHeader curBlock) { if (curBlock.getNumber() > bestBlockNumber) { // pruning only on // increasing blocks long pruneBlockNumber = curBlock.getNumber() - pruneBlockCount; @@ -459,13 +462,13 @@ private void pruneBlocks(A0BlockHeader curBlock) { byte[] pruneBlockHash = blockStore.getBlockHashByNumber(pruneBlockNumber); if (pruneBlockHash != null) { A0BlockHeader header = blockStore.getBlockByHash(pruneBlockHash).getHeader(); - stateDSPrune.prune(header); - detailsDS.getStorageDSPrune().prune(header); + // stateDSPrune.prune(header); + // detailsDS.getStorageDSPrune().prune(header); } } } bestBlockNumber = curBlock.getNumber(); - } + } */ public Trie getWorldState() { return worldState; @@ -478,7 +481,7 @@ public synchronized IRepository getSnapshotTo(byte[] root) { repo.blockStore = blockStore; repo.cfg = cfg; repo.stateDatabase = this.stateDatabase; - repo.stateDSPrune = this.stateDSPrune; + // repo.stateDSPrune = this.stateDSPrune; repo.pruneBlockCount = this.pruneBlockCount; repo.detailsDS = this.detailsDS; repo.isSnapshot = true; diff --git a/modAionImpl/test/org/aion/zero/impl/BlockchainDataRecoveryTest.java b/modAionImpl/test/org/aion/zero/impl/BlockchainDataRecoveryTest.java index 23325b75f4..610d8cb71d 100644 --- a/modAionImpl/test/org/aion/zero/impl/BlockchainDataRecoveryTest.java +++ b/modAionImpl/test/org/aion/zero/impl/BlockchainDataRecoveryTest.java @@ -36,7 +36,7 @@ import org.aion.base.db.IByteArrayKeyValueDatabase; import org.aion.mcf.core.ImportResult; -import org.aion.mcf.trie.JournalPruneDataSource; +// import org.aion.mcf.trie.JournalPruneDataSource; import org.aion.mcf.trie.TrieImpl; import org.aion.zero.impl.db.AionRepositoryImpl; import org.aion.zero.impl.types.AionBlock; @@ -89,7 +89,7 @@ public void testRecoverWorldStateWithPartialWorldState() { // delete some world state root entries from the database TrieImpl trie = (TrieImpl) ((AionRepositoryImpl) chain.getRepository()).getWorldState(); - IByteArrayKeyValueDatabase database = ((JournalPruneDataSource) trie.getCache().getDb()).getSrc(); + IByteArrayKeyValueDatabase database = (IByteArrayKeyValueDatabase) trie.getCache().getDb(); for (byte[] key : statesToDelete) { database.delete(key); @@ -140,7 +140,7 @@ public void testRecoverWorldStateWithStartFromGenesis() { // delete some world state root entries from the database TrieImpl trie = (TrieImpl) ((AionRepositoryImpl) chain.getRepository()).getWorldState(); - IByteArrayKeyValueDatabase database = ((JournalPruneDataSource) trie.getCache().getDb()).getSrc(); + IByteArrayKeyValueDatabase database = (IByteArrayKeyValueDatabase) trie.getCache().getDb(); for (byte[] key : statesToDelete) { database.delete(key); @@ -189,7 +189,7 @@ public void testRecoverWorldStateWithoutGenesis() { // delete some world state root entries from the database TrieImpl trie = (TrieImpl) ((AionRepositoryImpl) chain.getRepository()).getWorldState(); - IByteArrayKeyValueDatabase database = ((JournalPruneDataSource) trie.getCache().getDb()).getSrc(); + IByteArrayKeyValueDatabase database = (IByteArrayKeyValueDatabase) trie.getCache().getDb(); List statesToDelete = new ArrayList<>(); statesToDelete.addAll(database.keys()); diff --git a/modMcf/src/org/aion/mcf/db/AbstractRepository.java b/modMcf/src/org/aion/mcf/db/AbstractRepository.java index aa3c181b02..616af584d7 100644 --- a/modMcf/src/org/aion/mcf/db/AbstractRepository.java +++ b/modMcf/src/org/aion/mcf/db/AbstractRepository.java @@ -33,7 +33,7 @@ //import org.aion.dbmgr.exception.DriverManagerNoSuitableDriverRegisteredException; import org.aion.log.AionLoggerFactory; import org.aion.log.LogEnum; -import org.aion.mcf.trie.JournalPruneDataSource; +// import org.aion.mcf.trie.JournalPruneDataSource; import org.aion.mcf.trie.Trie; import org.aion.mcf.types.AbstractBlock; import org.aion.mcf.vm.types.DataWord; @@ -84,7 +84,7 @@ public abstract class AbstractRepository databaseGroup; - protected JournalPruneDataSource stateDSPrune; + // protected JournalPruneDataSource stateDSPrune; protected DetailsDataStore detailsDS; // Read Write Lock @@ -200,7 +200,9 @@ protected void initializeDatabasesAndCaches() throws Exception { // Setup the cache for transaction data source. this.detailsDS = new DetailsDataStore<>(detailsDatabase, storageDatabase, this.cfg); - stateDSPrune = new JournalPruneDataSource<>(stateDatabase); + // disabling use of JournalPruneDataSource until functionality properly tested + // TODO-AR: enable pruning with the JournalPruneDataSource + // stateDSPrune = new JournalPruneDataSource<>(stateDatabase); pruneBlockCount = pruneEnabled ? this.cfg.getPrune() : -1; } catch (Exception e) { // Setting up databases and caches went wrong. throw e; diff --git a/modMcf/src/org/aion/mcf/db/DetailsDataStore.java b/modMcf/src/org/aion/mcf/db/DetailsDataStore.java index e89f197c4a..0c7546976d 100644 --- a/modMcf/src/org/aion/mcf/db/DetailsDataStore.java +++ b/modMcf/src/org/aion/mcf/db/DetailsDataStore.java @@ -37,7 +37,7 @@ import org.aion.base.type.ITransaction; import org.aion.base.util.ByteArrayWrapper; import org.aion.mcf.vm.types.DataWord; -import org.aion.mcf.trie.JournalPruneDataSource; +// import org.aion.mcf.trie.JournalPruneDataSource; import org.aion.mcf.types.AbstractBlock; /** @@ -45,7 +45,7 @@ */ public class DetailsDataStore, BH extends IBlockHeader> { - private JournalPruneDataSource storageDSPrune; + // private JournalPruneDataSource storageDSPrune; private IRepositoryConfig repoConfig; private IByteArrayKeyValueDatabase detailsSrc; @@ -66,7 +66,7 @@ public DetailsDataStore withDb(IByteArrayKeyValueDatabase detailsSrc, IByteArrayKeyValueDatabase storageSrc) { this.detailsSrc = detailsSrc; this.storageSrc = storageSrc; - this.storageDSPrune = new JournalPruneDataSource<>(storageSrc); + // this.storageDSPrune = new JournalPruneDataSource<>(storageSrc); return this; } @@ -95,7 +95,7 @@ public synchronized IContractDetails get(byte[] key) { // Found something from cache or database, return it by decoding it. IContractDetails detailsImpl = repoConfig.contractDetailsImpl(); - detailsImpl.setDataSource(storageDSPrune); + detailsImpl.setDataSource(storageSrc); detailsImpl.decode(rawDetails.get()); // We can safely get as we checked // if it is present. @@ -164,7 +164,7 @@ public void syncLargeStorage() { // Decode the details. IContractDetails detailsImpl = repoConfig.contractDetailsImpl(); - detailsImpl.setDataSource(storageDSPrune); + detailsImpl.setDataSource(storageSrc); detailsImpl.decode(rawDetails.get()); // We can safely get as we // checked if it is present. @@ -173,9 +173,9 @@ public void syncLargeStorage() { } } - public JournalPruneDataSource getStorageDSPrune() { + /* public JournalPruneDataSource getStorageDSPrune() { return storageDSPrune; - } + } */ public synchronized Set keys() { // TODO - @yao do we wanted a sorted set?