Skip to content
This repository has been archived by the owner on Aug 23, 2020. It is now read-only.

Commit

Permalink
Merge branch 'release-v1.5.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gal Rogozinski committed Jul 25, 2018
2 parents 54ffd2a + 0797ce8 commit f407de4
Show file tree
Hide file tree
Showing 39 changed files with 801 additions and 418 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.1 -p 14265```
```docker run iotaledger/iri:v1.5.2 -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.1 -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.2 -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.1 \
iotaledger/iri:v1.5.2 \
-p 14265 \
--zmq-enabled \
--testnet
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM ubuntu:18.04 as local_stage_java
MAINTAINER [email protected]

# Install Java
ARG JAVA_VERSION=8u171-1
ARG JAVA_VERSION=8u181-1
RUN \
apt-get update && \
apt-get install -y software-properties-common --no-install-recommends && \
Expand Down
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
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"
- Replace all trit representations from int[] to byte[] (#879)

1.5.1
- Update snapshot to 2018-07-09 8:00 UTC (#855)

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.1</version>
<version>1.5.2</version>

<name>IRI</name>
<description>IOTA Reference Implementation</description>
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/iota/iri/BundleValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public static List<List<TransactionViewModel>> validate(Tangle tangle, Hash tail
final Sponge curlInstance = SpongeFactory.create(SpongeFactory.Mode.KERL);
final Sponge addressInstance = SpongeFactory.create(SpongeFactory.Mode.KERL);

final int[] addressTrits = new int[TransactionViewModel.ADDRESS_TRINARY_SIZE];
final int[] bundleHashTrits = new int[TransactionViewModel.BUNDLE_TRINARY_SIZE];
final int[] normalizedBundle = new int[Curl.HASH_LENGTH / ISS.TRYTE_WIDTH];
final int[] digestTrits = new int[Curl.HASH_LENGTH];
final byte[] addressTrits = new byte[TransactionViewModel.ADDRESS_TRINARY_SIZE];
final byte[] bundleHashTrits = new byte[TransactionViewModel.BUNDLE_TRINARY_SIZE];
final byte[] normalizedBundle = new byte[Curl.HASH_LENGTH / ISS.TRYTE_WIDTH];
final byte[] digestTrits = new byte[Curl.HASH_LENGTH];

MAIN_LOOP:
while (true) {
Expand Down
18 changes: 16 additions & 2 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.1";
public static final String VERSION = "1.5.2";

public static void main(String[] args) throws Exception {
// Logging is configured first before any references to Logger or LoggerFactory.
Expand Down Expand Up @@ -154,7 +154,8 @@ private static boolean isValidated(final Configuration configuration, final Stri
final Option<Integer> milestoneStartIndex = parser.addIntegerOption("milestone-start");
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 @@ -330,7 +331,20 @@ private static boolean isValidated(final Configuration configuration, final Stri
if (vmaxPeers != null) {
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
10 changes: 7 additions & 3 deletions src/main/java/com/iota/iri/Iota.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ public Iota(Configuration configuration) throws IOException {
int milestoneStartIndex = configuration.integer(Configuration.DefaultConfSettings.MILESTONE_START_INDEX);
int numKeysMilestone = configuration.integer(Configuration.DefaultConfSettings.NUMBER_OF_KEYS_IN_A_MILESTONE);
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 @@ -101,7 +104,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);
tipsSelector = createTipSelector(milestoneStartIndex, alpha, belowMaxDepthTxLimit, walkValidatorCacheSize);
}

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

private TipSelector createTipSelector(int milestoneStartIndex, double alpha) {
private TipSelector createTipSelector(int milestoneStartIndex, double alpha, int belowMaxDepthTxLimit,
int walkValidatorCacheSize) {
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);
walker, milestone, maxTipSearchDepth, belowMaxDepthTxLimit, walkValidatorCacheSize);
}
}
6 changes: 3 additions & 3 deletions src/main/java/com/iota/iri/Milestone.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ private Validity validateMilestone(SpongeFactory.Mode mode, TransactionViewModel
&& transactionViewModel.getBranchTransactionHash().equals(transactionViewModel2.getTrunkTransactionHash())
&& transactionViewModel.getBundleHash().equals(transactionViewModel2.getBundleHash())) {

final int[] trunkTransactionTrits = transactionViewModel.getTrunkTransactionHash().trits();
final int[] signatureFragmentTrits = Arrays.copyOfRange(transactionViewModel.trits(), TransactionViewModel.SIGNATURE_MESSAGE_FRAGMENT_TRINARY_OFFSET, TransactionViewModel.SIGNATURE_MESSAGE_FRAGMENT_TRINARY_OFFSET + TransactionViewModel.SIGNATURE_MESSAGE_FRAGMENT_TRINARY_SIZE);
final byte[] trunkTransactionTrits = transactionViewModel.getTrunkTransactionHash().trits();
final byte[] signatureFragmentTrits = Arrays.copyOfRange(transactionViewModel.trits(), TransactionViewModel.SIGNATURE_MESSAGE_FRAGMENT_TRINARY_OFFSET, TransactionViewModel.SIGNATURE_MESSAGE_FRAGMENT_TRINARY_OFFSET + TransactionViewModel.SIGNATURE_MESSAGE_FRAGMENT_TRINARY_SIZE);

final int[] merkleRoot = ISS.getMerkleRoot(mode, ISS.address(mode, ISS.digest(mode,
final byte[] merkleRoot = ISS.getMerkleRoot(mode, ISS.address(mode, ISS.digest(mode,
Arrays.copyOf(ISS.normalizedBundle(trunkTransactionTrits),
ISS.NUMBER_OF_FRAGMENT_CHUNKS),
signatureFragmentTrits)),
Expand Down
28 changes: 14 additions & 14 deletions src/main/java/com/iota/iri/SignedFiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
public class SignedFiles {

public static boolean isFileSignatureValid(String filename, String signatureFilename, String publicKey, int depth, int index) throws IOException {
int[] signature = digestFile(filename, SpongeFactory.create(SpongeFactory.Mode.KERL));
byte[] signature = digestFile(filename, SpongeFactory.create(SpongeFactory.Mode.KERL));
return validateSignature(signatureFilename, publicKey, depth, index, signature);
}

private static boolean validateSignature(String signatureFilename, String publicKey, int depth, int index, int[] digest) throws IOException {
private static boolean validateSignature(String signatureFilename, String publicKey, int depth, int index, byte[] digest) throws IOException {
//validate signature
SpongeFactory.Mode mode = SpongeFactory.Mode.CURLP81;
int[] digests = new int[0];
int[] bundle = ISS.normalizedBundle(digest);
int[] root;
byte[] digests = new byte[0];
byte[] bundle = ISS.normalizedBundle(digest);
byte[] root;
int i;

try (InputStream inputStream = SignedFiles.class.getResourceAsStream(signatureFilename);
Expand All @@ -31,33 +31,33 @@ private static boolean validateSignature(String signatureFilename, String public

String line;
for (i = 0; i < 3 && (line = reader.readLine()) != null; i++) {
int[] lineTrits = Converter.allocateTritsForTrytes(line.length());
byte[] lineTrits = Converter.allocateTritsForTrytes(line.length());
Converter.trits(line, lineTrits, 0);
int[] normalizedBundleFragment = Arrays.copyOfRange(bundle, i * ISS.NORMALIZED_FRAGMENT_LENGTH, (i + 1) * ISS.NORMALIZED_FRAGMENT_LENGTH);
int[] issDigest = ISS.digest(mode, normalizedBundleFragment, lineTrits);
byte[] normalizedBundleFragment = Arrays.copyOfRange(bundle, i * ISS.NORMALIZED_FRAGMENT_LENGTH, (i + 1) * ISS.NORMALIZED_FRAGMENT_LENGTH);
byte[] issDigest = ISS.digest(mode, normalizedBundleFragment, lineTrits);
digests = ArrayUtils.addAll(digests, issDigest);
}

if ((line = reader.readLine()) != null) {
int[] lineTrits = Converter.allocateTritsForTrytes(line.length());
byte[] lineTrits = Converter.allocateTritsForTrytes(line.length());
Converter.trits(line, lineTrits, 0);
root = ISS.getMerkleRoot(mode, ISS.address(mode, digests), lineTrits, 0, index, depth);
} else {
root = ISS.address(mode, digests);
}

int[] pubkeyTrits = Converter.allocateTritsForTrytes(publicKey.length());
byte[] pubkeyTrits = Converter.allocateTritsForTrytes(publicKey.length());
Converter.trits(publicKey, pubkeyTrits, 0);
return Arrays.equals(pubkeyTrits, root); // valid
}
}

private static int[] digestFile(String filename, Sponge curl) throws IOException {
private static byte[] digestFile(String filename, Sponge curl) throws IOException {
try (InputStream inputStream = SignedFiles.class.getResourceAsStream(filename);
BufferedReader reader = new BufferedReader((inputStream == null)
? new FileReader(filename) : new InputStreamReader(inputStream))) {

int[] buffer = new int[Curl.HASH_LENGTH * 3];
byte[] buffer = new byte[Curl.HASH_LENGTH * 3];

reader.lines().forEach(line -> {
String trytes = Converter.asciiToTrytes(line); // can return a null
Expand All @@ -66,10 +66,10 @@ private static int[] digestFile(String filename, Sponge curl) throws IOException
}
Converter.trits(trytes, buffer, 0);
curl.absorb(buffer, 0, buffer.length);
Arrays.fill(buffer, 0);
Arrays.fill(buffer, (byte) 0);
});

int[] signature = new int[Curl.HASH_LENGTH];
byte[] signature = new byte[Curl.HASH_LENGTH];
curl.squeeze(signature, 0, Curl.HASH_LENGTH);
return signature;
} catch (UncheckedIOException e) {
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/iota/iri/TransactionValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public TransactionValidator(Tangle tangle, TipsViewModel tipsViewModel, Transact

public void init(boolean testnet, int mwm) {
MIN_WEIGHT_MAGNITUDE = mwm;

//lowest allowed MWM encoded in 46 bytes.
if (!testnet && MIN_WEIGHT_MAGNITUDE<13){
MIN_WEIGHT_MAGNITUDE = 13;
Expand Down Expand Up @@ -104,17 +104,17 @@ public static void runValidation(TransactionViewModel transactionViewModel, fina
}
}

public static TransactionViewModel validate(final int[] trits, int minWeightMagnitude) {
public static TransactionViewModel validateTrits(final byte[] trits, int minWeightMagnitude) {
TransactionViewModel transactionViewModel = new TransactionViewModel(trits, Hash.calculate(trits, 0, trits.length, SpongeFactory.create(SpongeFactory.Mode.CURLP81)));
runValidation(transactionViewModel, minWeightMagnitude);
return transactionViewModel;
}
public static TransactionViewModel validate(final byte[] bytes, int minWeightMagnitude) {
return validate(bytes, minWeightMagnitude, SpongeFactory.create(SpongeFactory.Mode.CURLP81));

public static TransactionViewModel validateBytes(final byte[] bytes, int minWeightMagnitude) {
return validateBytes(bytes, minWeightMagnitude, SpongeFactory.create(SpongeFactory.Mode.CURLP81));
}

public static TransactionViewModel validate(final byte[] bytes, int minWeightMagnitude, Sponge curl) {
public static TransactionViewModel validateBytes(final byte[] bytes, int minWeightMagnitude, Sponge curl) {
TransactionViewModel transactionViewModel = new TransactionViewModel(bytes, Hash.calculate(bytes, TransactionViewModel.TRINARY_SIZE, curl));
runValidation(transactionViewModel, minWeightMagnitude);
return transactionViewModel;
Expand Down Expand Up @@ -186,7 +186,7 @@ private Runnable spawnSolidTransactionsPropagation() {
for(Hash h: approvers) {
TransactionViewModel tx = TransactionViewModel.fromHash(tangle, h);
if(quietQuickSetSolid(tx)) {
tx.update(tangle, "solid");
tx.update(tangle, "solid");
} else {
if (transaction.isSolid()) {
addSolidTransaction(hash);
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/com/iota/iri/conf/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public class Configuration {
public static final String TESTNET_PACKET_SIZE = "1653";
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 @@ -104,7 +105,9 @@ public enum DefaultConfSettings {
TRANSACTION_PACKET_SIZE,
REQUEST_HASH_SIZE,
SNAPSHOT_TIME,
TIPSELECTION_ALPHA
TIPSELECTION_ALPHA,
BELOW_MAX_DEPTH_TRANSACTION_LIMIT,
WALK_VALIDATOR_CACHE_SIZE
}


Expand Down Expand Up @@ -170,7 +173,8 @@ public enum DefaultConfSettings {
conf.put(DefaultConfSettings.REQUEST_HASH_SIZE.name(), REQ_HASH_SIZE);
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
Loading

0 comments on commit f407de4

Please sign in to comment.