Skip to content

Commit

Permalink
BEP-410: Add Agent for Validators (#410)
Browse files Browse the repository at this point in the history
  • Loading branch information
cosinlink authored Jul 18, 2024
1 parent 1390735 commit d79d411
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
106 changes: 106 additions & 0 deletions BEPs/BEP-410.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<pre>
BEP: 410
Title: Add Agent for Validators
Status: Draft
Type: Standards
Created: 2024-07-15
</pre>

# BEP-410: Add Agent for Validators

- [BEP-410: Add Agent for Validators](https://github.com/bnb-chain/BEPs/pull/410)
- [1. Summary](#1-summary)
- [2. Abstract](#2-abstract)
- [3. Motivation](#3-motivation)
- [4. Specification](#4-specification)
- [5. Reference Implementations](#5-reference-implementations)
- [6. License](#6-license)


## 1. Summary

This BEP attempts to enhance the security of validator account management through account isolation by delegating some of the validator operator's permissions to other accounts.

## 2. Abstract

Currently, validators need to manage the operator key, consensus key, and vote key. Among these, the operator key is used for operating a validator, including creating a validator, editing the information of a validator, and undelegating.
When creating a validator, the operator key is also used for self-delegating with more than 2001 BNB. Since the operator key holds a large amount of staking, it is not suitable for daily management of the validator.
Therefore, we have introduced a new `updateAgent` interface in the system contract. Through this interface, the operator can delegate another account to manage the validator.

## 3. Motivation

Before this BEP, the consensus address, commission rate, validator description and vote address can only be changed by the operator which also manages staking for the validator.
To reduce the usage of operator key and improve the security of operator key management, validators can set an agent to help them to take on the mentioned tasks below.

## 4. Specification
### Data Structure
The current [`Validator`](https://github.com/bnb-chain/bsc-genesis-contract/blob/2dbebb57a0d436d6a30b78c1f123395035249035/contracts/BC_fusion/StakeHub.sol#L154) struct is as follows.
```solidity
struct Validator {
address consensusAddress;
address operatorAddress;
address creditContract;
uint256 createdTime;
bytes voteAddress;
Commission commission;
Description description;
bool jailed;
uint256 jailUntil;
uint256 updateTime;
uint256[20] __reservedSlots;
}
```


The new `Validator` struct is as follows. This BEP adds a new field `agent` and reduce a slot of `__reservedSlots` in the `Validator` struct to keep
the slot layer compatibility of upgradeable contracts.

```solidity
struct Validator {
address consensusAddress;
address operatorAddress;
address creditContract;
uint256 createdTime;
bytes voteAddress;
Description description;
Commission commission;
bool jailed;
uint256 jailUntil;
uint256 updateTime;
// The agent can perform transactions on behalf of the operatorAddress in certain scenarios.
address agent;
uint256[19] __reservedSlots;
}
```

### Interface

The validator operator can set the agent address for the validator by calling the following function.
The `newAgent` cannot be any operator address or any existing agent.
Each validator can only have one agent assigned at a time. Updating to a new agent will override the previous one.

```solidity
function updateAgent(address newAgent) external validatorExist(msg.sender);
```

### Agent Permission

The agent is allowed to edit the consensus address, commission rate, description and vote address of the validator.
The methods that can be accessed are as follows:

```solidity
function editConsensusAddress(address newConsensusAddress) external;
function editCommissionRate(uint64 commissionRate) external;
function editDescription(Description memory description) external;
function editVoteAddress(bytes calldata newVoteAddress, bytes calldata blsProof) external;
```

It is notable that even after the agent is set, the operator retains the ability to edit the information listed below.

## 5. Reference Implementations
See https://github.com/bnb-chain/bsc-genesis-contract/pull/568.


## 6. License

The content is licensed under [CC0](https://creativecommons.org/publicdomain/zero/1.0/).
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Here is the list of subjects of BEPs:
| [BEP-366](./BEPs/BEP-366.md) | PGreenfield Atomic Object Update | Standards | Candidate |
| [BEP-402](./BEPs/BEP-402.md) | Complete Missing Fields in Block Header to Generate Signature | Standards | Candidate |
| [BEP-404](./BEPs/BEP-404.md) | Clear Miner History when Switching Validator Set | Standards | Candidate |
| [BEP-410](./BEPs/BEP-410.md) | Add Agent for Validators | Standards | Draft |



Expand Down

0 comments on commit d79d411

Please sign in to comment.