Skip to content

Commit

Permalink
Merge pull request tronprotocol#3319 from tronprotocol/master-merge-t…
Browse files Browse the repository at this point in the history
…o-develop

Master merge to develop
  • Loading branch information
lvs007 authored Jul 31, 2020
2 parents 9e644e6 + 9a9c97c commit 85ee283
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 32 deletions.
4 changes: 2 additions & 2 deletions actuator/src/main/java/org/tron/core/utils/ProposalUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public static void validator(DynamicPropertiesStore dynamicPropertiesStore,
break;
}
case ALLOW_PBFT: {
if (!forkController.pass(ForkBlockVersionEnum.VERSION_3_8)) {
if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_1)) {
throw new ContractValidateException(
"Bad chain parameter id [ALLOW_PBFT]");
}
Expand All @@ -318,7 +318,7 @@ public static void validator(DynamicPropertiesStore dynamicPropertiesStore,
break;
}
case ALLOW_SHIELDED_TRC20_TRANSACTION: {
if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_0)) {
if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_0_1)) {
throw new ContractValidateException(
"Bad chain parameter id [ALLOW_SHIELDED_TRC20_TRANSACTION]");
}
Expand Down
35 changes: 35 additions & 0 deletions chainbase/src/main/java/org/tron/common/utils/ForkController.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ public boolean pass(ForkBlockVersionEnum forkBlockVersionEnum) {
}

public synchronized boolean pass(int version) {
if (version > ForkBlockVersionEnum.VERSION_4_0.getValue()) {
return passNew(version);
} else {
return passOld(version);
}
}

private boolean passOld(int version) {
if (version == ForkBlockVersionConsts.ENERGY_LIMIT) {
return checkForEnergyLimit();
}
Expand All @@ -52,6 +60,33 @@ public synchronized boolean pass(int version) {
return check(stats);
}

private boolean passNew(int version) {
ForkBlockVersionEnum versionEnum = ForkBlockVersionEnum.getForkBlockVersionEnum(version);
if (versionEnum == null) {
logger.error("not exist block version: {}", version);
return false;
}
long latestBlockTime = manager.getDynamicPropertiesStore().getLatestBlockHeaderTimestamp();
long maintenanceTimeInterval = manager.getDynamicPropertiesStore().getMaintenanceTimeInterval();
long hardForkTime = ((versionEnum.getHardForkTime() - 1) / maintenanceTimeInterval + 1)
* maintenanceTimeInterval;
if (latestBlockTime < hardForkTime) {
return false;
}
byte[] stats = manager.getDynamicPropertiesStore().statsByVersion(version);
if (stats == null || stats.length == 0) {
return false;
}
int count = 0;
for (int i = 0; i < stats.length; i++) {
if (check[i] == stats[i]) {
++count;
}
}
return count >= versionEnum.getHardForkCount();
}


// when block.version = 5,
// it make block use new energy to handle transaction when block number >= 4727890L.
// version !=5, skip this.
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class DynamicPropertiesStore extends TronStoreWithRevoking<BytesCapsule>
private static final byte[] TOTAL_STORAGE_TAX = "TOTAL_STORAGE_TAX".getBytes();
private static final byte[] TOTAL_STORAGE_RESERVED = "TOTAL_STORAGE_RESERVED".getBytes();
private static final byte[] STORAGE_EXCHANGE_TAX_RATE = "STORAGE_EXCHANGE_TAX_RATE".getBytes();
private static final byte[] FORK_CONTROLLER = "FORK_CONTROLLER".getBytes();
private static final String FORK_CONTROLLER = "FORK_CONTROLLER";
private static final String FORK_PREFIX = "FORK_VERSION_";
//This value is only allowed to be 0, 1, -1
private static final byte[] REMOVE_THE_POWER_OF_THE_GR = "REMOVE_THE_POWER_OF_THE_GR".getBytes();
Expand Down Expand Up @@ -1876,8 +1876,9 @@ public void addTotalTransactionCost(long fee) {
saveTotalTransactionCost(newValue);
}

public void forked() {
put(FORK_CONTROLLER, new BytesCapsule(Boolean.toString(true).getBytes()));
public void forked(int version, boolean value) {
String forkKey = FORK_CONTROLLER + version;
put(forkKey.getBytes(), new BytesCapsule(Boolean.toString(value).getBytes()));
}

public void statsByVersion(int version, byte[] stats) {
Expand All @@ -1890,9 +1891,10 @@ public byte[] statsByVersion(int version) {
return revokingDB.getUnchecked(statsKey.getBytes());
}

public boolean getForked() {
byte[] value = revokingDB.getUnchecked(FORK_CONTROLLER);
return value == null ? Boolean.FALSE : Boolean.valueOf(new String(value));
public Boolean getForked(int version) {
String forkKey = FORK_CONTROLLER + version;
byte[] value = revokingDB.getUnchecked(forkKey.getBytes());
return value == null ? null : Boolean.valueOf(new String(value));
}

/**
Expand Down
9 changes: 0 additions & 9 deletions common/src/main/java/org/tron/common/entity/NodeInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,6 @@ public static class ConfigNodeInfo {

/*node information*/
private String codeVersion;
private String versionName;
private String versionNum;
private String p2pVersion;
private int listenPort;
Expand Down Expand Up @@ -534,14 +533,6 @@ public ConfigNodeInfo setCodeVersion(String codeVersion) {
return this;
}

public String getVersionName() {
return versionName;
}

public void setVersionName(String versionName) {
this.versionName = versionName;
}

public String getVersionNum() {
return versionNum;
}
Expand Down
36 changes: 26 additions & 10 deletions common/src/main/java/org/tron/core/config/Parameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,36 @@
public class Parameter {

public enum ForkBlockVersionEnum {
ENERGY_LIMIT(5),
VERSION_3_2_2(6),
VERSION_3_5(7),
VERSION_3_6(8),
VERSION_3_6_5(9),
VERSION_3_6_6(10),
VERSION_3_8(16),
VERSION_4_0(15);
ENERGY_LIMIT(5, 0L, 0),
VERSION_3_2_2(6, 0L, 0),
VERSION_3_5(7, 0L, 0),
VERSION_3_6(8, 0L, 0),
VERSION_3_6_5(9, 0L, 0),
VERSION_3_6_6(10, 0L, 0),
VERSION_4_0(16, 0L, 0),
VERSION_4_0_1(17, 1596780000000L, 22),//GMT 2020-08-07 06:00:00
VERSION_4_1(19, 1596780000000L, 22);//GMT 2020-08-07 06:00:00

@Getter
private int value;
@Getter
private long hardForkTime;
@Getter
private int hardForkCount;

ForkBlockVersionEnum(int value) {
ForkBlockVersionEnum(int value, long hardForkTime, int hardForkCount) {
this.value = value;
this.hardForkTime = hardForkTime;
this.hardForkCount = hardForkCount;
}

public static ForkBlockVersionEnum getForkBlockVersionEnum(int value) {
for (ForkBlockVersionEnum versionEnum : values()) {
if (versionEnum.getValue() == value) {
return versionEnum;
}
}
return null;
}
}

Expand All @@ -45,7 +61,7 @@ public class ChainConstant {
public static final int SINGLE_REPEAT = 1;
public static final int BLOCK_FILLED_SLOTS_NUMBER = 128;
public static final int MAX_FROZEN_NUMBER = 1;
public static final int BLOCK_VERSION = 16;
public static final int BLOCK_VERSION = 19;
public static final long FROZEN_PERIOD = 86_400_000L;
public static final long TRX_PRECISION = 1000_000L;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,6 @@ public static void logConfig() {
logger.info("Backup member size: {}", parameter.getBackupMembers().size());
logger.info("************************ Code version *************************");
logger.info("Code version : {}", Version.getVersion());
logger.info("Version name: {}", Version.versionName);
logger.info("Version code: {}", Version.versionCode);
logger.info("************************ DB config *************************");
logger.info("DB version : {}", parameter.getStorage().getDbVersion());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ private void setConnectInfo(NodeInfo nodeInfo) {
private void setConfigNodeInfo(NodeInfo nodeInfo) {
ConfigNodeInfo configNodeInfo = new ConfigNodeInfo();
configNodeInfo.setCodeVersion(Version.getVersion());
configNodeInfo.setVersionName(Version.versionName);
configNodeInfo.setVersionNum(Version.versionCode);
configNodeInfo.setP2pVersion(String.valueOf(parameter.getNodeP2pVersion()));
configNodeInfo.setListenPort(parameter.getNodeListenPort());
Expand Down
6 changes: 3 additions & 3 deletions framework/src/main/java/org/tron/program/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

public class Version {

public static final String versionName = "Odyssey-v3.7-216-gb01d5c721";
public static final String versionCode = "13200";
private static final String version = "4.0.0";
public static final String versionName = "GreatVoyage-v4.0.0-8-g67170b635";
public static final String versionCode = "13210";
private static final String version = "4.0.1";

public static String getVersion() {
return version;
Expand Down

0 comments on commit 85ee283

Please sign in to comment.