diff --git a/common/src/main/java/org/tron/common/config/DbBackupConfig.java b/common/src/main/java/org/tron/common/config/DbBackupConfig.java deleted file mode 100644 index 694ae7c3155..00000000000 --- a/common/src/main/java/org/tron/common/config/DbBackupConfig.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.tron.common.config; - -import java.io.File; -import lombok.Getter; -import lombok.Setter; -import lombok.extern.slf4j.Slf4j; -import org.tron.common.utils.FileUtil; - -@Slf4j -public class DbBackupConfig { - - private static volatile DbBackupConfig instance; - @Getter - @Setter - private String propPath; - @Getter - @Setter - private String bak1path; - @Getter - @Setter - private String bak2path; - @Setter - @Getter - private int frequency; - @Getter - @Setter - private boolean enable = false; - - // singleton - public static DbBackupConfig getInstance() { - if (instance == null) { - synchronized (DbBackupConfig.class) { - if (instance == null) { - instance = new DbBackupConfig(); - } - } - } - return instance; - } - - public DbBackupConfig initArgs(boolean enable, String propPath, String bak1path, String bak2path, - int frequency) { - setEnable(enable); - if (isEnable()) { - if (!bak1path.endsWith(File.separator)) { - bak1path = bak1path + File.separator; - } - - if (!bak2path.endsWith(File.separator)) { - bak2path = bak2path + File.separator; - } - - if (!FileUtil.createFileIfNotExists(propPath)) { - throw new RuntimeException("failure to create file:" + propPath); - } - - if (!FileUtil.createDirIfNotExists(bak1path)) { - throw new RuntimeException("failure to mkdir: " + bak1path); - } - - if (!FileUtil.createDirIfNotExists(bak2path)) { - throw new RuntimeException("failure to mkdir: " + bak2path); - } - - if (bak1path.equals(bak2path)) { - throw new RuntimeException("bak1path and bak2path must be different."); - } - - if (frequency <= 0) { - throw new IllegalArgumentException("frequency must be positive number."); - } - - setPropPath(propPath); - setBak1path(bak1path); - setBak2path(bak2path); - setFrequency(frequency); - logger.info( - "success to enable the db backup plugin. bak1path:{}, bak2path:{}, " - + "backup once every {} blocks handled", - bak1path, bak2path, frequency); - } - - return this; - } -} \ No newline at end of file diff --git a/common/src/main/java/org/tron/common/parameter/CommonParameter.java b/common/src/main/java/org/tron/common/parameter/CommonParameter.java index 39278872f5e..eaf56bf48e8 100644 --- a/common/src/main/java/org/tron/common/parameter/CommonParameter.java +++ b/common/src/main/java/org/tron/common/parameter/CommonParameter.java @@ -9,7 +9,6 @@ import lombok.Setter; import org.slf4j.bridge.SLF4JBridgeHandler; import org.tron.common.args.GenesisBlock; -import org.tron.common.config.DbBackupConfig; import org.tron.common.cron.CronExpression; import org.tron.common.logsfilter.EventPluginConfig; import org.tron.common.logsfilter.FilterQuery; @@ -425,8 +424,6 @@ public class CommonParameter { @Setter public double rateLimiterDisconnect; // clearParam: 1.0 @Getter - public DbBackupConfig dbBackupConfig; - @Getter public RocksDbSettings rocksDBCustomSettings; @Getter public GenesisBlock genesisBlock; diff --git a/common/src/main/java/org/tron/core/config/args/StorageConfig.java b/common/src/main/java/org/tron/core/config/args/StorageConfig.java index 2517f4d10d7..3d7046ebae2 100644 --- a/common/src/main/java/org/tron/core/config/args/StorageConfig.java +++ b/common/src/main/java/org/tron/core/config/args/StorageConfig.java @@ -25,7 +25,6 @@ public class StorageConfig { private TransHistoryConfig transHistory = new TransHistoryConfig(); private boolean needToUpdateAsset = true; private DbSettingsConfig dbSettings = new DbSettingsConfig(); - private BackupConfig backup = new BackupConfig(); private BalanceConfig balance = new BalanceConfig(); private CheckpointConfig checkpoint = new CheckpointConfig(); private SnapshotConfig snapshot = new SnapshotConfig(); @@ -129,16 +128,6 @@ void postProcess() { } } - @Getter - @Setter - public static class BackupConfig { - private boolean enable = false; - private String propPath = "prop.properties"; - private String bak1path = "bak1/database/"; - private String bak2path = "bak2/database/"; - private int frequency = 10000; - } - @Getter @Setter public static class BalanceConfig { diff --git a/common/src/main/resources/reference.conf b/common/src/main/resources/reference.conf index 67343b9b75a..7f88719d7f8 100644 --- a/common/src/main/resources/reference.conf +++ b/common/src/main/resources/reference.conf @@ -120,15 +120,6 @@ storage { # Number of blocks flushed to db in each batch during node syncing. snapshot.maxFlushCount = 1 - # Database backup settings (RocksDB only) - backup = { - enable = false - propPath = "prop.properties" - bak1path = "bak1/database/" - bak2path = "bak2/database/" - frequency = 10000 - } - # Data root setting, for check data, currently only reward-vi is used. # merkleRoot = { # reward-vi = 9debcb9924055500aaae98cdee10501c5c39d4daa75800a996f4bdda73dbccd8 // main-net diff --git a/common/src/test/java/org/tron/core/config/args/StorageConfigTest.java b/common/src/test/java/org/tron/core/config/args/StorageConfigTest.java index 5a679be89e5..ecb956e406a 100644 --- a/common/src/test/java/org/tron/core/config/args/StorageConfigTest.java +++ b/common/src/test/java/org/tron/core/config/args/StorageConfigTest.java @@ -28,8 +28,6 @@ public void testDefaults() { assertEquals("database", sc.getDb().getDirectory()); assertEquals("index", sc.getIndex().getDirectory()); assertTrue(sc.isNeedToUpdateAsset()); - assertFalse(sc.getBackup().isEnable()); - assertEquals(10000, sc.getBackup().getFrequency()); assertEquals(7, sc.getDbSettings().getLevelNumber()); assertEquals(5000, sc.getDbSettings().getMaxOpenFiles()); } @@ -44,8 +42,6 @@ public void testFromConfig() { assertEquals("ROCKSDB", sc.getDb().getEngine()); assertTrue(sc.getDb().isSync()); assertEquals("mydb", sc.getDb().getDirectory()); - assertTrue(sc.getBackup().isEnable()); - assertEquals(5000, sc.getBackup().getFrequency()); assertEquals(5, sc.getDbSettings().getLevelNumber()); assertEquals(3000, sc.getDbSettings().getMaxOpenFiles()); } diff --git a/framework/Daily_Build_Report b/framework/Daily_Build_Report deleted file mode 100644 index 49e63dbdc5f..00000000000 --- a/framework/Daily_Build_Report +++ /dev/null @@ -1 +0,0 @@ -3.Stest report: \ No newline at end of file diff --git a/framework/build.gradle b/framework/build.gradle index 7b3e6ddb968..fd59d3cc4e7 100644 --- a/framework/build.gradle +++ b/framework/build.gradle @@ -114,7 +114,6 @@ def configureTestTask = { Task t -> } if (isWindows()) { t.exclude '**/ShieldedTransferActuatorTest.class' - t.exclude '**/BackupDbUtilTest.class' t.exclude '**/ManagerTest.class' t.exclude 'org/tron/core/zksnark/**' t.exclude 'org/tron/common/runtime/vm/PrecompiledContractsVerifyProofTest.class' @@ -161,7 +160,6 @@ tasks.register('testWithRocksDb', Test) { include 'org/tron/core/config/args/ArgsTest.class' include 'org/tron/core/db/DBIteratorTest.class' include 'org/tron/core/db/TronDatabaseTest.class' - include 'org/tron/core/db/backup/BackupDbUtilTest.class' include 'org/tron/core/db2/ChainbaseTest.class' exclude '**/LevelDbDataSourceImplTest.class' } diff --git a/framework/prop.properties b/framework/prop.properties deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/framework/src/main/java/org/tron/core/config/DefaultConfig.java b/framework/src/main/java/org/tron/core/config/DefaultConfig.java index 9bce903d411..06d93682342 100755 --- a/framework/src/main/java/org/tron/core/config/DefaultConfig.java +++ b/framework/src/main/java/org/tron/core/config/DefaultConfig.java @@ -5,14 +5,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.tron.common.utils.StorageUtils; import org.tron.core.config.args.Args; import org.tron.core.db.RevokingDatabase; -import org.tron.core.db.backup.BackupRocksDBAspect; -import org.tron.core.db.backup.NeedBeanCondition; import org.tron.core.db2.core.SnapshotManager; import org.tron.core.services.interfaceOnPBFT.RpcApiServiceOnPBFT; import org.tron.core.services.interfaceOnPBFT.http.PBFT.HttpApiOnPBFTService; @@ -88,9 +85,4 @@ public HttpApiOnPBFTService getHttpApiOnPBFTService() { return null; } - @Bean - @Conditional(NeedBeanCondition.class) - public BackupRocksDBAspect backupRocksDBAspect() { - return new BackupRocksDBAspect(); - } } diff --git a/framework/src/main/java/org/tron/core/config/args/Args.java b/framework/src/main/java/org/tron/core/config/args/Args.java index f84a3d1646c..12cb9b35188 100644 --- a/framework/src/main/java/org/tron/core/config/args/Args.java +++ b/framework/src/main/java/org/tron/core/config/args/Args.java @@ -39,7 +39,6 @@ import org.tron.common.args.Account; import org.tron.common.args.GenesisBlock; import org.tron.common.args.Witness; -import org.tron.common.config.DbBackupConfig; import org.tron.common.cron.CronExpression; import org.tron.common.logsfilter.EventPluginConfig; import org.tron.common.logsfilter.FilterQuery; @@ -225,12 +224,6 @@ private static void applyStorageConfig(StorageConfig sc) { PARAMETER.storage.setTxCacheInitOptimization(sc.getTxCache().isInitOptimization()); PARAMETER.storage.setMaxFlushCount(sc.getSnapshot().getMaxFlushCount()); - // backup - StorageConfig.BackupConfig backup = sc.getBackup(); - PARAMETER.dbBackupConfig = DbBackupConfig.getInstance() - .initArgs(backup.isEnable(), backup.getPropPath(), - backup.getBak1path(), backup.getBak2path(), backup.getFrequency()); - // RocksDB settings StorageConfig.DbSettingsConfig dbs = sc.getDbSettings(); PARAMETER.rocksDBCustomSettings = RocksDbSettings diff --git a/framework/src/main/java/org/tron/core/db/backup/BackupDbUtil.java b/framework/src/main/java/org/tron/core/db/backup/BackupDbUtil.java deleted file mode 100644 index ecaeb19d004..00000000000 --- a/framework/src/main/java/org/tron/core/db/backup/BackupDbUtil.java +++ /dev/null @@ -1,176 +0,0 @@ -package org.tron.core.db.backup; - -import java.util.List; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; -import org.rocksdb.RocksDBException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.tron.common.parameter.CommonParameter; -import org.tron.common.utils.PropUtil; -import org.tron.core.capsule.BlockCapsule; -import org.tron.core.config.args.Args; -import org.tron.core.db.RevokingDatabase; -import org.tron.core.db2.core.Chainbase; -import org.tron.core.db2.core.SnapshotManager; -import org.tron.core.db2.core.SnapshotRoot; - -@Slf4j(topic = "DB") -@Component -public class BackupDbUtil { - - @Getter - private static final String DB_BACKUP_STATE = "DB"; - private static final int DB_BACKUP_INDEX1 = 1; - private static final int DB_BACKUP_INDEX2 = 2; - - @Getter - private static final int DB_BACKUP_STATE_DEFAULT = 11; - @Getter - @Autowired - private RevokingDatabase db; - private CommonParameter parameter = Args.getInstance(); - - private int getBackupState() { - try { - return Integer.valueOf(PropUtil - .readProperty(parameter.getDbBackupConfig().getPropPath(), BackupDbUtil.DB_BACKUP_STATE) - ); - } catch (NumberFormatException ignore) { - return DB_BACKUP_STATE_DEFAULT; //get default state if prop file is newly created - } - } - - private void setBackupState(int status) { - PropUtil.writeProperty(parameter.getDbBackupConfig() - .getPropPath(), BackupDbUtil.DB_BACKUP_STATE, - String.valueOf(status)); - } - - private void switchBackupState() { - switch (State.valueOf(getBackupState())) { - case BAKINGONE: - setBackupState(State.BAKEDONE.getStatus()); - break; - case BAKEDONE: - setBackupState(State.BAKEDTWO.getStatus()); - break; - case BAKINGTWO: - setBackupState(State.BAKEDTWO.getStatus()); - break; - case BAKEDTWO: - setBackupState(State.BAKEDONE.getStatus()); - break; - default: - break; - } - } - - public void doBackup(BlockCapsule block) { - long t1 = System.currentTimeMillis(); - try { - switch (State.valueOf(getBackupState())) { - case BAKINGONE: - deleteBackup(DB_BACKUP_INDEX1); - backup(DB_BACKUP_INDEX1); - switchBackupState(); - deleteBackup(DB_BACKUP_INDEX2); - break; - case BAKEDONE: - deleteBackup(DB_BACKUP_INDEX2); - backup(DB_BACKUP_INDEX2); - switchBackupState(); - deleteBackup(DB_BACKUP_INDEX1); - break; - case BAKINGTWO: - deleteBackup(DB_BACKUP_INDEX2); - backup(DB_BACKUP_INDEX2); - switchBackupState(); - deleteBackup(DB_BACKUP_INDEX1); - break; - case BAKEDTWO: - deleteBackup(DB_BACKUP_INDEX1); - backup(DB_BACKUP_INDEX1); - switchBackupState(); - deleteBackup(DB_BACKUP_INDEX2); - break; - default: - logger.warn("invalid backup state {}.", getBackupState()); - } - } catch (RocksDBException | SecurityException e) { - logger.warn("Backup db error.", e); - } - long timeUsed = System.currentTimeMillis() - t1; - logger - .info("Current block number is {}, backup all store use {} ms!", block.getNum(), timeUsed); - if (timeUsed >= 3000) { - logger.warn("Backing up db uses too much time. {} ms.", timeUsed); - } - } - - private void backup(int i) throws RocksDBException { - String path = ""; - if (i == DB_BACKUP_INDEX1) { - path = parameter.getDbBackupConfig().getBak1path(); - } else if (i == DB_BACKUP_INDEX2) { - path = parameter.getDbBackupConfig().getBak2path(); - } else { - throw new RuntimeException(String.format("error backup with undefined index %d", i)); - } - List stores = ((SnapshotManager) db).getDbs(); - for (Chainbase store : stores) { - if (((SnapshotRoot) (store.getHead().getRoot())).getDb().getClass() - == org.tron.core.db2.common.RocksDB.class) { - ((org.tron.core.db2.common.RocksDB) ((SnapshotRoot) (store.getHead().getRoot())).getDb()) - .getDb().backup(path); - } - } - } - - private void deleteBackup(int i) { - String path = ""; - if (i == DB_BACKUP_INDEX1) { - path = parameter.getDbBackupConfig().getBak1path(); - } else if (i == DB_BACKUP_INDEX2) { - path = parameter.getDbBackupConfig().getBak2path(); - } else { - throw new RuntimeException(String.format("error deleteBackup with undefined index %d", i)); - } - List stores = ((SnapshotManager) db).getDbs(); - for (Chainbase store : stores) { - if (((SnapshotRoot) (store.getHead().getRoot())).getDb().getClass() - == org.tron.core.db2.common.RocksDB.class) { - ((org.tron.core.db2.common.RocksDB) (((SnapshotRoot) (store.getHead().getRoot())).getDb())) - .getDb().deleteDbBakPath(path); - } - } - } - - public enum State { - BAKINGONE(1), BAKEDONE(11), BAKINGTWO(2), BAKEDTWO(22); - private int status; - - State(int status) { - this.status = status; - } - - public static State valueOf(int value) { - switch (value) { - case 1: - return BAKINGONE; - case 11: - return BAKEDONE; - case 2: - return BAKINGTWO; - case 22: - return BAKEDTWO; - default: - return BAKEDONE; - } - } - - public int getStatus() { - return status; - } - } -} diff --git a/framework/src/main/java/org/tron/core/db/backup/BackupRocksDBAspect.java b/framework/src/main/java/org/tron/core/db/backup/BackupRocksDBAspect.java deleted file mode 100644 index 25ef66fb8d0..00000000000 --- a/framework/src/main/java/org/tron/core/db/backup/BackupRocksDBAspect.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.tron.core.db.backup; - -import lombok.extern.slf4j.Slf4j; -import org.aspectj.lang.annotation.AfterThrowing; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; -import org.aspectj.lang.annotation.Pointcut; -import org.springframework.beans.factory.annotation.Autowired; -import org.tron.common.backup.BackupManager; -import org.tron.common.backup.BackupManager.BackupStatusEnum; -import org.tron.core.capsule.BlockCapsule; -import org.tron.core.config.args.Args; - -@Slf4j -@Aspect -public class BackupRocksDBAspect { - - @Autowired - private BackupDbUtil util; - - @Autowired - private BackupManager backupManager; - - - @Pointcut("execution(** org.tron.core.db.Manager.pushBlock(..)) && args(block)") - public void pointPushBlock(BlockCapsule block) { - - } - - @Before("pointPushBlock(block)") - public void backupDb(BlockCapsule block) { - //SR-Master Node do not backup db; - if (Args.getInstance().isWitness() && backupManager.getStatus() != BackupStatusEnum.SLAVER) { - return; - } - - //backup db when reach frequency. - if (block.getNum() % Args.getInstance().getDbBackupConfig().getFrequency() == 0) { - try { - util.doBackup(block); - } catch (Exception e) { - logger.error("backup db failed:", e); - } - } - } - - @AfterThrowing("pointPushBlock(block)") - public void logErrorPushBlock(BlockCapsule block) { - logger.info("AfterThrowing pushBlock"); - } -} \ No newline at end of file diff --git a/framework/src/main/java/org/tron/core/db/backup/NeedBeanCondition.java b/framework/src/main/java/org/tron/core/db/backup/NeedBeanCondition.java deleted file mode 100644 index 02ed63907d4..00000000000 --- a/framework/src/main/java/org/tron/core/db/backup/NeedBeanCondition.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.tron.core.db.backup; - -import org.springframework.context.annotation.Condition; -import org.springframework.context.annotation.ConditionContext; -import org.springframework.core.type.AnnotatedTypeMetadata; -import org.tron.core.config.args.Args; - -public class NeedBeanCondition implements Condition { - - @Override - public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { - if (Args.getInstance() == null || Args.getInstance().getStorage() == null - || Args.getInstance().getStorage().getDbEngine() == null - || Args.getInstance().getDbBackupConfig() == null) { - return false; - } - return "ROCKSDB".equalsIgnoreCase(Args.getInstance().getStorage().getDbEngine()) - && Args.getInstance().getDbBackupConfig().isEnable() && !Args.getInstance().isWitness(); - } -} \ No newline at end of file diff --git a/framework/src/test/java/org/tron/common/TestConstants.java b/framework/src/test/java/org/tron/common/TestConstants.java index 8e1057f2f67..88f28688936 100644 --- a/framework/src/test/java/org/tron/common/TestConstants.java +++ b/framework/src/test/java/org/tron/common/TestConstants.java @@ -25,7 +25,6 @@ public class TestConstants { public static final String TEST_CONF = "config-test.conf"; public static final String NET_CONF = "config.conf"; public static final String MAINNET_CONF = "config-test-mainnet.conf"; - public static final String DBBACKUP_CONF = "config-test-dbbackup.conf"; public static final String LOCAL_CONF = "config-localtest.conf"; public static final String STORAGE_CONF = "config-test-storagetest.conf"; public static final String INDEX_CONF = "config-test-index.conf"; diff --git a/framework/src/test/java/org/tron/common/storage/rocksdb/RocksDbDataSourceImplTest.java b/framework/src/test/java/org/tron/common/storage/rocksdb/RocksDbDataSourceImplTest.java index f3ca15c7cbe..b0f13eb9154 100644 --- a/framework/src/test/java/org/tron/common/storage/rocksdb/RocksDbDataSourceImplTest.java +++ b/framework/src/test/java/org/tron/common/storage/rocksdb/RocksDbDataSourceImplTest.java @@ -2,7 +2,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThrows; -import static org.tron.common.TestConstants.DBBACKUP_CONF; +import static org.tron.common.TestConstants.TEST_CONF; import static org.tron.common.TestConstants.assumeLevelDbAvailable; import java.io.File; @@ -49,7 +49,8 @@ public static void destroy() { @BeforeClass public static void initDb() throws IOException { Args.setParam(new String[]{"--output-directory", - temporaryFolder.newFolder().toString()}, DBBACKUP_CONF); + temporaryFolder.newFolder().toString()}, TEST_CONF); + CommonParameter.getInstance().storage.setDbEngine("ROCKSDB"); } @Test diff --git a/framework/src/test/java/org/tron/core/db/backup/BackupDbUtilTest.java b/framework/src/test/java/org/tron/core/db/backup/BackupDbUtilTest.java deleted file mode 100644 index 0153faeab71..00000000000 --- a/framework/src/test/java/org/tron/core/db/backup/BackupDbUtilTest.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.tron.core.db.backup; - -import java.io.File; -import javax.annotation.Resource; -import lombok.extern.slf4j.Slf4j; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.rocksdb.RocksDB; -import org.tron.common.BaseTest; -import org.tron.common.parameter.CommonParameter; -import org.tron.common.utils.FileUtil; -import org.tron.common.utils.PropUtil; -import org.tron.consensus.dpos.DposSlot; -import org.tron.core.config.args.Args; -import org.tron.core.consensus.ConsensusService; -import org.tron.core.db.ManagerForTest; - -@Slf4j -public class BackupDbUtilTest extends BaseTest { - - static { - RocksDB.loadLibrary(); - } - - @Resource - public ConsensusService consensusService; - @Resource - public DposSlot dposSlot; - public ManagerForTest mngForTest; - - String propPath; - String bak1Path; - String bak2Path; - int frequency; - - private static final String dbPath; - - static { - dbPath = dbPath(); - Args.setParam( - new String[]{ - "--output-directory", dbPath, - "--storage-db-directory", "database", - "--storage-index-directory", "index" - }, - "config-test-dbbackup.conf" - ); - } - - @Before - public void before() { - consensusService.start(); - mngForTest = new ManagerForTest(dbManager, dposSlot); - //prepare prop.properties - propPath = dbPath + File.separator + "test_prop.properties"; - bak1Path = dbPath + File.separator + "bak1/database"; - bak2Path = dbPath + File.separator + "bak2/database"; - frequency = 50; - CommonParameter parameter = Args.getInstance(); - parameter.getDbBackupConfig() - .initArgs(true, propPath, bak1Path, bak2Path, frequency); - FileUtil.createFileIfNotExists(propPath); - } - - @Test - public void testDoBackup() { - PropUtil.writeProperty(propPath, BackupDbUtil.getDB_BACKUP_STATE(), "11"); - mngForTest.pushNTestBlock(50); - - Assert.assertEquals(50, dbManager.getDynamicPropertiesStore().getLatestBlockHeaderNumber()); - Assert.assertEquals("22", PropUtil.readProperty(propPath, BackupDbUtil.getDB_BACKUP_STATE())); - - mngForTest.pushNTestBlock(50); - Assert.assertEquals(100, dbManager.getDynamicPropertiesStore().getLatestBlockHeaderNumber()); - Assert.assertEquals("11", PropUtil.readProperty(propPath, BackupDbUtil.getDB_BACKUP_STATE())); - - mngForTest.pushNTestBlock(50); - Assert.assertEquals(150, dbManager.getDynamicPropertiesStore().getLatestBlockHeaderNumber()); - Assert.assertEquals("22", PropUtil.readProperty(propPath, BackupDbUtil.getDB_BACKUP_STATE())); - - PropUtil.writeProperty(propPath, BackupDbUtil.getDB_BACKUP_STATE(), "1"); - mngForTest.pushNTestBlock(50); - Assert.assertEquals(200, dbManager.getDynamicPropertiesStore().getLatestBlockHeaderNumber()); - Assert.assertEquals("11", PropUtil.readProperty(propPath, BackupDbUtil.getDB_BACKUP_STATE())); - - PropUtil.writeProperty(propPath, BackupDbUtil.getDB_BACKUP_STATE(), "2"); - mngForTest.pushNTestBlock(50); - Assert.assertEquals(250, dbManager.getDynamicPropertiesStore().getLatestBlockHeaderNumber()); - Assert.assertEquals("22", PropUtil.readProperty(propPath, BackupDbUtil.getDB_BACKUP_STATE())); - } -} diff --git a/framework/src/test/java/org/tron/program/SupplementTest.java b/framework/src/test/java/org/tron/program/SupplementTest.java index 483922cf8c5..f95f3222108 100644 --- a/framework/src/test/java/org/tron/program/SupplementTest.java +++ b/framework/src/test/java/org/tron/program/SupplementTest.java @@ -16,7 +16,6 @@ import org.junit.rules.ExpectedException; import org.tron.common.BaseTest; import org.tron.common.TestConstants; -import org.tron.common.config.DbBackupConfig; import org.tron.common.entity.PeerInfo; import org.tron.common.utils.CompactEncoder; import org.tron.common.utils.JsonUtil; @@ -49,9 +48,6 @@ public void testGet() throws Exception { StorageRowCapsule storageRowCapsule = storageRowStore.get(new byte[]{}); assertNotNull(storageRowCapsule); - DbBackupConfig dbBackupConfig = new DbBackupConfig(); - String p = dbPath + File.separator; - dbBackupConfig.initArgs(true, p + "propPath", p + "bak1path/", p + "bak2path/", 1); Value value = new Value(new byte[]{1}); value.asBytes(); diff --git a/framework/src/test/resources/config-test-dbbackup.conf b/framework/src/test/resources/config-test-dbbackup.conf deleted file mode 100644 index b660965f3e9..00000000000 --- a/framework/src/test/resources/config-test-dbbackup.conf +++ /dev/null @@ -1,401 +0,0 @@ -net { - # type is deprecated and has no effect. - # type = mainnet -} - -storage { - # Directory for storing persistent data - db.engine = "ROCKSDB", - db.directory = "database", - index.directory = "index", - - # You can custom these 14 databases' configs: - - # account, account-index, asset-issue, block, block-index, - # block_KDB, peers, properties, recent-block, trans, - # utxo, votes, witness, witness_schedule. - - # Otherwise, db configs will remain defualt and data will be stored in - # the path of "output-directory" or which is set by "-d" ("--output-directory"). - - # Attention: name is a required field that must be set !!! - properties = [ - // { - // name = "account", - // path = "storage_directory_test", - // createIfMissing = true, - // paranoidChecks = true, - // verifyChecksums = true, - // compressionType = 1, // compressed with snappy - // blockSize = 4096, // 4 KB = 4 * 1024 B - // writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - // cacheSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - // maxOpenFiles = 100 - // }, - // { - // name = "account-index", - // path = "storage_directory_test", - // createIfMissing = true, - // paranoidChecks = true, - // verifyChecksums = true, - // compressionType = 1, // compressed with snappy - // blockSize = 4096, // 4 KB = 4 * 1024 B - // writeBufferSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - // cacheSize = 10485760, // 10 MB = 10 * 1024 * 1024 B - // maxOpenFiles = 100 - // }, - ] - - needToUpdateAsset = true - - backup = { - enable = true - properties = "test_prop.properties" - bak1path = "bak1/database" - bak2path = "bak2/database" - frequency = 10000 // backup db every ? blocks processed. - } -} - -node.discovery = { - enable = true - persist = true - external.ip = "" -} - -node.backup { - port = 10001 - - # my priority, each member should use different priority - priority = 8 - - # peer's ip list, can't contain mine - members = [ - # "ip", - # "ip" - ] -} - -node { - # trust node for solidity node - # trustNode = "ip:port" - trustNode = "127.0.0.1:50051" - - # expose extension api to public or not - walletExtensionApi = true - - listen.port = 18888 - - connection.timeout = 2 - - tcpNettyWorkThreadNum = 0 - - udpNettyWorkThreadNum = 1 - - # Number of validate sign thread, default availableProcessors / 2 - # validateSignThreadNum = 16 - - maxConnectionsWithSameIp = 2 - - minParticipationRate = 15 - - # check the peer data transfer ,disconnect factor - isOpenFullTcpDisconnect = true - - p2p { - version = 11111 # 11111: mainnet; 20180622: testnet - } - - active = [ - # Active establish connection in any case - # Sample entries: - # "ip:port", - # "ip:port" - ] - - passive = [ - # Passive accept connection in any case - # Sample entries: - # "ip:port", - # "ip:port" - ] - - http { - fullNodePort = 8090 - solidityPort = 8091 - } - - rpc { - port = 50051 - #solidityPort = 50061 - # Number of gRPC thread, default availableProcessors / 2 - # thread = 16 - - # The maximum number of concurrent calls permitted for each incoming connection - # maxConcurrentCallsPerConnection = - - # The HTTP/2 flow control window, default 1MB - # flowControlWindow = - - # Connection being idle for longer than which will be gracefully terminated - maxConnectionIdleInMillis = 60000 - - # Connection lasting longer than which will be gracefully terminated - # maxConnectionAgeInMillis = - - # The maximum message size allowed to be received on the server, default 4MB - # maxMessageSize = - - # The maximum size of header list allowed to be received, default 8192 - # maxHeaderListSize = - } - - # Limits the maximum percentage (default 75%) of producing block interval - # to provide sufficient time to perform other operations e.g. broadcast block - # blockProducedTimeOut = 75 - - # Limits the maximum number (default 700) of transaction from network layer - # netMaxTrxPerSecond = 700 -} - - -seed.node = { - # List of the seed nodes - # Seed nodes are stable full nodes - # example: - # ip.list = [ - # "ip:port", - # "ip:port" - # ] - ip.list = [ - "54.236.37.243:18888", - "52.53.189.99:18888", - "18.196.99.16:18888", - "34.253.187.192:18888", - "52.56.56.149:18888", - "35.180.51.163:18888", - "54.252.224.209:18888", - "18.228.15.36:18888", - "52.15.93.92:18888", - "34.220.77.106:18888", - "13.127.47.162:18888", - "13.124.62.58:18888", - "13.229.128.108:18888", - "35.182.37.246:18888", - "34.200.228.125:18888", - "18.220.232.201:18888", - "13.57.30.186:18888", - "35.165.103.105:18888", - "18.184.238.21:18888", - "34.250.140.143:18888", - "35.176.192.130:18888", - "52.47.197.188:18888", - "52.62.210.100:18888", - "13.231.4.243:18888", - "18.231.76.29:18888", - "35.154.90.144:18888", - "13.125.210.234:18888", - "13.250.40.82:18888", - "35.183.101.48:18888" - ] -} - -genesis.block = { - # Reserve balance - assets = [ - { - accountName = "Zion" - accountType = "AssetIssue" - address = "TLLM21wteSPs4hKjbxgmH1L6poyMjeTbHm" - balance = "99000000000000000" - }, - { - accountName = "Sun" - accountType = "AssetIssue" - address = "TXmVpin5vq5gdZsciyyjdZgKRUju4st1wM" - balance = "0" - }, - { - accountName = "Blackhole" - accountType = "AssetIssue" - address = "TLsV52sRDL79HXGGm9yzwKibb6BeruhUzy" - balance = "-9223372036854775808" - } - ] - - witnesses = [ - { - address: THKJYuUmMKKARNf7s2VT51g5uPY6KEqnat, - url = "http://GR1.com", - voteCount = 100000026 - }, - { - address: TVDmPWGYxgi5DNeW8hXrzrhY8Y6zgxPNg4, - url = "http://GR2.com", - voteCount = 100000025 - }, - { - address: TWKZN1JJPFydd5rMgMCV5aZTSiwmoksSZv, - url = "http://GR3.com", - voteCount = 100000024 - }, - { - address: TDarXEG2rAD57oa7JTK785Yb2Et32UzY32, - url = "http://GR4.com", - voteCount = 100000023 - }, - { - address: TAmFfS4Tmm8yKeoqZN8x51ASwdQBdnVizt, - url = "http://GR5.com", - voteCount = 100000022 - }, - { - address: TK6V5Pw2UWQWpySnZyCDZaAvu1y48oRgXN, - url = "http://GR6.com", - voteCount = 100000021 - }, - { - address: TGqFJPFiEqdZx52ZR4QcKHz4Zr3QXA24VL, - url = "http://GR7.com", - voteCount = 100000020 - }, - { - address: TC1ZCj9Ne3j5v3TLx5ZCDLD55MU9g3XqQW, - url = "http://GR8.com", - voteCount = 100000019 - }, - { - address: TWm3id3mrQ42guf7c4oVpYExyTYnEGy3JL, - url = "http://GR9.com", - voteCount = 100000018 - }, - { - address: TCvwc3FV3ssq2rD82rMmjhT4PVXYTsFcKV, - url = "http://GR10.com", - voteCount = 100000017 - }, - { - address: TFuC2Qge4GxA2U9abKxk1pw3YZvGM5XRir, - url = "http://GR11.com", - voteCount = 100000016 - }, - { - address: TNGoca1VHC6Y5Jd2B1VFpFEhizVk92Rz85, - url = "http://GR12.com", - voteCount = 100000015 - }, - { - address: TLCjmH6SqGK8twZ9XrBDWpBbfyvEXihhNS, - url = "http://GR13.com", - voteCount = 100000014 - }, - { - address: TEEzguTtCihbRPfjf1CvW8Euxz1kKuvtR9, - url = "http://GR14.com", - voteCount = 100000013 - }, - { - address: TZHvwiw9cehbMxrtTbmAexm9oPo4eFFvLS, - url = "http://GR15.com", - voteCount = 100000012 - }, - { - address: TGK6iAKgBmHeQyp5hn3imB71EDnFPkXiPR, - url = "http://GR16.com", - voteCount = 100000011 - }, - { - address: TLaqfGrxZ3dykAFps7M2B4gETTX1yixPgN, - url = "http://GR17.com", - voteCount = 100000010 - }, - { - address: TX3ZceVew6yLC5hWTXnjrUFtiFfUDGKGty, - url = "http://GR18.com", - voteCount = 100000009 - }, - { - address: TYednHaV9zXpnPchSywVpnseQxY9Pxw4do, - url = "http://GR19.com", - voteCount = 100000008 - }, - { - address: TCf5cqLffPccEY7hcsabiFnMfdipfyryvr, - url = "http://GR20.com", - voteCount = 100000007 - }, - { - address: TAa14iLEKPAetX49mzaxZmH6saRxcX7dT5, - url = "http://GR21.com", - voteCount = 100000006 - }, - { - address: TBYsHxDmFaRmfCF3jZNmgeJE8sDnTNKHbz, - url = "http://GR22.com", - voteCount = 100000005 - }, - { - address: TEVAq8dmSQyTYK7uP1ZnZpa6MBVR83GsV6, - url = "http://GR23.com", - voteCount = 100000004 - }, - { - address: TRKJzrZxN34YyB8aBqqPDt7g4fv6sieemz, - url = "http://GR24.com", - voteCount = 100000003 - }, - { - address: TRMP6SKeFUt5NtMLzJv8kdpYuHRnEGjGfe, - url = "http://GR25.com", - voteCount = 100000002 - }, - { - address: TDbNE1VajxjpgM5p7FyGNDASt3UVoFbiD3, - url = "http://GR26.com", - voteCount = 100000001 - }, - { - address: TLTDZBcPoJ8tZ6TTEeEqEvwYFk2wgotSfD, - url = "http://GR27.com", - voteCount = 100000000 - } - ] - - timestamp = "0" #2017-8-26 12:00:00 - - parentHash = "0xe58f33f9baf9305dc6f82b9f1934ea8f0ade2defb951258d50167028c780351f" -} - -localwitness = [ -] - -#localwitnesskeystore = [ -# "localwitnesskeystore.json" -#] - -block = { - needSyncCheck = true - maintenanceTimeInterval = 21600000 - proposalExpireTime = 259200000 // 3 day: 259200000(ms) -} - -# Transaction reference block, default is "head", configure to "solid" can avoid TaPos error -# trx.reference.block = "head" // head;solid; - -vm = { - supportConstant = false - minTimeRatio = 0.0 - maxTimeRatio = 5.0 - - # In rare cases, transactions that will be within the specified maximum execution time (default 10(ms)) are re-executed and packaged - # longRunningTime = 10 -} - -committee = { - allowCreationOfContracts = 0 //mainnet:0 (reset by committee),test:1 - allowAdaptiveEnergy = 0 //mainnet:0 (reset by committee),test:1 -} - -log.level = { - root = "INFO" // TRACE;DEBUG;INFO;WARN;ERROR -} diff --git a/plugins/src/test/java/org/tron/plugins/DbLiteTest.java b/plugins/src/test/java/org/tron/plugins/DbLiteTest.java index f7cb7b7f74f..960c1414769 100644 --- a/plugins/src/test/java/org/tron/plugins/DbLiteTest.java +++ b/plugins/src/test/java/org/tron/plugins/DbLiteTest.java @@ -18,7 +18,6 @@ import org.tron.common.application.Application; import org.tron.common.application.ApplicationFactory; import org.tron.common.application.TronApplicationContext; -import org.tron.common.config.DbBackupConfig; import org.tron.common.crypto.ECKey; import org.tron.common.utils.FileUtil; import org.tron.common.utils.PublicMethod; @@ -82,8 +81,6 @@ public void init(String dbType, boolean historyBalanceLookup) throws IOException Args.getInstance().setRpcEnable(true); Args.getInstance().setHistoryBalanceLookup(historyBalanceLookup); databaseDir = Args.getInstance().getStorage().getDbDirectory(); - // init dbBackupConfig to avoid NPE - Args.getInstance().dbBackupConfig = DbBackupConfig.getInstance(); } @After diff --git a/prop.properties b/prop.properties deleted file mode 100644 index e69de29bb2d..00000000000