Skip to content

Commit

Permalink
Transfer the fee to the SR but not to voters
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-liu55 committed Nov 11, 2020
1 parent ef538d3 commit 12d2492
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public class DynamicPropertiesStore extends TronStoreWithRevoking<BytesCapsule>
private static final byte[] MARKET_CANCEL_FEE = "MARKET_CANCEL_FEE".getBytes();
private static final byte[] MARKET_QUANTITY_LIMIT = "MARKET_QUANTITY_LIMIT".getBytes();

//todo, maybe change proposal name later
private static final byte[] ALLOW_TRANSACTION_FEE_POOL = "ALLOW_TRANSACTION_FEE_POOL".getBytes();
private static final byte[] TRANSACTION_FEE_POOL = "TRANSACTION_FEE_POOL".getBytes();

Expand Down Expand Up @@ -1414,8 +1415,6 @@ public long getTransactionFeePool() {
() -> new IllegalArgumentException("not found TRANSACTION_FEE_POOL"));
}



public void saveTotalTransactionCost(long value) {
this.put(TOTAL_TRANSACTION_COST,
new BytesCapsule(ByteArray.fromLong(value)));
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/org/tron/core/Constant.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Constant {
public static final long TRANSACTION_MAX_BYTE_SIZE = 500 * 1_024L;
public static final long MAXIMUM_TIME_UNTIL_EXPIRATION = 24 * 60 * 60 * 1_000L; //one day
public static final long TRANSACTION_DEFAULT_EXPIRATION_TIME = 60 * 1_000L; //60 seconds
public static final long TRANSACTION_FEE_POOL_PERIOD = 60; //60 blocks
public static final long TRANSACTION_FEE_POOL_PERIOD = 1; //1 blocks
// config for smart contract
public static final long SUN_PER_ENERGY = 100; // 1 us = 100 SUN = 100 * 10^-6 TRX
public static final long ENERGY_LIMIT_IN_CONSTANT_TX = 3_000_000L; // ref: 1 us = 1 energy
Expand Down
30 changes: 14 additions & 16 deletions framework/src/main/java/org/tron/core/db/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1352,31 +1352,29 @@ private void payReward(BlockCapsule block) {
mortgageService.payBlockReward(witnessCapsule.getAddress().toByteArray(),
getDynamicPropertiesStore().getWitnessPayPerBlock());
mortgageService.payStandbyWitness();

if (chainBaseManager.getDynamicPropertiesStore().supportTransactionFeePool()) {
long transactionFeeReward = Math
.floorDiv(chainBaseManager.getDynamicPropertiesStore().getTransactionFeePool(),
Constant.TRANSACTION_FEE_POOL_PERIOD);
mortgageService.payTransactionFeeReward(witnessCapsule.getAddress().toByteArray(),
transactionFeeReward);
}
} else {
byte[] witness = block.getWitnessAddress().toByteArray();
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);
}

if (chainBaseManager.getDynamicPropertiesStore().supportTransactionFeePool()) {
byte[] witness = block.getWitnessAddress().toByteArray();
AccountCapsule account = getAccountStore().get(witness);

long transactionFeeReward = Math
.floorDiv(chainBaseManager.getDynamicPropertiesStore().getTransactionFeePool(),
Constant.TRANSACTION_FEE_POOL_PERIOD);

chainBaseManager.getDynamicPropertiesStore().saveTransactionFeePool(
chainBaseManager.getDynamicPropertiesStore().getTransactionFeePool()
- transactionFeeReward);

account.setAllowance(account.getAllowance() + transactionFeeReward);
getAccountStore().put(account.createDbKey(), account);
}
}

private void postSolidityLogContractTrigger(Long blockNum, Long lastSolidityNum) {
Expand Down

0 comments on commit 12d2492

Please sign in to comment.