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: add pauser role to tss #386

Merged
merged 3 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
1 change: 1 addition & 0 deletions v2/contracts/evm/ERC20Custody.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ contract ERC20Custody is
tssAddress = tssAddress_;
_grantRole(DEFAULT_ADMIN_ROLE, admin_);
_grantRole(PAUSER_ROLE, admin_);
_grantRole(PAUSER_ROLE, tssAddress_);
_grantRole(WITHDRAWER_ROLE, tssAddress_);
_grantRole(WHITELISTER_ROLE, admin_);
_grantRole(WHITELISTER_ROLE, tssAddress_);
Expand Down
1 change: 1 addition & 0 deletions v2/contracts/evm/GatewayEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ contract GatewayEVM is

_grantRole(DEFAULT_ADMIN_ROLE, admin_);
_grantRole(PAUSER_ROLE, admin_);
_grantRole(PAUSER_ROLE, tssAddress_);
tssAddress = tssAddress_;
_grantRole(TSS_ROLE, tssAddress_);

Expand Down
1 change: 1 addition & 0 deletions v2/contracts/evm/ZetaConnectorBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ abstract contract ZetaConnectorBase is
_grantRole(WITHDRAWER_ROLE, tssAddress_);
_grantRole(TSS_ROLE, tssAddress_);
_grantRole(PAUSER_ROLE, admin_);
_grantRole(PAUSER_ROLE, tssAddress_);
}

/// @dev Authorizes the upgrade of the contract, sender must be owner.
Expand Down
12 changes: 7 additions & 5 deletions v2/test/ERC20Custody.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ contract ERC20CustodyTest is Test, IGatewayEVMErrors, IGatewayEVMEvents, IReceiv
address owner;
address destination;
address tssAddress;
address foo;
RevertContext revertContext;

error EnforcedPause();
Expand All @@ -53,6 +54,7 @@ contract ERC20CustodyTest is Test, IGatewayEVMErrors, IGatewayEVMEvents, IReceiv
owner = address(this);
destination = address(0x1234);
tssAddress = address(0x5678);
foo = address(0x9876);

token = new TestERC20("test", "TTK");
zeta = new TestERC20("zeta", "ZETA");
Expand Down Expand Up @@ -221,15 +223,15 @@ contract ERC20CustodyTest is Test, IGatewayEVMErrors, IGatewayEVMEvents, IReceiv
}

function testForwardCallToReceiveERC20ThroughCustodyTogglePause() public {
vm.prank(tssAddress);
vm.expectRevert(abi.encodeWithSelector(AccessControlUnauthorizedAccount.selector, tssAddress, PAUSER_ROLE));
vm.prank(foo);
vm.expectRevert(abi.encodeWithSelector(AccessControlUnauthorizedAccount.selector, foo, PAUSER_ROLE));
custody.pause();

vm.prank(tssAddress);
vm.expectRevert(abi.encodeWithSelector(AccessControlUnauthorizedAccount.selector, tssAddress, PAUSER_ROLE));
vm.prank(foo);
vm.expectRevert(abi.encodeWithSelector(AccessControlUnauthorizedAccount.selector, foo, PAUSER_ROLE));
gateway.unpause();

vm.prank(owner);
vm.prank(tssAddress);
custody.pause();

uint256 amount = 100_000;
Expand Down
12 changes: 7 additions & 5 deletions v2/test/GatewayEVM.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ contract GatewayEVMTest is Test, IGatewayEVMErrors, IGatewayEVMEvents, IReceiver
address owner;
address destination;
address tssAddress;
address foo;
RevertOptions revertOptions;
RevertContext revertContext;

Expand All @@ -52,6 +53,7 @@ contract GatewayEVMTest is Test, IGatewayEVMErrors, IGatewayEVMEvents, IReceiver
owner = address(this);
destination = address(0x1234);
tssAddress = address(0x5678);
foo = address(0x9876);

token = new TestERC20("test", "TTK");

Expand Down Expand Up @@ -281,15 +283,15 @@ contract GatewayEVMTest is Test, IGatewayEVMErrors, IGatewayEVMEvents, IReceiver
}

function testForwardCallToReceiveNoParamsTogglePause() public {
vm.prank(tssAddress);
vm.expectRevert(abi.encodeWithSelector(AccessControlUnauthorizedAccount.selector, tssAddress, PAUSER_ROLE));
vm.prank(foo);
vm.expectRevert(abi.encodeWithSelector(AccessControlUnauthorizedAccount.selector, foo, PAUSER_ROLE));
gateway.pause();

vm.prank(tssAddress);
vm.expectRevert(abi.encodeWithSelector(AccessControlUnauthorizedAccount.selector, tssAddress, PAUSER_ROLE));
vm.prank(foo);
vm.expectRevert(abi.encodeWithSelector(AccessControlUnauthorizedAccount.selector, foo, PAUSER_ROLE));
skosito marked this conversation as resolved.
Show resolved Hide resolved
gateway.unpause();

vm.prank(owner);
vm.prank(tssAddress);
skosito marked this conversation as resolved.
Show resolved Hide resolved
gateway.pause();

bytes memory data = abi.encodeWithSignature("receiveNoParams()");
Expand Down
12 changes: 7 additions & 5 deletions v2/test/ZetaConnectorNative.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ contract ZetaConnectorNativeTest is
address owner;
address destination;
address tssAddress;
address foo;
RevertContext revertContext;

error EnforcedPause();
Expand All @@ -55,6 +56,7 @@ contract ZetaConnectorNativeTest is
owner = address(this);
destination = address(0x1234);
tssAddress = address(0x5678);
foo = address(0x9876);

zetaToken = new TestERC20("zeta", "ZETA");

Expand Down Expand Up @@ -151,15 +153,15 @@ contract ZetaConnectorNativeTest is
uint256 amount = 100_000;
bytes32 internalSendHash = "";

vm.prank(tssAddress);
vm.expectRevert(abi.encodeWithSelector(AccessControlUnauthorizedAccount.selector, tssAddress, PAUSER_ROLE));
vm.prank(foo);
vm.expectRevert(abi.encodeWithSelector(AccessControlUnauthorizedAccount.selector, foo, PAUSER_ROLE));
zetaConnector.pause();

vm.prank(tssAddress);
vm.expectRevert(abi.encodeWithSelector(AccessControlUnauthorizedAccount.selector, tssAddress, PAUSER_ROLE));
vm.prank(foo);
vm.expectRevert(abi.encodeWithSelector(AccessControlUnauthorizedAccount.selector, foo, PAUSER_ROLE));
zetaConnector.unpause();

vm.prank(owner);
vm.prank(tssAddress);
zetaConnector.pause();

vm.expectRevert(EnforcedPause.selector);
Expand Down
12 changes: 7 additions & 5 deletions v2/test/ZetaConnectorNonNative.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ contract ZetaConnectorNonNativeTest is
address owner;
address destination;
address tssAddress;
address foo;
RevertContext revertContext;

error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
Expand All @@ -55,6 +56,7 @@ contract ZetaConnectorNonNativeTest is
owner = address(this);
destination = address(0x1234);
tssAddress = address(0x5678);
foo = address(0x9876);

zetaToken = new ZetaNonEth(tssAddress, tssAddress);

Expand Down Expand Up @@ -109,15 +111,15 @@ contract ZetaConnectorNonNativeTest is
uint256 amount = 100_000;
bytes32 internalSendHash = "";

vm.prank(tssAddress);
vm.expectRevert(abi.encodeWithSelector(AccessControlUnauthorizedAccount.selector, tssAddress, PAUSER_ROLE));
vm.prank(foo);
vm.expectRevert(abi.encodeWithSelector(AccessControlUnauthorizedAccount.selector, foo, PAUSER_ROLE));
zetaConnector.pause();

vm.prank(tssAddress);
vm.expectRevert(abi.encodeWithSelector(AccessControlUnauthorizedAccount.selector, tssAddress, PAUSER_ROLE));
vm.prank(foo);
vm.expectRevert(abi.encodeWithSelector(AccessControlUnauthorizedAccount.selector, foo, PAUSER_ROLE));
zetaConnector.unpause();

vm.prank(owner);
vm.prank(tssAddress);
zetaConnector.pause();

vm.expectRevert(EnforcedPause.selector);
Expand Down
1 change: 1 addition & 0 deletions v2/test/utils/upgrades/GatewayEVMUpgradeTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ contract GatewayEVMUpgradeTest is

_grantRole(DEFAULT_ADMIN_ROLE, admin_);
_grantRole(PAUSER_ROLE, admin_);
_grantRole(PAUSER_ROLE, tssAddress_);
tssAddress = tssAddress_;
_grantRole(TSS_ROLE, tssAddress_);

Expand Down
Loading