Skip to content

Commit

Permalink
Merge pull request #1 from emailtovamos/emailtovamos-patch-1
Browse files Browse the repository at this point in the history
Update BEP-174 with newer function changes
  • Loading branch information
emailtovamos authored Jan 23, 2023
2 parents 877c4dd + ec524cf commit 8f5cca5
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions BEP174.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@

## 1. Summary

This BEP introduces a new governance proposal type to manage the set of whitelisted Relayers. A Relayer whitelist was introduced recently to the BSC genesis contracts ([PR-198](https://github.com/bnb-chain/bsc-genesis-contract/pull/198)). This BEP will improve the management of the relayer whitelist by introducing Relayer Managers, where a Relayer Manager can manage the registration of a single Relayer. Managers will be elected and ejected via governance.
This BEP introduces a new governance proposal type to manage the set of whitelisted Relayers.
A Relayer whitelist was introduced recently to the BSC genesis contracts ([PR-198](https://github.com/bnb-chain/bsc-genesis-contract/pull/198)).
This BEP will improve the management of the relayer whitelist by introducing Relayer Managers, where a Relayer Manager can manage the registration of a single Relayer.
Managers will be elected and ejected via governance.

## 2. Abstract

This BEP introduces a new governance proposal type to manage Relayer Manager public keys that will be stored in the [`RelayerHub`](https://github.com/bnb-chain/bsc-genesis-contract/blob/71dcd4c409a68a6e084645a9f1f80adecd5a4269/contracts/RelayerHub.sol) genesis contract on BSC.

Relayer Managers will be able to manage their individual elayer public key. Only Relayer public keys registered via Managers will be able to invoke the `RelayerHub` smart contract for cross chain transfers.
Relayer Managers will be able to manage their individual relayer public key. Only Relayer public keys registered via Managers will be able to invoke the `RelayerHub` smart contract for cross chain transfers.


## 3. Status

This BEP is a draft.
This BEP is under progress. See https://github.com/bnb-chain/bsc-genesis-contract/pull/205.

## 4. Motivation

Expand All @@ -32,50 +35,48 @@ After the implementation of this BEP:

- A Relayer Manager role will be introduced with corresponding public keys.
- The set of Managers will be updated via governance using the existing [param change proposal](https://github.com/bnb-chain/bnb-chain.github.io/blob/master/docs/learn/bsc-gov-workflow.md#submit-cross-chain-param-change-proposal) mechanism.
- Managers will have to register the 100BNB once their public key has been added to the set of Managers via governance
- Once registered, Managers will be able to add an associated Relayer public key
- Managers will NOT have to deposit any BNB (as opposed to 100BNB requirement which was before).
- Once selected by governance, Managers will be able to add an associated Relayer public key.
- There will be a 1:1 relationship between Manager public key to active Relayer public key.
- Only associated Relayers can send cross chain messages.
- Managers can modify public key of their Relayer at any time. This will facilitate rotation of Relayer instances.
- Managers can modify public key of their Relayer at any time. This will facilitate rotation of Relayer instances.
- The old `unregister` function will still be active to allow the existing whitelisted relayers to safely exit.

### 5.3 `RelayerHub` Smart Contract Changes
#### Relayer Manager functions

```
function removeManagerByGov(address) external onlyGov
```
Removes Manager public key from current set of Managers. 100BNB will be returned to Manager address if the Manager has desposited. Emits an event on success. This is only called via governance.
```
function removeManager() external onlyManager
```
Removes Manager public key from current set of Managers. 100BNB will be returned to Manager address if the Manager has desposited. Emits an event on success.
```
fuction addManagerByGov(address) external onlyGov
function updateParam(string calldata key, bytes calldata value) external override onlyInit onlyGov
```
Adds a Manager public key to the current set of Managers. This is only called via governance. Emits an event on success.
The pre-existing function will be updated to support `addManager` and `removeManager` keys to facilitate adding and
removing of managers via governance.

```
function registerManager() external payable onlyManager
function removeManagerByHimself() external
```
Registers an Manager and accepts 100BNB fee. Emits an event on success.
Allows a manager to remove himself if required.

```
function addRelayer(address) external onlyManager
fuction addManagerByGov(address) external onlyGov
```
Adds a Relayer for the calling Manager. Overwrites Relayer if there is an existing Relayer already added. Emits an event on success.
Adds a Manager public key to the current set of Managers. This is only called via governance. Emits an event on success.

```
function registerManagerAddRelayer(address) external payable onlyManager
function updateRelayer(address relayerToBeAdded) public onlyManager
```
Calls both `registerManager` and `addRelayer`.
This can be used by the manager to add or remove its relayer. Overwrites Relayer if there is an existing Relayer already
added. Emits an event on success. The `relayerToBeAdded` parameter can be set to `0` address to enable removal of a
relayer (e.g. if the private key gets compromised).

```
function removeRelayer() external onlyManager
function whitelistInit() external
```
Removes a Relayer associated to the calling Manager. Emits an event on successful removal.
This is to ensure smooth transition so that the presently existing hardcoded whitelisted relayers continue to be
relayers after the hardfork. This function needs to be **manually** called once after the hardfork.

#### Relayer functions
```
function isRelayer(address) external bool
function isRelayer(address relayerAddress) external override view returns (bool)
```
This will be called by the Relayer codebase, instead of registering. Relayer can stop if this returns false

Expand All @@ -84,11 +85,7 @@ This will be called by the Relayer codebase, instead of registering. Relayer ca

```
function updateParam(string calldata key, bytes calldata value) external override onlyInit onlyGov{
if (Memory.compareStrings(key,"requiredDeposit")) {
...
} else if (Memory.compareStrings(key,"dues")) {
...
} else if (Memory.compareStrings(key,"addManager")) {
if (Memory.compareStrings(key,"addManager")) {
// TODO check and parse value
// addManagerAddress(...)
} else if (Memory.compareStrings(key,"removeManager")) {
Expand All @@ -104,14 +101,17 @@ The `updateParam` function will be modified accept two new keys
- `addManager` to add a Manager to the stored Manager set.
- `removeManager` to remove a Manager from the stored Manager set.

Also `requiredDeposit` and `dues` will be removed. So no need to account for them in the keys check.

#### Functions to be Deprecated

These Relayer functions will be deprecated:
```
function register() external payable ...
function unregister() external ...
```

`unregister()` function isn't deprecated to allow existing hardcoded whitelisted relayers to have safe exit.

### 5.4 Relayer Changes

Update Relayer codebase to no longer register and deposit. Update abi? and run code generation to call new `verifyRelayer` method on `RelayerHub` smart contract and proceed to relay cross chain messages on success.
Expand All @@ -134,4 +134,4 @@ The commands used to create a change proposal to governance.

## 7. License

The content is licensed under [CC0](https://creativecommons.org/publicdomain/zero/1.0/).
The content is licensed under [CC0](https://creativecommons.org/publicdomain/zero/1.0/).

0 comments on commit 8f5cca5

Please sign in to comment.