Skip to content

Commit

Permalink
chore: revert transaction when delegator in blacklist (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 authored Jan 8, 2024
1 parent fe8749f commit ea00161
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion abi/bscgovernor.abi
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@
],
"outputs": [
{
"name": "",
"name": "proposalId",
"type": "uint256",
"internalType": "uint256"
}
Expand Down
4 changes: 2 additions & 2 deletions abi/stakehub.abi
Original file line number Diff line number Diff line change
Expand Up @@ -1202,10 +1202,10 @@
"internalType": "uint256"
},
{
"name": "status",
"name": "respCode",
"type": "uint8",
"indexed": false,
"internalType": "enum StakeHub.StakeMigrationStatus"
"internalType": "enum StakeHub.StakeMigrationRespCode"
}
],
"anonymous": false
Expand Down
4 changes: 2 additions & 2 deletions contracts/BC_fusion/StakeHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ contract StakeHub is System, Initializable {
enum StakeMigrationRespCode {
MIGRATE_SUCCESS,
CLAIM_FUND_FAILED,
ILLEGAL_DELEGATOR,
VALIDATOR_NOT_EXISTED,
VALIDATOR_JAILED,
BALANCE_NOT_ENOUGH
Expand Down Expand Up @@ -1031,12 +1030,13 @@ contract StakeHub is System, Initializable {
returns (StakeMigrationRespCode)
{
if (blackList[migrationPkg.delegator] || migrationPkg.delegator == address(0)) {
return StakeMigrationRespCode.ILLEGAL_DELEGATOR;
revert InBlackList();
}

if (!_validatorSet.contains(migrationPkg.operatorAddress)) {
return StakeMigrationRespCode.VALIDATOR_NOT_EXISTED;
}

Validator memory valInfo = _validators[migrationPkg.operatorAddress];
if (valInfo.jailed && migrationPkg.delegator != migrationPkg.operatorAddress) {
return StakeMigrationRespCode.VALIDATOR_JAILED;
Expand Down
1 change: 0 additions & 1 deletion test/StakeHub.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ contract StakeHubTest is Deployer {
enum StakeMigrationRespCode {
MIGRATE_SUCCESS,
CLAIM_FUND_FAILED,
ILLEGAL_DELEGATOR,
VALIDATOR_NOT_EXISTED,
VALIDATOR_JAILED,
BALANCE_NOT_ENOUGH
Expand Down
2 changes: 1 addition & 1 deletion test/utils/interface/IBSCGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ interface BSCGovernor {
uint256[] memory values,
bytes[] memory calldatas,
bytes32 descriptionHash
) external returns (uint256);
) external returns (uint256 proposalId);
function queue(uint256 proposalId) external;
function quorum(uint256 timepoint) external view returns (uint256);
function quorumDenominator() external view returns (uint256);
Expand Down
4 changes: 2 additions & 2 deletions test/utils/interface/IStakeHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.10;

interface StakeHub {
type SlashType is uint8;
type StakeMigrationStatus is uint8;
type StakeMigrationRespCode is uint8;

struct Commission {
uint64 rate;
Expand Down Expand Up @@ -58,7 +58,7 @@ interface StakeHub {
event DescriptionEdited(address indexed operatorAddress);
event Initialized(uint8 version);
event MigrateFailed(
address indexed operatorAddress, address indexed delegator, uint256 bnbAmount, StakeMigrationStatus status
address indexed operatorAddress, address indexed delegator, uint256 bnbAmount, StakeMigrationRespCode respCode
);
event MigrateSuccess(address indexed operatorAddress, address indexed delegator, uint256 shares, uint256 bnbAmount);
event ParamChange(string key, bytes value);
Expand Down

0 comments on commit ea00161

Please sign in to comment.