Skip to content

Commit

Permalink
Add getRecentPrioritizationFees RPC endpoint (solana-labs#27278)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
CriesofCarrots authored Sep 1, 2022
1 parent dce99f1 commit 9b8bed8
Show file tree
Hide file tree
Showing 6 changed files with 482 additions and 198 deletions.
1 change: 1 addition & 0 deletions core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,7 @@ impl Validator {
leader_schedule_cache.clone(),
connection_cache.clone(),
max_complete_transaction_status_slot,
prioritization_fee_cache.clone(),
)?;

(
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 @@ -2096,6 +2097,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
6 changes: 6 additions & 0 deletions rpc-client-api/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,3 +544,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,
}
Loading

0 comments on commit 9b8bed8

Please sign in to comment.