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

upgrade v1.7 #76

Merged
merged 3 commits into from
Aug 23, 2022
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
6 changes: 3 additions & 3 deletions docs/concepts/token.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ order: 4
Plug Chain is a Cosmos SDK based chain with full PVM support. Due to this architecture, tokens and assets in the network may come from different independent sources: bank module, token module, evm module.
`bank module, token module tokens belong to the PRC-10 protocol`, `pvm module belongs to the PRC-20 protocol`.

##PLUGCN
## PC

The `plugcn` token belongs to the native token of the bank module, which can be used for pledge, IBC transfer, community governance, handling fee, etc.
The `pc` token belongs to the native token of the bank module, which can be used for pledge, IBC transfer, community governance, handling fee, etc.

## PRC-10
PRC-10 is a token built into the Plug Chain public chain. PRC-10 is a technical token standard supported by the Plug Chain blockchain itself. It does not use a PVM virtual machine. In the Plug Chain network, each account can pass [`x/prc10`](../cli-client/token.md) module issues PRC-10 tokens. Users can lock their tokens individually. To issue tokens, the issuer needs to specify the token name, total size, precision, description, etc.

Tokens `plugcn`, `dhw1`, `kingdm`, `joey`, etc. belong to PRC-10 protocol tokens
Tokens `pc`, `dhw1`, `kingdm`, `joey`, etc. belong to PRC-10 protocol tokens


## PRC-20
Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/validator-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Self-delegation is delegation from a validator to himself. This amount can be in

### Is there a minimum amount of plugchaind that must be delegated to be an active (=bonded) validator

The minimum mortgage `1plugcn`, on the chain is `1*10^6 uplugcn`, you can create a validator, but whether you can become an active validator depends on whether the number of your mortgage (including delegated) exceeds the 100th validator.
The minimum mortgage `1pc`, on the chain is `1*10^6 uplugcn`, you can create a validator, but whether you can become an active validator depends on whether the number of your mortgage (including delegated) exceeds the 100th validator.

### Can a validator run away with their delegators' funds

Expand Down
4 changes: 2 additions & 2 deletions docs/daemon/local-testnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ plugchaind collect-gentxs

### plugchaind start

Change the default token denom to `plugcn`
Change the default token denom to `pc`

```bash
sed -i 's/stake/plugcn/g' $HOME/.plugchain/config/genesis.json
sed -i 's/stake/pc/g' $HOME/.plugchain/config/genesis.json
```

Now it‘s ready to start `plugchaind`
Expand Down
8 changes: 4 additions & 4 deletions docs/get-started/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ Client-facing, programming language specific SDKs will also be available to make

## Plug Chain Token

The *Plug Chain* hub has its own native token, called *plugcn* , which has three roles in the network.
The *Plug Chain* hub has its own native token, called *pc* , which has three roles in the network.

** Mortgage. ** Similar to the ATOM token in the Cosmos Hub, the *plugcn* token will be used as a collateral token to protect the safe operation of the PoS blockchain.
** Mortgage. ** Similar to the ATOM token in the Cosmos Hub, the *pc* token will be used as a collateral token to protect the safe operation of the PoS blockchain.

* **transaction fee. ** *plugcn* tokens will also be used to pay for all transactions in the *Plug Chain* network.
* **transaction fee. ** *pc* tokens will also be used to pay for all transactions in the *Plug Chain* network.

**Service charge. ** Service providers in the *Plug Chain* network need to charge service fees in units of *plugcn* tokens.
**Service charge. ** Service providers in the *Plug Chain* network need to charge service fees in units of *pc* tokens.

The *Plug Chain* network will eventually support all whitelisted fee tokens, which can be used to pay transaction fees and service fees.
2 changes: 1 addition & 1 deletion docs/pvm/cosmoswap.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Parameter Description:
| token | address | Token contract address |
| amountTokenDesired | uint256 | Amount of tokens injected into the pool |
| amountTokenMin | uint256 | The minimum number of tokens to withdraw from the pool, the minimum value can be 0 |
| amountPLUGMin | uint256 | The minimum amount of `plugcn` in the pool, the minimum can be filled in 0 |
| amountPLUGMin | uint256 | The minimum amount of `pc` in the pool, the minimum can be filled in 0 |
| to | address | LP output address, usually from address |
| deadline | uint256 | UTC time zone timestamp must be greater than current time |

Expand Down
4 changes: 2 additions & 2 deletions docs/zh/concepts/token.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ Plug Chain 是一个基于 Cosmos SDK 的链,具有完整的 PVM 支持。由

在 Plug Chain 上用于质押、治理和 gas 消耗的面额是PLUGCN. PLUGCN提供以下效用:保护权益证明链、用于治理提案的代币、费用分配以及作为在 PVM 上运行智能合约的气体手段。

$$ 1 plugcn = 1 ~ * ~ 10^{6} uplugcn $$
$$ 1 pc = 1 ~ * ~ 10^{6} uplugcn $$

## PRC-10
PRC-10是一种是通过 Plug Chain 公链内置的通证。 PRC-10是 Plug Chain 区块链本身支持的技术代币标准,没有使用PVM虚拟机, 在 Plug Chain 网络中,每个帐户都能够通过[`x/prc10`](../cli-client/token.md)模块发行PRC-10代币。 用户可以单独锁定其代币。 要发放代币,发行者需要指定代币名称、总大小、精度、描述、等信息。

代币 `plugcn`,`dhw1`,`kingdm`,`joey`等都属于 PRC-10 协议代币
代币 `pc`,`dhw1`,`kingdm`,`joey`等都属于 PRC-10 协议代币


## PRC-20
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/concepts/validator-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ order: 10

### 想要成为活跃的验证人最少要抵押多少plug

最低抵押 `1plugcn`,链上为 `1*10^6 uplugcn` 即可创建验证人,但能否成为活跃的验证人取决于您的抵押(包括受委托)数量是否超过第100名验证人。
最低抵押 `1pc`,链上为 `1*10^6 uplugcn` 即可创建验证人,但能否成为活跃的验证人取决于您的抵押(包括受委托)数量是否超过第100名验证人。

### 验证人可以卷走委托人的资金吗

Expand Down
4 changes: 2 additions & 2 deletions docs/zh/daemon/local-testnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ plugchaind collect-gentxs

### plugchaind start

修改默认token为 `plugcn`
修改默认token为 `pc`

```bash
sed -i 's/stake/plugcn/g' $HOME/.plugchain/config/genesis.json
sed -i 's/stake/pc/g' $HOME/.plugchain/config/genesis.json
```

现在可以启动 `plugchaind` 了
Expand Down
2 changes: 1 addition & 1 deletion docs/zh/features/distribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
### 收益的来源

1. 交易所产生的交易费 `fees`(由交易的第一个签名者支付`fees`)
2. 通胀的代币 `plugcn`(目前Plug Chain系统设置的通胀为13%每年,通证总量为`20亿`)
2. 通胀的代币 `pc`(目前Plug Chain系统设置的通胀为13%每年,通证总量为`20亿`)

### 收益的去向

Expand Down
12 changes: 6 additions & 6 deletions docs/zh/features/governance.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@

- **投票:**

一旦抵押数量达到某个特定值(`最小抵押`),提议将被确认,对该提议的投票也将开启。之后,质押的 plugcn 持有者可以发送 `TxGovVote` 交易对此提议进行投票。
一旦抵押数量达到某个特定值(`最小抵押`),提议将被确认,对该提议的投票也将开启。之后,质押的 pc 持有者可以发送 `TxGovVote` 交易对此提议进行投票。

- 当提议涉及软件升级时,流程请参考 [`Upgrade`](./upgrade.md)

### 提议提交

#### 提交提议的权利

无论质押与否,任何 plugcn 持有者均可通过发送 `TxGovProposal` 交易来提交提议。一旦被提交,将生成一个唯一的 `proposalID` 来标识提议。
无论质押与否,任何 pc 持有者均可通过发送 `TxGovProposal` 交易来提交提议。一旦被提交,将生成一个唯一的 `proposalID` 来标识提议。

#### 提议类型

Expand Down Expand Up @@ -54,15 +54,15 @@

#### 参与者

_参与者_ 是对提议有投票权利的用户。在 Plug Chain Hub 上,参与者是质押的 plugcn 持有者。未质押的 plugcn 持有者和其他用户无权参与治理。但是他们能提交提议及抵押。
_参与者_ 是对提议有投票权利的用户。在 Plug Chain Hub 上,参与者是质押的 pc 持有者。未质押的 pc 持有者和其他用户无权参与治理。但是他们能提交提议及抵押。

注意,对于一个特定的验证人,如果一些参与者满足以下条件,则这些参与者可以被禁止为一个提议投票:

- 在提议进入投票期后,参与者对该验证人质押或解质押 plugcn
- 在提议进入投票期后,参与者对该验证人质押或解质押 pc

- 在提议进入投票期后,参与者成为验证人

但是这不阻止参与者用质押到其他验证人的 plugcn 进行投票。例如,在一个提议进入投票期之前,参与者质押一些 plugcn 到验证人 A;在该提议进入投票期之后,质押另一些 plugcn 到验证人 B;则仅仅在验证人 B 下的投票将被禁止。
但是这不阻止参与者用质押到其他验证人的 pc 进行投票。例如,在一个提议进入投票期之前,参与者质押一些 pc 到验证人 A;在该提议进入投票期之后,质押另一些 pc 到验证人 B;则仅仅在验证人 B 下的投票将被禁止。

#### 投票期

Expand Down Expand Up @@ -93,7 +93,7 @@ _注意: 在 UI 端,我们可以为一些紧急的提议增加一个 `Not Urge

阈值初始被设置为 50%,如果超过 1/3 的投票(排除 `弃权` 投票)是 `否决` 票,有一定的否决概率。这意味着在投票期结束时,如果 `赞成` 投票(排除 `弃权` 投票)的比例大于 50%,并且 `否决` 投票(排除 `弃权` 投票)的比例小于 1/3,则提议将被接受。

在投票期结束之前,如果满足一个特殊条件,提议可以被接受。即,如果 `赞成` 投票与 `InitTotalVotingPower`(`初始总投票权`)的比例超过 2:3,提议将立即被接受,即使 `投票期` 还没结束。`初始总投票权` 是投票开启时所有质押的 plugcn 持有人的总投票权。这个条件存在以至于在紧急情况下网络可以快速做出反应。
在投票期结束之前,如果满足一个特殊条件,提议可以被接受。即,如果 `赞成` 投票与 `InitTotalVotingPower`(`初始总投票权`)的比例超过 2:3,提议将立即被接受,即使 `投票期` 还没结束。`初始总投票权` 是投票开启时所有质押的 pc 持有人的总投票权。这个条件存在以至于在紧急情况下网络可以快速做出反应。

#### 继承

Expand Down
4 changes: 2 additions & 2 deletions docs/zh/features/mint.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ AnnualInflationAmount = inflationBasement * inflationRate
blockInflationAmount = AnnualInflationAmount * blockCostTime / (year)
```

`inflationBasement` 的值被定义在 genesis 文件中. 默认情况下,genesis 里面写入的值是 `15989000000uplugcn`(159.89亿个 plug,`1 plugcn` 等于 `1*10^6 uplugcn`)。
`inflationBasement` 的值被定义在 genesis 文件中. 默认情况下,genesis 里面写入的值是 `15989000000uplugcn`(159.89亿个 plug,`1 pc` 等于 `1*10^6 uplugcn`)。

假设 `blockCostTime` 是5000毫秒,通胀比例 `inflationRate` 是 `13%`,那么这个块增发的 token 数量是 `329000000uplugcn`(`329plugcn`)
假设 `blockCostTime` 是5000毫秒,通胀比例 `inflationRate` 是 `13%`,那么这个块增发的 token 数量是 `329000000uplugcn`(`329pc`)

## 对用户的影响

Expand Down
8 changes: 4 additions & 4 deletions docs/zh/get-started/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ order: 1

## Plug Chain 通证

*Plug Chain* 枢纽有自己的原生通证,称为 *plugcn* ,在网络中有三个作用。
*Plug Chain* 枢纽有自己的原生通证,称为 *pc* ,在网络中有三个作用。

* **抵押。** 与Cosmos Hub中的ATOM通证类似,*plugcn* 通证将用作抵押通证以保护PoS区块链的安全运行。
* **抵押。** 与Cosmos Hub中的ATOM通证类似,*pc* 通证将用作抵押通证以保护PoS区块链的安全运行。

* **交易费用。** *plugcn* 通证也将用于支付*Plug Chain* 网络中所有交易的费用。
* **交易费用。** *pc* 通证也将用于支付*Plug Chain* 网络中所有交易的费用。

* **服务费。** *Plug Chain* 网络中的服务提供者需要以*plugcn* 通证为单位收取服务费。
* **服务费。** *Plug Chain* 网络中的服务提供者需要以*pc* 通证为单位收取服务费。

*Plug Chain* 网络最终将支持所有列入白名单的费用通证,它们可用于支付交易费用和服务费用。

2 changes: 1 addition & 1 deletion docs/zh/pvm/cosmoswap.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ addLiquidityPLUG(address token,uint256 amountTokenDesired,uint256 amountTokenMin
| token | address | 代币合约地址 |
| amountTokenDesired | uint256 | 注入池子token代币数量 |
| amountTokenMin | uint256 | 最低提出池子token代币数量,最低可填写0 |
| amountPLUGMin | uint256 | 最低提出池子`plugcn`数量,最低可填写0 |
| amountPLUGMin | uint256 | 最低提出池子`pc`数量,最低可填写0 |
| to | address | LP输出地址,一般为from地址 |
| deadline | uint256 | UTC时区的时间戳 必须大于当前时间 |

Expand Down
37 changes: 21 additions & 16 deletions rpc/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,21 @@ const (
)

// APICreator creates the JSON-RPC API implementations.
type APICreator = func(*server.Context, client.Context, *rpcclient.WSClient) []rpc.API
type APICreator = func(
ctx *server.Context,
clientCtx client.Context,
tendermintWebsocketClient *rpcclient.WSClient,
allowUnprotectedTxs bool,
) []rpc.API

// apiCreators defines the JSON-RPC API namespaces.
var apiCreators map[string]APICreator

func init() {
apiCreators = map[string]APICreator{
EthNamespace: func(ctx *server.Context, clientCtx client.Context, tmWSClient *rpcclient.WSClient) []rpc.API {
EthNamespace: func(ctx *server.Context, clientCtx client.Context, tmWSClient *rpcclient.WSClient, allowUnprotectedTxs bool) []rpc.API {
nonceLock := new(types.AddrLocker)
evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx)
evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs)
return []rpc.API{
{
Namespace: EthNamespace,
Expand All @@ -71,7 +76,7 @@ func init() {
},
}
},
Web3Namespace: func(*server.Context, client.Context, *rpcclient.WSClient) []rpc.API {
Web3Namespace: func(*server.Context, client.Context, *rpcclient.WSClient, bool) []rpc.API {
return []rpc.API{
{
Namespace: Web3Namespace,
Expand All @@ -81,7 +86,7 @@ func init() {
},
}
},
NetNamespace: func(_ *server.Context, clientCtx client.Context, _ *rpcclient.WSClient) []rpc.API {
NetNamespace: func(_ *server.Context, clientCtx client.Context, _ *rpcclient.WSClient, _ bool) []rpc.API {
return []rpc.API{
{
Namespace: NetNamespace,
Expand All @@ -91,8 +96,8 @@ func init() {
},
}
},
PersonalNamespace: func(ctx *server.Context, clientCtx client.Context, _ *rpcclient.WSClient) []rpc.API {
evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx)
PersonalNamespace: func(ctx *server.Context, clientCtx client.Context, _ *rpcclient.WSClient, allowUnprotectedTxs bool) []rpc.API {
evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs)
return []rpc.API{
{
Namespace: PersonalNamespace,
Expand All @@ -102,7 +107,7 @@ func init() {
},
}
},
TxPoolNamespace: func(ctx *server.Context, _ client.Context, _ *rpcclient.WSClient) []rpc.API {
TxPoolNamespace: func(ctx *server.Context, _ client.Context, _ *rpcclient.WSClient, _ bool) []rpc.API {
return []rpc.API{
{
Namespace: TxPoolNamespace,
Expand All @@ -112,8 +117,8 @@ func init() {
},
}
},
DebugNamespace: func(ctx *server.Context, clientCtx client.Context, _ *rpcclient.WSClient) []rpc.API {
evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx)
DebugNamespace: func(ctx *server.Context, clientCtx client.Context, _ *rpcclient.WSClient, allowUnprotectedTxs bool) []rpc.API {
evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs)
return []rpc.API{
{
Namespace: DebugNamespace,
Expand All @@ -123,8 +128,8 @@ func init() {
},
}
},
MinerNamespace: func(ctx *server.Context, clientCtx client.Context, _ *rpcclient.WSClient) []rpc.API {
evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx)
MinerNamespace: func(ctx *server.Context, clientCtx client.Context, _ *rpcclient.WSClient, allowUnprotectedTxs bool) []rpc.API {
evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs)
return []rpc.API{
{
Namespace: MinerNamespace,
Expand All @@ -134,9 +139,9 @@ func init() {
},
}
},
RPCNamespace: func(ctx *server.Context, clientCtx client.Context, tmWSClient *rpcclient.WSClient) []rpc.API {
RPCNamespace: func(ctx *server.Context, clientCtx client.Context, tmWSClient *rpcclient.WSClient, allowUnprotectedTxs bool) []rpc.API {
nonceLock := new(types.AddrLocker)
evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx)
evmBackend := backend.NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs)
return []rpc.API{
{
Namespace: RPCNamespace,
Expand All @@ -150,12 +155,12 @@ func init() {
}

// GetRPCAPIs returns the list of all APIs
func GetRPCAPIs(ctx *server.Context, clientCtx client.Context, tmWSClient *rpcclient.WSClient, selectedAPIs []string) []rpc.API {
func GetRPCAPIs(ctx *server.Context, clientCtx client.Context, tmWSClient *rpcclient.WSClient, allowUnprotectedTxs bool, selectedAPIs []string) []rpc.API {
var apis []rpc.API

for _, ns := range selectedAPIs {
if creator, ok := apiCreators[ns]; ok {
apis = append(apis, creator(ctx, clientCtx, tmWSClient)...)
apis = append(apis, creator(ctx, clientCtx, tmWSClient, allowUnprotectedTxs)...)
} else {
ctx.Logger.Error("invalid namespace value", "namespace", ns)
}
Expand Down
29 changes: 16 additions & 13 deletions rpc/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type EVMBackend interface {
RPCGasCap() uint64 // global gas cap for eth_call over rpc: DoS protection
RPCEVMTimeout() time.Duration // global timeout for eth_call over rpc: DoS protection
RPCTxFeeCap() float64 // RPCTxFeeCap is the global transaction fee(price * gaslimit) cap for send-transaction variants. The unit is ether.
UnprotectedAllowed() bool

RPCMinGasPrice() int64
SuggestGasTipCap(baseFee *big.Int) (*big.Int, error)
Expand Down Expand Up @@ -86,16 +87,17 @@ var _ BackendI = (*Backend)(nil)

// Backend implements the BackendI interface
type Backend struct {
ctx context.Context
clientCtx client.Context
queryClient *types.QueryClient // gRPC query client
logger log.Logger
chainID *big.Int
cfg config.Config
ctx context.Context
clientCtx client.Context
queryClient *types.QueryClient // gRPC query client
logger log.Logger
chainID *big.Int
cfg config.Config
allowUnprotectedTxs bool
}

// NewBackend creates a new Backend instance for cosmos and ethereum namespaces
func NewBackend(ctx *server.Context, logger log.Logger, clientCtx client.Context) *Backend {
func NewBackend(ctx *server.Context, logger log.Logger, clientCtx client.Context, allowUnprotectedTxs bool) *Backend {
chainID, err := ethermint.ParseChainID(clientCtx.ChainID)
if err != nil {
panic(err)
Expand All @@ -104,11 +106,12 @@ func NewBackend(ctx *server.Context, logger log.Logger, clientCtx client.Context
appConf := config.GetConfig(ctx.Viper)

return &Backend{
ctx: context.Background(),
clientCtx: clientCtx,
queryClient: types.NewQueryClient(clientCtx),
logger: logger.With("module", "backend"),
chainID: chainID,
cfg: appConf,
ctx: context.Background(),
clientCtx: clientCtx,
queryClient: types.NewQueryClient(clientCtx),
logger: logger.With("module", "backend"),
chainID: chainID,
cfg: appConf,
allowUnprotectedTxs: allowUnprotectedTxs,
}
}
Loading