Skip to content

Commit

Permalink
Deprecate double signing slasher (#10998)
Browse files Browse the repository at this point in the history
  • Loading branch information
pahor167 authored May 17, 2024
1 parent a4c608b commit 272dd19
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "../common/interfaces/ICeloVersionedContract.sol";

import "./SlasherUtil.sol";
import "../../contracts-0.8/common/IsL2Check.sol";

contract DoubleSigningSlasher is ICeloVersionedContract, SlasherUtil {
contract DoubleSigningSlasher is ICeloVersionedContract, SlasherUtil, IsL2Check {
using SafeMath for uint256;

// For each signer address, check if a block header has already been slashed
Expand Down Expand Up @@ -44,7 +45,7 @@ contract DoubleSigningSlasher is ICeloVersionedContract, SlasherUtil {
* @return Patch version of the contract.
*/
function getVersionNumber() external pure returns (uint256, uint256, uint256, uint256) {
return (1, 1, 1, 1);
return (1, 1, 2, 0);
}

/**
Expand Down Expand Up @@ -80,7 +81,7 @@ contract DoubleSigningSlasher is ICeloVersionedContract, SlasherUtil {
address[] memory groupElectionLessers,
address[] memory groupElectionGreaters,
uint256[] memory groupElectionIndices
) public {
) public onlyL1 {
checkIfAlreadySlashed(signer, headerA);
checkIfAlreadySlashed(signer, headerB);
uint256 blockNumber = checkForDoubleSigning(signer, index, headerA, headerB);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ contract DoubleSigningSlasherBaseTest is Test {
address caller2;
uint256 caller2PK;
address public registryAddress = 0x000000000000000000000000000000000000ce10;
address constant proxyAdminAddress = 0x4200000000000000000000000000000000000018;

struct SlashingIncentives {
// Value of LockedGold to slash from the account.
Expand Down Expand Up @@ -147,6 +148,10 @@ contract DoubleSigningSlasherBaseTest is Test {
lockedGold.setAccountTotalLockedGold(group, 50000);
lockedGold.setAccountTotalLockedGold(otherGroup, 50000);
}

function _whenL2() public {
deployCodeTo("Registry.sol", abi.encode(false), proxyAdminAddress);
}
}

contract DoubleSigningSlasherInitialize is DoubleSigningSlasherBaseTest {
Expand Down Expand Up @@ -387,4 +392,23 @@ contract DoubleSigningSlasherSlash is DoubleSigningSlasherBaseTest {
vm.expectRevert("Already slashed");
slasher.mockSlash(params);
}

function test_Reverts_WhenL2() public {
_whenL2();
params = DoubleSigningSlasherTest.SlashParams({
signer: validator,
index: validatorIndex,
headerA: headerA,
headerB: headerC,
groupMembershipHistoryIndex: 0,
validatorElectionLessers: validatorElectionLessers,
validatorElectionGreaters: validatorElectionGreaters,
validatorElectionIndices: validatorElectionIndices,
groupElectionLessers: groupElectionLessers,
groupElectionGreaters: groupElectionGreaters,
groupElectionIndices: groupElectionIndices
});
vm.expectRevert("This method is not supported in L2 anymore.");
slasher.mockSlash(params);
}
}

0 comments on commit 272dd19

Please sign in to comment.