rpc, evm: fix eth_coinbase endpoint to return ethereum address of the validator node (#153)

* fix coinbase rpc endpoint to return ethereum address of the validator

* update changelog

* fix lint

* clean code and simplify logic

* fix changelog

* change request variable name and type

* add test

* fix proto comments

* fix proto comments

* Update x/evm/keeper/grpc_query.go

* Update x/evm/keeper/grpc_query.go

Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
Thomas Nguy
2021-06-22 06:14:40 -04:00
committed by GitHub
co-authored by Federico Kunze
parent 4ca7c43b62
commit fada59551d
11 changed files with 857 additions and 91 deletions
+14 -1
View File
@@ -57,7 +57,7 @@ Check the JSON-RPC methods and namespaces supported on Ethermint. {synopsis}
| `eth_compileSerpent` | Eth | | |
| `eth_signTransaction` | Eth | | |
| `eth_mining` | Eth | N/A | Not relevant to Ethermint |
| `eth_coinbase` | Eth | N/A | Not relevant to Ethermint |
| [`eth_coinbase`](#eth-coinbase) | Eth | | |
| `eth_hashrate` | Eth | N/A | Not relevant to Ethermint |
| `eth_getUncleCountByBlockHash` | Eth | N/A | Not relevant to Ethermint |
| `eth_getUncleCountByBlockNumber` | Eth | N/A | Not relevant to Ethermint |
@@ -731,6 +731,19 @@ curl -X POST --data '{"jsonrpc":"2.0","method":"txpool_status","params":[],"id":
{"jsonrpc":"2.0","id":1,"result":{"pending":"0x0","queued":"0x0"}}
```
### eth_coinbase
Returns the account the mining rewards will be send to.
```json
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_coinbase","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x7cB61D4117AE31a12E393a1Cfa3BaC666481D02E"}
```
## WebSocket Methods
Read about websockets in [events](./../quickstart/events.md) {hide}
+36 -1
View File
@@ -45,6 +45,8 @@
- [QueryStorageResponse](#ethermint.evm.v1alpha1.QueryStorageResponse)
- [QueryTxLogsRequest](#ethermint.evm.v1alpha1.QueryTxLogsRequest)
- [QueryTxLogsResponse](#ethermint.evm.v1alpha1.QueryTxLogsResponse)
- [QueryValidatorAccountRequest](#ethermint.evm.v1alpha1.QueryValidatorAccountRequest)
- [QueryValidatorAccountResponse](#ethermint.evm.v1alpha1.QueryValidatorAccountResponse)
- [Query](#ethermint.evm.v1alpha1.Query)
@@ -704,6 +706,38 @@ QueryTxLogs is the response type for the Query/TxLogs RPC method.
<a name="ethermint.evm.v1alpha1.QueryValidatorAccountRequest"></a>
### QueryValidatorAccountRequest
QueryValidatorAccountRequest is the request type for the Query/ValidatorAccount RPC method.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `cons_address` | [string](#string) | | cons_address is the validator cons address to query the account for. |
<a name="ethermint.evm.v1alpha1.QueryValidatorAccountResponse"></a>
### QueryValidatorAccountResponse
QueryValidatorAccountResponse is the response type for the Query/ValidatorAccount RPC method.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `account_address` | [string](#string) | | account_address is the cosmos address of the account in bech32 format. |
| `sequence` | [uint64](#uint64) | | sequence is the account's sequence number. |
| `account_number` | [uint64](#uint64) | | account_number is the account number |
<!-- end messages -->
<!-- end enums -->
@@ -719,7 +753,8 @@ Query defines the gRPC querier service.
| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `Account` | [QueryAccountRequest](#ethermint.evm.v1alpha1.QueryAccountRequest) | [QueryAccountResponse](#ethermint.evm.v1alpha1.QueryAccountResponse) | Account queries an Ethereum account. | GET|/ethermint/evm/v1alpha1/account/{address}|
| `CosmosAccount` | [QueryCosmosAccountRequest](#ethermint.evm.v1alpha1.QueryCosmosAccountRequest) | [QueryCosmosAccountResponse](#ethermint.evm.v1alpha1.QueryCosmosAccountResponse) | Account queries an Ethereum account's Cosmos Address. | GET|/ethermint/evm/v1alpha1/cosmos_account/{address}|
| `CosmosAccount` | [QueryCosmosAccountRequest](#ethermint.evm.v1alpha1.QueryCosmosAccountRequest) | [QueryCosmosAccountResponse](#ethermint.evm.v1alpha1.QueryCosmosAccountResponse) | CosmosAccount queries an Ethereum account's Cosmos Address. | GET|/ethermint/evm/v1alpha1/cosmos_account/{address}|
| `ValidatorAccount` | [QueryValidatorAccountRequest](#ethermint.evm.v1alpha1.QueryValidatorAccountRequest) | [QueryValidatorAccountResponse](#ethermint.evm.v1alpha1.QueryValidatorAccountResponse) | ValidatorAccount queries an Ethereum account's from a validator consensus Address. | GET|/ethermint/evm/v1alpha1/validator_account/{cons_address}|
| `Balance` | [QueryBalanceRequest](#ethermint.evm.v1alpha1.QueryBalanceRequest) | [QueryBalanceResponse](#ethermint.evm.v1alpha1.QueryBalanceResponse) | Balance queries the balance of a the EVM denomination for a single EthAccount. | GET|/ethermint/evm/v1alpha1/balances/{address}|
| `Storage` | [QueryStorageRequest](#ethermint.evm.v1alpha1.QueryStorageRequest) | [QueryStorageResponse](#ethermint.evm.v1alpha1.QueryStorageResponse) | Storage queries the balance of all coins for a single account. | GET|/ethermint/evm/v1alpha1/storage/{address}/{key}|
| `Code` | [QueryCodeRequest](#ethermint.evm.v1alpha1.QueryCodeRequest) | [QueryCodeResponse](#ethermint.evm.v1alpha1.QueryCodeResponse) | Code queries the balance of all coins for a single account. | GET|/ethermint/evm/v1alpha1/codes/{address}|