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

update docs #62

Merged
merged 6 commits into from
Jun 6, 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
2 changes: 1 addition & 1 deletion docs/concepts/addr.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ sequence: "0"
- Hierarchical deterministic wallet based on [BIP44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki).
- BIP44 defines a logical hierarchy of deterministic wallets based on the algorithm described in [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki), which allows the processing of multiple tokens , multiple accounts, external and internal chains per account, and millions of addresses per chain, such as Bitcoin and Ethereum.
- pubkey type `secp256k1` .
- The root HD path of the account is `44'/118'/0'/0/0` .
- The root HD path of the account is `m/44'/118'/0'/0/0` .
- coin-type is 118 .
- Those that support the [PRC-10](./token.md#prc-10) protocol do not support the [PRC-20](./token.md#prc-20) protocol
- bech32 identified as (gx...)
Expand Down
35 changes: 35 additions & 0 deletions docs/concepts/fees.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
order: 6
---

# Gas and Fees

Learn the difference between "Gas" and "Fees" in PVM and Cosmos.

## Introducing `Gas` and `Fees`

In the Cosmos SDK, `gas` is a special unit used to track resource consumption during execution. `gas` is normally consumed when reading and writing to storage, but it can also be consumed if expensive computations are required. It has two main purposes:

* Make sure the block doesn't consume too many resources and will be finalized.
* Prevent spam and abuse by end users. To this end, `gas` consumed during the execution of `Msg` is usually priced, resulting in `fee` (`fees = gas * gas-prices`). `fees` must generally be paid by the sender executing the `Msg`. Note that the Cosmos SDK does not enforce "gas" pricing by default, as there may be other ways to prevent spam (such as bandwidth schemes). Nonetheless, most applications will implement a "fee" mechanism to prevent spam.


## Cosmos SDK `Fees`

* Verify that the gas price offered by the transaction is higher than the local `min-gas-prices`. `min-gas-prices` is a local parameter for each full node and is used during `CheckTx` to discard transactions that do not offer minimum fees. This ensures that the mempool is not spammed by spam transactions.
* EQ: `fees = gas * gas-price`
* For example: `gas=200000` (default), `gas-price=0.0001`, `fees=20uplugcn`


## PVM `Fees`


The main difference between PVM and Cosmos state transitions is that PVM uses a [gas table](https://github.com/ethereum/go-ethereum/blob/master/params/protocol_params.go) for each OPCODE, while Cosmos Use "GasConfig" to charge gas for each CRUD operation by setting the unit of access to the database and the cost per byte.

The gas usage of PVM and EVM is calculated in the same way, but the PVM `gas` usage is different from the EVM `gas` usage process. When the gas is enough to pay the transaction, the excess gas will be returned. PVM fee gas will not be returned.

* PVM transactions must first meet the minimum handling fee required by `fees` greater than Cosmos SDK` (currently the minimum handling fee is 0.0001*200000=20uplugcn)`
* The gas provided by the transaction should be greater than or equal to the gas sum calculated according to the [gas table](https://github.com/ethereum/go-ethereum/blob/master/params) transaction bytes /protocol_params.go)
* Minimum gasPrice is `7`
* EQ: fees = `math.Ceil( (gas*gasPrice) / 1000 )` (Proposal [v1.5.0](https://www.plugchain.network/v2/communityDetail?id=9) algorithm after upgrade)
* For example: `gas=654321`,`gasPrice=7`,`fees=4581uplugcn`
97 changes: 57 additions & 40 deletions docs/get-started/mainnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,92 +2,117 @@
order: 3
---

# Join The Mainnet
# Join mainnet

:::tip
**Requirements:** [install plugchaind](install.md) or download the corresponding version of the binary file [releases](https://github.com/oracleNetworkProtocol/plugchain/releases)
You need to [install plugchaind](install.md) first, or download the corresponding version of the binary file [releases](https://github.com/oracleNetworkProtocol/plugchain/releases)
:::

## Run a Full Node
## run a full node

### Start node from genesis
### Using the genesis file

:::tip
You must use Plug Chain [v1.1.0](https://github.com/oracleNetworkProtocol/plugchain.git) to initialize your node.
Your node must be initialized with Plug Chain [v1.1.0](https://github.com/oracleNetworkProtocol/plugchain.git)
:::

1. Initialize the node

```bash
plugchaind init <moniker> --chain-id=plugchain_520-1
```
````

2. Download the `genesis.json`, `app.toml`, `config.toml` public on the mainnet:

```bash
curl -o ~/.plugchain/config/genesis.json https://raw.githubusercontent.com/oracleNetworkProtocol/mainnet/main/v1/genesis.json
curl -o ~/.plugchain/config/app.toml https://raw.githubusercontent.com/oracleNetworkProtocol/mainnet/main/v1/app.toml
curl -o ~/.plugchain/config/config.toml https://raw.githubusercontent.com/oracleNetworkProtocol/mainnet/main/v1/config.toml
````
3. Before starting, if you want to modify the service port, seed information, peering point, sentinel mode, etc., you can modify the file by yourself, and then start the node.
```
3. Before starting, if you want to modify the service port, seed information, peering point, sentinel mode, etc., you can modify the file yourself, and then synchronize the block.


### Sync block

Sync mainnet block data
#### One snapshot synchronization

Depending on the snapshot height, lock the `plugchaind` binary version to use


| Block height | Database | plugchaind version | Download address |
| ---- | --------- | -------- | ----|
| 4256215 | goleveldb (default) | [v1.5](https://github.com/oracleNetworkProtocol/plugchain/tree/v1.5.0) | [mainnet-4256215-20220602-goleveldb](https://snapshot-node-mainnet.oss-cn-hangzhou.aliyuncs.com/mainnet-4256215-20220602-goleveldb.zip) |

1. Download snapshot data

2. Data override `~/.plugchain/data/` directory

3. Use the corresponding plugchaind version to start `plugchaind start`



4. Start the node service
#### 2 Gradual upgrade synchronization
start node service

```bash
# Start the node (you can also use nohup or systemd to run in the background)


plugchaind start --minimum-gas-prices 0.0001uplugcn
plugchaind start
```


Next, your node will perform all chain upgrade procedures. Between each upgrade, you must sync blocks with a specific version. Don't worry about using an older version at an upgrade height, the node will stop automatically.

| Proposal | Starting Height | Upgrade Height | plugchaind Version |
| -------- | ------------ | -------------- | ----- |
| [v1.0](https://www.plugchain.network/v2/communityDetail?id=7) | 3000000 | | [v1.1.0](https://github.com/oracleNetworkProtocol/plugchain/releases/tag/v1.1.0) |
| [v1.2.1](https://www.plugchain.network/v2/communityDetail?id=8) | 3349542 | 3576853 | [v1.2.1](https://github.com/oracleNetworkProtocol/plugchain/releases/tag/v1.2.1) |
| [v1.5.0](https://www.plugchain.network/v2/communityDetail?id=9) | 3935641 | 4152263 | [v1.5.0](https://github.com/oracleNetworkProtocol/plugchain/releases/tag/v1.5.0) |
| [v1.0](https://www.plugchain.network/v2/communityDetail?id=7) | 3000000 | | [v1.1.0](https://github.com/oracleNetworkProtocol/plugchain/tree/v1 .1.0) |
| [v1.2.1](https://www.plugchain.network/v2/communityDetail?id=8) | 3349542 | 3576853 | [v1.2.1](https://github.com/oracleNetworkProtocol/plugchain/tree/ v1.2.1) |
| [v1.5.0](https://www.plugchain.network/v2/communityDetail?id=9) | 3935641 | 4152263 | [v1.5.0](https://github.com/oracleNetworkProtocol/plugchain/tree/ v1.5.0) |






:::tip
You may see some connection errors, that's okay, the P2P network is trying to find an available connection


:::

## Upgrade to Validator Node

### Create a Wallet
## Upgrade to validator node

### Create wallet

You can [create a new wallet](../cli-client/keys.md#create-a-new-key) or [import an existing one](../cli-client/keys.md#recover-an-existing-key-from-seed-phrase), then get some plugchaind from the exchanges or anywhere else into the wallet you just created, .e.g.
You can [create a new wallet](../cli-client/keys.md#create a key) or [import an existing wallet](../cli-client/keys.md#recover the key with the mnemonic phrase key), then transfer some plugs from the exchange or anywhere into the wallet you just created:

```bash
# create a new wallet
# Create a new wallet
plugchaind keys add <key-name>
```

:::warning
**Important**

write the seed phrase in a safe place! It is the only way to recover your account if you ever forget your password.
Back up your mnemonic phrases in a safe place! If you forget your password, this is the only way to recover your account.
:::

### Confirm your node has caught-up
### Confirm node synchronization status

```bash
# if you have not installed jq
# You can install jq with this command
# apt-get update && apt-get install -y jq

# if the output is false, means your node has caught-up
# If the output is false, your node has finished syncing
plugchaind status 2>&1 | jq -r '.SyncInfo.catching_up'
```

### Create Validator
### Create validator

Only if your node has caught-up, you can run the following command to upgrade your node to be a validator.
You can run the following command to promote your node to a validator only if the node has finished syncing:

```bash
plugchaind tx staking create-validator \
--from mywallet \
plugchaind tx staking create-validator --from mywallet \
--amount 1000000uplugcn \
--pubkey $(plugchaind tendermint show-validator) \
--moniker="my validator" \
Expand All @@ -98,19 +123,11 @@ plugchaind tx staking create-validator \
--fees 20uplugcn --chain-id plugchain_520-1
```


:::warning
**Important**
**important**

Backup the `config` directory located in your plugchaind home (default ~/.plugchain/) carefully! It is the only way to recover your validator.
Be sure to back up the `config` directory in your home (~/.plugchain/ by default) directory! This is the only way to recover validators if your server disk is damaged or if you are migrating your server.
:::

If there are no errors, then your node is now a validator or candidate (depending on whether your delegation amount is in the top 100)

Read more:

- Concepts
- [General Concepts](../concepts/general-concepts.md)
- [Validator FAQ](../concepts/validator-faq.md)
- Validator Security
- [Sentry Nodes (DDOS Protection)](../concepts/sentry-nodes.md)
- [Key Management](../tools/kms.md)
If the above command gives no errors, your node is already a validator or candidate (depending on whether your Voting Power is in the top 50)
38 changes: 3 additions & 35 deletions docs/pvm/json-rpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ This can be configured in `~/.plugchain/config/app.toml`:
| [`rpc_getCode`](#rpc-getcode) | Rpc | ✔ | ✔ | |
| [`rpc_getTransactionLogs`](#rpc-gettransactionlogs) | Rpc | ✔ | ✔ | |
| [`rpc_sign`](#rpc-sign) | Rpc | ✔ | ✔ | |
| [`rpc_sendTransaction`](#rpc-sendtransaction) | Rpc | ✔ | ✔ | |
| [`rpc_sendRawTransaction`](#rpc-sendrawtransaction) | Rpc | ✔ | ✔ | |
| [`rpc_call`](#rpc-call) | Rpc | ✔ | ✔ | |
| [`rpc_estimateGas`](#rpc-estimategas) | Rpc | ✔ | ✔ | |
Expand All @@ -75,7 +74,7 @@ This can be configured in `~/.plugchain/config/app.toml`:
| [`eth_getBlockTransactionCountByHash`](#eth-getblocktransactioncountbyhash) | Eth | ✔ | ✔ | |
| [`eth_getCode`](#eth-getcode) | Eth | ✔ | ✔ | |
| [`eth_sign`](#eth-sign) | Eth | ✔ | ✔ | |
| [`eth_sendTransaction`](#eth-sendtransaction) | Eth | ✔ | ✔ | |
<!-- | [`eth_sendTransaction`](#eth-sendtransaction) | Eth | ✔ | ✔ | | -->
| [`eth_sendRawTransaction`](#eth-sendrawtransaction) | Eth | ✔ | ✔ | |
| [`eth_call`](#eth-call) | Eth | ✔ | ✔ | |
| [`eth_estimateGas`](#eth-estimategas) | Eth | ✔ | ✔ | |
Expand Down Expand Up @@ -476,37 +475,6 @@ curl -X POST --data '{"jsonrpc":"2.0","method":"rpc_sign","params":["gx1vt7svcst
// Result
{ "Jsonrpc": "2.0", "id": 1, "result": "0x909809c76ed2a5d38733de39207d0f411222b9b49c64a192bf649cb13f63f37b45acb4f6939facb4f1c277bc70fb00407564140c0f18600ac44388f2c1dfd1dc1b"}
```

### `rpc_sendTransaction`

Send a transaction from the given account to the given account.

#### parameters

- Trading partners:

`from`: `DATA`, 20 Bytes - The address to send the transaction to.

`to`: `DATA`, 20 Bytes - (optional when creating a new contract) The address to which the transaction points.

`gas`: QUANTITY - (optional, default: 20000) Integer of gas provided for transaction execution. It will return unused gas.

`gasPrice`: QUANTITY - (optional, default: to be determined) Integer of gas to use for the price of each paid gas

`value`: QUANTITY - the value sent with this transaction

`data`: `DATA` - The compiled code of the contract or the hash of the method signature and encoded parameters of the call. See contract ABI for details

`nonce`: QUANTITY - (optional) an integer for the nonce. This allows overriding your own pending transactions that use the same nonce.

```json
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"rpc_sendTransaction","params":[{"from":"gx1vt7svcst6982ka4c3ufxmqrs05a9e9eq676tyv", "to":"gx1n4m7gafr6cxtj8q4w9mm3480ar4gq3t95k6he9", "value" :"0x16345", "gasLimit":"0x5208", "gasPrice":"0x55ae82600"}],"id":1}' -H "Content-Type: application/json" http://localhost:8545

// Result
{"jsonrpc":"2.0","id":1,"result":"0x33653249db68ebe5c7ae36d93c9b2abc10745c80a72f591e296f598e2d4709f6"}
```

### `rpc_sendRawTransaction`

Create a new message for a signed transaction to invoke transaction or contract creation.
Expand Down Expand Up @@ -933,7 +901,7 @@ curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sign","params":["0x3b7252d00
{"jsonrpc":"2.0","id":1,"result":"0x909809c76ed2a5d38733de39207d0f411222b9b49c64a192bf649cb13f63f37b45acb4f6939facb4f1c277bc70fb00407564140c0f18600ac44388f2c1dfd1dc1b"}
```

### `eth_sendTransaction`
<!-- ### `eth_sendTransaction`

Sends transaction from given account to a given account.

Expand Down Expand Up @@ -961,7 +929,7 @@ curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{

// Result
{"jsonrpc":"2.0","id":1,"result":"0x33653249db68ebe5c7ae36d93c9b2abc10745c80a72f591e296f598e2d4709f6"}
```
``` -->

### `eth_sendRawTransaction`

Expand Down
4 changes: 2 additions & 2 deletions docs/tools/service.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ order: 3
The Plug Chain Hub client SDK is a software development kit based on the Endpoint provided by Plug Chain Hub, which provides great convenience for users to quickly develop applications based on the Plug Chain Hub chain.

- [plugchain-sdk-go](https://github.com/oracleNetworkProtocol/plugchain-sdk-go)
- [Java in development]()
- [Python in development]()
<!-- - [Java in development]() -->
<!-- - [Python in development]() -->

## Design goals and concepts

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/concepts/addr.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ sequence: "0"
- 基于[BIP44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)的分层确定性钱包。
- BIP44基于[BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki)中描述的算法定义确定性钱包的逻辑层次结构,该算法允许处理多种代币,多个帐户,每个帐户的外部和内部链以及每个链的数百万个地址,例如比特币和以太坊。
- pubkey类型 `secp256k1` 。
- 账户的根 HD 路径是 `44'/118'/0'/0/0` 。
- 账户的根 HD 路径是 `m/44'/118'/0'/0/0` 。
- coin-type是 118 。
- 支持 [PRC-10](./token.md#prc-10)协议的,不支持[PRC-20](./token.md#prc-20)协议
- bech32标识为(gx...)
Expand Down
35 changes: 35 additions & 0 deletions docs/zh/concepts/fees.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
order: 6
---

# Gas and Fees

了解 PVM 和 Cosmos 中“Gas”和“Fees”之间的区别。

## 介绍 `Gas` 和 `Fees`

在 Cosmos SDK 中,`gas` 是一个特殊的单位,用于跟踪执行期间的资源消耗。 `gas` 通常在对存储进行读写时消耗,但如果需要进行昂贵的计算,也可以消耗它。 它有两个主要目的:

* 确保区块不会消耗太多资源并将最终确定。
* 防止最终用户的垃圾邮件和滥用。 为此,在 `Msg` 执行期间消耗的 `gas` 通常会被定价,从而产生 `fee`(`fees = gas * gas-prices`)。 `fees`一般必须由执行`Msg`的发送者支付。 请注意,Cosmos SDK 默认不强制执行“gas”定价,因为可能有其他方法可以防止垃圾邮件(例如带宽方案)。 尽管如此,大多数应用程序将实施“费用”机制来防止垃圾邮件。


## Cosmos SDK `Fees`

* 验证交易提供的 gas 价格是否高于当地的 `min-gas-prices`。 `min-gas-prices` 是每个全节点的本地参数,在 `CheckTx` 期间用于丢弃不提供最低费用的交易。 这确保了内存池不会被垃圾事务发送到垃圾邮件中。
* 公式: `fees = gas * gas-price`
* 例如: `gas=200000`(默认)、`gas-price=0.0001`、`fees=20uplugcn`


## PVM `Fees`


PVM 和 Cosmos 状态转换之间的主要区别在于,PVM 对每个 OPCODE 使用 [gas table](https://github.com/ethereum/go-ethereum/blob/master/params/protocol_params.go),而 Cosmos 使用“GasConfig”,通过设置访问数据库的单位和每字节成本来为每个 CRUD 操作收取 gas。

PVM和EVM的Gas使用计算方式相同, 但PVM `gas`使用 不同于EVM `gas`使用流程,EVM当gas足够支付交易时,多余的gas会返回。PVM手续费gas不会返回。

* PVM交易首先要满足`fees`大于Cosmos SDK`要求的最低手续费(目前最低手续费为0.0001*200000=20uplugcn)`
* 交易提供的gas应大于或等于根据[gas table](https://github.com/ethereum/go-ethereum/blob/master/params)交易字节计算的gas总和
* `gasPrice` 最低为 `7`
* 公式: `fees = math.Ceil( (gas*gasPrice) / 1000 )` (提案[v1.5.0](https://www.plugchain.network/v2/communityDetail?id=9) 升级之后的算法)
* 例如: `gas=654321`,`gasPrice=7`,`fees=4581uplugcn`
Loading