From 3e33c13aca62f61a4874dba6620bad9f592b644a Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Wed, 17 Mar 2021 18:55:53 -0600 Subject: [PATCH 1/6] Add new confirmed block struct --- core/src/rpc.rs | 16 ++++++++-------- transaction-status/src/lib.rs | 29 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/core/src/rpc.rs b/core/src/rpc.rs index 17365d897e9d2b..2ba55c892b63ba 100644 --- a/core/src/rpc.rs +++ b/core/src/rpc.rs @@ -66,8 +66,8 @@ use solana_sdk::{ }; use solana_stake_program::stake_state::StakeState; use solana_transaction_status::{ - EncodedConfirmedBlock, EncodedConfirmedTransaction, TransactionConfirmationStatus, - TransactionStatus, UiTransactionEncoding, + EncodedConfirmedTransaction, TransactionConfirmationStatus, TransactionStatus, + UiConfirmedBlock, UiTransactionEncoding, }; use solana_vote_program::vote_state::{VoteState, MAX_LOCKOUT_HISTORY}; use spl_token_v2_0::{ @@ -720,7 +720,7 @@ impl JsonRpcRequestProcessor { &self, slot: Slot, config: Option>, - ) -> Result> { + ) -> Result> { let config = config .map(|config| config.convert_to_current()) .unwrap_or_default(); @@ -743,13 +743,13 @@ impl JsonRpcRequestProcessor { self.check_bigtable_result(&bigtable_result)?; return Ok(bigtable_result .ok() - .map(|confirmed_block| confirmed_block.encode(encoding))); + .map(|confirmed_block| confirmed_block.encode(encoding).into())); } } self.check_slot_cleaned_up(&result, slot)?; Ok(result .ok() - .map(|confirmed_block| confirmed_block.encode(encoding))) + .map(|confirmed_block| confirmed_block.encode(encoding).into())) } else { Err(RpcCustomError::BlockNotAvailable { slot }.into()) } @@ -2185,7 +2185,7 @@ pub mod rpc_full { meta: Self::Metadata, slot: Slot, config: Option>, - ) -> Result>; + ) -> Result>; #[rpc(meta, name = "getBlockTime")] fn get_block_time(&self, meta: Self::Metadata, slot: Slot) @@ -2793,7 +2793,7 @@ pub mod rpc_full { meta: Self::Metadata, slot: Slot, config: Option>, - ) -> Result> { + ) -> Result> { debug!("get_confirmed_block rpc request received: {:?}", slot); meta.get_confirmed_block(slot, config) } @@ -3119,7 +3119,7 @@ pub mod tests { transaction::{self, TransactionError}, }; use solana_transaction_status::{ - EncodedTransaction, EncodedTransactionWithStatusMeta, UiMessage, + EncodedConfirmedBlock, EncodedTransaction, EncodedTransactionWithStatusMeta, UiMessage, }; use solana_vote_program::{ vote_instruction, diff --git a/transaction-status/src/lib.rs b/transaction-status/src/lib.rs index 10f7d0570a1feb..97d3c315b1ad78 100644 --- a/transaction-status/src/lib.rs +++ b/transaction-status/src/lib.rs @@ -375,6 +375,35 @@ pub struct EncodedConfirmedBlock { pub block_time: Option, } +#[derive(Debug, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct UiConfirmedBlock { + pub previous_blockhash: String, + pub blockhash: String, + pub parent_slot: Slot, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub transactions: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub signatures: Option>, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub rewards: Option, + pub block_time: Option, +} + +impl From for UiConfirmedBlock { + fn from(block: EncodedConfirmedBlock) -> Self { + Self { + previous_blockhash: block.previous_blockhash, + blockhash: block.blockhash, + parent_slot: block.parent_slot, + transactions: Some(block.transactions), + signatures: None, + rewards: Some(block.rewards), + block_time: block.block_time, + } + } +} + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct ConfirmedTransaction { From 67ea7d8b0d6c85f97c238f8b400ad9a1726bf986 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Wed, 17 Mar 2021 19:17:47 -0600 Subject: [PATCH 2/6] Add RpcConfirmedBlockConfig options --- client/src/rpc_config.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/client/src/rpc_config.rs b/client/src/rpc_config.rs index cb7b913093afa5..32105df0c22082 100644 --- a/client/src/rpc_config.rs +++ b/client/src/rpc_config.rs @@ -129,16 +129,33 @@ pub trait EncodingConfig { fn new_with_encoding(encoding: &Option) -> Self; } +#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub enum TransactionDetails { + All, + Signatures, + None, +} + +impl Default for TransactionDetails { + fn default() -> Self { + Self::All + } +} + #[derive(Debug, Clone, Copy, Default, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct RpcConfirmedBlockConfig { pub encoding: Option, + pub transaction_details: Option, + pub no_rewards: Option, } impl EncodingConfig for RpcConfirmedBlockConfig { fn new_with_encoding(encoding: &Option) -> Self { Self { encoding: *encoding, + ..Self::default() } } } From b23a4574112496598d0dfb1f05f875bd42986ae2 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Wed, 17 Mar 2021 21:11:49 -0600 Subject: [PATCH 3/6] Configure block response based on new options --- client/src/rpc_config.rs | 16 +-------- core/src/rpc.rs | 68 +++++++++++++++++++++++++++++++---- transaction-status/src/lib.rs | 56 +++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+), 22 deletions(-) diff --git a/client/src/rpc_config.rs b/client/src/rpc_config.rs index 32105df0c22082..1e45d8efe9f151 100644 --- a/client/src/rpc_config.rs +++ b/client/src/rpc_config.rs @@ -4,7 +4,7 @@ use solana_sdk::{ clock::Epoch, commitment_config::{CommitmentConfig, CommitmentLevel}, }; -use solana_transaction_status::UiTransactionEncoding; +use solana_transaction_status::{TransactionDetails, UiTransactionEncoding}; #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] @@ -129,20 +129,6 @@ pub trait EncodingConfig { fn new_with_encoding(encoding: &Option) -> Self; } -#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub enum TransactionDetails { - All, - Signatures, - None, -} - -impl Default for TransactionDetails { - fn default() -> Self { - Self::All - } -} - #[derive(Debug, Clone, Copy, Default, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct RpcConfirmedBlockConfig { diff --git a/core/src/rpc.rs b/core/src/rpc.rs index 2ba55c892b63ba..0405fee0d6227a 100644 --- a/core/src/rpc.rs +++ b/core/src/rpc.rs @@ -725,6 +725,8 @@ impl JsonRpcRequestProcessor { .map(|config| config.convert_to_current()) .unwrap_or_default(); let encoding = config.encoding.unwrap_or(UiTransactionEncoding::Json); + let transaction_details = config.transaction_details.unwrap_or_default(); + let show_rewards = !config.no_rewards.unwrap_or_default(); if self.config.enable_rpc_transaction_history && slot <= self @@ -741,15 +743,15 @@ impl JsonRpcRequestProcessor { .runtime .block_on(bigtable_ledger_storage.get_confirmed_block(slot)); self.check_bigtable_result(&bigtable_result)?; - return Ok(bigtable_result - .ok() - .map(|confirmed_block| confirmed_block.encode(encoding).into())); + return Ok(bigtable_result.ok().map(|confirmed_block| { + confirmed_block.configure(encoding, transaction_details, show_rewards) + })); } } self.check_slot_cleaned_up(&result, slot)?; - Ok(result - .ok() - .map(|confirmed_block| confirmed_block.encode(encoding).into())) + Ok(result.ok().map(|confirmed_block| { + confirmed_block.configure(encoding, transaction_details, show_rewards) + })) } else { Err(RpcCustomError::BlockNotAvailable { slot }.into()) } @@ -3119,7 +3121,8 @@ pub mod tests { transaction::{self, TransactionError}, }; use solana_transaction_status::{ - EncodedConfirmedBlock, EncodedTransaction, EncodedTransactionWithStatusMeta, UiMessage, + EncodedConfirmedBlock, EncodedTransaction, EncodedTransactionWithStatusMeta, + TransactionDetails, UiMessage, }; use solana_vote_program::{ vote_instruction, @@ -5077,6 +5080,7 @@ pub mod tests { serde_json::from_value(result["result"].clone()).unwrap(); let confirmed_block = confirmed_block.unwrap(); assert_eq!(confirmed_block.transactions.len(), 3); + assert_eq!(confirmed_block.rewards, vec![]); for EncodedTransactionWithStatusMeta { transaction, meta } in confirmed_block.transactions.into_iter() @@ -5121,6 +5125,7 @@ pub mod tests { serde_json::from_value(result["result"].clone()).unwrap(); let confirmed_block = confirmed_block.unwrap(); assert_eq!(confirmed_block.transactions.len(), 3); + assert_eq!(confirmed_block.rewards, vec![]); for EncodedTransactionWithStatusMeta { transaction, meta } in confirmed_block.transactions.into_iter() @@ -5156,6 +5161,55 @@ pub mod tests { } } + #[test] + fn test_get_confirmed_block_config() { + let bob_pubkey = solana_sdk::pubkey::new_rand(); + let RpcHandler { + io, + meta, + confirmed_block_signatures, + .. + } = start_rpc_handler_with_tx(&bob_pubkey); + + let req = format!( + r#"{{"jsonrpc":"2.0","id":1,"method":"getConfirmedBlock","params":[0,{}]}}"#, + json!(RpcConfirmedBlockConfig { + encoding: None, + transaction_details: Some(TransactionDetails::Signatures), + no_rewards: Some(true), + }) + ); + let res = io.handle_request_sync(&req, meta.clone()); + let result: Value = serde_json::from_str(&res.expect("actual response")) + .expect("actual response deserialization"); + let confirmed_block: Option = + serde_json::from_value(result["result"].clone()).unwrap(); + let confirmed_block = confirmed_block.unwrap(); + assert!(confirmed_block.transactions.is_none()); + assert!(confirmed_block.rewards.is_none()); + for (i, signature) in confirmed_block.signatures.unwrap()[..2].iter().enumerate() { + assert_eq!(*signature, confirmed_block_signatures[i].to_string()); + } + + let req = format!( + r#"{{"jsonrpc":"2.0","id":1,"method":"getConfirmedBlock","params":[0,{}]}}"#, + json!(RpcConfirmedBlockConfig { + encoding: None, + transaction_details: Some(TransactionDetails::None), + no_rewards: Some(false), + }) + ); + let res = io.handle_request_sync(&req, meta); + let result: Value = serde_json::from_str(&res.expect("actual response")) + .expect("actual response deserialization"); + let confirmed_block: Option = + serde_json::from_value(result["result"].clone()).unwrap(); + let confirmed_block = confirmed_block.unwrap(); + assert!(confirmed_block.transactions.is_none()); + assert!(confirmed_block.signatures.is_none()); + assert_eq!(confirmed_block.rewards.unwrap(), vec![]); + } + #[test] fn test_get_confirmed_blocks() { let bob_pubkey = solana_sdk::pubkey::new_rand(); diff --git a/transaction-status/src/lib.rs b/transaction-status/src/lib.rs index 97d3c315b1ad78..e6260cb4e5efcd 100644 --- a/transaction-status/src/lib.rs +++ b/transaction-status/src/lib.rs @@ -362,6 +362,48 @@ impl ConfirmedBlock { block_time: self.block_time, } } + + pub fn configure( + self, + encoding: UiTransactionEncoding, + transaction_details: TransactionDetails, + show_rewards: bool, + ) -> UiConfirmedBlock { + let (transactions, signatures) = match transaction_details { + TransactionDetails::All => ( + Some( + self.transactions + .into_iter() + .map(|tx| tx.encode(encoding)) + .collect(), + ), + None, + ), + TransactionDetails::Signatures => ( + None, + Some( + self.transactions + .into_iter() + .map(|tx| tx.transaction.signatures[0].to_string()) + .collect(), + ), + ), + TransactionDetails::None => (None, None), + }; + UiConfirmedBlock { + previous_blockhash: self.previous_blockhash, + blockhash: self.blockhash, + parent_slot: self.parent_slot, + transactions, + signatures, + rewards: if show_rewards { + Some(self.rewards) + } else { + None + }, + block_time: self.block_time, + } + } } #[derive(Debug, PartialEq, Serialize, Deserialize)] @@ -404,6 +446,20 @@ impl From for UiConfirmedBlock { } } +#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub enum TransactionDetails { + All, + Signatures, + None, +} + +impl Default for TransactionDetails { + fn default() -> Self { + Self::All + } +} + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct ConfirmedTransaction { From e7ed9cd59b4006719cb7854d6cfce6007c9ce88d Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Wed, 17 Mar 2021 21:34:33 -0600 Subject: [PATCH 4/6] Add client api, use in cli fetch_epoch_rewards --- cli/src/stake.rs | 7 ++++--- client/src/rpc_client.rs | 17 +++++++++++++---- client/src/rpc_config.rs | 9 +++++++++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/cli/src/stake.rs b/cli/src/stake.rs index de71f3c87f58b2..0e92aea913f00a 100644 --- a/cli/src/stake.rs +++ b/cli/src/stake.rs @@ -27,6 +27,7 @@ use solana_client::{ client_error::{ClientError, ClientErrorKind}, nonce_utils, rpc_client::RpcClient, + rpc_config::RpcConfirmedBlockConfig, rpc_custom_error, rpc_request::{self, DELINQUENT_VALIDATOR_SLOT_DISTANCE}, }; @@ -1674,9 +1675,9 @@ pub(crate) fn fetch_epoch_rewards( .get(0) .ok_or_else(|| format!("Unable to fetch first confirmed block for epoch {}", epoch))?; - let first_confirmed_block = match rpc_client.get_confirmed_block_with_encoding( + let first_confirmed_block = match rpc_client.get_configured_confirmed_block( first_confirmed_block_in_epoch, - solana_transaction_status::UiTransactionEncoding::Base64, + RpcConfirmedBlockConfig::rewards_only(), ) { Ok(first_confirmed_block) => first_confirmed_block, Err(ClientError { @@ -1702,7 +1703,7 @@ pub(crate) fn fetch_epoch_rewards( }; // Rewards for the previous epoch are found in the first confirmed block of the current epoch - let previous_epoch_rewards = first_confirmed_block.rewards; + let previous_epoch_rewards = first_confirmed_block.rewards.unwrap_or_default(); if let Some((effective_slot, epoch_end_time, epoch_rewards)) = epoch_info { let wallclock_epoch_duration = if epoch_end_time > epoch_start_time { diff --git a/client/src/rpc_client.rs b/client/src/rpc_client.rs index 2ba50e51c7b0e2..5a57de4bbc6013 100644 --- a/client/src/rpc_client.rs +++ b/client/src/rpc_client.rs @@ -4,9 +4,9 @@ use crate::{ mock_sender::{MockSender, Mocks}, rpc_config::RpcAccountInfoConfig, rpc_config::{ - RpcGetConfirmedSignaturesForAddress2Config, RpcLargestAccountsConfig, - RpcProgramAccountsConfig, RpcSendTransactionConfig, RpcSimulateTransactionConfig, - RpcTokenAccountsFilter, + RpcConfirmedBlockConfig, RpcGetConfirmedSignaturesForAddress2Config, + RpcLargestAccountsConfig, RpcProgramAccountsConfig, RpcSendTransactionConfig, + RpcSimulateTransactionConfig, RpcTokenAccountsFilter, }, rpc_request::{RpcError, RpcRequest, RpcResponseErrorData, TokenAccountsFilter}, rpc_response::*, @@ -33,7 +33,8 @@ use solana_sdk::{ transaction::{self, uses_durable_nonce, Transaction}, }; use solana_transaction_status::{ - EncodedConfirmedBlock, EncodedConfirmedTransaction, TransactionStatus, UiTransactionEncoding, + EncodedConfirmedBlock, EncodedConfirmedTransaction, TransactionStatus, UiConfirmedBlock, + UiTransactionEncoding, }; use solana_vote_program::vote_state::MAX_LOCKOUT_HISTORY; use std::{ @@ -507,6 +508,14 @@ impl RpcClient { self.send(RpcRequest::GetConfirmedBlock, json!([slot, encoding])) } + pub fn get_configured_confirmed_block( + &self, + slot: Slot, + config: RpcConfirmedBlockConfig, + ) -> ClientResult { + self.send(RpcRequest::GetConfirmedBlock, json!([slot, config])) + } + pub fn get_confirmed_blocks( &self, start_slot: Slot, diff --git a/client/src/rpc_config.rs b/client/src/rpc_config.rs index 1e45d8efe9f151..821aaf535f222f 100644 --- a/client/src/rpc_config.rs +++ b/client/src/rpc_config.rs @@ -146,6 +146,15 @@ impl EncodingConfig for RpcConfirmedBlockConfig { } } +impl RpcConfirmedBlockConfig { + pub fn rewards_only() -> Self { + Self { + transaction_details: Some(TransactionDetails::None), + ..Self::default() + } + } +} + #[derive(Debug, Clone, Copy, Default, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct RpcConfirmedTransactionConfig { From f3d474f1e7489b7074f84aa7f0a44918d25d7cc3 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Wed, 17 Mar 2021 22:12:40 -0600 Subject: [PATCH 5/6] Update docs --- docs/src/developing/clients/jsonrpc-api.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/src/developing/clients/jsonrpc-api.md b/docs/src/developing/clients/jsonrpc-api.md index c82ed1911bccb6..83fab7dfe4b9d3 100644 --- a/docs/src/developing/clients/jsonrpc-api.md +++ b/docs/src/developing/clients/jsonrpc-api.md @@ -460,6 +460,8 @@ Returns identity and transaction information about a confirmed block in the ledg - `` - (optional) Configuration object containing the following optional fields: - (optional) `encoding: ` - encoding for each returned Transaction, either "json", "jsonParsed", "base58" (*slow*), "base64". If parameter not provided, the default encoding is "json". "jsonParsed" encoding attempts to use program-specific instruction parsers to return more human-readable and explicit data in the `transaction.message.instructions` list. If "jsonParsed" is requested but a parser cannot be found, the instruction falls back to regular JSON encoding (`accounts`, `data`, and `programIdIndex` fields). + - (optional) `transactionDetails: ` - level of transaction detail to return, either "all", "signatures", or "none". If parameter not provided, the default detail level is "all". + - (optional) `noRewards: bool` - whether to skip returning rewards for epoch-boundary blocks. If parameter not provided, the default returns rewards. #### Results: @@ -470,7 +472,7 @@ The result field will be an object with the following fields: - `blockhash: ` - the blockhash of this block, as base-58 encoded string - `previousBlockhash: ` - the blockhash of this block's parent, as base-58 encoded string; if the parent block is not available due to ledger cleanup, this field will return "11111111111111111111111111111111" - `parentSlot: ` - the slot index of this block's parent - - `transactions: ` - an array of JSON objects containing: + - `transactions: ` - present if "all" transaction details are requested; an array of JSON objects containing: - `transaction: ` - [Transaction](#transaction-structure) object, either in JSON format or encoded binary data, depending on encoding parameter - `meta: ` - transaction status metadata object, containing `null` or: - `err: ` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://github.com/solana-labs/solana/blob/master/sdk/src/transaction.rs#L24) @@ -484,7 +486,8 @@ The result field will be an object with the following fields: - DEPRECATED: `status: ` - Transaction status - `"Ok": ` - Transaction was successful - `"Err": ` - Transaction failed with TransactionError - - `rewards: ` - an array of JSON objects containing: + - `signatures: ` - present if "signatures" are requested for transaction details; an array of signatures strings, corresponding to the transaction order in the block + - `rewards: ` - present if rewards are not suppressed; an array of JSON objects containing: - `pubkey: ` - The public key, as base-58 encoded string, of the account that received the reward - `lamports: `- number of reward lamports credited or debited by the account, as a i64 - `postBalance: ` - account balance in lamports after the reward was applied @@ -496,7 +499,7 @@ The result field will be an object with the following fields: Request: ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc": "2.0","id":1,"method":"getConfirmedBlock","params":[430, {"encoding": "json"}]} + {"jsonrpc": "2.0","id":1,"method":"getConfirmedBlock","params":[430, {"encoding": "json","transactionDetails":"all","noRewards":true}]} ' ``` @@ -509,7 +512,6 @@ Result: "blockhash": "3Eq21vXNB5s86c62bVuUfTeaMif1N2kUqRPBmGRJhyTA", "parentSlot": 429, "previousBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B", - "rewards": [], "transactions": [ { "meta": { From 3b10f62e7faaa79eb0053f1f435481c34a00f7eb Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Thu, 18 Mar 2021 00:16:53 -0600 Subject: [PATCH 6/6] Apply review suggestions --- client/src/rpc_config.rs | 2 +- core/src/rpc.rs | 6 +++--- docs/src/developing/clients/jsonrpc-api.md | 10 +++++----- transaction-status/src/lib.rs | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/client/src/rpc_config.rs b/client/src/rpc_config.rs index 821aaf535f222f..f2af1beaa272e0 100644 --- a/client/src/rpc_config.rs +++ b/client/src/rpc_config.rs @@ -134,7 +134,7 @@ pub trait EncodingConfig { pub struct RpcConfirmedBlockConfig { pub encoding: Option, pub transaction_details: Option, - pub no_rewards: Option, + pub rewards: Option, } impl EncodingConfig for RpcConfirmedBlockConfig { diff --git a/core/src/rpc.rs b/core/src/rpc.rs index 0405fee0d6227a..325fa50702e156 100644 --- a/core/src/rpc.rs +++ b/core/src/rpc.rs @@ -726,7 +726,7 @@ impl JsonRpcRequestProcessor { .unwrap_or_default(); let encoding = config.encoding.unwrap_or(UiTransactionEncoding::Json); let transaction_details = config.transaction_details.unwrap_or_default(); - let show_rewards = !config.no_rewards.unwrap_or_default(); + let show_rewards = config.rewards.unwrap_or(true); if self.config.enable_rpc_transaction_history && slot <= self @@ -5176,7 +5176,7 @@ pub mod tests { json!(RpcConfirmedBlockConfig { encoding: None, transaction_details: Some(TransactionDetails::Signatures), - no_rewards: Some(true), + rewards: Some(false), }) ); let res = io.handle_request_sync(&req, meta.clone()); @@ -5196,7 +5196,7 @@ pub mod tests { json!(RpcConfirmedBlockConfig { encoding: None, transaction_details: Some(TransactionDetails::None), - no_rewards: Some(false), + rewards: Some(true), }) ); let res = io.handle_request_sync(&req, meta); diff --git a/docs/src/developing/clients/jsonrpc-api.md b/docs/src/developing/clients/jsonrpc-api.md index 83fab7dfe4b9d3..6786d099510215 100644 --- a/docs/src/developing/clients/jsonrpc-api.md +++ b/docs/src/developing/clients/jsonrpc-api.md @@ -460,8 +460,8 @@ Returns identity and transaction information about a confirmed block in the ledg - `` - (optional) Configuration object containing the following optional fields: - (optional) `encoding: ` - encoding for each returned Transaction, either "json", "jsonParsed", "base58" (*slow*), "base64". If parameter not provided, the default encoding is "json". "jsonParsed" encoding attempts to use program-specific instruction parsers to return more human-readable and explicit data in the `transaction.message.instructions` list. If "jsonParsed" is requested but a parser cannot be found, the instruction falls back to regular JSON encoding (`accounts`, `data`, and `programIdIndex` fields). - - (optional) `transactionDetails: ` - level of transaction detail to return, either "all", "signatures", or "none". If parameter not provided, the default detail level is "all". - - (optional) `noRewards: bool` - whether to skip returning rewards for epoch-boundary blocks. If parameter not provided, the default returns rewards. + - (optional) `transactionDetails: ` - level of transaction detail to return, either "full", "signatures", or "none". If parameter not provided, the default detail level is "full". + - (optional) `rewards: bool` - whether to populate the `rewards` array. If parameter not provided, the default includes rewards. #### Results: @@ -472,7 +472,7 @@ The result field will be an object with the following fields: - `blockhash: ` - the blockhash of this block, as base-58 encoded string - `previousBlockhash: ` - the blockhash of this block's parent, as base-58 encoded string; if the parent block is not available due to ledger cleanup, this field will return "11111111111111111111111111111111" - `parentSlot: ` - the slot index of this block's parent - - `transactions: ` - present if "all" transaction details are requested; an array of JSON objects containing: + - `transactions: ` - present if "full" transaction details are requested; an array of JSON objects containing: - `transaction: ` - [Transaction](#transaction-structure) object, either in JSON format or encoded binary data, depending on encoding parameter - `meta: ` - transaction status metadata object, containing `null` or: - `err: ` - Error if transaction failed, null if transaction succeeded. [TransactionError definitions](https://github.com/solana-labs/solana/blob/master/sdk/src/transaction.rs#L24) @@ -487,7 +487,7 @@ The result field will be an object with the following fields: - `"Ok": ` - Transaction was successful - `"Err": ` - Transaction failed with TransactionError - `signatures: ` - present if "signatures" are requested for transaction details; an array of signatures strings, corresponding to the transaction order in the block - - `rewards: ` - present if rewards are not suppressed; an array of JSON objects containing: + - `rewards: ` - present if rewards are requested; an array of JSON objects containing: - `pubkey: ` - The public key, as base-58 encoded string, of the account that received the reward - `lamports: `- number of reward lamports credited or debited by the account, as a i64 - `postBalance: ` - account balance in lamports after the reward was applied @@ -499,7 +499,7 @@ The result field will be an object with the following fields: Request: ```bash curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d ' - {"jsonrpc": "2.0","id":1,"method":"getConfirmedBlock","params":[430, {"encoding": "json","transactionDetails":"all","noRewards":true}]} + {"jsonrpc": "2.0","id":1,"method":"getConfirmedBlock","params":[430, {"encoding": "json","transactionDetails":"full","rewards":false}]} ' ``` diff --git a/transaction-status/src/lib.rs b/transaction-status/src/lib.rs index e6260cb4e5efcd..e5e2ac81b73df0 100644 --- a/transaction-status/src/lib.rs +++ b/transaction-status/src/lib.rs @@ -370,7 +370,7 @@ impl ConfirmedBlock { show_rewards: bool, ) -> UiConfirmedBlock { let (transactions, signatures) = match transaction_details { - TransactionDetails::All => ( + TransactionDetails::Full => ( Some( self.transactions .into_iter() @@ -449,14 +449,14 @@ impl From for UiConfirmedBlock { #[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub enum TransactionDetails { - All, + Full, Signatures, None, } impl Default for TransactionDetails { fn default() -> Self { - Self::All + Self::Full } }