Skip to content

Commit

Permalink
Merge pull request #636 from rsksmart/0.5.0_RC
Browse files Browse the repository at this point in the history
0.5.0 release
  • Loading branch information
aeidelman authored Sep 4, 2018
2 parents 9d65b3b + d94b035 commit db78228
Show file tree
Hide file tree
Showing 348 changed files with 6,005 additions and 4,367 deletions.
11 changes: 5 additions & 6 deletions rskj-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,20 @@ tasks.withType(AbstractArchiveTask) {
ext {
slf4jVersion = '1.7.25'
leveldbVersion = '0.9'
scastleVersion = '1.52.0.0'
springVersion = '4.2.9.RELEASE'
junitVersion = '4.12'
mockitoVersion = '1.10.19'
powermockitoVersion = '1.6.4'
rskLllVersion = '0.0.2'
logbackVersion = '1.2.2'
bitcoinjVersion = '0.14.4-rsk-4'
bitcoinjVersion = '0.14.4-rsk-5'
nettyVersion = '4.0.56.Final'
}

dependencies {
compile "com.madgag.spongycastle:core:1.52.0.0"
compile "io.netty:netty-codec-http:$nettyVersion"
compile "com.madgag.spongycastle:core:${scastleVersion}" // for SHA3 and SECP256K1
compile "com.madgag.spongycastle:prov:${scastleVersion}" // for SHA3 and SECP256K1
compile "org.bouncycastle:bclcrypto-jdk15on:1.59"
compile "org.iq80.leveldb:leveldb:${leveldbVersion}"
compile "org.fusesource.leveldbjni:leveldbjni:1.8"
compile "org.ethereum:leveldbjni-all:1.18.3"
Expand Down Expand Up @@ -117,7 +116,7 @@ dependencyVerification {
'aopalliance:aopalliance:0addec670fedcd3f113c5c8091d783280d23f75e3acb841b61a9cdb079376a08',
'ch.qos.logback:logback-classic:48ade385bbae0222b2934b65738892117d8cb8366b3a3df442d3826c11cedff1',
'ch.qos.logback:logback-core:280be7a9327e7434d214d6b9eb881c083c3e057a22d0ed7663a7ce81a718a494',
'co.rsk.bitcoinj:bitcoinj-thin:4535d56e40a2cc67dde3b807a2dbb3e6763b996ee0d4184c4d87aa141edf7c19',
'co.rsk.bitcoinj:bitcoinj-thin:dd2cc70c2b37c2d76467bbc2bc69c926df388181ccb9aa333ec2b6b433ea1490',
'co.rsk:lll-compiler:a645fdb272f56721761f65dd32caa952453efc07d98d292259d99353b6f647d0',
'com.fasterxml.jackson.core:jackson-annotations:4caf3936315439b509b8c3ef494d4e47eaa6d25c3b5299aadb0eafb3944ed32f',
'com.fasterxml.jackson.core:jackson-core:256ff34118ab292d1b4f3ee4d2c3e5e5f0f609d8e07c57e8ad1f51c46d4fbb46',
Expand All @@ -130,7 +129,6 @@ dependencyVerification {
'com.h2database:h2:b1cf34c64871014aa73580281cc464dfa72450d8860cc0752fc175e87edd6544',
'com.lambdaworks:scrypt:9a82d218099fb14c10c0e86e7eefeebd8c104de920acdc47b8b4b7a686fb73b4',
'com.madgag.spongycastle:core:07a401edbe26e1028e2324754557b741cc57306008df7b71a9e12ec32d65be8f',
'com.madgag.spongycastle:prov:becbb70797b0103517693d2a97ce93174cc4d1f732897ed965a24e32dd99503e',
'com.squareup.okhttp:okhttp:b4c943138fcef2bcc9d2006b2250c4aabbedeafc5947ed7c0af7fd103ceb2707',
'com.squareup.okio:okio:114bdc1f47338a68bcbc95abf2f5cdc72beeec91812f2fcd7b521c1937876266',
'com.typesafe:config:b5f1d6071f1548d05be82f59f9039c7d37a1787bd8e3c677e31ee275af4a4621',
Expand All @@ -147,6 +145,7 @@ dependencyVerification {
'org.apache.commons:commons-collections4:b1fe8b5968b57d8465425357ed2d9dc695504518bed2df5b565c4b8e68c1c8a5',
'org.apache.commons:commons-lang3:8ac96fc686512d777fca85e144f196cd7cfe0c0aec23127229497d1a38ff651c',
'org.awaitility:awaitility:a02982e89585a52c1c84296a895bfeb86ea250cca1a53bcfc8a14092fffa87c4',
'org.bouncycastle:bclcrypto-jdk15on:7d03ba37df4d0ddc4ea40d56554324c6f18062a930edadb0a1b3acbbbea28efc',
'org.ethereum:leveldbjni-all:18da00444c77080d4422b16c9d4750c4addabda350b702b4a6d628b86658e585',
'org.fusesource.hawtjni:hawtjni-runtime:74fe9764e1fb1ef20b159dbca2d29abd6de292082ce3fcf538f81ac912390416',
'org.fusesource.leveldbjni:leveldbjni:05fe3a006d030aaf8d1e43f6c640a85f9f6b967c4499ce1ad5055ac236c3b944',
Expand Down
2 changes: 1 addition & 1 deletion rskj-core/src/main/java/co/rsk/DoPrune.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.ethereum.vm.PrecompiledContracts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongycastle.util.encoders.Hex;
import org.bouncycastle.util.encoders.Hex;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
Expand Down
2 changes: 1 addition & 1 deletion rskj-core/src/main/java/co/rsk/GenNodeKeyId.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import org.ethereum.crypto.ECKey;
import org.ethereum.crypto.HashUtil;
import org.spongycastle.util.encoders.Hex;
import org.bouncycastle.util.encoders.Hex;

import java.nio.charset.StandardCharsets;

Expand Down
2 changes: 1 addition & 1 deletion rskj-core/src/main/java/co/rsk/blocks/FileBlockPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.ethereum.core.Block;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongycastle.util.encoders.Hex;
import org.bouncycastle.util.encoders.Hex;

import java.io.BufferedReader;
import java.io.FileReader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.ethereum.core.Block;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongycastle.util.encoders.Hex;
import org.bouncycastle.util.encoders.Hex;

import java.io.BufferedWriter;
import java.io.FileWriter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import co.rsk.peg.Federation;
import com.google.common.collect.Lists;
import org.ethereum.crypto.ECKey;
import org.spongycastle.util.encoders.Hex;
import org.bouncycastle.util.encoders.Hex;

import java.time.Instant;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import co.rsk.peg.Federation;
import com.google.common.collect.Lists;
import org.ethereum.crypto.ECKey;
import org.spongycastle.util.encoders.Hex;
import org.bouncycastle.util.encoders.Hex;

import java.time.Instant;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import com.google.common.collect.Lists;
import org.ethereum.crypto.ECKey;
import org.ethereum.crypto.HashUtil;
import org.spongycastle.util.encoders.Hex;
import org.bouncycastle.util.encoders.Hex;

import java.nio.charset.StandardCharsets;
import java.time.Instant;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import co.rsk.peg.Federation;
import com.google.common.collect.Lists;
import org.ethereum.crypto.ECKey;
import org.spongycastle.util.encoders.Hex;
import org.bouncycastle.util.encoders.Hex;

import java.time.Instant;
import java.util.Arrays;
Expand Down
1 change: 1 addition & 0 deletions rskj-core/src/main/java/co/rsk/config/RemascConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@ public long getPunishmentDivisor() {
public long getPublishersDivisor() {
return publishersDivisor;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public RskSystemProperties(ConfigLoader loader) {
@Nullable
public RskAddress coinbaseAddress() {
if (!isMinerServerEnabled()) {
return RskAddress.nullAddress();
//todo(diegoll): we should carefully handle the case when you don't have a coinbase and want to execute pending blocks
return new RskAddress(new byte[20]);
}

// validity checks are performed by localCoinbaseAccount
Expand Down
8 changes: 0 additions & 8 deletions rskj-core/src/main/java/co/rsk/core/BlockDifficulty.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ public class BlockDifficulty implements Comparable<BlockDifficulty>, Serializabl

private final BigInteger value;

/**
* @param bytes the difficulty bytes, as expected by {@link java.math.BigInteger#BigInteger(byte[])}.
* Since we previously converted an empty array to ZERO, we'll do that here too.
*/
public BlockDifficulty(byte[] bytes) {
this(bytes.length == 0 ? BigInteger.ZERO : new BigInteger(bytes));
}

/**
* @param value the difficulty value, which should be positive.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.ethereum.vm.PrecompiledContracts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongycastle.util.encoders.Hex;
import org.bouncycastle.util.encoders.Hex;

import java.io.BufferedWriter;
import java.io.File;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public ProgramResult executeTransaction(
byte[] toAddress,
byte[] value,
byte[] data,
byte[] fromAddress) {
RskAddress fromAddress) {
Repository repository = track.getSnapshotTo(executionBlock.getStateRoot()).startTracking();

byte[] nonce = repository.getNonce(new RskAddress(fromAddress)).toByteArray();
byte[] nonce = repository.getNonce(fromAddress).toByteArray();
UnsignedTransaction tx = new UnsignedTransaction(
nonce,
gasPrice,
Expand Down Expand Up @@ -108,9 +108,9 @@ private UnsignedTransaction(
byte[] receiveAddress,
byte[] value,
byte[] data,
byte[] fromAddress) {
RskAddress fromAddress) {
super(nonce, gasPrice, gasLimit, receiveAddress, value, data);
this.sender = new RskAddress(fromAddress);
this.sender = fromAddress;
}

@Override
Expand Down
11 changes: 9 additions & 2 deletions rskj-core/src/main/java/co/rsk/core/RskAddress.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.google.common.primitives.UnsignedBytes;
import org.ethereum.rpc.TypeConverter;
import org.ethereum.vm.DataWord;
import org.spongycastle.util.encoders.Hex;
import org.bouncycastle.util.encoders.Hex;

import java.util.Arrays;
import java.util.Comparator;
Expand All @@ -39,7 +39,7 @@ public class RskAddress {
*/
private static final int LENGTH_IN_BYTES = 20;

private static final RskAddress NULL_ADDRESS = new RskAddress(new byte[LENGTH_IN_BYTES]);
private static final RskAddress NULL_ADDRESS = new RskAddress();

/**
* This compares using the lexicographical order of the sender unsigned bytes.
Expand Down Expand Up @@ -75,6 +75,13 @@ public RskAddress(byte[] bytes) {
this.bytes = bytes;
}

/**
* This instantiates the contract creation address.
*/
private RskAddress() {
this.bytes = new byte[0];
}

/**
* @return the null address, which is the receiver of contract creation transactions.
*/
Expand Down
2 changes: 1 addition & 1 deletion rskj-core/src/main/java/co/rsk/core/Wallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.ethereum.crypto.Keccak256Helper;
import org.ethereum.datasource.KeyValueDataSource;
import org.ethereum.rpc.TypeConverter;
import org.spongycastle.crypto.params.KeyParameter;
import org.bouncycastle.crypto.params.KeyParameter;

import javax.annotation.concurrent.GuardedBy;
import java.io.*;
Expand Down
2 changes: 1 addition & 1 deletion rskj-core/src/main/java/co/rsk/core/bc/BlockExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.ethereum.vm.program.invoke.ProgramInvokeFactoryImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongycastle.util.encoders.Hex;
import org.bouncycastle.util.encoders.Hex;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ private Block createFakePendingBlock(Block best) {
// creating fake lightweight calculated block with no hashes calculations
return new Block(best.getHash().getBytes(),
emptyUncleHashList, // uncleHash
RskAddress.nullAddress().getBytes(), //coinbase
new byte[20], //coinbase
new byte[32], // log bloom - from tx receipts
best.getDifficulty().getBytes(), // difficulty
best.getNumber() + 1, //number
Expand Down
2 changes: 1 addition & 1 deletion rskj-core/src/main/java/co/rsk/crypto/Keccak256.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.google.common.primitives.Ints;
import org.ethereum.rpc.TypeConverter;
import org.ethereum.util.ByteUtil;
import org.spongycastle.util.encoders.Hex;
import org.bouncycastle.util.encoders.Hex;

import java.io.Serializable;
import java.util.Arrays;
Expand Down
2 changes: 1 addition & 1 deletion rskj-core/src/main/java/co/rsk/crypto/KeyCrypter.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

package co.rsk.crypto;

import org.spongycastle.crypto.params.KeyParameter;
import org.bouncycastle.crypto.params.KeyParameter;

import java.io.Serializable;

Expand Down
16 changes: 8 additions & 8 deletions rskj-core/src/main/java/co/rsk/crypto/KeyCrypterAes.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@

package co.rsk.crypto;

import org.spongycastle.crypto.BufferedBlockCipher;
import org.spongycastle.crypto.engines.AESFastEngine;
import org.spongycastle.crypto.modes.CBCBlockCipher;
import org.spongycastle.crypto.paddings.PaddedBufferedBlockCipher;
import org.spongycastle.crypto.params.KeyParameter;
import org.spongycastle.crypto.params.ParametersWithIV;
import org.bouncycastle.crypto.BufferedBlockCipher;
import org.bouncycastle.crypto.engines.AESEngine;
import org.bouncycastle.crypto.modes.CBCBlockCipher;
import org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.crypto.params.ParametersWithIV;

import java.security.SecureRandom;
import java.util.Arrays;
Expand Down Expand Up @@ -77,7 +77,7 @@ public EncryptedData encrypt(byte[] plainBytes, KeyParameter key) {
ParametersWithIV keyWithIv = new ParametersWithIV(key, iv);

// Encrypt using AES.
BufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine()));
BufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESEngine()));
cipher.init(true, keyWithIv);
byte[] encryptedBytes = new byte[cipher.getOutputSize(plainBytes.length)];
final int length1 = cipher.processBytes(plainBytes, 0, plainBytes.length, encryptedBytes, 0);
Expand Down Expand Up @@ -106,7 +106,7 @@ public byte[] decrypt(EncryptedData dataToDecrypt, KeyParameter key) {
ParametersWithIV keyWithIv = new ParametersWithIV(new KeyParameter(key.getKey()), dataToDecrypt.initialisationVector);

// Decrypt the message.
BufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESFastEngine()));
BufferedBlockCipher cipher = new PaddedBufferedBlockCipher(new CBCBlockCipher(new AESEngine()));
cipher.init(false, keyWithIv);

byte[] cipherBytes = dataToDecrypt.encryptedBytes;
Expand Down
4 changes: 2 additions & 2 deletions rskj-core/src/main/java/co/rsk/db/ContractDetailsImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
import org.ethereum.vm.DataWord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongycastle.pqc.math.linearalgebra.ByteUtils;
import org.spongycastle.util.encoders.Hex;
import org.bouncycastle.pqc.math.linearalgebra.ByteUtils;
import org.bouncycastle.util.encoders.Hex;

import javax.annotation.Nullable;
import java.util.*;
Expand Down
12 changes: 12 additions & 0 deletions rskj-core/src/main/java/co/rsk/db/RemascCache.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package co.rsk.db;

import co.rsk.crypto.Keccak256;
import co.rsk.remasc.Sibling;

import java.util.List;
import java.util.Map;

public interface RemascCache {

Map<Long, List<Sibling>> getSiblingsFromBlockByHash(Keccak256 hash);
}
2 changes: 1 addition & 1 deletion rskj-core/src/main/java/co/rsk/db/RepositoryImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.ethereum.vm.DataWord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongycastle.util.encoders.Hex;
import org.bouncycastle.util.encoders.Hex;

import javax.annotation.Nonnull;
import java.math.BigInteger;
Expand Down
Loading

0 comments on commit db78228

Please sign in to comment.