Skip to content

Commit

Permalink
add transactionFeePool proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-liu55 committed Nov 11, 2020
1 parent 4fe888b commit ed50dba
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
16 changes: 15 additions & 1 deletion actuator/src/main/java/org/tron/core/utils/ProposalUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,19 @@ public static void validator(DynamicPropertiesStore dynamicPropertiesStore,
}
break;
}
case ALLOW_TRANSACTION_FEE_POOL: {
if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_1)) {//todo, set later
throw new ContractValidateException(
"Bad chain parameter id [ALLOW_TRANSACTION_FEE_POOL]");
}
if (value != 1 && value != 0) {
throw new ContractValidateException(
"This value[ALLOW_TRANSACTION_FEE_POOL] is only allowed to be 1 or 0");
}
break;
}


default:
break;
}
Expand Down Expand Up @@ -449,7 +462,8 @@ public enum ProposalType { // current value, value range
ALLOW_TVM_STAKE(43), // 0, 1
ALLOW_MARKET_TRANSACTION(44), // {0, 1}
MARKET_SELL_FEE(45), // 0 [0,10_000_000_000]
MARKET_CANCEL_FEE(46); // 0 [0,10_000_000_000]
MARKET_CANCEL_FEE(46), // 0 [0,10_000_000_000]
ALLOW_TRANSACTION_FEE_POOL(50); // 0, 1

private long code;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,13 @@ private DynamicPropertiesStore(@Value("properties") String dbName) {
this.saveMarketQuantityLimit(1_000_000_000_000_000L);
}


try {
this.getAllowTransactionFeePool();
} catch (IllegalArgumentException e) {
this.saveAllowTransactionFeePool(0L);
}

try {
this.getTotalTransactionCost();
} catch (IllegalArgumentException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ public static boolean process(Manager manager, ProposalCapsule proposalCapsule)
manager.getDynamicPropertiesStore().saveMarketCancelFee(entry.getValue());
break;
}
case ALLOW_TRANSACTION_FEE_POOL: {
manager.getDynamicPropertiesStore().saveAllowTransactionFeePool(entry.getValue());
break;
}
default:
find = false;
break;
Expand Down
8 changes: 8 additions & 0 deletions framework/src/main/java/org/tron/core/db/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,14 @@ private void payReward(BlockCapsule block) {
AccountCapsule account = getAccountStore().get(witness);
account.setAllowance(account.getAllowance()
+ chainBaseManager.getDynamicPropertiesStore().getWitnessPayPerBlock());

if (chainBaseManager.getDynamicPropertiesStore().supportTransactionFeePool()) {
long transactionFeeReward = Math
.floorDiv(chainBaseManager.getDynamicPropertiesStore().getTransactionFeePool(),
Constant.TRANSACTION_FEE_POOL_PERIOD);
account.setAllowance(account.getAllowance() + transactionFeeReward);
}

getAccountStore().put(account.createDbKey(), account);
}

Expand Down

0 comments on commit ed50dba

Please sign in to comment.