Skip to content

Commit

Permalink
Add getRecentPrioritizationFees RPC endpoint (backport #27278) (#29562)
Browse files Browse the repository at this point in the history
* Add getRecentPrioritizationFees RPC endpoint (#27278)

* Plumb priority_fee_cache into rpc

* Add PrioritizationFeeCache api

* Add getRecentPrioritizationFees rpc endpoint

* Use MAX_TX_ACCOUNT_LOCKS to limit input keys

* Remove unused cache apis

* Map fee data by slot, and make rpc account inputs optional

* Add priority_fee_cache to rpc test framework, and add test

* Add endpoint to jsonrpc docs

* Update docs/src/developing/clients/jsonrpc-api.md

* Update docs/src/developing/clients/jsonrpc-api.md

* Fix conflicts
  • Loading branch information
CriesofCarrots authored Jan 7, 2023
1 parent 6c66421 commit fa7055e
Show file tree
Hide file tree
Showing 6 changed files with 473 additions and 237 deletions.
6 changes: 6 additions & 0 deletions client/src/rpc_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,3 +541,9 @@ pub struct RpcSnapshotSlotInfo {
pub full: Slot,
pub incremental: Option<Slot>,
}

#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
pub struct RpcPrioritizationFee {
pub slot: Slot,
pub prioritization_fee: u64,
}
1 change: 1 addition & 0 deletions core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,7 @@ impl Validator {
leader_schedule_cache.clone(),
connection_cache.clone(),
max_complete_transaction_status_slot,
prioritization_fee_cache.clone(),
)),
if !config.rpc_config.full_api {
None
Expand Down
60 changes: 60 additions & 0 deletions docs/src/developing/clients/jsonrpc-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ gives a convenient interface for the RPC methods.
- [getMultipleAccounts](jsonrpc-api.md#getmultipleaccounts)
- [getProgramAccounts](jsonrpc-api.md#getprogramaccounts)
- [getRecentPerformanceSamples](jsonrpc-api.md#getrecentperformancesamples)
- [getRecentPrioritizationFees](jsonrpc-api.md#getrecentprioritizationfees)
- [getSignaturesForAddress](jsonrpc-api.md#getsignaturesforaddress)
- [getSignatureStatuses](jsonrpc-api.md#getsignaturestatuses)
- [getSlot](jsonrpc-api.md#getslot)
Expand Down Expand Up @@ -2114,6 +2115,65 @@ Result:
}
```

### getRecentPrioritizationFees

Returns a list of minimum prioritization fees from recent blocks. Currently, a
node's prioritization-fee cache stores data from up to 150 blocks.

#### Parameters:

- `<array>` - (optional) An array of account address strings. If this parameter is provided, the response will reflect the minimum prioritization fee to land a transaction locking all of the provided accounts as writable.

#### Results:

An array of:

- `RpcPrioritizationFee<object>`
- `slot: <u64>` - Slot in which minimum fee was observed
- `prioritizationFee: <u64>` - Minimum fee paid for a successfully landed transaction

#### Example:

Request:

```bash
// Request
curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d '
{"jsonrpc":"2.0", "id":1, "method":"getRecentPrioritizationFees", "params": [["CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY"]]}
'
```

Result:

```json
{
"jsonrpc": "2.0",
"result": [
{
"slot": 348125,
"prioritizationFee": 0,
},
{
"slot": 348126,
"prioritizationFee": 1000,
},
{
"slot": 348127,
"prioritizationFee": 500,
},
{
"slot": 348128,
"prioritizationFee": 0,
},
{
"slot": 348129,
"prioritizationFee": 1234,
}
],
"id": 1
}
```

### getSignaturesForAddress

Returns signatures for confirmed transactions that include the given address in
Expand Down
Loading

0 comments on commit fa7055e

Please sign in to comment.