Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling JournalPruneDataSource #478

Merged
merged 10 commits into from
Jun 1, 2018
Prev Previous commit
Next Next commit
disabled pruning when pruneBlockCount is negative; set a lower bound …
…for the pruneBlockCount variable
  • Loading branch information
AlexandraRoatis committed May 11, 2018

Verified

This commit was signed with the committer’s verified signature.
snyk-bot Snyk bot
commit 93771380b659c3e54a41e05a6b1f423a8a95b55d
11 changes: 8 additions & 3 deletions modAionImpl/src/org/aion/zero/impl/db/AionRepositoryImpl.java
Original file line number Diff line number Diff line change
@@ -76,7 +76,12 @@ private static class AionRepositoryImplHolder {
// repository singleton instance
private final static AionRepositoryImpl inst = new AionRepositoryImpl(
new RepositoryConfig(new File(config.getBasePath(), config.getDb().getPath()).getAbsolutePath(),
config.getDb().getPrune(),
config.getDb().getPrune() > 0 ?
// if the value is smaller than backward step
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pruning value should dictate parameters for our sync. So if we set a value of 16 as our pruning parameter, sync should respect that value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the interaction between pruning and sync is tuned in #498

// there is the risk of importing state-less blocks after reboot
(128 > config.getDb().getPrune() ? 128 : config.getDb().getPrune()) :
// negative value => pruning disabled
config.getDb().getPrune(),
ContractDetailsAion.getInstance(),
config.getDb()));
}
@@ -115,7 +120,7 @@ public TransactionStore<AionTransaction, AionTxReceipt, AionTxInfo> getTransacti
}

private Trie createStateTrie() {
return new SecureTrie(stateDSPrune).withPruningEnabled(pruneBlockCount >= 0);
return new SecureTrie(stateDSPrune).withPruningEnabled(pruneBlockCount > 0);
}

@Override
@@ -501,7 +506,7 @@ public void commitBlock(A0BlockHeader blockHeader) {
worldState.sync();
detailsDS.syncLargeStorage();

if (pruneBlockCount >= 0) {
if (pruneBlockCount > 0) {
stateDSPrune.storeBlockChanges(blockHeader);
detailsDS.getStorageDSPrune().storeBlockChanges(blockHeader);
pruneBlocks(blockHeader);
6 changes: 4 additions & 2 deletions modMcf/src/org/aion/mcf/db/AbstractRepository.java
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@
import org.aion.mcf.config.CfgDb;
import org.aion.mcf.core.AccountState;
import org.aion.mcf.db.exception.InvalidFilePathException;
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;
@@ -48,7 +49,6 @@
import static org.aion.db.impl.DatabaseFactory.Props;

//import org.aion.dbmgr.exception.DriverManagerNoSuitableDriverRegisteredException;
import org.aion.mcf.trie.JournalPruneDataSource;

/**
* Abstract Repository class.
@@ -243,8 +243,10 @@ protected void initializeDatabasesAndCaches() throws Exception {
this.detailsDS = new DetailsDataStore<>(detailsDatabase, storageDatabase, this.cfg);
stateDSPrune = new JournalPruneDataSource<>(stateDatabase);
pruneBlockCount = pruneEnabled ? this.cfg.getPrune() : -1;
if (pruneEnabled) {
if (pruneEnabled && pruneBlockCount > 0) {
LOGGEN.info("Pruning block count set to {}.", pruneBlockCount);
} else {
stateDSPrune.setPruneEnabled(false);
}
} catch (Exception e) { // Setting up databases and caches went wrong.
throw e;