Skip to content

Commit

Permalink
Merge pull request tronprotocol#2 from tronprotocol/develop
Browse files Browse the repository at this point in the history
synchronize code
  • Loading branch information
Parachuteuk authored Nov 29, 2019
2 parents b72c473 + 00551d6 commit 0435534
Show file tree
Hide file tree
Showing 26 changed files with 100 additions and 372 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ matrix:


after_success:
- "bash <(curl -s https://codecov.io/bash) -t $codecov_token_key -s framework/build/reports/jacoco/"
- "bash <(curl -s https://codecov.io/bash) -s framework/build/reports/jacoco/"

skip_build:
- README.md:
Expand Down
28 changes: 24 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,23 @@ please let us know if anything feels wrong or incomplete.

### Pull requests

First of all, java-tron follows [gitflow workflow](
https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow).
Please open pull requests to the **develop** branch. Once approved,
we will close the pull request and merge into master branch.
First of all, java-tron follows GitFlow, The overall flow of Gitflow is:

1. A develop branch is created from master
2. A release branch is created from develop
3. Feature branches are created from develop
4. When a feature is completed it is merged into the develop branch
5. When the release branch is done it is merged into develop and master
6. If an issue in master is detected a hotfix branch is created from master
7. Once the hotfix is complete it is merged to both develop and master


If you'd like to contribute to java-tron, please fork a repository from tronprotocol/java-tron,
fix, commit, and send a pull request for the maintainers to review and merge into the main code base.

Please open pull requests(PR) to the **develop** branch. After the PR is valided by our Sonar check or Travis CI check,
we maintainers will review the code changed and give some advices for modifying if necessary.Once approved,
we will close the PR and merge into the protocol/java-tron's develop branch.

We are always happy to receive pull requests, and do our best to
review them as fast as possible. Not sure if that typo is worth a pull
Expand All @@ -24,6 +37,13 @@ If your pull request is not accepted on the first try, don't be
discouraged as it can be a possible oversight. Please explain your code as
detailed as possible to make it easier for us to understand.

Please make sure your contributions adhere to our coding guidelines:

- Code must be documented adhering to the [Google Style](https://google.github.io/styleguide/javaguide.html)
- Code must pass Sonar detection.
- Pull requests need to be based on and opened against the develop branch.
- Commit messages should be started with verb, and the first letter should be a lowercase.The length of commit message
must be limited in 50 words.
### Create issues

Any significant improvement should be documented as [a GitHub
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,8 @@ public static contractResult getContractRet(Transaction transaction) {


public static long getCallValue(Transaction.Contract contract) {
int energyForTrx;
try {
Any contractParameter = contract.getParameter();
long callValue;
switch (contract.getType()) {
case TriggerSmartContract:
return contractParameter.unpack(TriggerSmartContract.class).getCallValue();
Expand All @@ -166,10 +164,8 @@ public static long getCallValue(Transaction.Contract contract) {
}

public static long getCallTokenValue(Transaction.Contract contract) {
int energyForTrx;
try {
Any contractParameter = contract.getParameter();
long callValue;
switch (contract.getType()) {
case TriggerSmartContract:
return contractParameter.unpack(TriggerSmartContract.class).getCallTokenValue();
Expand Down
13 changes: 5 additions & 8 deletions actuator/src/main/java/org/tron/core/vm/VMUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ private static File createProgramTraceFile(String txHash) {
} else {
try {
file.getParentFile().mkdirs();
file.createNewFile();
if (!file.createNewFile()){
logger.error("failed to create file {}", file.getPath());
}
result = file;
} catch (IOException e) {
// ignored
Expand Down Expand Up @@ -193,9 +195,7 @@ public static boolean validateForSmartContract(Repository deposit, byte[] ownerA
"Validate InternalTransfer error, balance is not sufficient.");
}

if (toAccount != null) {
long toAddressBalance = Math.addExact(toAccount.getBalance(), amount);
}
Math.addExact(toAccount.getBalance(), amount);
} catch (ArithmeticException e) {
logger.debug(e.getMessage(), e);
throw new ContractValidateException(e.getMessage());
Expand All @@ -210,7 +210,6 @@ public static boolean validateForSmartContract(Repository deposit, byte[] ownerA
throw new ContractValidateException("No deposit!");
}

long fee = 0;
byte[] tokenIdWithoutLeadingZero = ByteUtil.stripLeadingZeroes(tokenId);

if (!DecodeUtil.addressValid(ownerAddress)) {
Expand All @@ -219,9 +218,7 @@ public static boolean validateForSmartContract(Repository deposit, byte[] ownerA
if (!DecodeUtil.addressValid(toAddress)) {
throw new ContractValidateException("Invalid toAddress");
}
// if (!TransactionUtil.validAssetName(assetName)) {
// throw new ContractValidateException("Invalid assetName");
// }

if (amount <= 0) {
throw new ContractValidateException("Amount must greater than 0.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public class RocksDbDataSourceImpl implements DbSourceInter<byte[]>,
private boolean alive;
private String parentPath;
private ReadWriteLock resetDbLock = new ReentrantReadWriteLock();
private static final String KEY_ENGINE = "ENGINE";
private static final String ROCKSDB = "ROCKSDB";

public RocksDbDataSourceImpl(String parentPath, String name, RocksDbSettings settings) {
this.dataBaseName = name;
Expand Down Expand Up @@ -150,18 +152,13 @@ public boolean checkOrInitEngine() {
}

// for the first init engine
String engine = PropUtil.readProperty(enginePath, "ENGINE");
if (engine.equals("")) {
if (!PropUtil.writeProperty(enginePath, "ENGINE", "ROCKSDB")) {
return false;
}
}
engine = PropUtil.readProperty(enginePath, "ENGINE");
if (engine.equals("ROCKSDB")) {
return true;
} else {
String engine = PropUtil.readProperty(enginePath, KEY_ENGINE);
if (engine.isEmpty() && !PropUtil.writeProperty(enginePath, KEY_ENGINE, ROCKSDB)) {
return false;
}
engine = PropUtil.readProperty(enginePath, KEY_ENGINE);

return ROCKSDB.equals(engine);
}

public void initDB() {
Expand Down
1 change: 0 additions & 1 deletion chainbase/src/main/java/org/tron/common/utils/Commons.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
@Slf4j(topic = "Commons")
public class Commons {

public static final int ADDRESS_SIZE = 42;
public static final int ASSET_ISSUE_COUNT_LIMIT_MAX = 1000;

public static byte[] clone(byte[] value) {
Expand Down
187 changes: 0 additions & 187 deletions chainbase/src/main/java/org/tron/common/utils/Hash.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.extern.slf4j.Slf4j;
import org.tron.common.utils.ByteArray;
import org.tron.common.utils.ByteUtil;
import org.tron.common.utils.DBConfig;
import org.tron.common.zksnark.LibrustzcashParam.BindingSigParams;
import org.tron.common.zksnark.LibrustzcashParam.CheckOutputParams;
Expand Down Expand Up @@ -95,7 +96,7 @@ public static boolean librustzcashComputeNf(ComputeNfParams params) {
*/
public static byte[] librustzcashAskToAk(byte[] ask) throws ZksnarkException {
if (!isOpenZen()) {
return ByteArray.EMPTY_BYTE_ARRAY;
return ByteUtil.EMPTY_BYTE_ARRAY;
}
LibrustzcashParam.valid32Params(ask);
byte[] ak = new byte[32];
Expand All @@ -109,7 +110,7 @@ public static byte[] librustzcashAskToAk(byte[] ask) throws ZksnarkException {
*/
public static byte[] librustzcashNskToNk(byte[] nsk) throws ZksnarkException {
if (!isOpenZen()) {
return ByteArray.EMPTY_BYTE_ARRAY;
return ByteUtil.EMPTY_BYTE_ARRAY;
}
LibrustzcashParam.valid32Params(nsk);
byte[] nk = new byte[32];
Expand All @@ -124,7 +125,7 @@ public static byte[] librustzcashNskToNk(byte[] nsk) throws ZksnarkException {
*/
public static byte[] librustzcashSaplingGenerateR(byte[] r) throws ZksnarkException {
if (!isOpenZen()) {
return ByteArray.EMPTY_BYTE_ARRAY;
return ByteUtil.EMPTY_BYTE_ARRAY;
}
LibrustzcashParam.valid32Params(r);
INSTANCE.librustzcashSaplingGenerateR(r);
Expand Down
4 changes: 0 additions & 4 deletions common/src/main/java/org/tron/common/utils/Base58.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ public static byte[] decode(String input) throws IllegalArgumentException {
return copyOfRange(temp, j - zeroCount, temp.length);
}

public static BigInteger decodeToBigInteger(String input) throws IllegalArgumentException {
return new BigInteger(1, decode(input));
}

//
// number -> number / 58, returns number % 58
//
Expand Down
Loading

0 comments on commit 0435534

Please sign in to comment.