Skip to content

Commit

Permalink
Merge branch 'release-v1.5.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gal Rogozinski committed Aug 2, 2018
2 parents f407de4 + 42a8f6f commit d195cc7
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 85 deletions.
6 changes: 3 additions & 3 deletions DOCKER.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

Run the official iotaledger/iri container, passing the mandatory -p option:

```docker run iotaledger/iri:v1.5.2 -p 14265```
```docker run iotaledger/iri:v1.5.3 -p 14265```

This will get your a running IRI with its API listening on port 14265, no neighbours and an empty database. The IRI Docker container by default expects data at /iri/data. Use the `-v` option of the `docker run` command to mount volumes so to have persistent data. You can also pass more command line options to the docker run command and those will be passed to IRI.

If you want to use a iri.ini file with the docker container, supposing it's stored under /path/to/conf/iri.ini on your docker host, then pass `-v /path/to/conf:/iri/conf` and add -c /iri/conf/iri.ini as docker run arguments. So for example the `docker run` command above would become:

```docker run -v /path/to/conf:/iri/conf -v /path/to/data:/iri/data iotaledger/iri:v1.5.2 -p 14265 -c /iri/conf/iri.ini```
```docker run -v /path/to/conf:/iri/conf -v /path/to/data:/iri/data iotaledger/iri:v1.5.3 -p 14265 -c /iri/conf/iri.ini```

Please refer to the IRI documentation for further command line options and iri.ini options.

Expand Down Expand Up @@ -61,7 +61,7 @@ ExecStart=/usr/bin/docker run \
-p 14265:14265 \
-p 15600:15600 \
-p 14600:14600/udp \
iotaledger/iri:v1.5.2 \
iotaledger/iri:v1.5.3 \
-p 14265 \
--zmq-enabled \
--testnet
Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
1.5.3
- Remove WalkValidator cache of tips that are below max depth (#903)

1.5.2
- Fail early on below max depth and don't solidify on api calls (#883)
- Two new configurations added: "max-depth-tx-limit" and "--walk-validator-cache"
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.iota</groupId>
<artifactId>iri</artifactId>
<version>1.5.2</version>
<version>1.5.3</version>

<name>IRI</name>
<description>IOTA Reference Implementation</description>
Expand Down
15 changes: 1 addition & 14 deletions src/main/java/com/iota/iri/IRI.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class IRI {

public static final String MAINNET_NAME = "IRI";
public static final String TESTNET_NAME = "IRI Testnet";
public static final String VERSION = "1.5.2";
public static final String VERSION = "1.5.3";

public static void main(String[] args) throws Exception {
// Logging is configured first before any references to Logger or LoggerFactory.
Expand Down Expand Up @@ -155,7 +155,6 @@ private static boolean isValidated(final Configuration configuration, final Stri
final Option<Integer> milestoneKeys = parser.addIntegerOption("milestone-keys");
final Option<Long> snapshotTime = parser.addLongOption("snapshot-timestamp");
final Option<Integer> belowMaxDepthTxLimit = parser.addIntegerOption("max-depth-tx-limit");
final Option<Integer> walkValidatorCacheSize = parser.addIntegerOption("walk-validator-cache");

try {
parser.parse(args);
Expand Down Expand Up @@ -332,19 +331,7 @@ private static boolean isValidated(final Configuration configuration, final Stri
configuration.put(DefaultConfSettings.MAX_PEERS, vmaxPeers);
}

final Integer belowMaxDepthLimit = parser.getOptionValue(belowMaxDepthTxLimit);
if (belowMaxDepthLimit != null) {
configuration.put(DefaultConfSettings.BELOW_MAX_DEPTH_TRANSACTION_LIMIT,
String.valueOf(belowMaxDepthLimit));
}

final Integer walkValidatorCache = parser.getOptionValue(walkValidatorCacheSize);
if (walkValidatorCache != null) {
configuration.put(DefaultConfSettings.WALK_VALIDATOR_CACHE_SIZE, String.valueOf(walkValidatorCache));
}

return true;

}

private static void printUsage() {
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/iota/iri/Iota.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ public Iota(Configuration configuration) throws IOException {
double alpha = configuration.doubling(Configuration.DefaultConfSettings.TIPSELECTION_ALPHA.name());
int belowMaxDepthTxLimit = configuration.integer(
Configuration.DefaultConfSettings.BELOW_MAX_DEPTH_TRANSACTION_LIMIT);
int walkValidatorCacheSize = configuration.integer(Configuration.DefaultConfSettings.WALK_VALIDATOR_CACHE_SIZE);

boolean dontValidateMilestoneSig = configuration.booling(Configuration.DefaultConfSettings
.DONT_VALIDATE_TESTNET_MILESTONE_SIG);
Expand Down Expand Up @@ -104,7 +103,7 @@ public Iota(Configuration configuration) throws IOException {
udpReceiver = new UDPReceiver(udpPort, node, configuration.integer(Configuration.DefaultConfSettings.TRANSACTION_PACKET_SIZE));
ledgerValidator = new LedgerValidator(tangle, milestone, transactionRequester, messageQ);
tipsSolidifier = new TipsSolidifier(tangle, transactionValidator, tipsViewModel);
tipsSelector = createTipSelector(milestoneStartIndex, alpha, belowMaxDepthTxLimit, walkValidatorCacheSize);
tipsSelector = createTipSelector(milestoneStartIndex, alpha, belowMaxDepthTxLimit);
}

public void init() throws Exception {
Expand Down Expand Up @@ -201,13 +200,12 @@ private void initializeTangle() {
}
}

private TipSelector createTipSelector(int milestoneStartIndex, double alpha, int belowMaxDepthTxLimit,
int walkValidatorCacheSize) {
private TipSelector createTipSelector(int milestoneStartIndex, double alpha, int belowMaxDepthTxLimit) {
EntryPointSelector entryPointSelector = new EntryPointSelectorImpl(tangle, milestone, testnet, milestoneStartIndex);
RatingCalculator ratingCalculator = new CumulativeWeightCalculator(tangle);
TailFinder tailFinder = new TailFinderImpl(tangle);
Walker walker = new WalkerAlpha(alpha, new SecureRandom(), tangle, messageQ, tailFinder);
return new TipSelectorImpl(tangle, ledgerValidator, transactionValidator, entryPointSelector, ratingCalculator,
walker, milestone, maxTipSearchDepth, belowMaxDepthTxLimit, walkValidatorCacheSize);
walker, milestone, maxTipSearchDepth, belowMaxDepthTxLimit);
}
}
3 changes: 0 additions & 3 deletions src/main/java/com/iota/iri/conf/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public class Configuration {
public static final String REQ_HASH_SIZE = "46";
public static final String TESTNET_REQ_HASH_SIZE = "49";
public static final String BELOW_MAX_DEPTH_LIMIT = "20000";
public static final String WALK_VALIDATOR_CACHE = "200000";



Expand Down Expand Up @@ -107,7 +106,6 @@ public enum DefaultConfSettings {
SNAPSHOT_TIME,
TIPSELECTION_ALPHA,
BELOW_MAX_DEPTH_TRANSACTION_LIMIT,
WALK_VALIDATOR_CACHE_SIZE
}


Expand Down Expand Up @@ -174,7 +172,6 @@ public enum DefaultConfSettings {
conf.put(DefaultConfSettings.SNAPSHOT_TIME.name(), GLOBAL_SNAPSHOT_TIME);
conf.put(DefaultConfSettings.TIPSELECTION_ALPHA.name(), "0.001");
conf.put(DefaultConfSettings.BELOW_MAX_DEPTH_TRANSACTION_LIMIT.name(), BELOW_MAX_DEPTH_LIMIT);
conf.put(DefaultConfSettings.WALK_VALIDATOR_CACHE_SIZE.name(), WALK_VALIDATOR_CACHE);
}

public boolean init() throws IOException {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/iota/iri/service/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,7 @@ private AbstractResponse checkConsistencyStatement(List<String> transactionsList
try {
WalkValidatorImpl walkValidator = new WalkValidatorImpl(instance.tangle, instance.ledgerValidator,
instance.transactionValidator, instance.milestone, instance.tipsSelector.getMaxDepth(),
instance.configuration.integer(DefaultConfSettings.BELOW_MAX_DEPTH_TRANSACTION_LIMIT),
instance.configuration.integer(DefaultConfSettings.WALK_VALIDATOR_CACHE_SIZE));
instance.configuration.integer(DefaultConfSettings.BELOW_MAX_DEPTH_TRANSACTION_LIMIT));
for (Hash transaction : transactions) {
if (!walkValidator.isValid(transaction)) {
state = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import com.iota.iri.service.tipselection.*;
import com.iota.iri.storage.Tangle;
import com.iota.iri.utils.collections.interfaces.UnIterableMap;
import com.iota.iri.zmq.MessageQ;

import java.security.InvalidAlgorithmParameterException;
import java.security.SecureRandom;
import java.util.*;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;

/**
* Implementation of <tt>TipSelector</tt> that selects 2 tips,
Expand All @@ -34,7 +34,6 @@ public class TipSelectorImpl implements TipSelector {
private final Tangle tangle;
private final Milestone milestone;
private final int belowMaxDepthTxLimit;
private final int validatorCacheSize;

@Override
public int getMaxDepth() {
Expand All @@ -49,8 +48,7 @@ public TipSelectorImpl(Tangle tangle,
Walker walkerAlpha,
Milestone milestone,
int maxDepth,
int belowMaxDepthTxLimit,
int validatorCacheSize) {
int belowMaxDepthTxLimit) {


this.entryPointSelector = entryPointSelector;
Expand All @@ -65,7 +63,6 @@ public TipSelectorImpl(Tangle tangle,
this.transactionValidator = transactionValidator;
this.tangle = tangle;
this.milestone = milestone;
this.validatorCacheSize = validatorCacheSize;
}

/**
Expand Down Expand Up @@ -96,7 +93,7 @@ public List<Hash> getTransactionsToApprove(int depth, Optional<Hash> reference)
//random walk
List<Hash> tips = new LinkedList<>();
WalkValidator walkValidator = new WalkValidatorImpl(tangle, ledgerValidator, transactionValidator, milestone,
maxDepth, belowMaxDepthTxLimit, validatorCacheSize);
maxDepth, belowMaxDepthTxLimit);
Hash tip = walker.walk(entryPoint, rating, walkValidator);
tips.add(tip);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@
import com.iota.iri.model.Hash;
import com.iota.iri.service.tipselection.WalkValidator;
import com.iota.iri.storage.Tangle;
import com.iota.iri.utils.collections.impl.BoundedSetWrapper;
import com.iota.iri.utils.collections.interfaces.BoundedSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;
import java.util.concurrent.ConcurrentSkipListSet;

/**
* Implementation of <tt>WalkValidator</tt> that checks consistency of the ledger as part of validity checks.
Expand All @@ -29,9 +26,6 @@
*/
public class WalkValidatorImpl implements WalkValidator {

public static final int INITIAL_CACHE_CAPACITY = 10_000;
//As long as tip selection is synchronized we are fine with the collection not being thread safe
static BoundedSet<Hash> failedBelowMaxDepthCache;
private int maxAnalyzedTxs;

private final Tangle tangle;
Expand All @@ -47,28 +41,19 @@ public class WalkValidatorImpl implements WalkValidator {
private Set<Hash> myApprovedHashes;

public WalkValidatorImpl(Tangle tangle, LedgerValidator ledgerValidator, TransactionValidator transactionValidator,
Milestone milestone, int maxDepth, int maxAnalyzedTxs, int cacheSize) {
Milestone milestone, int maxDepth, int maxAnalyzedTxs) {
this.tangle = tangle;
this.ledgerValidator = ledgerValidator;
this.transactionValidator = transactionValidator;
this.milestone = milestone;
this.maxDepth = maxDepth;
this.maxAnalyzedTxs = maxAnalyzedTxs;

failedBelowMaxDepthCache = fetchCache(cacheSize);
maxDepthOkMemoization = new HashSet<>();
myDiff = new HashMap<>();
myApprovedHashes = new HashSet<>();
}

private BoundedSet<Hash> fetchCache(int cacheSize) {
if (failedBelowMaxDepthCache == null) {
failedBelowMaxDepthCache = new BoundedSetWrapper<>(
new ConcurrentSkipListSet<>(), cacheSize);
}
return failedBelowMaxDepthCache;
}

@Override
public boolean isValid(Hash transactionHash) throws Exception {

Expand Down Expand Up @@ -102,23 +87,16 @@ private boolean belowMaxDepth(Hash tip, int lowerAllowedSnapshotIndex) throws Ex
Set<Hash> analyzedTransactions = new HashSet<>();
Hash hash;
while ((hash = nonAnalyzedTransactions.poll()) != null) {
if (failedBelowMaxDepthCache.contains(hash)) {
log.debug("failed below max depth because of a previously failed tx cache hit");
updateCache(analyzedTransactions);
return true;
}
if (analyzedTransactions.size() == maxAnalyzedTxs) {
log.debug("failed below max depth because of exceeding max threshold of {} analyzed transactions",
maxAnalyzedTxs);
updateCache(analyzedTransactions);
return true;
}

if (analyzedTransactions.add(hash)) {
TransactionViewModel transaction = TransactionViewModel.fromHash(tangle, hash);
if ((transaction.snapshotIndex() != 0 || Objects.equals(Hash.NULL_HASH, transaction.getHash()))
&& transaction.snapshotIndex() < lowerAllowedSnapshotIndex) {
updateCache(analyzedTransactions);
log.debug("failed below max depth because of reaching a tx below the allowed snapshot index {}",
lowerAllowedSnapshotIndex);
return true;
Expand All @@ -134,9 +112,4 @@ private boolean belowMaxDepth(Hash tip, int lowerAllowedSnapshotIndex) throws Ex
maxDepthOkMemoization.add(tip);
return false;
}

private void updateCache(Set<Hash> txsToBeAdded) {
failedBelowMaxDepthCache.addAll(txsToBeAdded);
}

}
Loading

0 comments on commit d195cc7

Please sign in to comment.