|
4 | 4 | import static org.tron.common.math.Maths.max; |
5 | 5 | import static org.tron.common.math.Maths.min; |
6 | 6 | import static org.tron.core.Constant.ADD_PRE_FIX_BYTE_MAINNET; |
7 | | -import static org.tron.core.Constant.DEFAULT_PROPOSAL_VOTING_WINDOW; |
| 7 | +import static org.tron.core.Constant.DEFAULT_PROPOSAL_EXPIRE_TIME; |
8 | 8 | import static org.tron.core.Constant.DYNAMIC_ENERGY_INCREASE_FACTOR_RANGE; |
9 | 9 | import static org.tron.core.Constant.DYNAMIC_ENERGY_MAX_FACTOR_RANGE; |
| 10 | +import static org.tron.core.Constant.MAX_PROPOSAL_EXPIRE_TIME; |
| 11 | +import static org.tron.core.Constant.MIN_PROPOSAL_EXPIRE_TIME; |
10 | 12 | import static org.tron.core.config.Parameter.ChainConstant.BLOCK_PRODUCE_TIMEOUT_PERCENT; |
11 | 13 | import static org.tron.core.config.Parameter.ChainConstant.MAX_ACTIVE_WITNESS_NUM; |
12 | 14 |
|
@@ -248,7 +250,6 @@ public static void clearParam() { |
248 | 250 | PARAMETER.consensusLogicOptimization = 0; |
249 | 251 | PARAMETER.allowTvmCancun = 0; |
250 | 252 | PARAMETER.allowTvmBlob = 0; |
251 | | - PARAMETER.proposalVotingWindow = DEFAULT_PROPOSAL_VOTING_WINDOW; |
252 | 253 | } |
253 | 254 |
|
254 | 255 | /** |
@@ -817,9 +818,7 @@ public static void setParam(final Config config) { |
817 | 818 | config.hasPath(Constant.BLOCK_MAINTENANCE_TIME_INTERVAL) ? config |
818 | 819 | .getInt(Constant.BLOCK_MAINTENANCE_TIME_INTERVAL) : 21600000L; |
819 | 820 |
|
820 | | - PARAMETER.proposalExpireTime = |
821 | | - config.hasPath(Constant.BLOCK_PROPOSAL_EXPIRE_TIME) ? config |
822 | | - .getInt(Constant.BLOCK_PROPOSAL_EXPIRE_TIME) : 259200000L; |
| 821 | + PARAMETER.proposalExpireTime = getProposalExpirationTime(config); |
823 | 822 |
|
824 | 823 | PARAMETER.checkFrozenTime = |
825 | 824 | config.hasPath(Constant.BLOCK_CHECK_FROZEN_TIME) ? config |
@@ -1299,13 +1298,29 @@ public static void setParam(final Config config) { |
1299 | 1298 | config.hasPath(Constant.COMMITTEE_ALLOW_TVM_BLOB) ? config |
1300 | 1299 | .getInt(Constant.COMMITTEE_ALLOW_TVM_BLOB) : 0; |
1301 | 1300 |
|
1302 | | - PARAMETER.proposalVotingWindow = |
1303 | | - config.hasPath(Constant.COMMITTEE_PROPOSAL_VOTING_WINDOW) ? config |
1304 | | - .getInt(Constant.COMMITTEE_PROPOSAL_VOTING_WINDOW) : DEFAULT_PROPOSAL_VOTING_WINDOW; |
1305 | | - |
1306 | 1301 | logConfig(); |
1307 | 1302 | } |
1308 | 1303 |
|
| 1304 | + private static long getProposalExpirationTime(final Config config) { |
| 1305 | + if (config.hasPath(Constant.COMMITTEE_PROPOSAL_EXPIRE_TIME)) { |
| 1306 | + throw new IllegalArgumentException("It is not allowed to configure " |
| 1307 | + + "commit.proposalExpireTime in config.conf, please set the value in " |
| 1308 | + + "block.proposalExpireTime."); |
| 1309 | + } |
| 1310 | + if (config.hasPath(Constant.BLOCK_PROPOSAL_EXPIRE_TIME)) { |
| 1311 | + long proposalExpireTime = config.getLong(Constant.BLOCK_PROPOSAL_EXPIRE_TIME); |
| 1312 | + if (proposalExpireTime <= MIN_PROPOSAL_EXPIRE_TIME |
| 1313 | + || proposalExpireTime >= MAX_PROPOSAL_EXPIRE_TIME) { |
| 1314 | + throw new IllegalArgumentException("The value[block.proposalExpireTime] is only allowed to " |
| 1315 | + + "be greater than " + MIN_PROPOSAL_EXPIRE_TIME + " and less than " |
| 1316 | + + MAX_PROPOSAL_EXPIRE_TIME + "!"); |
| 1317 | + } |
| 1318 | + return proposalExpireTime; |
| 1319 | + } else { |
| 1320 | + return DEFAULT_PROPOSAL_EXPIRE_TIME; |
| 1321 | + } |
| 1322 | + } |
| 1323 | + |
1309 | 1324 | private static List<Witness> getWitnessesFromConfig(final com.typesafe.config.Config config) { |
1310 | 1325 | return config.getObjectList(Constant.GENESIS_BLOCK_WITNESSES).stream() |
1311 | 1326 | .map(Args::createWitness) |
|
0 commit comments