Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolve review comments #454

Merged
merged 4 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should put isLast before the channel check, because in most cases isLast will be false, then channel check will be unnecessary, it can save gas.

&& 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);
}
Loading