From 204c3610438d4ef704aff5ba95c116bd103f1641 Mon Sep 17 00:00:00 2001 From: Guillermo Paoletti Date: Mon, 23 Aug 2021 19:47:09 +0200 Subject: [PATCH] docs: miner namespace (#481) * miner_namespace docs * use GetConfig to maintain user configuration instead of the default * Minimal changes to the docs * Changelog updated Co-authored-by: ramacarlucho --- CHANGELOG.md | 1 + docs/api/json-rpc/endpoints.md | 40 ++++++++++++++++++++++++++++ docs/api/json-rpc/namespaces.md | 2 +- ethereum/rpc/namespaces/miner/api.go | 13 +++------ 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eaf9f55f..c2e66927 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes * (encoding) [tharsis#478](https://github.com/tharsis/ethermint/pull/478) Register `Evidence` to amino codec. +* (rpc) [tharsis#478](https://github.com/tharsis/ethermint/pull/481) Getting the node configuration when calling the `miner` rpc methods. ## [v0.5.0] - 2021-08-20 diff --git a/docs/api/json-rpc/endpoints.md b/docs/api/json-rpc/endpoints.md index d2a94750..1c763ab1 100644 --- a/docs/api/json-rpc/endpoints.md +++ b/docs/api/json-rpc/endpoints.md @@ -977,3 +977,43 @@ curl -X POST --data '{"jsonrpc":"2.0","method":"personal_ecRecover","params":["0 // Result {"jsonrpc":"2.0","id":1,"result":"0x3b7252d007059ffc82d16d022da3cbf9992d2f70"} ``` + +## Miner Methods + +### `miner_setGasPrice` + +Sets the minimal gas price used to accept transactions. Any transaction below this limit is excluded from the validator block proposal process. + +This method requires a `node` restart after being called because it changes the configuration file. + +Make sure your `ethermintd start` call is not using the flag `minimum-gas-prices` because this value will be used instead of the one set on the configuration file. + +#### Parameters + +- Hex Gas Price + + +```json +// Request +curl -X POST --data '{"jsonrpc":"2.0","method":"miner_setGasPrice","params":["0x0"],"id":1}' -H "Content-Type: application/json" http://localhost:8545 + +// Result +{"jsonrpc":"2.0","id":1,"result":true} +``` + +### `miner_setEtherbase` + +Sets the etherbase. It changes the wallet where the validator rewards will be deposited. + +#### Parameters + +- Account Address + + +```json +// Request +curl -X POST --data '{"jsonrpc":"2.0","method":"miner_setEtherbase","params":["0x3b7252d007059ffc82d16d022da3cbf9992d2f70"],"id":1}' -H "Content-Type: application/json" http://localhost:8545 + +// Result +{"jsonrpc":"2.0","id":1,"result":true} +``` diff --git a/docs/api/json-rpc/namespaces.md b/docs/api/json-rpc/namespaces.md index 91153a9d..afcfd3d1 100644 --- a/docs/api/json-rpc/namespaces.md +++ b/docs/api/json-rpc/namespaces.md @@ -20,7 +20,7 @@ Check the JSON-RPC namespaces supported on Ethermint. {synopsis} | `clique` | The `clique` API provides access to the state of the clique consensus engine. You can use this API to manage signer votes and to check the health of a private network. | ❌ | | | `debug` | The `debug` API gives you access to several non-standard RPC methods, which will allow you to inspect, debug and set certain debugging flags during runtime. | ✔ | | | `les` | The `les` API allows you to manage LES server settings, including client parameters and payment settings for prioritized clients. It also provides functions to query checkpoint information in both server and client mode. | ❌ | | -| `miner` | The `miner` API allows you to remote control the node’s mining operation and set various mining specific settings. | ✔ | ❌ | +| [`miner`](./endpoints#miner-methods) | The `miner` API allows you to remote control the node’s mining operation and set various mining specific settings. | ✔ | ❌ | | [`txpool`](./endpoints#txpool-methods) | The `txpool` API gives you access to several non-standard RPC methods to inspect the contents of the transaction pool containing all the currently pending transactions as well as the ones queued for future processing. | ✔ | ❌ | | `admin` | The `admin` API gives you access to several non-standard RPC methods, which will allow you to have a fine grained control over your nodeinstance, including but not limited to network peer and RPC endpoint management. | ❌ | | | [`personal`](./endpoints#personal-methods) | The `personal` API manages private keys in the key store. | ✔ | ❌ | diff --git a/ethereum/rpc/namespaces/miner/api.go b/ethereum/rpc/namespaces/miner/api.go index 47e9ac88..223ed0e7 100644 --- a/ethereum/rpc/namespaces/miner/api.go +++ b/ethereum/rpc/namespaces/miner/api.go @@ -80,11 +80,7 @@ func (api *API) SetEtherbase(etherbase common.Address) bool { } // Fetch minimun gas price to calculate fees using the configuration. - appConf, err := config.ParseConfig(api.ctx.Viper) - if err != nil { - api.logger.Error("failed to parse file.", "file", api.ctx.Viper.ConfigFileUsed(), "error:", err.Error()) - return false - } + appConf := config.GetConfig(api.ctx.Viper) minGasPrices := appConf.GetMinGasPrices() if len(minGasPrices) == 0 || minGasPrices.Empty() { @@ -164,17 +160,14 @@ func (api *API) SetEtherbase(etherbase common.Address) bool { // to use float values, the gas prices must be configured using the configuration file func (api *API) SetGasPrice(gasPrice hexutil.Big) bool { api.logger.Info(api.ctx.Viper.ConfigFileUsed()) - appConf, err := config.ParseConfig(api.ctx.Viper) - if err != nil { - api.logger.Debug("failed to parse config file", "file", api.ctx.Viper.ConfigFileUsed(), "error", err.Error()) - return false - } + appConf := config.GetConfig(api.ctx.Viper) var unit string minGasPrices := appConf.GetMinGasPrices() // fetch the base denom from the sdk Config in case it's not currently defined on the node config if len(minGasPrices) == 0 || minGasPrices.Empty() { + var err error unit, err = sdk.GetBaseDenom() if err != nil { api.logger.Debug("could not get the denom of smallest unit registered", "error", err.Error())