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

chore: backport tss updater #367

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions v2/contracts/evm/ERC20Custody.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ contract ERC20Custody is IERC20Custody, ReentrancyGuard, AccessControl, Pausable
_unpause();
}

/// @notice Update tss address
/// @param newTSSAddress new tss address
function updateTSSAddress(address newTSSAddress) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (newTSSAddress == address(0)) revert ZeroAddress();

_revokeRole(WITHDRAWER_ROLE, tssAddress);
_revokeRole(WHITELISTER_ROLE, tssAddress);

_grantRole(WITHDRAWER_ROLE, newTSSAddress);
_grantRole(WHITELISTER_ROLE, newTSSAddress);

tssAddress = newTSSAddress;

emit UpdatedCustodyTSSAddress(newTSSAddress);
}

/// @notice Unpause contract.
function setSupportsLegacy(bool _supportsLegacy) external onlyRole(DEFAULT_ADMIN_ROLE) {
supportsLegacy = _supportsLegacy;
Expand Down
13 changes: 13 additions & 0 deletions v2/contracts/evm/GatewayEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ contract GatewayEVM is
return result;
}

/// @notice Update tss address
/// @param newTSSAddress new tss address
function updateTSSAddress(address newTSSAddress) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (newTSSAddress == address(0)) revert ZeroAddress();

_revokeRole(TSS_ROLE, tssAddress);
_grantRole(TSS_ROLE, newTSSAddress);

tssAddress = newTSSAddress;

emit UpdatedGatewayTSSAddress(newTSSAddress);
}

/// @notice Pause contract.
function pause() external onlyRole(PAUSER_ROLE) {
_pause();
Expand Down
19 changes: 19 additions & 0 deletions v2/contracts/evm/ZetaConnectorBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ abstract contract ZetaConnectorBase is IZetaConnectorEvents, ReentrancyGuard, Pa
IGatewayEVM public immutable gateway;
/// @notice The address of the Zeta token.
address public immutable zetaToken;
/// @notice The address of the TSS (Threshold Signature Scheme) contract.
address public tssAddress;

/// @notice New role identifier for withdrawer role.
bytes32 public constant WITHDRAWER_ROLE = keccak256("WITHDRAWER_ROLE");
Expand All @@ -40,13 +42,30 @@ abstract contract ZetaConnectorBase is IZetaConnectorEvents, ReentrancyGuard, Pa
}
gateway = IGatewayEVM(gateway_);
zetaToken = zetaToken_;
tssAddress = tssAddress_;

_grantRole(DEFAULT_ADMIN_ROLE, admin_);
_grantRole(WITHDRAWER_ROLE, tssAddress_);
_grantRole(TSS_ROLE, tssAddress_);
_grantRole(PAUSER_ROLE, admin_);
}

/// @notice Update tss address
/// @param newTSSAddress new tss address
function updateTSSAddress(address newTSSAddress) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (newTSSAddress == address(0)) revert ZeroAddress();

_revokeRole(WITHDRAWER_ROLE, tssAddress);
_revokeRole(TSS_ROLE, tssAddress);

_grantRole(WITHDRAWER_ROLE, newTSSAddress);
_grantRole(TSS_ROLE, newTSSAddress);

tssAddress = newTSSAddress;

emit UpdatedZetaConnectorTSSAddress(newTSSAddress);
}

/// @notice Pause contract.
function pause() external onlyRole(PAUSER_ROLE) {
_pause();
Expand Down
4 changes: 4 additions & 0 deletions v2/contracts/evm/interfaces/IERC20Custody.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ interface IERC20CustodyEvents {

/// @notice Emitted in legacy deposit method.
event Deposited(bytes recipient, IERC20 indexed asset, uint256 amount, bytes message);

/// @notice Emitted when tss address is updated
/// @param newTSSAddress new tss address
event UpdatedCustodyTSSAddress(address newTSSAddress);
}

/// @title IERC20CustodyErrors
Expand Down
4 changes: 4 additions & 0 deletions v2/contracts/evm/interfaces/IGatewayEVM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ interface IGatewayEVMEvents {
/// @param payload The calldata passed to the call.
/// @param revertOptions Revert options.
event Called(address indexed sender, address indexed receiver, bytes payload, RevertOptions revertOptions);

/// @notice Emitted when tss address is updated
/// @param newTSSAddress new tss address
event UpdatedGatewayTSSAddress(address newTSSAddress);
}

/// @title IGatewayEVMErrors
Expand Down
4 changes: 4 additions & 0 deletions v2/contracts/evm/interfaces/IZetaConnector.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ interface IZetaConnectorEvents {
/// @param data The calldata passed to the contract call.
/// @param revertContext Revert context to pass to onRevert.
event WithdrawnAndReverted(address indexed to, uint256 amount, bytes data, RevertContext revertContext);

/// @notice Emitted when tss address is updated
/// @param newTSSAddress new tss address
event UpdatedZetaConnectorTSSAddress(address newTSSAddress);
}
159 changes: 157 additions & 2 deletions v2/pkg/erc20custody.sol/erc20custody.go

Large diffs are not rendered by default.

366 changes: 364 additions & 2 deletions v2/pkg/erc20custody.t.sol/erc20custodytest.go

Large diffs are not rendered by default.

159 changes: 157 additions & 2 deletions v2/pkg/erc20custodyechidnatest.sol/erc20custodyechidnatest.go

Large diffs are not rendered by default.

159 changes: 157 additions & 2 deletions v2/pkg/gatewayevm.sol/gatewayevm.go

Large diffs are not rendered by default.

138 changes: 136 additions & 2 deletions v2/pkg/gatewayevm.t.sol/gatewayevminboundtest.go

Large diffs are not rendered by default.

335 changes: 333 additions & 2 deletions v2/pkg/gatewayevm.t.sol/gatewayevmtest.go

Large diffs are not rendered by default.

159 changes: 157 additions & 2 deletions v2/pkg/gatewayevmechidnatest.sol/gatewayevmechidnatest.go

Large diffs are not rendered by default.

138 changes: 136 additions & 2 deletions v2/pkg/gatewayevmupgrade.t.sol/gatewayevmuupsupgradetest.go

Large diffs are not rendered by default.

138 changes: 136 additions & 2 deletions v2/pkg/gatewayevmupgradetest.sol/gatewayevmupgradetest.go

Large diffs are not rendered by default.

138 changes: 136 additions & 2 deletions v2/pkg/gatewayevmzevm.t.sol/gatewayevmzevmtest.go

Large diffs are not rendered by default.

136 changes: 135 additions & 1 deletion v2/pkg/ierc20custody.sol/ierc20custody.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading