diff --git a/docs/endpoints/action.md b/docs/endpoints/action.md deleted file mode 100644 index a808ceb06..000000000 --- a/docs/endpoints/action.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -order: 7 ---- - -## Events -Values that describe different events - -## message.module -- bank -- distribution -- governance -- staking -- slashing -- token -- transfer -- evm -- liquidity -- ibc_client -- ibc_channel -- ibc_connection - - -## message.action -- /cosmos.bank.v1beta1.MsgSend -- /cosmos.bank.v1beta1.MsgMultiSend -- /cosmos.distribution.v1beta1.MsgFundCommunityPool -- /cosmos.distribution.v1beta1.MsgSetWithdrawAddress -- /cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward -- /cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission -- /cosmos.gov.v1beta1.MsgVote - -- /cosmos.slashing.v1beta1.MsgUnjail -- /cosmos.staking.v1beta1.MsgBeginRedelegate -- /cosmos.staking.v1beta1.MsgCreateValidator -- /cosmos.staking.v1beta1.MsgDelegate -- /cosmos.staking.v1beta1.MsgEditValidator -- /cosmos.staking.v1beta1.MsgUndelegate -- /ethermint.evm.v1.MsgEthereumTx -- /ibc.applications.transfer.v1.MsgTransfer -- /ibc.core.client.v1.MsgCreateClient -- /ibc.core.channel.v1.MsgAcknowledgement -- /ibc.core.channel.v1.MsgChannelOpenAck -- /ibc.core.channel.v1.MsgChannelOpenInit -- /ibc.core.channel.v1.MsgRecvPacket -- /ibc.core.channel.v1.MsgTimeout -- /ibc.core.connection.v1.MsgConnectionOpenAck -- /ibc.core.connection.v1.MsgConnectionOpenInit -- /plugchain.prc10.MsgBurnToken -- /plugchain.prc10.MsgEditToken -- /plugchain.prc10.MsgIssueToken -- /plugchain.prc10.MsgMintToken -- /tendermint.liquidity.v1beta1.MsgCreatePool -- /tendermint.liquidity.v1beta1.MsgDepositWithinBatch -- /tendermint.liquidity.v1beta1.MsgSwapWithinBatch -- /tendermint.liquidity.v1beta1.MsgWithdrawWithinBatch \ No newline at end of file diff --git a/docs/endpoints/grpc-rest.md b/docs/endpoints/grpc-rest.md index fbb77240b..35d3fb8d0 100644 --- a/docs/endpoints/grpc-rest.md +++ b/docs/endpoints/grpc-rest.md @@ -155,12 +155,37 @@ The following example shows how to query events using the Cosmos SDK. | ------------------------- | ------------------------------- | | tx.height=23 | Query all transactions with height 23 | | tx.hash='DF9738772AAECE776187EFF106190FF169F00C725968A15D23FA1DC9B4A1B651' | Query the specified hash transaction | -| [message.action](./action.md#messageaction)=='/cosmos.bank.v1beta1.MsgSend' | Query all transactions containing x/bank `Send`. | -| [message.module](./action.md#messagemodule)='bank' | Query all transactions that contain messages from the `x/bank` module. | - - - - +| message.action='/cosmos.bank.v1beta1.MsgSend' | Query all transactions containing x/bank `Send`. | +| message.module='bank' | Query all transactions that contain messages from the `x/bank` module. | + + +| message.module | message.action | +| ------ | ------------- | +| bank | /cosmos.bank.v1beta1.MsgSend | +| bank | /cosmos.bank.v1beta1.MsgMultiSend | +| distribution | /cosmos.distribution.v1beta1.MsgFundCommunityPool | +| distribution | /cosmos.distribution.v1beta1.MsgSetWithdrawAddress | +| distribution | /cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward | +| distribution | /cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission | +| governance | /cosmos.gov.v1beta1.MsgVote | +| governance | /cosmos.gov.v1beta1.MsgVoteWeighted | +| governance | /cosmos.gov.v1beta1.MsgSubmitProposal | +| governance | /cosmos.gov.v1beta1.MsgDeposit | +| staking | /cosmos.staking.v1beta1.MsgBeginRedelegate | +| staking | /cosmos.staking.v1beta1.MsgCreateValidator | +| staking | /cosmos.staking.v1beta1.MsgDelegate | +| staking | /cosmos.staking.v1beta1.MsgEditValidator | +| staking | /cosmos.staking.v1beta1.MsgUndelegate | +| slashing | /cosmos.slashing.v1beta1.MsgUnjail | +| token | /plugchain.prc10.MsgBurnToken | +| token | /plugchain.prc10.MsgEditToken | +| token | /plugchain.prc10.MsgIssueToken | +| token | /plugchain.prc10.MsgMintToken | +| evm | /ethermint.evm.v1.MsgEthereumTx | +| liquidity | /tendermint.liquidity.v1beta1.MsgCreatePool | +| liquidity | /tendermint.liquidity.v1beta1.MsgDepositWithinBatch | +| liquidity | /tendermint.liquidity.v1beta1.MsgSwapWithinBatch | +| liquidity | /tendermint.liquidity.v1beta1.MsgWithdrawWithinBatch | diff --git a/docs/endpoints/subscription.md b/docs/endpoints/subscription.md index 93461bad7..5397f9e4f 100644 --- a/docs/endpoints/subscription.md +++ b/docs/endpoints/subscription.md @@ -2,67 +2,167 @@ order: 6 --- -# Subscribing to events via Websocket +# Subscribe -Tendermint emits different events, which you can subscribe to via -[Websocket](https://en.wikipedia.org/wiki/WebSocket). This can be useful -for third-party applications (for analysis) or for inspecting state. +`Event`s are objects that contain information about the execution of the application. They are +mainly used by service providers like block explorers and wallet to track the execution of various +messages and index transactions. -[List of events](https://godoc.org/github.com/tendermint/tendermint/types#pkg-constants) +## Pre-requisite Readings -To connect to a node via websocket from the CLI, you can use a tool such as -[wscat](https://github.com/websockets/wscat) and run: +- [Cosmos SDK Events](https://docs.cosmos.network/master/core/events.html) +- [Ethereum's PubSub JSON-RPC API](https://geth.ethereum.org/docs/rpc/pubsub) -```sh -wscat ws://127.0.0.1:26657/websocket -``` +## SDK and Tendermint Events -You can subscribe to any of the events above by calling the `subscribe` RPC -method via Websocket along with a valid query. +It is possible to subscribe to `Events` via Tendermint's [Websocket](https://tendermint.com/docs/app-dev/subscribing-to-events-via-websocket.html#subscribing-to-events-via-websocket). +This is done by calling the `subscribe` RPC method via Websocket: ```json { "jsonrpc": "2.0", "method": "subscribe", - "id": 0, + "id": "0", "params": { - "query": "tm.event='NewBlock'" + "query": "tm.event='eventCategory' AND eventType.eventAttribute='attributeValue'" } } ``` -## ValidatorSetUpdates +The main `eventCategory` you can subscribe to are: + +- `NewBlock`: Contains `events` triggered during `BeginBlock` and `EndBlock`. +- `Tx`: Contains `events` triggered during `DeliverTx` (i.e. transaction processing). +- `ValidatorSetUpdates`: Contains validator set updates for the block. -When validator set changes, ValidatorSetUpdates event is published. The -event carries a list of pubkey/power pairs. The list is the same -Tendermint receives from ABCI application (see [EndBlock -section](https://github.com/tendermint/spec/blob/master/spec/abci/abci.md#endblock) in -the ABCI spec). +These events are triggered from the `state` package after a block is committed. You can get the full +list of `event` categories +[here](https://godoc.org/github.com/tendermint/tendermint/types#pkg-constants). -Response: +The `type` and `attribute` value of the `query` allow you to filter the specific `event` you are +looking for. For example, a `MsgEthereumTx` transaction triggers an `event` of type `ethermint` and +has `sender` and `recipient` as `attributes`. Subscribing to this `event` would be done like so: ```json { "jsonrpc": "2.0", - "id": 0, - "result": { - "query": "tm.event='ValidatorSetUpdates'", - "data": { - "type": "tendermint/event/ValidatorSetUpdates", - "value": { - "validator_updates": [ - { - "address": "09EAD022FD25DE3A02E64B0FE9610B1417183EE4", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "ww0z4WaZ0Xg+YI10w43wTWbBmM3dpVza4mmSQYsd0ck=" - }, - "voting_power": "10", - "proposer_priority": "0" - } - ] - } - } + "method": "subscribe", + "id": "0", + "params": { + "query": "tm.event='Tx' AND ethereum.recipient='hexAddress'" } } ``` + +where `hexAddress` is an EIP-55 address (eg: `0x1122334455667788990011223344556677889900`). + +### Tendermint Websocket + +To start a connection with the Tendermint websocket you need to define the address with the `--rpc.laddr` +flag when starting the node (default `tcp://127.0.0.1:26657`): + +```bash +plugchaind start --rpc.laddr="tcp://127.0.0.1:26657" +``` + +Then, start a websocket subscription with [ws](https://github.com/hashrocket/ws) + +```bash +# connect to tendermint websocket at port 8080 as defined above +ws ws://localhost:8080/websocket + +# subscribe to new Tendermint block headers +> { "jsonrpc": "2.0", "method": "subscribe", "params": ["tm.event='NewBlockHeader'"], "id": 1 } +``` + +### List of Tendermint Events + +The main events you can subscribe to are: + +- `NewBlock`: Contains `events` triggered during `BeginBlock` and `EndBlock`. +- `Tx`: Contains `events` triggered during `DeliverTx` (i.e. transaction processing). +- `ValidatorSetUpdates`: Contains validator set updates for the block. + +List of all Tendermint event keys: + +| | Event Type | Categories | +| ---------------------------------------------------- | ---------------- | ----------- | +| Subscribe to a specific event | `"tm.event"` | `block` | +| Subscribe to a specific transaction | `"tx.hash"` | `block` | +| Subscribe to transactions at a specific block height | `"tx.height"` | `block` | +| Index `BeginBlock` and `Endblock` events | `"block.height"` | `block` | +| Subscribe to ABCI `BeginBlock` events | `"begin_block"` | `block` | +| Subscribe to ABCI `EndBlock` events | `"end_block"` | `consensus` | + +Below is a list of values that you can use to subscribe for the `tm.event` type: + +| | Event Value | Categories | +| ---------------------- | ----------------------- | ----------- | +| New block | `"NewBlock"` | `block` | +| New block header | `"NewBlockHeader"` | `block` | +| New Byzantine Evidence | `"NewEvidence"` | `block` | +| New transaction | `"Tx"` | `block` | +| Validator set updated | `"ValidatorSetUpdates"` | `block` | +| Block sync status | `"BlockSyncStatus"` | `consensus` | +| lock | `"Lock"` | `consensus` | +| New consensus round | `"NewRound"` | `consensus` | +| Polka | `"Polka"` | `consensus` | +| Relock | `"Relock"` | `consensus` | +| State sync status | `"StateSyncStatus"` | `consensus` | +| Timeout propose | `"TimeoutPropose"` | `consensus` | +| Timeout wait | `"TimeoutWait"` | `consensus` | +| Unlock | `"Unlock"` | `consensus` | +| Block is valid | `"ValidBlock"` | `consensus` | +| Consensus vote | `"Vote"` | `consensus` | + + +## Ethereum JSON-RPC Events + +Plug Chain also supports the Ethereum [JSON-RPC](https://eth.wiki/json-rpc/API) filters calls to +subscribe to [state logs](https://eth.wiki/json-rpc/API#eth_newfilter), +[blocks](https://eth.wiki/json-rpc/API#eth_newblockfilter) or [pending +transactions](https://eth.wiki/json-rpc/API#eth_newpendingtransactionfilter) changes. + +Under the hood, it uses the Tendermint RPC client's event system to process subscriptions that are +then formatted to Ethereum-compatible events. + +```bash +curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newBlockFilter","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545 + +{"jsonrpc":"2.0","id":1,"result":"0x3503de5f0c766c68f78a03a3b05036a5"} +``` + +Then you can check if the state changes with the [`eth_getFilterChanges`](https://eth.wiki/json-rpc/API#eth_getfilterchanges) call: + +```bash +curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getFilterChanges","params":["0x3503de5f0c766c68f78a03a3b05036a5"],"id":1}' -H "Content-Type: application/json" http://localhost:8545 + +{"jsonrpc":"2.0","id":1,"result":["0x7d44dceff05d5963b5bc81df7e9f79b27e777b0a03a6feca09f3447b99c6fa71","0x3961e4050c27ce0145d375255b3cb829a5b4e795ac475c05a219b3733723d376","0xd7a497f95167d63e6feca70f344d9f6e843d097b62729b8f43bdcd5febf142ab","0x55d80a4ba6ef54f2a8c0b99589d017b810ed13a1fda6a111e1b87725bc8ceb0e","0x9e8b92c17280dd05f2562af6eea3285181c562ebf41fc758527d4c30364bcbc4","0x7353a4b9d6b35c9eafeccaf9722dd293c46ae2ffd4093b2367165c3620a0c7c9","0x026d91bda61c8789c59632c349b38fd7e7557e6b598b94879654a644cfa75f30","0x73e3245d4ddc3bba48fa67633f9993c6e11728a36401fa1206437f8be94ef1d3"]} +``` + + +### Ethereum Websocket + +Since Plug Chain runs uses Tendermint Core as it's consensus Engine and it's built with the Cosmos +SDK framework, it inherits the event format from them. However, in order to support the native Web3 +compatibility for websockets of the [Ethereum's +PubSubAPI](https://geth.ethereum.org/docs/rpc/pubsub), Plug Chain needs to cast the Tendermint +responses retrieved into the Ethereum types. + +You can start a connection with the Ethereum websocket using the `--json-rpc.ws-address` flag when starting +the node (default `"0.0.0.0:8546"`): + +```bash +plugchaind start --json-rpc.address"0.0.0.0:8545" --json-rpc.ws-address="0.0.0.0:8546" --evm.rpc.api="eth,web3,net,txpool,debug" --json-rpc.enable +``` + +Then, start a websocket subscription with [`ws`](https://github.com/hashrocket/ws) + +```bash +# connect to tendermint websocet at port 8546 as defined above +ws ws://localhost:8546/ + +# subscribe to new Ethereum-formatted block Headers +> {"id": 1, "method": "eth_subscribe", "params": ["newHeads", {}]} +< {"jsonrpc":"2.0","result":"0x44e010cb2c3161e9c02207ff172166ef","id":1} +``` diff --git a/docs/get-started/mainnet.md b/docs/get-started/mainnet.md index d44004a20..70b51b6cb 100644 --- a/docs/get-started/mainnet.md +++ b/docs/get-started/mainnet.md @@ -42,7 +42,7 @@ Depending on the snapshot height, lock the `plugchaind` binary version to use | Block height | Database | plugchaind version | Download address | | ---- | --------- | -------- | ----| -| 4451314 | goleveldb (default) | [v1.5](https://github.com/oracleNetworkProtocol/plugchain/releases/tag/v1.5.0) | [mainnet-4451314-20220614-goleveldb](https://snapshot-node-mainnet.oss-cn-hangzhou.aliyuncs.com/mainnet-4451314-20220614-goleveldb.zip) | +| 4879326 | goleveldb (default) | [v1.5](https://github.com/oracleNetworkProtocol/plugchain/releases/tag/v1.5.0) | [mainnet-4879326-20220712-goleveldb.zip](https://snapshot-node-mainnet.oss-cn-hangzhou.aliyuncs.com/mainnet-4879326-20220712-goleveldb.zip.zip) | 1. Download snapshot data diff --git a/docs/pvm/events.md b/docs/pvm/events.md deleted file mode 100644 index 1ba6e4b46..000000000 --- a/docs/pvm/events.md +++ /dev/null @@ -1,130 +0,0 @@ ---- -order: 4 ---- - -# Events - -`Event`s are objects that contain information about the execution of the application. They are -mainly used by service providers like block explorers and wallet to track the execution of various -messages and index transactions. - -## Pre-requisite Readings - -- [Cosmos SDK Events](https://docs.cosmos.network/master/core/events.html) -- [Ethereum's PubSub JSON-RPC API](https://geth.ethereum.org/docs/rpc/pubsub) - -## Subscribing to Events - -### SDK and Tendermint Events - -It is possible to subscribe to `Events` via Tendermint's [Websocket](https://tendermint.com/docs/app-dev/subscribing-to-events-via-websocket.html#subscribing-to-events-via-websocket). -This is done by calling the `subscribe` RPC method via Websocket: - -```json -{ - "jsonrpc": "2.0", - "method": "subscribe", - "id": "0", - "params": { - "query": "tm.event='eventCategory' AND eventType.eventAttribute='attributeValue'" - } -} -``` - -The main `eventCategory` you can subscribe to are: - -- `NewBlock`: Contains `events` triggered during `BeginBlock` and `EndBlock`. -- `Tx`: Contains `events` triggered during `DeliverTx` (i.e. transaction processing). -- `ValidatorSetUpdates`: Contains validator set updates for the block. - -These events are triggered from the `state` package after a block is committed. You can get the full -list of `event` categories -[here](https://godoc.org/github.com/tendermint/tendermint/types#pkg-constants). - -The `type` and `attribute` value of the `query` allow you to filter the specific `event` you are -looking for. For example, a `MsgEthereumTx` transaction triggers an `event` of type `ethermint` and -has `sender` and `recipient` as `attributes`. Subscribing to this `event` would be done like so: - -```json -{ - "jsonrpc": "2.0", - "method": "subscribe", - "id": "0", - "params": { - "query": "tm.event='Tx' AND ethereum.recipient='hexAddress'" - } -} -``` - -where `hexAddress` is an EIP-55 address (eg: `0x1122334455667788990011223344556677889900`). - -### Ethereum JSON-RPC Events - -Plug Chain also supports the Ethereum [JSON-RPC](https://eth.wiki/json-rpc/API) filters calls to -subscribe to [state logs](https://eth.wiki/json-rpc/API#eth_newfilter), -[blocks](https://eth.wiki/json-rpc/API#eth_newblockfilter) or [pending -transactions](https://eth.wiki/json-rpc/API#eth_newpendingtransactionfilter) changes. - -Under the hood, it uses the Tendermint RPC client's event system to process subscriptions that are -then formatted to Ethereum-compatible events. - -```bash -curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newBlockFilter","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545 - -{"jsonrpc":"2.0","id":1,"result":"0x3503de5f0c766c68f78a03a3b05036a5"} -``` - -Then you can check if the state changes with the [`eth_getFilterChanges`](https://eth.wiki/json-rpc/API#eth_getfilterchanges) call: - -```bash -curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getFilterChanges","params":["0x3503de5f0c766c68f78a03a3b05036a5"],"id":1}' -H "Content-Type: application/json" http://localhost:8545 - -{"jsonrpc":"2.0","id":1,"result":["0x7d44dceff05d5963b5bc81df7e9f79b27e777b0a03a6feca09f3447b99c6fa71","0x3961e4050c27ce0145d375255b3cb829a5b4e795ac475c05a219b3733723d376","0xd7a497f95167d63e6feca70f344d9f6e843d097b62729b8f43bdcd5febf142ab","0x55d80a4ba6ef54f2a8c0b99589d017b810ed13a1fda6a111e1b87725bc8ceb0e","0x9e8b92c17280dd05f2562af6eea3285181c562ebf41fc758527d4c30364bcbc4","0x7353a4b9d6b35c9eafeccaf9722dd293c46ae2ffd4093b2367165c3620a0c7c9","0x026d91bda61c8789c59632c349b38fd7e7557e6b598b94879654a644cfa75f30","0x73e3245d4ddc3bba48fa67633f9993c6e11728a36401fa1206437f8be94ef1d3"]} -``` - -## Websocket Connection - -### Tendermint Websocket - -To start a connection with the Tendermint websocket you need to define the address with the `--rpc.laddr` -flag when starting the node (default `tcp://127.0.0.1:26657`): - -```bash -plugchaind start --rpc.laddr="tcp://127.0.0.1:26657" -``` - -Then, start a websocket subscription with [ws](https://github.com/hashrocket/ws) - -```bash -# connect to tendermint websocket at port 8080 as defined above -ws ws://localhost:8080/websocket - -# subscribe to new Tendermint block headers -> { "jsonrpc": "2.0", "method": "subscribe", "params": ["tm.event='NewBlockHeader'"], "id": 1 } -``` - -### Ethereum Websocket - -Since Plug Chain runs uses Tendermint Core as it's consensus Engine and it's built with the Cosmos -SDK framework, it inherits the event format from them. However, in order to support the native Web3 -compatibility for websockets of the [Ethereum's -PubSubAPI](https://geth.ethereum.org/docs/rpc/pubsub), Plug Chain needs to cast the Tendermint -responses retrieved into the Ethereum types. - -You can start a connection with the Ethereum websocket using the `--json-rpc.ws-address` flag when starting -the node (default `"0.0.0.0:8546"`): - -```bash -plugchaind start --json-rpc.address"0.0.0.0:8545" --json-rpc.ws-address="0.0.0.0:8546" --evm.rpc.api="eth,web3,net,txpool,debug" --json-rpc.enable -``` - -Then, start a websocket subscription with [`ws`](https://github.com/hashrocket/ws) - -```bash -# connect to tendermint websocet at port 8546 as defined above -ws ws://localhost:8546/ - -# subscribe to new Ethereum-formatted block Headers -> {"id": 1, "method": "eth_subscribe", "params": ["newHeads", {}]} -< {"jsonrpc":"2.0","result":"0x44e010cb2c3161e9c02207ff172166ef","id":1} -``` diff --git a/docs/tools/connection.md b/docs/tools/connection.md new file mode 100644 index 000000000..45fd6c92b --- /dev/null +++ b/docs/tools/connection.md @@ -0,0 +1,21 @@ +--- +order: 4 +--- + +# Quick Connect + +Quickly connect your app or client to Plug Chain services + +## Public Available Endpoints + +Below is a list of publicly available endpoints that you can use to connect to the Plug Chain mainnet + + +| Address | Category | +| --------------------------------------------- | ---------------------- | +| `http://124.248.67.122:9090` | `Cosmos` `gRPC` | +| [Restful](http://124.248.67.122:1317) | `Cosmos` `REST` | +| [RPC](http://124.248.67.122:26657) | `Tendermint` `RPC` | +| `http://124.248.67.122:8545` | `Ethereum` `JSON-RPC` | +| `ws://124.248.67.122:8546` | `Ethereum` `Websocket` | + diff --git a/docs/zh/endpoints/action.md b/docs/zh/endpoints/action.md deleted file mode 100644 index 5c0732bc6..000000000 --- a/docs/zh/endpoints/action.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -order: 7 ---- - -## Events - -描述不同事件的值 - -## message.module -- bank -- distribution -- governance -- staking -- slashing -- token -- transfer -- evm -- liquidity -- ibc_client -- ibc_channel -- ibc_connection - - -## message.action -- /cosmos.bank.v1beta1.MsgSend -- /cosmos.bank.v1beta1.MsgMultiSend -- /cosmos.distribution.v1beta1.MsgFundCommunityPool -- /cosmos.distribution.v1beta1.MsgSetWithdrawAddress -- /cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward -- /cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission -- /cosmos.gov.v1beta1.MsgVote - -- /cosmos.slashing.v1beta1.MsgUnjail -- /cosmos.staking.v1beta1.MsgBeginRedelegate -- /cosmos.staking.v1beta1.MsgCreateValidator -- /cosmos.staking.v1beta1.MsgDelegate -- /cosmos.staking.v1beta1.MsgEditValidator -- /cosmos.staking.v1beta1.MsgUndelegate -- /ethermint.evm.v1.MsgEthereumTx -- /ibc.applications.transfer.v1.MsgTransfer -- /ibc.core.client.v1.MsgCreateClient -- /ibc.core.channel.v1.MsgAcknowledgement -- /ibc.core.channel.v1.MsgChannelOpenAck -- /ibc.core.channel.v1.MsgChannelOpenInit -- /ibc.core.channel.v1.MsgRecvPacket -- /ibc.core.channel.v1.MsgTimeout -- /ibc.core.connection.v1.MsgConnectionOpenAck -- /ibc.core.connection.v1.MsgConnectionOpenInit -- /plugchain.prc10.MsgBurnToken -- /plugchain.prc10.MsgEditToken -- /plugchain.prc10.MsgIssueToken -- /plugchain.prc10.MsgMintToken -- /tendermint.liquidity.v1beta1.MsgCreatePool -- /tendermint.liquidity.v1beta1.MsgDepositWithinBatch -- /tendermint.liquidity.v1beta1.MsgSwapWithinBatch -- /tendermint.liquidity.v1beta1.MsgWithdrawWithinBatch \ No newline at end of file diff --git a/docs/zh/endpoints/grpc-rest.md b/docs/zh/endpoints/grpc-rest.md index 5aa2aeed6..2f3e397de 100644 --- a/docs/zh/endpoints/grpc-rest.md +++ b/docs/zh/endpoints/grpc-rest.md @@ -153,18 +153,41 @@ address = "tcp://0.0.0.0:1317" 以下示例展示了如何使用 Cosmos SDK 查询事件。 -| Event | 描述 | -| ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -| tx.height=23 | 查询23块高的所有交易 | -| tx.hash='DF9738772AAECE776187EFF106190FF169F00C725968A15D23FA1DC9B4A1B651' | 查询指定hash交易 | -| [message.action](./action.md#messageaction)='/cosmos.bank.v1beta1.MsgSend' | 查询所有包含 x/bank `Send` 的交易。 | -| [message.module](./action.md#messagemodule)='bank' | 查询所有包含来自 `x/bank` 模块的消息的交易。 | - - - - - - +| Event | 描述 | +|--------------------- | -------------------- | +| tx.height=23 | 查询23块高的所有交易 | +| tx.hash='DF9738772AAECE...' | 查询指定hash交易 | +| message.action='/cosmos.bank.v1beta1.MsgSend' | 查询所有包含 x/bank `Send` 的交易。 | +| message.module='bank' | 查询所有包含来自 `x/bank` 模块的消息的交易。 | + + +| | message.module | message.action | +| ------ | ------------- | ----------------------- | +| 交易 | bank | /cosmos.bank.v1beta1.MsgSend | +| 批量交易 | bank | /cosmos.bank.v1beta1.MsgMultiSend | +| 资助社区池 | distribution | /cosmos.distribution.v1beta1.MsgFundCommunityPool | +| 设置提现地址 | distribution | /cosmos.distribution.v1beta1.MsgSetWithdrawAddress | +| 提取质押收益 | distribution | /cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward | +| 验证者提取佣金 | distribution | /cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission | +| 投票 | governance | /cosmos.gov.v1beta1.MsgVote | +| 加权投票 | governance | /cosmos.gov.v1beta1.MsgVoteWeighted | +| 发起提案 | governance | /cosmos.gov.v1beta1.MsgSubmitProposal | +| 向现有提案提交存款 | governance | /cosmos.gov.v1beta1.MsgDeposit | +| 把现有质押从当前节点转质押到另一个节点 | staking | /cosmos.staking.v1beta1.MsgBeginRedelegate | +| 创建验证者 | staking | /cosmos.staking.v1beta1.MsgCreateValidator | +| 质押到验证者获取收益 | staking | /cosmos.staking.v1beta1.MsgDelegate | +| 修改验证者信息 | staking | /cosmos.staking.v1beta1.MsgEditValidator | +| 赎回质押 | staking | /cosmos.staking.v1beta1.MsgUndelegate | +| 验证者解除监禁 | slashing | /cosmos.slashing.v1beta1.MsgUnjail | +| 销毁prc10 代币 | token | /plugchain.prc10.MsgBurnToken | +| 修改prc10 代币信息 | token | /plugchain.prc10.MsgEditToken | +| 创建prc10 代币 | token | /plugchain.prc10.MsgIssueToken | +| 增发prc10 代币 | token | /plugchain.prc10.MsgMintToken | +| pvm交易 | evm | /ethermint.evm.v1.MsgEthereumTx | +| | liquidity | /tendermint.liquidity.v1beta1.MsgCreatePool | +| | liquidity | /tendermint.liquidity.v1beta1.MsgDepositWithinBatch | +| | liquidity | /tendermint.liquidity.v1beta1.MsgSwapWithinBatch | +| | liquidity | /tendermint.liquidity.v1beta1.MsgWithdrawWithinBatch | ## 构造和签名交易 diff --git a/docs/zh/endpoints/subscription.md b/docs/zh/endpoints/subscription.md index 08af59f76..9b06585dc 100644 --- a/docs/zh/endpoints/subscription.md +++ b/docs/zh/endpoints/subscription.md @@ -2,66 +2,156 @@ order: 6 --- -# 通过 Websocket 订阅事件 +# 订阅 -Tendermint 发出不同的事件,您可以通过以下方式订阅 -[Websocket](https://en.wikipedia.org/wiki/WebSocket)。这很有用 -用于第三方应用程序(用于分析)或用于检查状态。 +`Event`s 是包含有关应用程序执行信息的对象。他们是主要由区块浏览器和钱包等服务提供商用于跟踪各种执行情况消息和索引事务。 -[params-活动列表](https://godoc.org/github.com/tendermint/tendermint/types#pkg-constants) +## 先决条件 -要从 CLI 通过 websocket 连接到节点,您可以使用诸如 -[wscat](https://github.com/websockets/wscat) 并运行: +- [Cosmos SDK Events](https://docs.cosmos.network/master/core/events.html) +- [Ethereum's PubSub JSON-RPC API](https://geth.ethereum.org/docs/rpc/pubsub) -```sh -wscat ws://127.0.0.1:26657/websocket -``` +## SDK 和 Tendermint 事件 -您可以通过调用 `subscribe` RPC 来订阅上述任何事件 -方法通过 Websocket 以及有效的查询。 +可以通过 Tendermint 的 [Websocket](https://tendermint.com/docs/app-dev/subscribing-to-events-via-websocket.html#subscribing-to-events-via-websocket) 订阅`events` )。 +这是通过 Websocket 调用 `subscribe` RPC 方法来完成的: ```json { "jsonrpc": "2.0", "method": "subscribe", - "id": 0, + "id": "0", "params": { - "query": "tm.event='NewBlock'" + "query": "tm.event='eventCategory' AND eventType.eventAttribute='attributeValue'" } } ``` -## 验证器集更新 +您可以订阅的主要 `eventCategory` 是: -当验证器集更改时,将发布 ValidatorSetUpdates 事件。这 -事件携带公钥/权力对的列表。名单是一样的 -Tendermint 从 ABCI 应用程序接收(参见 [EndBlock部分](https://github.com/tendermint/spec/blob/master/spec/abci/abci.md#endblock)在 -ABCI 规范)。 +- `NewBlock`:包含在`BeginBlock`和`EndBlock`期间触发的`events`。 +- `Tx`:包含在`DeliverTx`(即事务处理)期间触发的`events`。 +- `ValidatorSetUpdates`:包含块的验证器集更新。 -回复: +这些事件是在提交块后从`state`包中触发的。你可以获得完整的`events`类别列表。[这里](https://godoc.org/github.com/tendermint/tendermint/types#pkg-constants)。 +`query` 的 `type` 和 `attribute` 值允许您过滤您所在的特定 `event` +寻找。例如,`MsgEthereumTx`交易会触发`ethermint`类型的`event`,并且 +具有`sender`和`recipient`作为`attributes`。订阅此`event`将按如下方式完成: ```json { "jsonrpc": "2.0", - "id": 0, - "result": { - "query": "tm.event='ValidatorSetUpdates'", - "data": { - "type": "tendermint/event/ValidatorSetUpdates", - "value": { - "validator_updates": [ - { - "address": "09EAD022FD25DE3A02E64B0FE9610B1417183EE4", - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "ww0z4WaZ0Xg+YI10w43wTWbBmM3dpVza4mmSQYsd0ck=" - }, - "voting_power": "10", - "proposer_priority": "0" - } - ] - } - } + "method": "subscribe", + "id": "0", + "params": { + "query": "tm.event='Tx' AND ethereum.recipient='hexAddress'" } } -``` \ No newline at end of file +``` + +其中“hexAddress”是一个EIP-55地址(例如:“0x1122334455667788990011223344556677889900”)。 + +### Tendermint Websocket + +要开始与 Tendermint websocket 的连接,您需要使用 `--rpc.laddr` 定义地址 +启动节点时的标志(默认`tcp://127.0.0.1:26657`): + +```bash +plugchaind start --rpc.laddr="tcp://127.0.0.1:26657" +``` + +然后,使用 [ws](https://github.com/hashrocket/ws) 开始一个 websocket 订阅 + +```bash +# connect to tendermint websocket at port 8080 as defined above +ws ws://localhost:8080/websocket + +# subscribe to new Tendermint block headers +> { "jsonrpc": "2.0", "method": "subscribe", "params": ["tm.event='NewBlockHeader'"], "id": 1 } +``` +### Tendermint 事件列表 + +您可以订阅的主要事件是: + +- `NewBlock`:包含在`BeginBlock`和`EndBlock`期间触发的`events`。 +- `Tx`:包含在`DeliverTx`(即事务处理)期间触发的`events`。 +- `ValidatorSetUpdates`:包含块的验证器集更新。 + +所有 Tendermint 事件键的列表: + +| |活动类型 |分类 | +| -------------------------------------------------- | ---------------- | ------------ | +|订阅特定事件 | `"tm.event"` | `块` | +|订阅特定交易 | `"tx.hash"` | `块` | +|订阅特定区块高度的交易 | `"tx.height"` | `块` | +|索引 `BeginBlock` 和 `Endblock` 事件 | `"block.height"` | `块` | +|订阅 ABCI `BeginBlock` 事件 | `"begin_block"` | `块` | +|订阅 ABCI `EndBlock` 事件 | `"end_block"` | `共识` | + +以下是可用于订阅 `tm.event` 类型的值列表: + +| |事件价值 |分类 | +| ---------------------- | ------------------------------------ | ------------ | +|新区块 | `"NewBlock"` | `block` | +|新区块头 | `"NewBlockHeader"` | `block` | +|新拜占庭证据 | `"NewEvidence"` | `block` | +|新交易 | `"Tx"` | `block` | +|验证器集已更新 | `"ValidatorSetUpdates"` | `block` | +|块同步状态 | `"BlockSyncStatus"` | `consensus` | +|锁 | `"Lock"` | `consensus` | +|新一轮共识 | `"NewRound"` | `consensus` | +|波尔卡 | `"Polka"` | `consensus` | +|重新锁定 | `"Relock"` | `consensus` | +|状态同步状态 | `"StateSyncStatus"` | `consensus` | +|超时建议 | `"TimeoutPropose"` | `consensus` | +|超时等待 | `"TimeoutWait"` | `consensus` | +|解锁 | `"Unlock"` | `consensus` | +|块有效 | `"ValidBlock"` | `consensus` | +|共识投票 | `"Vote"` | `consensus` | + + +## Ethereum JSON-RPC Events + +Plug Chain 还支持 Ethereum [JSON-RPC](https://eth.wiki/json-rpc/API) 过滤器调用订阅 [状态日志](https://eth.wiki/json-rpc/API#eth_newfilter),[区块](https://eth.wiki/json-rpc/API#eth_newblockfilter) 或 [待定交易](https://eth.wiki/json-rpc/API#eth_newpendingtransactionfilter)更改。 + +在底层,它使用 Tendermint RPC 客户端的事件系统来处理订阅 +然后格式化为与以太坊兼容的事件。 + +```bash +curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newBlockFilter","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545 + +{"jsonrpc":"2.0","id":1,"result":"0x3503de5f0c766c68f78a03a3b05036a5"} +``` + +然后您可以使用 [`eth_getFilterChanges`](https://eth.wiki/json-rpc/API#eth_getfilterchanges) 调用检查状态是否发生变化: + +```bash +curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getFilterChanges","params":["0x3503de5f0c766c68f78a03a3b05036a5"],"id":1}' -H "Content-Type: application/json" http://localhost:8545 + +{"jsonrpc":"2.0","id":1,"result":["0x7d44dceff05d5963b5bc81df7e9f79b27e777b0a03a6feca09f3447b99c6fa71","0x3961e4050c27ce0145d375255b3cb829a5b4e795ac475c05a219b3733723d376","0xd7a497f95167d63e6feca70f344d9f6e843d097b62729b8f43bdcd5febf142ab","0x55d80a4ba6ef54f2a8c0b99589d017b810ed13a1fda6a111e1b87725bc8ceb0e","0x9e8b92c17280dd05f2562af6eea3285181c562ebf41fc758527d4c30364bcbc4","0x7353a4b9d6b35c9eafeccaf9722dd293c46ae2ffd4093b2367165c3620a0c7c9","0x026d91bda61c8789c59632c349b38fd7e7557e6b598b94879654a644cfa75f30","0x73e3245d4ddc3bba48fa67633f9993c6e11728a36401fa1206437f8be94ef1d3"]} +``` + +### Ethereum Websocket + +由于 Plug Chain 运行使用 Tendermint Core 作为它的共识引擎,并且它是使用 Cosmos 构建的 +SDK 框架,它继承了它们的事件格式。但是为了支持原生的Web3 +[Ethereum's websockets的兼容性 +PubSubAPI](https://geth.ethereum.org/docs/rpc/pubsub),Plug Chain 需要转换 Tendermint +检索到以太坊类型的响应。 + +您可以在启动时使用 `--json-rpc.ws-address` 标志启动与以太坊 websocket 的连接 +节点(默认“0.0.0.0:8546”): +```bash +plugchaind start --json-rpc.address"0.0.0.0:8545" --json-rpc.ws-address="0.0.0.0:8546" --evm.rpc.api="eth,web3,net,txpool,debug" --json-rpc.enable +``` + +然后,使用 [`ws`](https://github.com/hashrocket/ws) 开始一个 websocket 订阅 + +```bash +# connect to tendermint websocet at port 8546 as defined above +ws ws://localhost:8546/ + +# subscribe to new Ethereum-formatted block Headers +> {"id": 1, "method": "eth_subscribe", "params": ["newHeads", {}]} +< {"jsonrpc":"2.0","result":"0x44e010cb2c3161e9c02207ff172166ef","id":1} +``` diff --git a/docs/zh/pvm/events.md b/docs/zh/pvm/events.md deleted file mode 100644 index 96da13027..000000000 --- a/docs/zh/pvm/events.md +++ /dev/null @@ -1,121 +0,0 @@ ---- -order: 4 ---- - -# Events - -`Event`s 是包含有关应用程序执行信息的对象。他们是主要由区块浏览器和钱包等服务提供商用于跟踪各种执行情况消息和索引事务。 - -## 先决条件 - -- [Cosmos SDK Events](https://docs.cosmos.network/master/core/events.html) -- [Ethereum's PubSub JSON-RPC API](https://geth.ethereum.org/docs/rpc/pubsub) - -## 订阅事件 - -### SDK 和 Tendermint 事件 - -可以通过 Tendermint 的 [Websocket](https://tendermint.com/docs/app-dev/subscribing-to-events-via-websocket.html#subscribing-to-events-via-websocket) 订阅`events` )。 -这是通过 Websocket 调用 `subscribe` RPC 方法来完成的: - -```json -{ - "jsonrpc": "2.0", - "method": "subscribe", - "id": "0", - "params": { - "query": "tm.event='eventCategory' AND eventType.eventAttribute='attributeValue'" - } -} -``` - -您可以订阅的主要 `eventCategory` 是: - -- `NewBlock`:包含在`BeginBlock`和`EndBlock`期间触发的`events`。 -- `Tx`:包含在`DeliverTx`(即事务处理)期间触发的`events`。 -- `ValidatorSetUpdates`:包含块的验证器集更新。 - -这些事件是在提交块后从`state`包中触发的。你可以获得完整的`events`类别列表。[这里](https://godoc.org/github.com/tendermint/tendermint/types#pkg-constants)。 - -`query` 的 `type` 和 `attribute` 值允许您过滤您所在的特定 `event` -寻找。例如,`MsgEthereumTx`交易会触发`ethermint`类型的`event`,并且 -具有`sender`和`recipient`作为`attributes`。订阅此`event`将按如下方式完成: -```json -{ - "jsonrpc": "2.0", - "method": "subscribe", - "id": "0", - "params": { - "query": "tm.event='Tx' AND ethereum.recipient='hexAddress'" - } -} -``` - -其中“hexAddress”是一个EIP-55地址(例如:“0x1122334455667788990011223344556677889900”)。 - -### Ethereum JSON-RPC Events - -Plug Chain 还支持 Ethereum [JSON-RPC](https://eth.wiki/json-rpc/API) 过滤器调用订阅 [状态日志](https://eth.wiki/json-rpc/API#eth_newfilter),[区块](https://eth.wiki/json-rpc/API#eth_newblockfilter) 或 [待定交易](https://eth.wiki/json-rpc/API#eth_newpendingtransactionfilter)更改。 - -在底层,它使用 Tendermint RPC 客户端的事件系统来处理订阅 -然后格式化为与以太坊兼容的事件。 - -```bash -curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newBlockFilter","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545 - -{"jsonrpc":"2.0","id":1,"result":"0x3503de5f0c766c68f78a03a3b05036a5"} -``` - -然后您可以使用 [`eth_getFilterChanges`](https://eth.wiki/json-rpc/API#eth_getfilterchanges) 调用检查状态是否发生变化: - -```bash -curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getFilterChanges","params":["0x3503de5f0c766c68f78a03a3b05036a5"],"id":1}' -H "Content-Type: application/json" http://localhost:8545 - -{"jsonrpc":"2.0","id":1,"result":["0x7d44dceff05d5963b5bc81df7e9f79b27e777b0a03a6feca09f3447b99c6fa71","0x3961e4050c27ce0145d375255b3cb829a5b4e795ac475c05a219b3733723d376","0xd7a497f95167d63e6feca70f344d9f6e843d097b62729b8f43bdcd5febf142ab","0x55d80a4ba6ef54f2a8c0b99589d017b810ed13a1fda6a111e1b87725bc8ceb0e","0x9e8b92c17280dd05f2562af6eea3285181c562ebf41fc758527d4c30364bcbc4","0x7353a4b9d6b35c9eafeccaf9722dd293c46ae2ffd4093b2367165c3620a0c7c9","0x026d91bda61c8789c59632c349b38fd7e7557e6b598b94879654a644cfa75f30","0x73e3245d4ddc3bba48fa67633f9993c6e11728a36401fa1206437f8be94ef1d3"]} -``` - -## Websocket Connection - -### Tendermint Websocket - -要开始与 Tendermint websocket 的连接,您需要使用 `--rpc.laddr` 定义地址 -启动节点时的标志(默认`tcp://127.0.0.1:26657`): - -```bash -plugchaind start --rpc.laddr="tcp://127.0.0.1:26657" -``` - -然后,使用 [ws](https://github.com/hashrocket/ws) 开始一个 websocket 订阅 - -```bash -# connect to tendermint websocket at port 8080 as defined above -ws ws://localhost:8080/websocket - -# subscribe to new Tendermint block headers -> { "jsonrpc": "2.0", "method": "subscribe", "params": ["tm.event='NewBlockHeader'"], "id": 1 } -``` - -### Ethereum Websocket - -由于 Plug Chain 运行使用 Tendermint Core 作为它的共识引擎,并且它是使用 Cosmos 构建的 -SDK 框架,它继承了它们的事件格式。但是为了支持原生的Web3 -[Ethereum's websockets的兼容性 -PubSubAPI](https://geth.ethereum.org/docs/rpc/pubsub),Plug Chain 需要转换 Tendermint -检索到以太坊类型的响应。 - -您可以在启动时使用 `--json-rpc.ws-address` 标志启动与以太坊 websocket 的连接 -节点(默认“0.0.0.0:8546”): -```bash -plugchaind start --json-rpc.address"0.0.0.0:8545" --json-rpc.ws-address="0.0.0.0:8546" --evm.rpc.api="eth,web3,net,txpool,debug" --json-rpc.enable -``` - -然后,使用 [`ws`](https://github.com/hashrocket/ws) 开始一个 websocket 订阅 - -```bash -# connect to tendermint websocet at port 8546 as defined above -ws ws://localhost:8546/ - -# subscribe to new Ethereum-formatted block Headers -> {"id": 1, "method": "eth_subscribe", "params": ["newHeads", {}]} -< {"jsonrpc":"2.0","result":"0x44e010cb2c3161e9c02207ff172166ef","id":1} -``` diff --git a/docs/zh/tools/connection.md b/docs/zh/tools/connection.md new file mode 100644 index 000000000..5ead444bf --- /dev/null +++ b/docs/zh/tools/connection.md @@ -0,0 +1,20 @@ +--- +order: 4 +--- + +# 快速加入 + +快速加入Plug Chain 主网 + +## 公用节点 + +以下是可用于连接到 Plug Chain 主网的公开可用端点列表 + +| Address | Category | +| --------------------------------------------- | ---------------------- | +| `http://124.248.67.122:9090` | `Cosmos` `gRPC` | +| [Restful](http://124.248.67.122:1317) | `Cosmos` `REST` | +| [RPC](http://124.248.67.122:26657) | `Tendermint` `RPC` | +| `http://124.248.67.122:8545` | `Ethereum` `JSON-RPC` | +| `ws://124.248.67.122:8546` | `Ethereum` `Websocket` | +