Skip to content

Commit

Permalink
update description for contract status management (FISCO-BCOS#755)
Browse files Browse the repository at this point in the history
  • Loading branch information
chaychen2005 authored Mar 15, 2020
1 parent 4efbcff commit 97df233
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
19 changes: 15 additions & 4 deletions docs/design/features/contract_management.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# 合约管理

本文档描述合约生命周期管理中冻结/解冻/销毁操作及其操作权限的设计方案
本文档描述合约生命周期管理中冻结/解冻/销毁操作(以下简称合约状态管理操作)及其操作权限的设计方案

```eval_rst
.. important::
合约的冻结/解冻/销毁操作支持storagestate的存储模式,不支持mptstate的存储模式。这里提及的合约目前只限于智能合约,不包括预编译合约、CRUD合约。
合约状态管理操作支持storagestate的存储模式,不支持mptstate的存储模式。这里提及的合约目前只限于Solidity合约,不包括预编译合约、CRUD合约。
```

## 名词解释
Expand Down Expand Up @@ -32,7 +32,7 @@

- 复用合约表中已有的alive字段,用于记录该合约是否已销毁,该字段默认为true,销毁时该值为false;
- 新增一字段frozen,用于记录该合约是否已冻结,该字段默认为false,表示可用,冻结时该值为true;
- 新增一字段authority,用于记录能冻结/解冻/销毁该合约的账号,每个账号对应一行authority记录。
- 新增一字段authority,用于记录合约管理员账号,每个账号对应一行authority记录。

**注意:**

Expand All @@ -46,7 +46,7 @@ Executive中根据合约地址获取alive和frozen字段值,进行判断后交

### 管理权限判断

- 设置(冻结/解冻/销毁)合约状态的操作需进行权限判断,只有authority列表中的账号才能设置该合约的状态;
- 更新合约状态的操作需进行权限判断,只有authority列表中的账号才能设置该合约的状态;
- 授予权限的操作也需进行权限判断,只有authority列表中的账号才能授予其他账号管理该合约的权限;
- 查询合约状态及权限列表不需进行权限判断。

Expand All @@ -65,6 +65,17 @@ contract ContractStatusPrecompiled {
}
```

### 返回码描述

| code | message |
| ------ | ---------------------------------------------------------- |
| 0 | success |
| -50000 | permission denied |
| -51900 | the contract has been destroyed |
| -51901 | the contract has been frozen |
| -51902 | the contract is available |
| -51903 | the contract has been granted authorization with same user |

```eval_rst
.. important::
兼容性说明:合约管理相关操作只能在2.3及以上版本上进行。
Expand Down
19 changes: 15 additions & 4 deletions en/docs/design/features/contract_management.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Contract Management

This document describes the design of the freezing/unfreezing/destroying operations and their operation permissions in contract life cycle management.
This document describes the design of the freezing/unfreezing/destroying operations(referred to as contract status management operation on below) and their operation permissions in contract life cycle management.

```eval_rst
.. important::
The freezing/unfreezing/destroying operation on the contract supports storagestate storage mode, but not mptstate storage mode.The contracts mentioned here are only smart contracts and do not include pre-compiled contracts or CRUD contracts currently.
The contract status management operation on the contract supports storagestate storage mode, but not mptstate storage mode.The contracts mentioned here are only Solidity contracts and do not include pre-compiled contracts or CRUD contracts currently.
```

## noun explanation
Expand Down Expand Up @@ -32,7 +32,7 @@ The state transition moments are shown below:

- Reuse the existing `alive` field in the contract table to record whether the contract has been destroyed. This field defaults to true, and the value is false when killed.
- A new field `frozen` is used to record whether the contract has been frozen. The default of this field is false, indicating that it is available. When frozen, the value is true.
- A new field `authority` is used to record accounts that can freeze/unfreeze/destroy the contract. Each account with permission corresponds to one line of `authority` records.
- A new field `authority` is used to record accounts that can manage contract status. Each account with permission corresponds to one line of `authority` records.

**Note:**

Expand All @@ -46,7 +46,7 @@ In the Executive module, the values of alive and frozen fields are obtained acco

### Judgment of authority

- The authority to freeze/unfreeze/destroy contract needs to be determined. Only the accounts in authority list can set the contract status;
- The authority to update contract status needs to be determined. Only the accounts in authority list can set the contract status;
- The authority to grant authorization needs to be determined. Only the account in the authority list can grant other accounts the authorization to manage the contract;
- Any account can query contract status and authorization list.

Expand All @@ -65,6 +65,17 @@ contract ContractStatusPrecompiled {
}
```

### Description of return code

| code | message |
| ------ | ---------------------------------------------------------- |
| 0 | success |
| -50000 | permission denied |
| -51900 | the contract has been destroyed |
| -51901 | the contract has been frozen |
| -51902 | the contract is available |
| -51903 | the contract has been granted authorization with same user |

```eval_rst
.. important::
Contract management related operations can only be performed on 2.3 and above.
Expand Down

0 comments on commit 97df233

Please sign in to comment.