Skip to content

Commit 38bfb5e

Browse files
authored
Merge pull request #4694 from bladehan1/feat/config_for_proposal
feat(reward): add config for new reward algorithm proposal
2 parents d432b5d + 86524af commit 38bfb5e

4 files changed

Lines changed: 25 additions & 1 deletion

File tree

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,18 @@ private DynamicPropertiesStore(@Value("properties") String dbName) {
845845
this.saveAllowHigherLimitForMaxCpuTimeOfOneTx(
846846
CommonParameter.getInstance().getAllowHigherLimitForMaxCpuTimeOfOneTx());
847847
}
848+
849+
try {
850+
this.getNewRewardAlgorithmEffectiveCycle();
851+
} catch (IllegalArgumentException e) {
852+
if (CommonParameter.getInstance().getAllowNewRewardAlgorithm() == 1) {
853+
this.put(NEW_REWARD_ALGORITHM_EFFECTIVE_CYCLE,
854+
new BytesCapsule(ByteArray.fromLong(getCurrentCycleNumber())));
855+
} else {
856+
this.put(NEW_REWARD_ALGORITHM_EFFECTIVE_CYCLE,
857+
new BytesCapsule(ByteArray.fromLong(Long.MAX_VALUE)));
858+
}
859+
}
848860
}
849861

850862
public String intArrayToString(int[] a) {
@@ -2397,7 +2409,8 @@ public long getNewRewardAlgorithmEffectiveCycle() {
23972409
return Optional.ofNullable(getUnchecked(NEW_REWARD_ALGORITHM_EFFECTIVE_CYCLE))
23982410
.map(BytesCapsule::getData)
23992411
.map(ByteArray::toLong)
2400-
.orElse(Long.MAX_VALUE);
2412+
.orElseThrow(
2413+
() -> new IllegalArgumentException("not found NEW_REWARD_ALGORITHM_EFFECTIVE_CYCLE"));
24012414
}
24022415

24032416
public long getAllowAccountAssetOptimizationFromRoot() {

common/src/main/java/org/tron/common/parameter/CommonParameter.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,10 @@ public class CommonParameter {
557557
@Setter
558558
public long blockCacheTimeout = 60;
559559

560+
@Getter
561+
@Setter
562+
public long allowNewRewardAlgorithm;
563+
560564
private static double calcMaxTimeRatio() {
561565
//return max(2.0, min(5.0, 5 * 4.0 / max(Runtime.getRuntime().availableProcessors(), 1)));
562566
return 5.0;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ public class Constant {
290290
public static final String COMMITTEE_ALLOW_TVM_COMPATIBLE_EVM = "committee.allowTvmCompatibleEvm";
291291
public static final String COMMITTEE_ALLOW_HIGHER_LIMIT_FOR_MAX_CPU_TIME_OF_ONE_TX =
292292
"committee.allowHigherLimitForMaxCpuTimeOfOneTx";
293+
public static final String COMMITTEE_ALLOW_NEW_REWARD_ALGORITHM = "committee.allowNewRewardAlgorithm";
294+
293295

294296
public static final String METRICS_STORAGE_ENABLE = "node.metrics.storageEnable";
295297
public static final String METRICS_INFLUXDB_IP = "node.metrics.influxdb.ip";

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ public static void clearParam() {
214214
PARAMETER.shutdownBlockHeight = -1;
215215
PARAMETER.shutdownBlockCount = -1;
216216
PARAMETER.blockCacheTimeout = 60;
217+
PARAMETER.allowNewRewardAlgorithm = 0;
217218
}
218219

219220
/**
@@ -946,6 +947,10 @@ public static void setParam(final String[] args, final String confFileName) {
946947
config.hasPath(Constant.COMMITTEE_ALLOW_HIGHER_LIMIT_FOR_MAX_CPU_TIME_OF_ONE_TX) ? config
947948
.getInt(Constant.COMMITTEE_ALLOW_HIGHER_LIMIT_FOR_MAX_CPU_TIME_OF_ONE_TX) : 0;
948949

950+
PARAMETER.allowNewRewardAlgorithm =
951+
config.hasPath(Constant.COMMITTEE_ALLOW_NEW_REWARD_ALGORITHM) ? config
952+
.getInt(Constant.COMMITTEE_ALLOW_NEW_REWARD_ALGORITHM) : 0;
953+
949954
initBackupProperty(config);
950955
if (Constant.ROCKSDB.equalsIgnoreCase(CommonParameter
951956
.getInstance().getStorage().getDbEngine())) {

0 commit comments

Comments
 (0)