Skip to content

Commit

Permalink
add check to _jailValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 committed Jan 3, 2024
1 parent 64c57dc commit 348af6b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion contracts/BC_fusion/StakeHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "./System.sol";
import "./lib/Utils.sol";
import "./interface/IBSCValidatorSet.sol";
import "./interface/ICrossChain.sol";
import "./interface/IGovToken.sol";
import "./interface/IStakeCredit.sol";

Expand Down Expand Up @@ -1015,7 +1016,11 @@ contract StakeHub is System, Initializable {
function _jailValidator(Validator storage valInfo, uint256 jailUntil) internal {
// keep the last eligible validator
bool isLast = (numOfJailed >= _validatorSet.length() - 1);
if (isLast) {
// 0x08 is the staking channel id. If this channel is closed, then BC-fusion is finished and we should keep the last eligible validator here
if (
!ICrossChain(CROSS_CHAIN_CONTRACT_ADDR).registeredContractChannelMap(VALIDATOR_CONTRACT_ADDR, 0x08)
&& isLast
) {
emit ValidatorEmptyJailed(valInfo.operatorAddress);
return;
}
Expand Down
6 changes: 6 additions & 0 deletions contracts/BC_fusion/interface/ICrossChain.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.17;

interface ICrossChain {
function registeredContractChannelMap(address, uint8) external view returns (bool);
}

0 comments on commit 348af6b

Please sign in to comment.