Skip to content

Commit

Permalink
Merge branch 'develop' into bc-fusion-bak
Browse files Browse the repository at this point in the history
# Conflicts:
#	contracts/SlashIndicator.sol
#	genesis-template.json
#	genesis.json
#	scripts/generate-tendermintLightClient.sh
#	scripts/generate.sh
  • Loading branch information
pythonberg1997 committed Dec 7, 2023
2 parents 843e4e3 + c7512be commit 7b0e0be
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 16 deletions.
6 changes: 3 additions & 3 deletions contracts/BSCValidatorSet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica

uint256 public constant BURN_RATIO_SCALE = 10000;
address public constant BURN_ADDRESS = 0x000000000000000000000000000000000000dEaD;
uint256 public constant INIT_BURN_RATIO = 0; // deprecated
uint256 public constant INIT_BURN_RATIO = 1000;
uint256 public burnRatio;
bool public burnRatioInitialized; // deprecated

Expand Down Expand Up @@ -321,7 +321,7 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica

if (isSystemRewardIncluded == false){
systemRewardRatio = INIT_SYSTEM_REWARD_RATIO;
burnRatio = 938; // 15/16*10% is 9.375%
burnRatio = INIT_BURN_RATIO;
isSystemRewardIncluded = true;
}

Expand Down Expand Up @@ -695,7 +695,7 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica
return;
}

totalValue = ISystemReward(SYSTEM_REWARD_ADDR).claimRewards(payable(address(this)), totalValue);
totalValue = ISystemReward(SYSTEM_REWARD_ADDR).claimRewardsforFinality(payable(address(this)), totalValue);
if (totalValue == 0) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/SlashIndicator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ contract SlashIndicator is ISlashIndicator,System,IParamSubscriber, IApplication
for (uint i; i < voteAddrs.length; ++i) {
if (BytesLib.equal(voteAddrs[i], _evidence.voteAddr)) {
uint256 amount = (address(SYSTEM_REWARD_ADDR).balance * finalitySlashRewardRatio) / 100;
ISystemReward(SYSTEM_REWARD_ADDR).claimRewards(msg.sender, amount);
ISystemReward(SYSTEM_REWARD_ADDR).claimRewardsforFinality(msg.sender, amount);
IBSCValidatorSet(VALIDATOR_CONTRACT_ADDR).felony(vals[i]);
break;
}
Expand Down
17 changes: 16 additions & 1 deletion contracts/SystemReward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import "./interface/IParamSubscriber.sol";
import "./interface/ISystemReward.sol";

contract SystemReward is System, IParamSubscriber, ISystemReward {
uint256 public constant MAX_REWARDS = 1e18;
uint256 public constant MAX_REWARDS/*_FOR_RELAYER*/ = 1e18;
uint256 public constant MAX_REWARDS_FOR_FINALITY = 5e18;

uint public numOperator;
mapping(address => bool) operators;
Expand Down Expand Up @@ -53,6 +54,20 @@ contract SystemReward is System, IParamSubscriber, ISystemReward {
return actualAmount;
}

function claimRewardsforFinality(address payable to, uint256 amount) external override(ISystemReward) doInit onlyOperator returns (uint256) {
uint256 actualAmount = amount < address(this).balance ? amount : address(this).balance;
if (actualAmount > MAX_REWARDS_FOR_FINALITY) {
actualAmount = MAX_REWARDS_FOR_FINALITY;
}
if (actualAmount != 0) {
to.transfer(actualAmount);
emit rewardTo(to, actualAmount);
} else {
emit rewardEmpty();
}
return actualAmount;
}

function isOperator(address addr) external view returns (bool) {
return operators[addr];
}
Expand Down
4 changes: 4 additions & 0 deletions contracts/TokenHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ contract TokenHub is ITokenHub, System, IParamSubscriber, IApplication, ISystemR
return actualAmount;
}

function claimRewardsforFinality(address payable, uint256) onlyInit onlyRelayerIncentivize external override returns(uint256) {
revert("CLAIM_REWARDS_FOR_FINALITY_NOT_ALLOWED");
}

function getMiniRelayFee() external view override returns(uint256) {
return relayFee;
}
Expand Down
1 change: 1 addition & 0 deletions contracts/interface/ISystemReward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ pragma solidity 0.6.4;

interface ISystemReward {
function claimRewards(address payable to, uint256 amount) external returns(uint256 actualAmount);
function claimRewardsforFinality(address payable to, uint256 amount) external returns(uint256 actualAmount);
}
1 change: 1 addition & 0 deletions genesis-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"berlinBlock": 8,
"londonBlock": 8,
"hertzBlock": 8,
"hertzfixBlock": 8,
"shanghaiTime": 0,
"keplerTime": 0,
"feynmanTime": 0,
Expand Down
23 changes: 12 additions & 11 deletions genesis.json

Large diffs are not rendered by default.

0 comments on commit 7b0e0be

Please sign in to comment.