Add last valid block height to rpc Fees (backport #17506) (#17507)

* Add last valid block height to rpc Fees (#17506)

* Add last_valid_block_height to fees rpc

* Add getBlockHeight rpc

* Update docs

(cherry picked from commit e9bc1c6b07)

# Conflicts:
#	client/src/rpc_request.rs
#	docs/src/developing/clients/jsonrpc-api.md

* Fix conflicts and a-z docs

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
This commit is contained in:
mergify[bot]
2021-05-26 16:25:41 +00:00
committed by GitHub
parent b9834ed9eb
commit f4cf7d2c84
7 changed files with 211 additions and 108 deletions

View File

@@ -20,6 +20,7 @@ gives a convenient interface for the RPC methods.
- [getAccountInfo](jsonrpc-api.md#getaccountinfo)
- [getBalance](jsonrpc-api.md#getbalance)
- [getBlockHeight](jsonrpc-api.md#getblockheight)
- [getBlockProduction](jsonrpc-api.md#getblockproduction)
- [getBlockCommitment](jsonrpc-api.md#getblockcommitment)
- [getBlockTime](jsonrpc-api.md#getblocktime)
@@ -377,6 +378,137 @@ Result:
}
```
### getBlockHeight
Returns the current block height of the node
#### Parameters:
- `<object>` - (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment)
#### Results:
- `<u64>` - Current block height
#### Example:
Request:
```bash
curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d '
{"jsonrpc":"2.0","id":1, "method":"getBlockHeight"}
'
```
Result:
```json
{"jsonrpc":"2.0","result":1233,"id":1}
```
### getBlockProduction
Returns recent block production information from the current or previous epoch.
#### Parameters:
- `<object>` - (optional) Configuration object containing the following optional fields:
- (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment)
- (optional) `range: <object>` - Slot range to return block production for. If parameter not provided, defaults to current epoch.
- `firstSlot: <u64>` - first slot to return block production information for (inclusive)
- (optional) `lastSlot: <u64>` - last slot to return block production information for (inclusive). If parameter not provided, defaults to the highest slot
- (optional) `identity: <string>` - Only return results for this validator identity (base-58 encoded)
#### Results:
The result will be an RpcResponse JSON object with `value` equal to:
- `<object>`
- `byIdentity: <object>` - a dictionary of validator identities,
as base-58 encoded strings. Value is a two element array containing the
number of leader slots and the number of blocks produced.
- `range: <object>` - Block production slot range
- `firstSlot: <u64>` - first slot of the block production information (inclusive)
- `lastSlot: <u64>` - last slot of block production information (inclusive)
#### Example:
Request:
```bash
curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d '
{"jsonrpc":"2.0","id":1, "method":"getBlockProduction"}
'
```
Result:
```json
{
"jsonrpc": "2.0",
"result": {
"context": {
"slot": 9887
},
"value": {
"byIdentity": {
"85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr": [
9888,
9886
]
},
"range": {
"firstSlot": 0,
"lastSlot": 9887,
}
}
},
"id": 1
}
```
#### Example:
Request:
```bash
curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getBlockProduction",
"params": [
{
"identity": "85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr",
"range": {
"firstSlot": 40,
"lastSlot": 50
}
}
]
}
'
```
Result:
```json
{
"jsonrpc": "2.0",
"result": {
"context": {
"slot": 10102
},
"value": {
"byIdentity": {
"85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr": [
11,
11
]
},
"range": {
"firstSlot": 50,
"lastSlot": 40
}
}
},
"id": 1
}
```
### getBlockTime
Returns the estimated production time of a block.
@@ -681,111 +813,6 @@ The JSON structure of token balances is defined as a list of objects in the foll
- `uiAmount: <number | null>` - Token amount as a float, accounting for decimals. **DEPRECATED**
- `uiAmountString: <string>` - Token amount as a string, accounting for decimals.
### getBlockProduction
Returns recent block production information from the current or previous epoch.
#### Parameters:
- `<object>` - (optional) Configuration object containing the following optional fields:
- (optional) [Commitment](jsonrpc-api.md#configuring-state-commitment)
- (optional) `range: <object>` - Slot range to return block production for. If parameter not provided, defaults to current epoch.
- `firstSlot: <u64>` - first slot to return block production information for (inclusive)
- (optional) `lastSlot: <u64>` - last slot to return block production information for (inclusive). If parameter not provided, defaults to the highest slot
- (optional) `identity: <string>` - Only return results for this validator identity (base-58 encoded)
#### Results:
The result will be an RpcResponse JSON object with `value` equal to:
- `<object>`
- `byIdentity: <object>` - a dictionary of validator identities,
as base-58 encoded strings. Value is a two element array containing the
number of leader slots and the number of blocks produced.
- `range: <object>` - Block production slot range
- `firstSlot: <u64>` - first slot of the block production information (inclusive)
- `lastSlot: <u64>` - last slot of block production information (inclusive)
#### Example:
Request:
```bash
curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d '
{"jsonrpc":"2.0","id":1, "method":"getBlockProduction"}
'
```
Result:
```json
{
"jsonrpc": "2.0",
"result": {
"context": {
"slot": 9887
},
"value": {
"byIdentity": {
"85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr": [
9888,
9886
]
},
"range": {
"firstSlot": 0,
"lastSlot": 9887,
}
}
},
"id": 1
}
```
#### Example:
Request:
```bash
curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getBlockProduction",
"params": [
{
"identity": "85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr",
"range": {
"firstSlot": 40,
"lastSlot": 50
}
}
]
}
'
```
Result:
```json
{
"jsonrpc": "2.0",
"result": {
"context": {
"slot": 10102
},
"value": {
"byIdentity": {
"85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr": [
11,
11
]
},
"range": {
"firstSlot": 50,
"lastSlot": 40
}
}
},
"id": 1
}
```
### getConfirmedBlocks
Returns a list of confirmed blocks between two slots
@@ -1329,6 +1356,7 @@ The result will be an RpcResponse JSON object with `value` set to a JSON object
- `blockhash: <string>` - a Hash as base-58 encoded string
- `feeCalculator: <object>` - FeeCalculator object, the fee schedule for this block hash
- `lastValidSlot: <u64>` - DEPRECATED - this value is inaccurate and should not be relied upon
- `lastValidBlockHeight: <u64>` - last [block height](../../terminology.md#block-height) at which a blockhash will be valid
#### Example:
@@ -1352,7 +1380,8 @@ Result:
"feeCalculator": {
"lamportsPerSignature": 5000
},
"lastValidSlot": 297
"lastValidSlot": 297,
"lastValidBlockHeight": 296
}
},
"id": 1