Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
buildscript {
repositories {
maven { url 'http://mvnrepository.com' }
mavenCentral()
jcenter()
}
Expand Down Expand Up @@ -46,7 +45,6 @@ task sourceJar(type: Jar, dependsOn: classes) {
}

repositories {
maven { url 'http://mvnrepository.com' }
mavenLocal()
mavenCentral()
maven { url 'http://repo.spring.io/plugins-release' }
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/org/tron/common/runtime/vm/program/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@
import java.math.BigInteger;
import java.util.Arrays;
import java.util.BitSet;
import java.util.List;
import java.util.Map;
import java.util.NavigableSet;
import java.util.Objects;
import java.util.TreeSet;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.spongycastle.util.encoders.Hex;
Expand Down Expand Up @@ -804,10 +802,9 @@ public DataWord getBlockHash(int index) {
if (index < this.getNumber().longValue()
&& index >= Math.max(256, this.getNumber().longValue()) - 256) {

List<BlockCapsule> blocks = this.invoke.getBlockStore().getBlockByLatestNum(index);
BlockCapsule blockCapsule = this.invoke.getBlockByNum(index);

if (CollectionUtils.isNotEmpty(blocks)) {
BlockCapsule blockCapsule = blocks.get(0);
if (Objects.nonNull(blockCapsule)) {
return new DataWord(blockCapsule.getBlockId().getBytes());
} else {
return DataWord.ZERO.clone();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.tron.common.runtime.vm.DataWord;
import org.tron.common.storage.Deposit;
import org.tron.core.capsule.BlockCapsule;
import org.tron.core.db.BlockStore;

/**
Expand Down Expand Up @@ -72,4 +73,6 @@ public interface ProgramInvoke {
long getEnergyLimit();

void setStaticCall();

BlockCapsule getBlockByNum(int index);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.tron.common.runtime.vm.DataWord;
import org.tron.common.runtime.vm.program.Program.IllegalOperationException;
import org.tron.common.storage.Deposit;
import org.tron.core.capsule.BlockCapsule;
import org.tron.core.db.BlockStore;
import org.tron.core.exception.StoreException;

@Slf4j
public class ProgramInvokeImpl implements ProgramInvoke {
Expand Down Expand Up @@ -374,4 +377,13 @@ public void setStaticCall() {
isStaticCall = true;
}

@Override
public BlockCapsule getBlockByNum(int index) {
try {
return deposit.getDbManager().getBlockByNum(index);
} catch (StoreException e) {
throw new IllegalOperationException("cannot find block num");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
import org.tron.common.crypto.ECKey;
import org.tron.common.crypto.Hash;
import org.tron.common.runtime.vm.DataWord;
import org.tron.common.runtime.vm.program.Program.IllegalOperationException;
import org.tron.common.storage.Deposit;
import org.tron.common.storage.DepositImpl;
import org.tron.core.capsule.BlockCapsule;
import org.tron.core.db.BlockStore;
import org.tron.core.exception.StoreException;
import org.tron.protos.Protocol;

// import org.tron.core.db.BlockStoreDummy;
Expand Down Expand Up @@ -234,6 +237,15 @@ public void setStaticCall() {

}

@Override
public BlockCapsule getBlockByNum(int index) {
try {
return deposit.getDbManager().getBlockByNum(index);
} catch (StoreException e) {
throw new IllegalOperationException("cannot find block num");
}
}

@Override
public boolean byTestingSuite() {
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/tron/common/utils/ForkController.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public class ForkController {
@Getter
private Manager manager;
private volatile int[] slots = new int[0];
private boolean forked;
private boolean forked = true;

public void init(Manager manager) {
this.manager = manager;
forked = manager.getDynamicPropertiesStore().getForked();
forked = true;
}

public synchronized boolean shouldBeForked() {
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/org/tron/core/config/args/Args.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package org.tron.core.config.args;

import static java.lang.Math.max;
import static java.lang.Math.min;

import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.typesafe.config.Config;
Expand Down Expand Up @@ -82,7 +79,7 @@ public class Args {
@Getter
@Setter
@Parameter(names = {"--min-time-ratio"})
private double minTimeRatio = 0.6;
private double minTimeRatio = 0.0;

@Getter
@Setter
Expand Down Expand Up @@ -391,7 +388,7 @@ public static void clearParam() {
INSTANCE.isOpenFullTcpDisconnect = false;
INSTANCE.supportConstant = false;
INSTANCE.debug = false;
INSTANCE.minTimeRatio = 0.6;
INSTANCE.minTimeRatio = 0.0;
INSTANCE.maxTimeRatio = 5.0;
INSTANCE.longRunningTime = 10;
}
Expand Down Expand Up @@ -542,7 +539,8 @@ public static void setParam(final String[] args, final String confFileName) {
config.hasPath("node.maxActiveNodes") ? config.getInt("node.maxActiveNodes") : 30;

INSTANCE.nodeMaxActiveNodesWithSameIp =
config.hasPath("node.maxActiveNodesWithSameIp") ? config.getInt("node.maxActiveNodesWithSameIp") : 2;
config.hasPath("node.maxActiveNodesWithSameIp") ? config
.getInt("node.maxActiveNodesWithSameIp") : 2;

INSTANCE.minParticipationRate =
config.hasPath("node.minParticipationRate") ? config.getInt("node.minParticipationRate")
Expand Down Expand Up @@ -649,7 +647,8 @@ public static void setParam(final String[] args, final String confFileName) {
config.getLong("node.receiveTcpMinDataLength") : 2048;
INSTANCE.isOpenFullTcpDisconnect = config.hasPath("node.isOpenFullTcpDisconnect") && config
.getBoolean("node.isOpenFullTcpDisconnect");
INSTANCE.logLevel = config.hasPath("log.level.root") ? config.getString("log.level.root") : "INFO";
INSTANCE.logLevel =
config.hasPath("log.level.root") ? config.getString("log.level.root") : "INFO";

initBackupProperty(config);

Expand Down Expand Up @@ -837,7 +836,8 @@ public ECKey getMyKey() {
}

private static double calcMaxTimeRatio() {
return max(2.0, min(5.0, 5 * 4.0 / max(Runtime.getRuntime().availableProcessors(), 1)));
//return max(2.0, min(5.0, 5 * 4.0 / max(Runtime.getRuntime().availableProcessors(), 1)));
return 5.0;
}

private static void initBackupProperty(Config config) {
Expand All @@ -849,7 +849,7 @@ private static void initBackupProperty(Config config) {
? config.getStringList("node.backup.members") : new ArrayList<>();
}

private static void logConfig(){
private static void logConfig() {
Args args = getInstance();
logger.info("\n");
logger.info("************************ Net config ************************");
Expand Down