Skip to content

Commit

Permalink
add account management design (#863)
Browse files Browse the repository at this point in the history
  • Loading branch information
chaychen2005 committed Jun 18, 2020
1 parent b89b960 commit 71da917
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 0 deletions.
49 changes: 49 additions & 0 deletions docs/design/features/account_management.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# 账号管理

本文档描述账号的冻结/解冻操作及其操作权限的设计方案。

```eval_rst
.. important::
账号冻结/解冻操作支持storagestate的存储模式,不支持mptstate的存储模式。
```

## 名词解释

账号管理的相关操作包括冻结、解冻、查询状态、授权、查询授权。

- [冻结账号](../../manual/console.html#freezeaccount):可逆操作,一账号冻结后不能部署及调用合约
- [解冻账号](../../manual/console.html#unfreezeaccount):撤销冻结的操作,一账号解冻后可部署及调用合约
- [查询账号状态](../../manual/console.html#getaccountstatus):查询账号状态,返回该账号可用/已冻结的状态

账号的冻结/解冻操作只能由链的委员进行。权限相关操作请参考[基于角色的权限控制](../security_control/ChainGovernance.md)

```eval_rst
.. important::
冻结账号的操作不会对原有账号内容进行修改,只会通过标志位进行记录。
```

账号状态(可用、已冻结)转换矩阵如下:

| | available(可用) | frozen(已冻结) |
| ---------------- | -------------------------- | ---------------- |
| freeze(冻结) | 冻结成功 | 失败,提示已冻结 |
| unfreeze(解冻) | 失败,提示账号可用无需解冻 | 解冻成功 |

## 具体实现

### 账号状态存储

- 复用字段frozen,用于记录该账号是否已冻结,该字段默认为false,表示可用,冻结时该值为true;

**注意:**

1. 对不存在字段frozen的账号表,查询该字段时将返回false;

### 账号状态判断

Executive中根据账号地址获取frozen字段值,进行判断后部署或执行交易,或者抛出异常,提示该账号已冻结。

```eval_rst
.. important::
兼容性说明:账号管理相关操作只能在2.5及以上版本上进行。
```
1 change: 1 addition & 0 deletions docs/design/features/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ FISCO BCOS引入的合约命名服务CNS通过提供链上合约名称与合约
storage_security.md
network_compress.md
contract_management.md
account_management.md
stat.md
flow_control.md
49 changes: 49 additions & 0 deletions en/docs/design/features/account_management.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Account Management

This document describes the design of the freezing/unfreezing account operations and their operation permissions.

```eval_rst
.. important::
The account life cycle management operation on the account supports storagestate storage mode, but not mptstate storage mode.
```

## noun explanation

Account management related operations include `freezeAccount`, `unfreezeAccount`, `getAccountStatus` and authority management related operations.

- [freezeAccount](../../manual/console.html#freezeaccount) : Reversible operation, the interfaces of a frozen account can not deploy or execute transaction
- [unfreezeAccount](../../manual/console.html#unfreezeaccount) : Undo the `freezeAccount` operation, the interfaces of an unfrozen account can deploy or execute transaction
- [getAccountStatus](../../manual/console.html#getaccountstatus) : Query the status of a account to return the status of available/frozen

The authority management related operations please refer to [ChainGovernance.md](../security_control/ChainGovernance.md).

```eval_rst
.. important::
The operation of freezing a account will not modify the original account content, and will only be recorded through a field.
```

The state transition moments are shown below:

| | available | frozen |
| -------- | --------- | ------- |
| freeze | Success | Fail |
| unfreeze | Fail | Success |

## Implementation

### Record of Account status

- A existing field `frozen` is used to record whether the account has been frozen. The default of this field is false, indicating that it is available. When frozen, the value is true.

**Note:**

1. False will be returned when querying the field for the account table with no field `frozen`;

### Judgment of account status

In the Executive module, the values of frozen fields are obtained according to the address of an account, then the account can deploy and execute transaction smoothly, or an exception is thrown to indicate that the account has been frozen after judgment.

```eval_rst
.. important::
Account management related operations can only be performed on 2.5 and above.
```
1 change: 1 addition & 0 deletions en/docs/design/features/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ Considering that data is accessible to each agency in consortium chain structure
storage_security.md
network_compress.md
contract_management.md
account_management.md
stat.md
flow_control.md

0 comments on commit 71da917

Please sign in to comment.