From e8d193336ad8f51e3e669517a98d7091a16efd23 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Sat, 26 Oct 2019 17:59:15 +0200
Subject: [PATCH 01/12] Remove empty test
---
src/test/java/net/helix/pendulum/service/MilestoneTest.java | 0
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 src/test/java/net/helix/pendulum/service/MilestoneTest.java
diff --git a/src/test/java/net/helix/pendulum/service/MilestoneTest.java b/src/test/java/net/helix/pendulum/service/MilestoneTest.java
deleted file mode 100644
index e69de29b..00000000
From 250b0e661e8b5c1bdd13d82817dc3046d7998f8f Mon Sep 17 00:00:00 2001
From: ofo42
Date: Sat, 26 Oct 2019 18:01:49 +0200
Subject: [PATCH 02/12] Add new previousEpochsSpentAddresses resource files
---
src/main/resources/previousEpochsSpentAddresses.sig | 4 ++--
src/main/resources/previousEpochsSpentAddresses.txt | 13 +++++++++++++
2 files changed, 15 insertions(+), 2 deletions(-)
mode change 100755 => 100644 src/main/resources/previousEpochsSpentAddresses.sig
mode change 100755 => 100644 src/main/resources/previousEpochsSpentAddresses.txt
diff --git a/src/main/resources/previousEpochsSpentAddresses.sig b/src/main/resources/previousEpochsSpentAddresses.sig
old mode 100755
new mode 100644
index 072ce121..1dcd1b80
--- a/src/main/resources/previousEpochsSpentAddresses.sig
+++ b/src/main/resources/previousEpochsSpentAddresses.sig
@@ -1,3 +1,3 @@
-b59766f0f98a37e854abc145ce29dee6d3425687e705276598ee1e5cc978b9aeeed25edac17336d67540375c58aa9a461764e4977d3736353219dcdb4449914deaacc6eaa1ff82326814690ecb3b02f3e5ba1d72535e1726339bc80a54d7ae0f909db021f095e81d1a33220018c84165cc7838c6d938816e59653f3a1860ae44e9ddd1257c84fc1798fcceef2ea3c55e527bf27a66d1d36eaf1d738ea7fd8ad664c21bb62408ac43b2897519af3c76017b991f7f1c8c0b624ff3753d533ce20de94ef08f3a4fd6f6cbdd88e24dc689ecb7c537b8d315a73b0573712cfc71cf92891316868f69b545c9ac4f384f9a1f9af9a84f990c54d482792c5eaf952df82a19483dd598934f75fb0dc7e4727c8c8cdbb122f1e8843266665fa7601b6cea8af3dcde8b291e0271284f1927960e65a9c4df45a0dafef7104756eb17dff29560ec25d8b00c13ed93bc40dd636936454aa71e34adb822adf6ba04296b76902b44d7a784d6f103d347119c2d53a81961d04b793ab95cfd576021026ff63ee2559e19812364047cb86d5b7254cb17bc2d8bdb9a92ec6f0c1e2ff4ef8bba1ebe5638a5c03c725f3e140511a32d93b432c99b7edab2d8c3625106d9850c7fe1fdeb7d31e5422474e31cb3f7bf556fa463e4a8708b9108f9b09946d8c3e3b2e44f8d426942ec03861841fc50e9ae2859e2afdea1d15f650e2bb31c3632e86f6eb81ffe
-5d6bbee80c74e0853ffb44016e68b6bf33092c090753315c8237147326f414fab3edc04b3f462750c8b135eb24335b8523f186b48b228340ff8b35e62f8fbb5209cf9b45356741eaac4e23e82bace68a3c9fb4f9af895fc917caaee08111b4fa551cd242dd80545d10d4560f1a784253ce129dfa04d5457d42657ddb4aaebea49cb1c37dd6cf08136328a6d74f4c20469a2ed00368f9db2c49544ec2e8d52d64cb56954f68d9cb29475840ab5d2a585f5e3e2305201f547d1a104d6a4742fc6e8baa014b56a25ab5ff635263d414478c31f6d53857d7770d9d073e17936eb41cb4f6e6f82c29a6f6f5f438e1953666e238591ad064455db0cf9fb6f1098d3896130b03fff84d3dafcf373e56bce1413a396734d9984b0e9633539f7fa7d64983afd8c37b8d2de9efa0f09a87096ad7f34f09f73a534f951abf95504a73c848a2bf7a6d249e29e19407d25f7dae13bc14c4b77ca6c2c501a7afa7783cfdeca4aa5b8d563a2d390186f75d228172857fcaa80c458708e964151296dd6d9a4b6b705d759d555379042246b2b5f4d2ec18f0720d6241498f954f102fe6572b177cb710e56296eaf88d87ae69623c45d4f295575c547459dba97d85316ce534f695a1c14d747351bbacd0a401e6b2a3176d50ce09ca23439dcca5836668111ffd6102e4c23468fc42011e9b2b8cb6d9f1edcdcb589d88350ad79c3dea1f016ce5441d
+d54189b20f649dd4f2139b22c61afb6412352660a935ee1713549c3c2614e080cc62333e4f9d5c24c84f507959dd7dce2851d66649125b61c0d84864147c9cacdfe58482527a0e06a5060a3e34998b7e91da5ba5bcb7f31c52d25ddb785a1ad02ef315df3eb125fc3871dde8f47c2f42de12ea26ea092ca8f3a2d53d60680c0ab59766f0f98a37e854abc145ce29dee6d3425687e705276598ee1e5cc978b9aecd97773c2137e43117e1419e990381c5d3fd1f35c5c48273cc4a20cd9487a8fbcc62333e4f9d5c24c84f507959dd7dce2851d66649125b61c0d84864147c9cacbb28fa2f114ac520e726db6ca0008cbe29a347059d2c7c280d7698998bdae972f0c9b65c73b05cafde461aee930ebbcd39ebb09c467b1d907988656e8f0c058ff0c9b65c73b05cafde461aee930ebbcd39ebb09c467b1d907988656e8f0c058fbb28fa2f114ac520e726db6ca0008cbe29a347059d2c7c280d7698998bdae972ec25d8b00c13ed93bc40dd636936454aa71e34adb822adf6ba04296b76902b44cf3bfc91633463acc5b08b15756adb29eb6477c94e98b12d8def8012e4fe1e0419812364047cb86d5b7254cb17bc2d8bdb9a92ec6f0c1e2ff4ef8bba1ebe563864c21bb62408ac43b2897519af3c76017b991f7f1c8c0b624ff3753d533ce20d19812364047cb86d5b7254cb17bc2d8bdb9a92ec6f0c1e2ff4ef8bba1ebe5638
+f3dcde8b291e0271284f1927960e65a9c4df45a0dafef7104756eb17dff29560ec25d8b00c13ed93bc40dd636936454aa71e34adb822adf6ba04296b76902b4419812364047cb86d5b7254cb17bc2d8bdb9a92ec6f0c1e2ff4ef8bba1ebe5638891316868f69b545c9ac4f384f9a1f9af9a84f990c54d482792c5eaf952df82ab3edc04b3f462750c8b135eb24335b8523f186b48b228340ff8b35e62f8fbb52b3edc04b3f462750c8b135eb24335b8523f186b48b228340ff8b35e62f8fbb5231e5422474e31cb3f7bf556fa463e4a8708b9108f9b09946d8c3e3b2e44f8d429cb1c37dd6cf08136328a6d74f4c20469a2ed00368f9db2c49544ec2e8d52d64f3dcde8b291e0271284f1927960e65a9c4df45a0dafef7104756eb17dff29560b3edc04b3f462750c8b135eb24335b8523f186b48b228340ff8b35e62f8fbb52b3edc04b3f462750c8b135eb24335b8523f186b48b228340ff8b35e62f8fbb52a5c03c725f3e140511a32d93b432c99b7edab2d8c3625106d9850c7fe1fdeb7d6942ec03861841fc50e9ae2859e2afdea1d15f650e2bb31c3632e86f6eb81ffebf7a6d249e29e19407d25f7dae13bc14c4b77ca6c2c501a7afa7783cfdeca4aac14d747351bbacd0a401e6b2a3176d50ce09ca23439dcca5836668111ffd6102e4c23468fc42011e9b2b8cb6d9f1edcdcb589d88350ad79c3dea1f016ce5441d
53dbf3faa1b7484ede3e498b7b3a52a0ff5ec1397035af7e91d9efa2be3be92bfe176801e7932129583a3b77ec5fb774f58d7b08517d228f80299bdc144eb4df33525ab036bd026748c7792ea433e3cd100c9e89e5a58acdd17bc1d35655ff4107564fa6420478464bcf3dc76976a8bd69fae53ba539ed96ec699d0f8c4e29e68783b7ca67423e70e96d725ab7878faeb63101af872118b3167d267828f525a4232c2e0fcb6dccac4fbb0b06694b83f192b81cf69b9ccb29dd9f1f1b58c3587f67696ca6750cc4d109bcb889fdbe0eb6fd950bbb3bc3b6907624827089164f0f517b4d0d75be8a7497f61861e730e4a768da4bfee4c623094aab12673a070f131b73c1b05108e51c8faa435d7473b79c6ac9081b091912df0a0eec07bd1faf0d8b8650707566ab1b6e0d2919d2b7b59a1a7757d1b4ddfa4cccba0dfaef8d472a
\ No newline at end of file
diff --git a/src/main/resources/previousEpochsSpentAddresses.txt b/src/main/resources/previousEpochsSpentAddresses.txt
old mode 100755
new mode 100644
index e69de29b..a96e77f2
--- a/src/main/resources/previousEpochsSpentAddresses.txt
+++ b/src/main/resources/previousEpochsSpentAddresses.txt
@@ -0,0 +1,13 @@
+00b6d443df1947319e5ffca7a9301db34e2228fe8659d36644687d99cbf644ac
+bacfd160e660126829417ab412d7eca4e46238f6d960ae8189b1544b9fa1682e
+d4f1b133130f4b76ba320a525e7e25b8c160535d07b4e68adfb3577fdf751b11
+848bccb86eb801438aa49fc7a94945351e8a1db0ecf8a88549d661574c18f645
+b074e54570eaed3f5eadfb98f3bff1e7647870f35be4f60591d95cbced3d0f75
+c04fffafc63e24eaeb6cae15f64e4d2234784834b7fd2c582456464deae61533
+3b7df152118bac759b4bffd4bd54f277edfe36360791ef4d729d13693e124da7
+cfab6470ae2f1da2b25a7834f0e9f520f816d11a4b530df15cf5e8a74e108d7c
+9562c56495fd50c8775fa993c1a7b52eadd06d5d160cb327b49e7aac2e71ffc3
+018d1ed69a8c3e232c4a96de5621937d75fb1e276340ad8aa3234f45c12aae0a
+fc74ba99be4b576d7cdcf42b4c3ac131518effd098f1e7a03be6747aaa431316
+b6f1fb91ec63421bb9a4c5fe41676fc1ee0d94aaf682a469ebdc4176ac8c5c5a
+2efaeedc6622e97e6e8443aaec9e99ce483800740882e2749d2d0c7de39bd031
From 488bf521a683e8fb54dbf4375c12848bff0919af Mon Sep 17 00:00:00 2001
From: ofo42
Date: Sat, 26 Oct 2019 18:02:11 +0200
Subject: [PATCH 03/12] Enable assertSpentAddressesDbExist
---
.../pendulum/service/snapshot/impl/SnapshotProviderImpl.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/main/java/net/helix/pendulum/service/snapshot/impl/SnapshotProviderImpl.java b/src/main/java/net/helix/pendulum/service/snapshot/impl/SnapshotProviderImpl.java
index 153a0b29..97e222c9 100644
--- a/src/main/java/net/helix/pendulum/service/snapshot/impl/SnapshotProviderImpl.java
+++ b/src/main/java/net/helix/pendulum/service/snapshot/impl/SnapshotProviderImpl.java
@@ -231,8 +231,7 @@ private Snapshot loadLocalSnapshot() throws SnapshotException, SpentAddressesExc
);
if (localSnapshotFile.exists() && localSnapshotFile.isFile() && localSnapshotMetaDataFile.exists() &&
localSnapshotMetaDataFile.isFile()) {
- //TODO: enable this for mainnet-1.0. This will cause issues on a testnet where value transfers might not be guaranteed during a local snapshot und thus would always be thrown.
- //assertSpentAddressesDbExist();
+ assertSpentAddressesDbExist();
SnapshotState snapshotState = readSnapshotStatefromFile(localSnapshotFile.getAbsolutePath());
if (!snapshotState.hasCorrectSupply()) {
throw new SnapshotException("the snapshot state file has an invalid supply");
@@ -245,7 +244,6 @@ private Snapshot loadLocalSnapshot() throws SnapshotException, SpentAddressesExc
return new SnapshotImpl(snapshotState, snapshotMetaData);
}
}
-
return null;
}
From 68d6195d5909b690a62798a32fdfea7245ecefc4 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Sat, 26 Oct 2019 18:04:07 +0200
Subject: [PATCH 04/12] bump to 1.0.5
---
CHANGELOG.md | 1 +
README.md | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c23e3b84..6261b36a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,6 @@
## 1.0.5
- Fixed `getBalance`: `RoundViewModel.get()` returns null on `index`=0, thus NPE was thrown when `references` were not passed and the first round hadn't been completed. In our implementation the snapshot is already constructed based on relative confirmations, thus it suffices for `getBalances` to respond with balance according to `latestSnapshot`.
+- Updated `previousEpochsSpentAddresses` resource files
## 1.0.4
- Fixed several zmq publish statements in which an incorrect format was specified.
diff --git a/README.md b/README.md
index 98d95a9e..170fdcbf 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
Pendulum is a quorum based [Tangle](https://github.com/iotaledger/iri/) implementation designed towards reliable timekeeping and high-throughput messaging.
-- **Latest release:** 1.0.4 pre-release
+- **Latest release:** 1.0.5 pre-release
- **License:** GPLv3
Special thanks to all of the [IOTA Contributors](https://github.com/iotaledger/iri/graphs/contributors)!
From 4b32a0972a965353d6998eded3db859c1a8b0233 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Sat, 26 Oct 2019 18:33:50 +0200
Subject: [PATCH 05/12] Remove spentAddresses db check from SnapshotProvider
---
.../snapshot/impl/SnapshotProviderImpl.java | 24 +++----------------
1 file changed, 3 insertions(+), 21 deletions(-)
diff --git a/src/main/java/net/helix/pendulum/service/snapshot/impl/SnapshotProviderImpl.java b/src/main/java/net/helix/pendulum/service/snapshot/impl/SnapshotProviderImpl.java
index 97e222c9..9c6c905d 100644
--- a/src/main/java/net/helix/pendulum/service/snapshot/impl/SnapshotProviderImpl.java
+++ b/src/main/java/net/helix/pendulum/service/snapshot/impl/SnapshotProviderImpl.java
@@ -5,8 +5,6 @@
import net.helix.pendulum.model.Hash;
import net.helix.pendulum.model.HashFactory;
import net.helix.pendulum.service.snapshot.*;
-import net.helix.pendulum.service.spentaddresses.SpentAddressesException;
-import net.helix.pendulum.service.spentaddresses.SpentAddressesProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -101,7 +99,7 @@ public class SnapshotProviderImpl implements SnapshotProvider {
* @return the initialized instance itself to allow chaining
*
*/
- public SnapshotProviderImpl init(SnapshotConfig config) throws SnapshotException, SpentAddressesException {
+ public SnapshotProviderImpl init(SnapshotConfig config) throws SnapshotException {
this.config = config;
File pathToLocalSnapshotDir = Paths.get(this.config.getLocalSnapshotsBasePath()).toFile();
if (!pathToLocalSnapshotDir.exists() || !pathToLocalSnapshotDir.isDirectory()) {
@@ -201,7 +199,7 @@ public void shutdown() {
*
* @throws SnapshotException if anything goes wrong while loading the snapshots
*/
- private void loadSnapshots() throws SnapshotException, SpentAddressesException {
+ private void loadSnapshots() throws SnapshotException {
initialSnapshot = loadLocalSnapshot();
if (initialSnapshot == null) {
initialSnapshot = loadBuiltInSnapshot();
@@ -220,7 +218,7 @@ private void loadSnapshots() throws SnapshotException, SpentAddressesException {
* @return local snapshot of the node
* @throws SnapshotException if local snapshot files exist but are malformed
*/
- private Snapshot loadLocalSnapshot() throws SnapshotException, SpentAddressesException {
+ private Snapshot loadLocalSnapshot() throws SnapshotException {
if (config.getLocalSnapshotsEnabled()) {
String fileSeperator = System.getProperty("file.separator");
File localSnapshotFile = new File(
@@ -231,7 +229,6 @@ private Snapshot loadLocalSnapshot() throws SnapshotException, SpentAddressesExc
);
if (localSnapshotFile.exists() && localSnapshotFile.isFile() && localSnapshotMetaDataFile.exists() &&
localSnapshotMetaDataFile.isFile()) {
- assertSpentAddressesDbExist();
SnapshotState snapshotState = readSnapshotStatefromFile(localSnapshotFile.getAbsolutePath());
if (!snapshotState.hasCorrectSupply()) {
throw new SnapshotException("the snapshot state file has an invalid supply");
@@ -247,21 +244,6 @@ private Snapshot loadLocalSnapshot() throws SnapshotException, SpentAddressesExc
return null;
}
- private void assertSpentAddressesDbExist() throws SpentAddressesException {
- try {
- File spentAddressFolder = new File(SpentAddressesProvider.SPENT_ADDRESSES_DB);
- //If there is at least one file in the db the check should pass
- if (Files.newDirectoryStream(spentAddressFolder.toPath(), "*.sst").iterator().hasNext()) {
- return;
- }
- }
- catch (IOException e){
- throw new SpentAddressesException("Can't load " + SpentAddressesProvider.SPENT_ADDRESSES_DB + " folder", e);
- }
-
- throw new SpentAddressesException(SpentAddressesProvider.SPENT_ADDRESSES_DB + " folder has no sst files");
- }
-
/**
* Loads the builtin snapshot (last global snapshot) that is embedded in the jar (if a different path is provided it
* can also load from the disk).
From 7dd36283d32328ff1a8897a56f0c14fcf74f4f97 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Sat, 26 Oct 2019 20:03:11 +0200
Subject: [PATCH 06/12] minor
---
.../service/validatormanager/impl/CandidateTrackerImpl.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/net/helix/pendulum/service/validatormanager/impl/CandidateTrackerImpl.java b/src/main/java/net/helix/pendulum/service/validatormanager/impl/CandidateTrackerImpl.java
index cf2c643d..abc11964 100644
--- a/src/main/java/net/helix/pendulum/service/validatormanager/impl/CandidateTrackerImpl.java
+++ b/src/main/java/net/helix/pendulum/service/validatormanager/impl/CandidateTrackerImpl.java
@@ -312,7 +312,7 @@ public boolean processCandidate(TransactionViewModel transaction) throws Validat
* message processor so external receivers get informed about this change.
*
*
- * @param candidateAddress
+ * @param validatorAddress
*
*/
From bbe95bf56e02a88a207d3264912441f11ab71517 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Sat, 26 Oct 2019 21:04:02 +0200
Subject: [PATCH 07/12] cleanup
---
src/main/java/net/helix/pendulum/Pendulum.java | 4 ----
1 file changed, 4 deletions(-)
diff --git a/src/main/java/net/helix/pendulum/Pendulum.java b/src/main/java/net/helix/pendulum/Pendulum.java
index 25273dcc..bd1cb26b 100644
--- a/src/main/java/net/helix/pendulum/Pendulum.java
+++ b/src/main/java/net/helix/pendulum/Pendulum.java
@@ -138,14 +138,12 @@ public Pendulum(PendulumConfig configuration) throws TransactionPruningException
? new LocalSnapshotManagerImpl()
: null;
milestoneService = new MilestoneServiceImpl();
- //validatorService = new ValidatorServiceImpl();
validatorManagerService = new ValidatorManagerServiceImpl();
latestMilestoneTracker = new MilestoneTrackerImpl();
candidateTracker = new CandidateTrackerImpl();
latestSolidMilestoneTracker = new LatestSolidMilestoneTrackerImpl();
seenMilestonesRetriever = new SeenMilestonesRetrieverImpl();
milestoneSolidifier = new MilestoneSolidifierImpl();
- //validatorSolidifier = new ValidatorSolidifierImpl();
candidateSolidifier = new CandidateSolidifierImpl();
transactionPruner = configuration.getLocalSnapshotsEnabled() && configuration.getLocalSnapshotsPruningEnabled()
? new AsyncTransactionPruner()
@@ -219,7 +217,6 @@ public void init() throws Exception {
}
}
- //TODO: bundleValidator should be passed to: milestoneService, spentAddressService and ledgerService.
private void injectDependencies() throws SnapshotException, TransactionPruningException, SpentAddressesException {
//snapshot provider must be initialized first
//because we check whether spent addresses data exists
@@ -238,7 +235,6 @@ private void injectDependencies() throws SnapshotException, TransactionPruningEx
latestMilestoneTracker);
seenMilestonesRetriever.init(tangle, snapshotProvider, transactionRequester);
milestoneSolidifier.init(snapshotProvider, transactionValidator);
- //validatorSolidifier.init(snapshotProvider, transactionValidator);
candidateSolidifier.init(snapshotProvider, transactionValidator);
ledgerService.init(tangle, snapshotProvider, snapshotService, milestoneService, configuration);
if (transactionPruner != null) {
From dd7a7fd18a4bff4ea3f87c9820d93ab512d31932 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Sun, 27 Oct 2019 12:49:15 +0100
Subject: [PATCH 08/12] Disable pruning by default
---
src/main/java/net/helix/pendulum/conf/BasePendulumConfig.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/net/helix/pendulum/conf/BasePendulumConfig.java b/src/main/java/net/helix/pendulum/conf/BasePendulumConfig.java
index a7a5f2e5..b6763176 100644
--- a/src/main/java/net/helix/pendulum/conf/BasePendulumConfig.java
+++ b/src/main/java/net/helix/pendulum/conf/BasePendulumConfig.java
@@ -1040,7 +1040,7 @@ public interface Defaults {
//Snapshot
boolean LOCAL_SNAPSHOTS_ENABLED = true;
- boolean LOCAL_SNAPSHOTS_PRUNING_ENABLED = true;
+ boolean LOCAL_SNAPSHOTS_PRUNING_ENABLED = false;
int LOCAL_SNAPSHOTS_PRUNING_DELAY = 50000;
int LOCAL_SNAPSHOTS_INTERVAL_SYNCED = 10;
int LOCAL_SNAPSHOTS_INTERVAL_UNSYNCED = 1000;
From 71f93ce56fa88328f300e275b7fe7997ed6ada32 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Sun, 27 Oct 2019 12:51:51 +0100
Subject: [PATCH 09/12] Refactor persistSpentAddresses
---
.../snapshot/impl/SnapshotServiceImpl.java | 9 ----
.../spentaddresses/SpentAddressesService.java | 10 +----
.../impl/SpentAddressesServiceImpl.java | 41 +++----------------
3 files changed, 6 insertions(+), 54 deletions(-)
diff --git a/src/main/java/net/helix/pendulum/service/snapshot/impl/SnapshotServiceImpl.java b/src/main/java/net/helix/pendulum/service/snapshot/impl/SnapshotServiceImpl.java
index 4dcd1abc..96fa0f4a 100644
--- a/src/main/java/net/helix/pendulum/service/snapshot/impl/SnapshotServiceImpl.java
+++ b/src/main/java/net/helix/pendulum/service/snapshot/impl/SnapshotServiceImpl.java
@@ -517,15 +517,6 @@ private void cleanupOldData(PendulumConfig config, TransactionPruner transaction
private void persistLocalSnapshot(SnapshotProvider snapshotProvider, Snapshot newSnapshot, PendulumConfig config)
throws SnapshotException {
- try {
- spentAddressesService.persistSpentAddresses(snapshotProvider.getInitialSnapshot().getIndex(),
- newSnapshot.getIndex());
-
- } catch (Exception e) {
- throw new SnapshotException(e);
- }
-
- // TODO: Add timestamp and hash to this snapshot so it can be saved into hashdir/timestamp-filename
snapshotProvider.writeSnapshotToDisk(newSnapshot, config.getLocalSnapshotsBasePath() );
snapshotProvider.getLatestSnapshot().lockWrite();
diff --git a/src/main/java/net/helix/pendulum/service/spentaddresses/SpentAddressesService.java b/src/main/java/net/helix/pendulum/service/spentaddresses/SpentAddressesService.java
index cfce39c1..8a72876e 100644
--- a/src/main/java/net/helix/pendulum/service/spentaddresses/SpentAddressesService.java
+++ b/src/main/java/net/helix/pendulum/service/spentaddresses/SpentAddressesService.java
@@ -1,5 +1,6 @@
package net.helix.pendulum.service.spentaddresses;
+import net.helix.pendulum.conf.PendulumConfig;
import net.helix.pendulum.controllers.TransactionViewModel;
import net.helix.pendulum.model.Hash;
@@ -20,15 +21,6 @@ public interface SpentAddressesService {
*/
boolean wasAddressSpentFrom(Hash addressHash) throws SpentAddressesException;
- /**
- * Calculates and persists all spent addresses in between a range that were validly signed
- *
- * @param fromMilestoneIndex the lower bound milestone index (inclusive)
- * @param toMilestoneIndex the upper bound milestone index (exclusive)
- * @throws Exception when anything went wrong whilst calculating.
- */
- void persistSpentAddresses(int fromMilestoneIndex, int toMilestoneIndex) throws Exception;
-
/**
* Persist all the verifiable spent from a given list of transactions
* @param transactions transactions to obtain spends from
diff --git a/src/main/java/net/helix/pendulum/service/spentaddresses/impl/SpentAddressesServiceImpl.java b/src/main/java/net/helix/pendulum/service/spentaddresses/impl/SpentAddressesServiceImpl.java
index d5e051bb..a332469c 100644
--- a/src/main/java/net/helix/pendulum/service/spentaddresses/impl/SpentAddressesServiceImpl.java
+++ b/src/main/java/net/helix/pendulum/service/spentaddresses/impl/SpentAddressesServiceImpl.java
@@ -1,10 +1,14 @@
package net.helix.pendulum.service.spentaddresses.impl;
import net.helix.pendulum.BundleValidator;
+import net.helix.pendulum.conf.BasePendulumConfig;
+import net.helix.pendulum.conf.PendulumConfig;
import net.helix.pendulum.controllers.AddressViewModel;
import net.helix.pendulum.controllers.RoundViewModel;
+import net.helix.pendulum.controllers.TipsViewModel;
import net.helix.pendulum.controllers.TransactionViewModel;
import net.helix.pendulum.model.Hash;
+import net.helix.pendulum.model.persistables.Transaction;
import net.helix.pendulum.service.snapshot.SnapshotProvider;
import net.helix.pendulum.service.snapshot.impl.SnapshotServiceImpl;
import net.helix.pendulum.service.spentaddresses.SpentAddressesException;
@@ -12,6 +16,7 @@
import net.helix.pendulum.service.spentaddresses.SpentAddressesService;
import net.helix.pendulum.service.tipselection.TailFinder;
import net.helix.pendulum.service.tipselection.impl.TailFinderImpl;
+import net.helix.pendulum.service.utils.RoundIndexUtil;
import net.helix.pendulum.storage.Tangle;
import net.helix.pendulum.utils.dag.DAGHelper;
import org.apache.commons.collections4.CollectionUtils;
@@ -80,42 +85,6 @@ public boolean wasAddressSpentFrom(Hash addressHash) throws SpentAddressesExcept
return false;
}
- @Override
- public void persistSpentAddresses(int fromMilestoneIndex, int toMilestoneIndex) throws SpentAddressesException {
- Set addressesToCheck = new HashSet<>();
- try {
- for (int i = fromMilestoneIndex; i < toMilestoneIndex; i++) {
- RoundViewModel currentMilestone = RoundViewModel.get(tangle, i);
- if (currentMilestone != null) {
- for (Hash confirmedTip : currentMilestone.getConfirmedTips(tangle, 1)) {
- DAGHelper.get(tangle).traverseApprovees(
- confirmedTip,
- transactionViewModel -> transactionViewModel.snapshotIndex() >= currentMilestone.index(),
- transactionViewModel -> addressesToCheck.add(transactionViewModel.getAddressHash())
- );
- }
- }
- }
- } catch (Exception e) {
- throw new SpentAddressesException(e);
- }
-
- //Can only throw runtime exceptions in streams
- try {
- spentAddressesProvider.saveAddressesBatch(addressesToCheck.stream()
- .filter(ThrowingPredicate.unchecked(this::wasAddressSpentFrom))
- .collect(Collectors.toList()));
- log.trace("spentAddressesService.persistSpentAddresses += 1");
- } catch (RuntimeException e) {
- if (e.getCause() instanceof SpentAddressesException) {
- throw (SpentAddressesException) e.getCause();
- } else {
- throw e;
- }
- }
-
- }
-
@Override
public void persistSpentAddresses(Collection transactions) throws SpentAddressesException {
try {
From 9795ec79e9848eb8c5494b373a6fbd8392837b30 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Mon, 28 Oct 2019 13:54:25 +0100
Subject: [PATCH 10/12] Modify logging
---
.../net/helix/pendulum/controllers/RoundViewModel.java | 6 ------
.../milestone/impl/LatestSolidMilestoneTrackerImpl.java | 7 +++++++
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/main/java/net/helix/pendulum/controllers/RoundViewModel.java b/src/main/java/net/helix/pendulum/controllers/RoundViewModel.java
index daddf779..8d72113d 100644
--- a/src/main/java/net/helix/pendulum/controllers/RoundViewModel.java
+++ b/src/main/java/net/helix/pendulum/controllers/RoundViewModel.java
@@ -269,9 +269,6 @@ public static Set getMilestoneTrunk(Tangle tangle, TransactionViewModel tr
// idx = 0 - (n-1): merkle root in branch, trunk is normal tx hash
trunk.add(transaction.getTrunkTransactionHash());
}
- if (log.isTraceEnabled()) {
- log.trace("trunk: {}", PendulumUtils.logHashList(trunk, 8));
- }
return trunk;
}
@@ -310,9 +307,6 @@ public static Set getMilestoneBranch(Tangle tangle, TransactionViewModel t
}
}
}
- if (log.isTraceEnabled()) {
- log.trace("Milestone branch: {}", PendulumUtils.logHashList(branch, 8));
- }
return branch;
}
diff --git a/src/main/java/net/helix/pendulum/service/milestone/impl/LatestSolidMilestoneTrackerImpl.java b/src/main/java/net/helix/pendulum/service/milestone/impl/LatestSolidMilestoneTrackerImpl.java
index 23f8d94f..9118e853 100644
--- a/src/main/java/net/helix/pendulum/service/milestone/impl/LatestSolidMilestoneTrackerImpl.java
+++ b/src/main/java/net/helix/pendulum/service/milestone/impl/LatestSolidMilestoneTrackerImpl.java
@@ -142,6 +142,9 @@ public void trackLatestSolidMilestones() throws MilestoneException {
try {
int currentSolidRoundIndex = snapshotProvider.getLatestSnapshot().getIndex();
RoundViewModel nextRound;
+ if (currentSolidRoundIndex < milestoneTracker.getCurrentRoundIndex()) {
+ log.delegate().trace("Current Solid Round = " + currentSolidRoundIndex + ", Current Round = " + milestoneTracker.getCurrentRoundIndex() + ", Still in Round = " + (currentSolidRoundIndex == milestoneTracker.getCurrentRoundIndex() - 1) + ", Round active = " + milestoneTracker.isRoundActive(RoundIndexUtil.getCurrentTime()));
+ }
while (!Thread.currentThread().isInterrupted() && (currentSolidRoundIndex < milestoneTracker.getCurrentRoundIndex())
&& (currentSolidRoundIndex != milestoneTracker.getCurrentRoundIndex() - 1 || !milestoneTracker.isRoundActive(RoundIndexUtil.getCurrentTime()))) {
@@ -151,19 +154,23 @@ public void trackLatestSolidMilestones() throws MilestoneException {
// round has finished without milestones
RoundViewModel latest = RoundViewModel.latest(tangle);
if (latest != null && latest.index() > currentSolidRoundIndex + 1 && isRoundSolid(latest)) {
+ log.delegate().trace("Round #" + (currentSolidRoundIndex + 1) + "has finished without milestones");
nextRound = new RoundViewModel(currentSolidRoundIndex + 1, new HashSet<>());
nextRound.store(tangle);
}
// round hasn't finished yet
else {
+ log.delegate().trace("Round #" + (currentSolidRoundIndex + 1) + "hasn't finished yet");
break;
}
}
+ log.delegate().trace("Round = " + nextRound.index() + ", solid = " + isRoundSolid(nextRound));
if (isRoundSolid(nextRound)) {
applyRoundToLedger(nextRound);
logChange(currentSolidRoundIndex);
currentSolidRoundIndex = snapshotProvider.getLatestSnapshot().getIndex();
tangle.publish("ctx %s %d", nextRound.getReferencedTransactions(tangle, nextRound.getConfirmedTips(tangle, BasePendulumConfig.Defaults.VALIDATOR_SECURITY)), nextRound.index());
+ log.delegate().trace("ctx= " + nextRound.getReferencedTransactions(tangle, nextRound.getConfirmedTips(tangle, BasePendulumConfig.Defaults.VALIDATOR_SECURITY)) + ", round=" + nextRound.index());
}
}
} catch (Exception e) {
From 33036f90040e41da2ae0f1cfb2580a677c133093 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Mon, 28 Oct 2019 14:02:36 +0100
Subject: [PATCH 11/12] Minor logging fixes
---
.../milestone/impl/LatestSolidMilestoneTrackerImpl.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/main/java/net/helix/pendulum/service/milestone/impl/LatestSolidMilestoneTrackerImpl.java b/src/main/java/net/helix/pendulum/service/milestone/impl/LatestSolidMilestoneTrackerImpl.java
index 9118e853..e2e2a037 100644
--- a/src/main/java/net/helix/pendulum/service/milestone/impl/LatestSolidMilestoneTrackerImpl.java
+++ b/src/main/java/net/helix/pendulum/service/milestone/impl/LatestSolidMilestoneTrackerImpl.java
@@ -154,13 +154,13 @@ public void trackLatestSolidMilestones() throws MilestoneException {
// round has finished without milestones
RoundViewModel latest = RoundViewModel.latest(tangle);
if (latest != null && latest.index() > currentSolidRoundIndex + 1 && isRoundSolid(latest)) {
- log.delegate().trace("Round #" + (currentSolidRoundIndex + 1) + "has finished without milestones");
+ log.delegate().trace("Round #" + (currentSolidRoundIndex + 1) + " has finished without milestones");
nextRound = new RoundViewModel(currentSolidRoundIndex + 1, new HashSet<>());
nextRound.store(tangle);
}
// round hasn't finished yet
else {
- log.delegate().trace("Round #" + (currentSolidRoundIndex + 1) + "hasn't finished yet");
+ log.delegate().trace("Round #" + (currentSolidRoundIndex + 1) + " hasn't finished yet");
break;
}
}
From 9cd8dc832441942ac623dd3ca16495ed2a270ed1 Mon Sep 17 00:00:00 2001
From: ofo42
Date: Wed, 30 Oct 2019 17:08:51 +0100
Subject: [PATCH 12/12] Remove unused imports
---
.../service/spentaddresses/SpentAddressesService.java | 1 -
.../spentaddresses/impl/SpentAddressesServiceImpl.java | 8 --------
2 files changed, 9 deletions(-)
diff --git a/src/main/java/net/helix/pendulum/service/spentaddresses/SpentAddressesService.java b/src/main/java/net/helix/pendulum/service/spentaddresses/SpentAddressesService.java
index 8a72876e..61d05465 100644
--- a/src/main/java/net/helix/pendulum/service/spentaddresses/SpentAddressesService.java
+++ b/src/main/java/net/helix/pendulum/service/spentaddresses/SpentAddressesService.java
@@ -1,6 +1,5 @@
package net.helix.pendulum.service.spentaddresses;
-import net.helix.pendulum.conf.PendulumConfig;
import net.helix.pendulum.controllers.TransactionViewModel;
import net.helix.pendulum.model.Hash;
diff --git a/src/main/java/net/helix/pendulum/service/spentaddresses/impl/SpentAddressesServiceImpl.java b/src/main/java/net/helix/pendulum/service/spentaddresses/impl/SpentAddressesServiceImpl.java
index a332469c..26c172e1 100644
--- a/src/main/java/net/helix/pendulum/service/spentaddresses/impl/SpentAddressesServiceImpl.java
+++ b/src/main/java/net/helix/pendulum/service/spentaddresses/impl/SpentAddressesServiceImpl.java
@@ -1,24 +1,16 @@
package net.helix.pendulum.service.spentaddresses.impl;
import net.helix.pendulum.BundleValidator;
-import net.helix.pendulum.conf.BasePendulumConfig;
-import net.helix.pendulum.conf.PendulumConfig;
import net.helix.pendulum.controllers.AddressViewModel;
-import net.helix.pendulum.controllers.RoundViewModel;
-import net.helix.pendulum.controllers.TipsViewModel;
import net.helix.pendulum.controllers.TransactionViewModel;
import net.helix.pendulum.model.Hash;
-import net.helix.pendulum.model.persistables.Transaction;
import net.helix.pendulum.service.snapshot.SnapshotProvider;
-import net.helix.pendulum.service.snapshot.impl.SnapshotServiceImpl;
import net.helix.pendulum.service.spentaddresses.SpentAddressesException;
import net.helix.pendulum.service.spentaddresses.SpentAddressesProvider;
import net.helix.pendulum.service.spentaddresses.SpentAddressesService;
import net.helix.pendulum.service.tipselection.TailFinder;
import net.helix.pendulum.service.tipselection.impl.TailFinderImpl;
-import net.helix.pendulum.service.utils.RoundIndexUtil;
import net.helix.pendulum.storage.Tangle;
-import net.helix.pendulum.utils.dag.DAGHelper;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;