Skip to content

Commit 455acee

Browse files
committed
fix(proposalExpireTime): optimize the minimum value of proposal expiration time
1 parent e3f9b52 commit 455acee

4 files changed

Lines changed: 8 additions & 9 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import static org.tron.core.Constant.DYNAMIC_ENERGY_INCREASE_FACTOR_RANGE;
66
import static org.tron.core.Constant.DYNAMIC_ENERGY_MAX_FACTOR_RANGE;
77
import static org.tron.core.Constant.MAX_PROPOSAL_EXPIRE_TIME;
8-
import static org.tron.core.Constant.MIN_PROPOSAL_EXPIRE_TIME;
98
import static org.tron.core.config.Parameter.ChainConstant.ONE_YEAR_BLOCK_NUMBERS;
109

1110
import org.tron.common.utils.ForkController;
@@ -846,11 +845,12 @@ public static void validator(DynamicPropertiesStore dynamicPropertiesStore,
846845
throw new ContractValidateException(
847846
"Bad chain parameter id [PROPOSAL_EXPIRE_TIME]");
848847
}
849-
if (value <= MIN_PROPOSAL_EXPIRE_TIME
848+
long minProposalExpireTime = dynamicPropertiesStore.getMaintenanceTimeInterval();
849+
if (value <= minProposalExpireTime
850850
|| value >= MAX_PROPOSAL_EXPIRE_TIME) {
851851
throw new ContractValidateException(
852852
"This value[PROPOSAL_EXPIRE_TIME] is only allowed to be greater than "
853-
+ MIN_PROPOSAL_EXPIRE_TIME + " and less than "
853+
+ minProposalExpireTime + " and less than "
854854
+ MAX_PROPOSAL_EXPIRE_TIME + "!");
855855
}
856856
break;

chainbase/src/main/java/org/tron/core/store/DynamicPropertiesStore.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import static org.tron.common.math.Maths.max;
44
import static org.tron.core.Constant.MAX_PROPOSAL_EXPIRE_TIME;
5-
import static org.tron.core.Constant.MIN_PROPOSAL_EXPIRE_TIME;
65
import static org.tron.core.config.Parameter.ChainConstant.BLOCK_PRODUCED_INTERVAL;
76
import static org.tron.core.config.Parameter.ChainConstant.DELEGATE_PERIOD;
87

@@ -2957,7 +2956,7 @@ public long getProposalExpireTime() {
29572956
return Optional.ofNullable(getUnchecked(PROPOSAL_EXPIRE_TIME))
29582957
.map(BytesCapsule::getData)
29592958
.map(ByteArray::toLong)
2960-
.filter(time -> time > MIN_PROPOSAL_EXPIRE_TIME && time < MAX_PROPOSAL_EXPIRE_TIME)
2959+
.filter(time -> time > getMaintenanceTimeInterval() && time < MAX_PROPOSAL_EXPIRE_TIME)
29612960
.orElse(CommonParameter.getInstance().getProposalExpireTime());
29622961
}
29632962

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ 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_EXPIRE_TIME = 0L; // 0 ms
42+
// public static final long MIN_PROPOSAL_EXPIRE_TIME = 0L; // 0 ms
4343
public static final long MAX_PROPOSAL_EXPIRE_TIME = 31536003000L; // ms of 365 days + 3000 ms
4444
public static final long DEFAULT_PROPOSAL_EXPIRE_TIME = 259200000L; // ms of 3 days
4545

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import static org.tron.core.Constant.DYNAMIC_ENERGY_INCREASE_FACTOR_RANGE;
99
import static org.tron.core.Constant.DYNAMIC_ENERGY_MAX_FACTOR_RANGE;
1010
import static org.tron.core.Constant.MAX_PROPOSAL_EXPIRE_TIME;
11-
import static org.tron.core.Constant.MIN_PROPOSAL_EXPIRE_TIME;
1211
import static org.tron.core.config.Parameter.ChainConstant.BLOCK_PRODUCE_TIMEOUT_PERCENT;
1312
import static org.tron.core.config.Parameter.ChainConstant.MAX_ACTIVE_WITNESS_NUM;
1413

@@ -1309,10 +1308,11 @@ private static long getProposalExpirationTime(final Config config) {
13091308
}
13101309
if (config.hasPath(Constant.BLOCK_PROPOSAL_EXPIRE_TIME)) {
13111310
long proposalExpireTime = config.getLong(Constant.BLOCK_PROPOSAL_EXPIRE_TIME);
1312-
if (proposalExpireTime <= MIN_PROPOSAL_EXPIRE_TIME
1311+
long minProposalExpireTime = PARAMETER.maintenanceTimeInterval;
1312+
if (proposalExpireTime <= minProposalExpireTime
13131313
|| proposalExpireTime >= MAX_PROPOSAL_EXPIRE_TIME) {
13141314
throw new IllegalArgumentException("The value[block.proposalExpireTime] is only allowed to "
1315-
+ "be greater than " + MIN_PROPOSAL_EXPIRE_TIME + " and less than "
1315+
+ "be greater than " + minProposalExpireTime + " and less than "
13161316
+ MAX_PROPOSAL_EXPIRE_TIME + "!");
13171317
}
13181318
return proposalExpireTime;

0 commit comments

Comments
 (0)