Skip to content

Commit b9c2c21

Browse files
committed
feat(conf): make compatible with old configurations
1 parent 399d159 commit b9c2c21

5 files changed

Lines changed: 18 additions & 11 deletions

File tree

actuator/src/main/java/org/tron/core/actuator/ProposalCreateActuator.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import static org.tron.core.actuator.ActuatorConstant.ACCOUNT_EXCEPTION_STR;
44
import static org.tron.core.actuator.ActuatorConstant.NOT_EXIST_STR;
55
import static org.tron.core.actuator.ActuatorConstant.WITNESS_EXCEPTION_STR;
6-
import static org.tron.core.config.Parameter.ChainConstant.BLOCK_PRODUCED_INTERVAL;
76

87
import com.google.protobuf.ByteString;
98
import com.google.protobuf.InvalidProtocolBufferException;
@@ -53,8 +52,7 @@ public boolean execute(Object result) throws ContractExeException {
5352

5453
long currentMaintenanceTime =
5554
chainBaseManager.getDynamicPropertiesStore().getNextMaintenanceTime();
56-
long now3 = now + chainBaseManager.getDynamicPropertiesStore().getProposalVotingWindow()
57-
* BLOCK_PRODUCED_INTERVAL;
55+
long now3 = now + chainBaseManager.getDynamicPropertiesStore().getProposalVotingWindow();
5856
long round = (now3 - currentMaintenanceTime) / maintenanceTimeInterval;
5957
long expirationTime =
6058
currentMaintenanceTime + (round + 1) * maintenanceTimeInterval;

actuator/src/main/java/org/tron/core/utils/ProposalUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ public enum ProposalType { // current value, value range
938938
ALLOW_STRICT_MATH(87), // 0, 1
939939
CONSENSUS_LOGIC_OPTIMIZATION(88), // 0, 1
940940
ALLOW_TVM_BLOB(89), // 0, 1
941-
PROPOSAL_VOTING_WINDOW(92); // (0, 10512000]
941+
PROPOSAL_VOTING_WINDOW(92); // (0, 31536000000]
942942

943943
private long code;
944944

common/src/main/java/org/tron/core/Constant.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ public class Constant {
3939
public static final long MAX_CONTRACT_RESULT_SIZE = 2L;
4040
public static final long PB_DEFAULT_ENERGY_LIMIT = 0L;
4141
public static final long CREATOR_DEFAULT_ENERGY_LIMIT = 1000 * 10_000L;
42-
public static final long MIN_PROPOSAL_VOTING_WINDOW = 0L; // Number of blocks to 0 day
43-
public static final long MAX_PROPOSAL_VOTING_WINDOW = 10512000L; // Number of blocks to 365 days
42+
public static final long MIN_PROPOSAL_VOTING_WINDOW = 0L; // 0 ms
43+
public static final long MAX_PROPOSAL_VOTING_WINDOW = 31536000000L; // ms of 365 days
4444
/**
4545
* default number of blocks to 3 days
4646
*/
47-
public static final long DEFAULT_PROPOSAL_VOTING_WINDOW = 86400L;
47+
public static final long DEFAULT_PROPOSAL_VOTING_WINDOW = 259200000L;
4848

4949

5050
// Numbers

framework/src/main/java/org/tron/core/config/args/Args.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,9 +1299,18 @@ public static void setParam(final Config config) {
12991299
config.hasPath(Constant.COMMITTEE_ALLOW_TVM_BLOB) ? config
13001300
.getInt(Constant.COMMITTEE_ALLOW_TVM_BLOB) : 0;
13011301

1302-
PARAMETER.proposalVotingWindow =
1303-
config.hasPath(Constant.COMMITTEE_PROPOSAL_VOTING_WINDOW) ? config
1304-
.getInt(Constant.COMMITTEE_PROPOSAL_VOTING_WINDOW) : DEFAULT_PROPOSAL_VOTING_WINDOW;
1302+
if (config.hasPath(Constant.COMMITTEE_PROPOSAL_VOTING_WINDOW)) {
1303+
// Highest priority: As long as COMMITTEE_PROPOSAL_VOTING_WINDOW is configured, it will be
1304+
// taken
1305+
PARAMETER.proposalVotingWindow = config.getInt(Constant.COMMITTEE_PROPOSAL_VOTING_WINDOW);
1306+
} else if (config.hasPath(Constant.BLOCK_PROPOSAL_EXPIRE_TIME)) {
1307+
// Secondary priority: If the former is not configured but the latter is configured,
1308+
// choose the latter
1309+
PARAMETER.proposalVotingWindow = config.getInt(Constant.BLOCK_PROPOSAL_EXPIRE_TIME);
1310+
} else {
1311+
// Lowest priority: Neither is configured, use default values
1312+
PARAMETER.proposalVotingWindow = DEFAULT_PROPOSAL_VOTING_WINDOW;
1313+
}
13051314

13061315
logConfig();
13071316
}

framework/src/test/java/org/tron/core/services/ProposalServiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public void testUpdateConsensusLogicOptimization() {
138138
public void testProposalVotingWindow() {
139139
long defaultWindow = dbManager.getDynamicPropertiesStore().getProposalVotingWindow();
140140
long proposalExpireTime = CommonParameter.getInstance().getProposalExpireTime();
141-
Assert.assertEquals(proposalExpireTime, defaultWindow * 3000);
141+
Assert.assertEquals(proposalExpireTime, defaultWindow);
142142

143143
Proposal proposal = Proposal.newBuilder().putParameters(PROPOSAL_VOTING_WINDOW.getCode(),
144144
MAX_PROPOSAL_VOTING_WINDOW).build();

0 commit comments

Comments
 (0)