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

Commit f407de4

Browse files
author
Gal Rogozinski
committed
Merge branch 'release-v1.5.2'
2 parents 54ffd2a + 0797ce8 commit f407de4

39 files changed

+801
-418
lines changed

DOCKER.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

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

5-
```docker run iotaledger/iri:v1.5.1 -p 14265```
5+
```docker run iotaledger/iri:v1.5.2 -p 14265```
66

77
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.
88

99
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:
1010

11-
```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```
11+
```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```
1212

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

@@ -61,7 +61,7 @@ ExecStart=/usr/bin/docker run \
6161
-p 14265:14265 \
6262
-p 15600:15600 \
6363
-p 14600:14600/udp \
64-
iotaledger/iri:v1.5.1 \
64+
iotaledger/iri:v1.5.2 \
6565
-p 14265 \
6666
--zmq-enabled \
6767
--testnet

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM ubuntu:18.04 as local_stage_java
22
33

44
# Install Java
5-
ARG JAVA_VERSION=8u171-1
5+
ARG JAVA_VERSION=8u181-1
66
RUN \
77
apt-get update && \
88
apt-get install -y software-properties-common --no-install-recommends && \

changelog.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
1.5.2
2+
- Fail early on below max depth and don't solidify on api calls (#883)
3+
- Two new configurations added: "max-depth-tx-limit" and "--walk-validator-cache"
4+
- Replace all trit representations from int[] to byte[] (#879)
5+
16
1.5.1
27
- Update snapshot to 2018-07-09 8:00 UTC (#855)
38

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.iota</groupId>
77
<artifactId>iri</artifactId>
8-
<version>1.5.1</version>
8+
<version>1.5.2</version>
99

1010
<name>IRI</name>
1111
<description>IOTA Reference Implementation</description>

src/main/java/com/iota/iri/BundleValidator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public static List<List<TransactionViewModel>> validate(Tangle tangle, Hash tail
3131
final Sponge curlInstance = SpongeFactory.create(SpongeFactory.Mode.KERL);
3232
final Sponge addressInstance = SpongeFactory.create(SpongeFactory.Mode.KERL);
3333

34-
final int[] addressTrits = new int[TransactionViewModel.ADDRESS_TRINARY_SIZE];
35-
final int[] bundleHashTrits = new int[TransactionViewModel.BUNDLE_TRINARY_SIZE];
36-
final int[] normalizedBundle = new int[Curl.HASH_LENGTH / ISS.TRYTE_WIDTH];
37-
final int[] digestTrits = new int[Curl.HASH_LENGTH];
34+
final byte[] addressTrits = new byte[TransactionViewModel.ADDRESS_TRINARY_SIZE];
35+
final byte[] bundleHashTrits = new byte[TransactionViewModel.BUNDLE_TRINARY_SIZE];
36+
final byte[] normalizedBundle = new byte[Curl.HASH_LENGTH / ISS.TRYTE_WIDTH];
37+
final byte[] digestTrits = new byte[Curl.HASH_LENGTH];
3838

3939
MAIN_LOOP:
4040
while (true) {

src/main/java/com/iota/iri/IRI.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class IRI {
2222

2323
public static final String MAINNET_NAME = "IRI";
2424
public static final String TESTNET_NAME = "IRI Testnet";
25-
public static final String VERSION = "1.5.1";
25+
public static final String VERSION = "1.5.2";
2626

2727
public static void main(String[] args) throws Exception {
2828
// Logging is configured first before any references to Logger or LoggerFactory.
@@ -154,7 +154,8 @@ private static boolean isValidated(final Configuration configuration, final Stri
154154
final Option<Integer> milestoneStartIndex = parser.addIntegerOption("milestone-start");
155155
final Option<Integer> milestoneKeys = parser.addIntegerOption("milestone-keys");
156156
final Option<Long> snapshotTime = parser.addLongOption("snapshot-timestamp");
157-
157+
final Option<Integer> belowMaxDepthTxLimit = parser.addIntegerOption("max-depth-tx-limit");
158+
final Option<Integer> walkValidatorCacheSize = parser.addIntegerOption("walk-validator-cache");
158159

159160
try {
160161
parser.parse(args);
@@ -330,7 +331,20 @@ private static boolean isValidated(final Configuration configuration, final Stri
330331
if (vmaxPeers != null) {
331332
configuration.put(DefaultConfSettings.MAX_PEERS, vmaxPeers);
332333
}
334+
335+
final Integer belowMaxDepthLimit = parser.getOptionValue(belowMaxDepthTxLimit);
336+
if (belowMaxDepthLimit != null) {
337+
configuration.put(DefaultConfSettings.BELOW_MAX_DEPTH_TRANSACTION_LIMIT,
338+
String.valueOf(belowMaxDepthLimit));
339+
}
340+
341+
final Integer walkValidatorCache = parser.getOptionValue(walkValidatorCacheSize);
342+
if (walkValidatorCache != null) {
343+
configuration.put(DefaultConfSettings.WALK_VALIDATOR_CACHE_SIZE, String.valueOf(walkValidatorCache));
344+
}
345+
333346
return true;
347+
334348
}
335349

336350
private static void printUsage() {

src/main/java/com/iota/iri/Iota.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ public Iota(Configuration configuration) throws IOException {
6666
int milestoneStartIndex = configuration.integer(Configuration.DefaultConfSettings.MILESTONE_START_INDEX);
6767
int numKeysMilestone = configuration.integer(Configuration.DefaultConfSettings.NUMBER_OF_KEYS_IN_A_MILESTONE);
6868
double alpha = configuration.doubling(Configuration.DefaultConfSettings.TIPSELECTION_ALPHA.name());
69+
int belowMaxDepthTxLimit = configuration.integer(
70+
Configuration.DefaultConfSettings.BELOW_MAX_DEPTH_TRANSACTION_LIMIT);
71+
int walkValidatorCacheSize = configuration.integer(Configuration.DefaultConfSettings.WALK_VALIDATOR_CACHE_SIZE);
6972

7073
boolean dontValidateMilestoneSig = configuration.booling(Configuration.DefaultConfSettings
7174
.DONT_VALIDATE_TESTNET_MILESTONE_SIG);
@@ -101,7 +104,7 @@ public Iota(Configuration configuration) throws IOException {
101104
udpReceiver = new UDPReceiver(udpPort, node, configuration.integer(Configuration.DefaultConfSettings.TRANSACTION_PACKET_SIZE));
102105
ledgerValidator = new LedgerValidator(tangle, milestone, transactionRequester, messageQ);
103106
tipsSolidifier = new TipsSolidifier(tangle, transactionValidator, tipsViewModel);
104-
tipsSelector = createTipSelector(milestoneStartIndex, alpha);
107+
tipsSelector = createTipSelector(milestoneStartIndex, alpha, belowMaxDepthTxLimit, walkValidatorCacheSize);
105108
}
106109

107110
public void init() throws Exception {
@@ -198,12 +201,13 @@ private void initializeTangle() {
198201
}
199202
}
200203

201-
private TipSelector createTipSelector(int milestoneStartIndex, double alpha) {
204+
private TipSelector createTipSelector(int milestoneStartIndex, double alpha, int belowMaxDepthTxLimit,
205+
int walkValidatorCacheSize) {
202206
EntryPointSelector entryPointSelector = new EntryPointSelectorImpl(tangle, milestone, testnet, milestoneStartIndex);
203207
RatingCalculator ratingCalculator = new CumulativeWeightCalculator(tangle);
204208
TailFinder tailFinder = new TailFinderImpl(tangle);
205209
Walker walker = new WalkerAlpha(alpha, new SecureRandom(), tangle, messageQ, tailFinder);
206210
return new TipSelectorImpl(tangle, ledgerValidator, transactionValidator, entryPointSelector, ratingCalculator,
207-
walker, milestone, maxTipSearchDepth);
211+
walker, milestone, maxTipSearchDepth, belowMaxDepthTxLimit, walkValidatorCacheSize);
208212
}
209213
}

src/main/java/com/iota/iri/Milestone.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,10 @@ private Validity validateMilestone(SpongeFactory.Mode mode, TransactionViewModel
204204
&& transactionViewModel.getBranchTransactionHash().equals(transactionViewModel2.getTrunkTransactionHash())
205205
&& transactionViewModel.getBundleHash().equals(transactionViewModel2.getBundleHash())) {
206206

207-
final int[] trunkTransactionTrits = transactionViewModel.getTrunkTransactionHash().trits();
208-
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);
207+
final byte[] trunkTransactionTrits = transactionViewModel.getTrunkTransactionHash().trits();
208+
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);
209209

210-
final int[] merkleRoot = ISS.getMerkleRoot(mode, ISS.address(mode, ISS.digest(mode,
210+
final byte[] merkleRoot = ISS.getMerkleRoot(mode, ISS.address(mode, ISS.digest(mode,
211211
Arrays.copyOf(ISS.normalizedBundle(trunkTransactionTrits),
212212
ISS.NUMBER_OF_FRAGMENT_CHUNKS),
213213
signatureFragmentTrits)),

src/main/java/com/iota/iri/SignedFiles.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
public class SignedFiles {
1414

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

20-
private static boolean validateSignature(String signatureFilename, String publicKey, int depth, int index, int[] digest) throws IOException {
20+
private static boolean validateSignature(String signatureFilename, String publicKey, int depth, int index, byte[] digest) throws IOException {
2121
//validate signature
2222
SpongeFactory.Mode mode = SpongeFactory.Mode.CURLP81;
23-
int[] digests = new int[0];
24-
int[] bundle = ISS.normalizedBundle(digest);
25-
int[] root;
23+
byte[] digests = new byte[0];
24+
byte[] bundle = ISS.normalizedBundle(digest);
25+
byte[] root;
2626
int i;
2727

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

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

4141
if ((line = reader.readLine()) != null) {
42-
int[] lineTrits = Converter.allocateTritsForTrytes(line.length());
42+
byte[] lineTrits = Converter.allocateTritsForTrytes(line.length());
4343
Converter.trits(line, lineTrits, 0);
4444
root = ISS.getMerkleRoot(mode, ISS.address(mode, digests), lineTrits, 0, index, depth);
4545
} else {
4646
root = ISS.address(mode, digests);
4747
}
4848

49-
int[] pubkeyTrits = Converter.allocateTritsForTrytes(publicKey.length());
49+
byte[] pubkeyTrits = Converter.allocateTritsForTrytes(publicKey.length());
5050
Converter.trits(publicKey, pubkeyTrits, 0);
5151
return Arrays.equals(pubkeyTrits, root); // valid
5252
}
5353
}
5454

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

60-
int[] buffer = new int[Curl.HASH_LENGTH * 3];
60+
byte[] buffer = new byte[Curl.HASH_LENGTH * 3];
6161

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

72-
int[] signature = new int[Curl.HASH_LENGTH];
72+
byte[] signature = new byte[Curl.HASH_LENGTH];
7373
curl.squeeze(signature, 0, Curl.HASH_LENGTH);
7474
return signature;
7575
} catch (UncheckedIOException e) {

src/main/java/com/iota/iri/TransactionValidator.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public TransactionValidator(Tangle tangle, TipsViewModel tipsViewModel, Transact
5454

5555
public void init(boolean testnet, int mwm) {
5656
MIN_WEIGHT_MAGNITUDE = mwm;
57-
57+
5858
//lowest allowed MWM encoded in 46 bytes.
5959
if (!testnet && MIN_WEIGHT_MAGNITUDE<13){
6060
MIN_WEIGHT_MAGNITUDE = 13;
@@ -104,17 +104,17 @@ public static void runValidation(TransactionViewModel transactionViewModel, fina
104104
}
105105
}
106106

107-
public static TransactionViewModel validate(final int[] trits, int minWeightMagnitude) {
107+
public static TransactionViewModel validateTrits(final byte[] trits, int minWeightMagnitude) {
108108
TransactionViewModel transactionViewModel = new TransactionViewModel(trits, Hash.calculate(trits, 0, trits.length, SpongeFactory.create(SpongeFactory.Mode.CURLP81)));
109109
runValidation(transactionViewModel, minWeightMagnitude);
110110
return transactionViewModel;
111111
}
112-
public static TransactionViewModel validate(final byte[] bytes, int minWeightMagnitude) {
113-
return validate(bytes, minWeightMagnitude, SpongeFactory.create(SpongeFactory.Mode.CURLP81));
114112

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

117-
public static TransactionViewModel validate(final byte[] bytes, int minWeightMagnitude, Sponge curl) {
117+
public static TransactionViewModel validateBytes(final byte[] bytes, int minWeightMagnitude, Sponge curl) {
118118
TransactionViewModel transactionViewModel = new TransactionViewModel(bytes, Hash.calculate(bytes, TransactionViewModel.TRINARY_SIZE, curl));
119119
runValidation(transactionViewModel, minWeightMagnitude);
120120
return transactionViewModel;
@@ -186,7 +186,7 @@ private Runnable spawnSolidTransactionsPropagation() {
186186
for(Hash h: approvers) {
187187
TransactionViewModel tx = TransactionViewModel.fromHash(tangle, h);
188188
if(quietQuickSetSolid(tx)) {
189-
tx.update(tangle, "solid");
189+
tx.update(tangle, "solid");
190190
} else {
191191
if (transaction.isSolid()) {
192192
addSolidTransaction(hash);

src/main/java/com/iota/iri/conf/Configuration.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public class Configuration {
4848
public static final String TESTNET_PACKET_SIZE = "1653";
4949
public static final String REQ_HASH_SIZE = "46";
5050
public static final String TESTNET_REQ_HASH_SIZE = "49";
51-
51+
public static final String BELOW_MAX_DEPTH_LIMIT = "20000";
52+
public static final String WALK_VALIDATOR_CACHE = "200000";
5253

5354

5455

@@ -104,7 +105,9 @@ public enum DefaultConfSettings {
104105
TRANSACTION_PACKET_SIZE,
105106
REQUEST_HASH_SIZE,
106107
SNAPSHOT_TIME,
107-
TIPSELECTION_ALPHA
108+
TIPSELECTION_ALPHA,
109+
BELOW_MAX_DEPTH_TRANSACTION_LIMIT,
110+
WALK_VALIDATOR_CACHE_SIZE
108111
}
109112

110113

@@ -170,7 +173,8 @@ public enum DefaultConfSettings {
170173
conf.put(DefaultConfSettings.REQUEST_HASH_SIZE.name(), REQ_HASH_SIZE);
171174
conf.put(DefaultConfSettings.SNAPSHOT_TIME.name(), GLOBAL_SNAPSHOT_TIME);
172175
conf.put(DefaultConfSettings.TIPSELECTION_ALPHA.name(), "0.001");
173-
176+
conf.put(DefaultConfSettings.BELOW_MAX_DEPTH_TRANSACTION_LIMIT.name(), BELOW_MAX_DEPTH_LIMIT);
177+
conf.put(DefaultConfSettings.WALK_VALIDATOR_CACHE_SIZE.name(), WALK_VALIDATOR_CACHE);
174178
}
175179

176180
public boolean init() throws IOException {

0 commit comments

Comments
 (0)